vc-extras 0.1.0 → 0.1.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/README.md +128 -71
- package/agent-install.mjs +159 -0
- package/agents/tester.md +23 -23
- package/install-extras.mjs +41 -109
- package/install-menu.mjs +22 -43
- package/install-skills.mjs +112 -112
- package/package.json +72 -28
- package/plugin-registry.mjs +73 -0
- package/plugins/config-ui/index.ts +159 -159
- package/plugins/config-ui/lib/arguments.mjs +24 -24
- package/plugins/config-ui/lib/documents.mjs +67 -67
- package/plugins/config-ui/lib/frontmatter.mjs +91 -91
- package/plugins/config-ui/lib/open.mjs +16 -16
- package/plugins/config-ui/lib/ownership.mjs +99 -99
- package/plugins/config-ui/lib/page.mjs +11 -11
- package/plugins/config-ui/lib/patch.mjs +35 -35
- package/plugins/config-ui/lib/paths.mjs +14 -14
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -86
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -28
- package/plugins/config-ui/lib/redaction.mjs +8 -8
- package/plugins/config-ui/lib/registry.mjs +282 -282
- package/plugins/config-ui/lib/secrets.mjs +44 -44
- package/plugins/config-ui/lib/server.mjs +250 -250
- package/plugins/config-ui/lib/sources.mjs +96 -96
- package/plugins/config-ui/lib/state.mjs +156 -156
- package/plugins/config-ui/lib/themes.mjs +113 -113
- package/plugins/config-ui/lib/writer.mjs +690 -690
- package/plugins/config-ui/project-local-owner.ts +106 -106
- package/plugins/config-ui/vc-extras.plugin.json +13 -0
- package/plugins/config-ui/web/app.mjs +997 -997
- package/plugins/config-ui/web/index.html +342 -342
- package/plugins/pi-blackhole/vc-extras.plugin.json +12 -0
- package/plugins/pi-btw/vc-extras.plugin.json +12 -0
- package/plugins/pi-claude-code/vc-extras.plugin.json +12 -0
- package/plugins/pi-fff/vc-extras.plugin.json +12 -0
- package/plugins/pi-jev-auto-mode/vc-extras.plugin.json +12 -0
- package/plugins/pi-mcp-adapter/vc-extras.plugin.json +12 -0
- package/plugins/pi-web-access/vc-extras.plugin.json +12 -0
- package/plugins/vc-ask/claude-hook.mjs +37 -0
- package/plugins/vc-ask/codex-native.mjs +28 -0
- package/plugins/vc-ask/host-channel.mjs +75 -0
- package/plugins/vc-ask/index.ts +57 -0
- package/plugins/vc-ask/native-questions.mjs +33 -0
- package/plugins/vc-ask/package.json +10 -0
- package/plugins/vc-ask/payload.ts +170 -0
- package/plugins/vc-ask/questionnaire/LICENSE.ask-user-question +21 -0
- package/plugins/vc-ask/questionnaire/UPSTREAM.md +104 -0
- package/plugins/vc-ask/questionnaire/answer-channel.ts +135 -0
- package/plugins/vc-ask/questionnaire/config.ts +180 -0
- package/plugins/vc-ask/questionnaire/events.ts +154 -0
- package/plugins/vc-ask/questionnaire/execute.ts +688 -0
- package/plugins/vc-ask/questionnaire/i18n.ts +73 -0
- package/plugins/vc-ask/questionnaire/inline-entry.ts +312 -0
- package/plugins/vc-ask/questionnaire/locales/de.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/en.json +42 -0
- package/plugins/vc-ask/questionnaire/locales/es.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/fr.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt-BR.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/ru.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/uk.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/zh.json +46 -0
- package/plugins/vc-ask/questionnaire/presentation.ts +11 -0
- package/plugins/vc-ask/questionnaire/question-preview.ts +6 -0
- package/plugins/vc-ask/questionnaire/rpc.ts +221 -0
- package/plugins/vc-ask/questionnaire/session-timeout.ts +67 -0
- package/plugins/vc-ask/questionnaire/state/build-questionnaire.ts +144 -0
- package/plugins/vc-ask/questionnaire/state/external-editor.ts +62 -0
- package/plugins/vc-ask/questionnaire/state/geometry.ts +131 -0
- package/plugins/vc-ask/questionnaire/state/key-router.ts +382 -0
- package/plugins/vc-ask/questionnaire/state/panel-router.ts +32 -0
- package/plugins/vc-ask/questionnaire/state/questionnaire-session.ts +642 -0
- package/plugins/vc-ask/questionnaire/state/row-intent.ts +143 -0
- package/plugins/vc-ask/questionnaire/state/selectors/contract.ts +24 -0
- package/plugins/vc-ask/questionnaire/state/selectors/derivations.ts +40 -0
- package/plugins/vc-ask/questionnaire/state/selectors/focus.ts +17 -0
- package/plugins/vc-ask/questionnaire/state/selectors/projections.ts +99 -0
- package/plugins/vc-ask/questionnaire/state/state-reducer.ts +455 -0
- package/plugins/vc-ask/questionnaire/state/state.ts +90 -0
- package/plugins/vc-ask/questionnaire/state/vertical.ts +158 -0
- package/plugins/vc-ask/questionnaire/timeout.ts +59 -0
- package/plugins/vc-ask/questionnaire/tool/external-answer.ts +103 -0
- package/plugins/vc-ask/questionnaire/tool/format-answer.ts +24 -0
- package/plugins/vc-ask/questionnaire/tool/normalize-params.ts +37 -0
- package/plugins/vc-ask/questionnaire/tool/response-envelope.ts +75 -0
- package/plugins/vc-ask/questionnaire/tool/types.ts +74 -0
- package/plugins/vc-ask/questionnaire/tool/validate-questionnaire.ts +75 -0
- package/plugins/vc-ask/questionnaire/view/card-theme.ts +245 -0
- package/plugins/vc-ask/questionnaire/view/components/inline-input.ts +66 -0
- package/plugins/vc-ask/questionnaire/view/components/multi-select-view.ts +177 -0
- package/plugins/vc-ask/questionnaire/view/components/option-list-view.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/markdown-content-cache.ts +101 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-block-renderer.ts +130 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-box-renderer.ts +86 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-layout-decider.ts +204 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-pane.ts +257 -0
- package/plugins/vc-ask/questionnaire/view/components/submit-picker.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/tab-bar.ts +57 -0
- package/plugins/vc-ask/questionnaire/view/components/wrapping-select.ts +269 -0
- package/plugins/vc-ask/questionnaire/view/dialog-builder.ts +319 -0
- package/plugins/vc-ask/questionnaire/view/document-theme.ts +53 -0
- package/plugins/vc-ask/questionnaire/view/document-view.ts +306 -0
- package/plugins/vc-ask/questionnaire/view/panel-chrome.ts +133 -0
- package/plugins/vc-ask/questionnaire/view/props-adapter.ts +77 -0
- package/plugins/vc-ask/questionnaire/view/stateful-view.ts +24 -0
- package/plugins/vc-ask/questionnaire/view/tab-components.ts +16 -0
- package/plugins/vc-ask/questionnaire/view/tab-content-strategy.ts +280 -0
- package/plugins/vc-ask/questionnaire/view/vertical-view.ts +218 -0
- package/plugins/vc-ask/user-input-events.ts +34 -0
- package/plugins/vc-ask/vc-extras.plugin.json +18 -0
- package/plugins/vc-footer/agents/claude-code/adapter.mjs +29 -0
- package/plugins/vc-footer/agents/claude-code/cli.mjs +23 -0
- package/plugins/vc-footer/agents/claude-code/renderer.mjs +1 -0
- package/plugins/vc-footer/agents/claude-code/types.d.ts +38 -0
- package/plugins/vc-footer/agents/codex/adapter.mjs +13 -0
- package/plugins/vc-footer/agents/codex/mcp.mjs +45 -0
- package/plugins/vc-footer/agents/codex/native.mjs +19 -0
- package/plugins/vc-footer/agents/codex/renderer.mjs +2 -0
- package/plugins/vc-footer/agents/pi/adapter.mjs +23 -0
- package/plugins/vc-footer/agents/pi/index.js +84 -0
- package/plugins/vc-footer/agents/pi/project-local-owner.mjs +97 -0
- package/plugins/vc-footer/agents/pi/renderer.mjs +5 -0
- package/plugins/vc-footer/core/data.mjs +218 -0
- package/plugins/vc-footer/core/render.mjs +291 -0
- package/plugins/vc-footer/core/types.d.ts +29 -0
- package/plugins/vc-footer/package.json +22 -0
- package/plugins/vc-footer/vc-extras.plugin.json +32 -0
- package/skills/animate/LICENSE +21 -21
- package/skills/animate/RECIPES.md +324 -324
- package/skills/animate/SKILL.md +208 -208
- package/skills/animate/UPSTREAM.md +19 -19
- package/skills/animation-performance/LICENSE +21 -21
- package/skills/animation-performance/SKILL.md +223 -223
- package/skills/animation-performance/UPSTREAM.md +19 -19
- package/skills/answer-me-with-html/SKILL.md +174 -174
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -12896
- package/skills/apple-design/LICENSE +21 -21
- package/skills/apple-design/SKILL.md +291 -291
- package/skills/apple-design/UPSTREAM.md +19 -19
- package/skills/bad-smell/SKILL.md +44 -44
- package/skills/commit/SKILL.md +90 -90
- package/skills/emil-design-eng/LICENSE +21 -21
- package/skills/emil-design-eng/SKILL.md +677 -677
- package/skills/emil-design-eng/UPSTREAM.md +19 -19
- package/skills/find-the-truth/SKILL.md +38 -38
- package/skills/find-the-truth/references/trace-method.md +48 -48
- package/skills/find-the-truth/references/truth-method.md +39 -39
- package/skills/gestures/LICENSE +21 -21
- package/skills/gestures/SKILL.md +107 -107
- package/skills/gestures/UPSTREAM.md +19 -19
- package/skills/humanizer-zh/LICENSE +21 -21
- package/skills/humanizer-zh/SKILL.md +409 -409
- package/skills/humanizer-zh/UPSTREAM.md +7 -7
- package/skills/impeccable/LICENSE +191 -191
- package/skills/impeccable/NOTICE.md +11 -11
- package/skills/impeccable/SKILL.md +89 -89
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +8 -8
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -21
- package/skills/impeccable/reference/adapt.md +318 -318
- package/skills/impeccable/reference/adapt.native.md +58 -58
- package/skills/impeccable/reference/android.md +46 -46
- package/skills/impeccable/reference/animate.md +89 -89
- package/skills/impeccable/reference/audit.md +139 -139
- package/skills/impeccable/reference/audit.native.md +139 -139
- package/skills/impeccable/reference/bolder.md +33 -33
- package/skills/impeccable/reference/clarify.md +94 -94
- package/skills/impeccable/reference/colorize.md +86 -86
- package/skills/impeccable/reference/component-review.md +63 -63
- package/skills/impeccable/reference/craft-floor.md +44 -44
- package/skills/impeccable/reference/craft.md +5 -5
- package/skills/impeccable/reference/critique.md +819 -819
- package/skills/impeccable/reference/degraded/asset-producer.md +41 -41
- package/skills/impeccable/reference/degraded/documenter.md +23 -23
- package/skills/impeccable/reference/degraded/finish-reviewer.md +37 -37
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -92
- package/skills/impeccable/reference/delight.md +70 -70
- package/skills/impeccable/reference/distill.md +111 -111
- package/skills/impeccable/reference/doctor.md +54 -54
- package/skills/impeccable/reference/document.md +416 -416
- package/skills/impeccable/reference/extract.md +69 -69
- package/skills/impeccable/reference/generate.md +101 -101
- package/skills/impeccable/reference/harden.md +362 -362
- package/skills/impeccable/reference/hooks.md +114 -114
- package/skills/impeccable/reference/init.md +131 -131
- package/skills/impeccable/reference/ios.md +51 -51
- package/skills/impeccable/reference/layout.md +84 -84
- package/skills/impeccable/reference/live-setup.md +104 -104
- package/skills/impeccable/reference/live.md +327 -327
- package/skills/impeccable/reference/mode-operate.md +21 -21
- package/skills/impeccable/reference/mode-persuade.md +19 -19
- package/skills/impeccable/reference/mode-read.md +21 -21
- package/skills/impeccable/reference/new-work.md +152 -152
- package/skills/impeccable/reference/onboard.md +234 -234
- package/skills/impeccable/reference/operate.md +61 -61
- package/skills/impeccable/reference/optimize.md +257 -257
- package/skills/impeccable/reference/overdrive.md +127 -127
- package/skills/impeccable/reference/polish.md +105 -105
- package/skills/impeccable/reference/quieter.md +99 -99
- package/skills/impeccable/reference/region-map.md +26 -26
- package/skills/impeccable/reference/routing.md +24 -24
- package/skills/impeccable/reference/shape.md +59 -59
- package/skills/impeccable/reference/typeset.md +90 -90
- package/skills/impeccable/reference/visualize.md +47 -47
- package/skills/impeccable/scripts/VERSION +1 -1
- package/skills/impeccable/scripts/command-metadata.json +98 -98
- package/skills/impeccable/scripts/data/font-index-failures.json +120 -120
- package/skills/impeccable/scripts/engine-checksums.txt +9 -9
- package/skills/impeccable/scripts/impeccable +249 -249
- package/skills/impeccable/scripts/impeccable.cmd +278 -278
- package/skills/impeccable/scripts/live-browser-dom.js +320 -320
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -246
- package/skills/impeccable/scripts/live-browser-session.js +183 -183
- package/skills/impeccable/scripts/live-browser.js +13862 -13862
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -14
- package/skills/improve-animations/AUDIT.md +115 -115
- package/skills/improve-animations/LICENSE +21 -21
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -73
- package/skills/improve-animations/SKILL.md +110 -110
- package/skills/improve-animations/UPSTREAM.md +19 -19
- package/skills/pick-ui-library/LICENSE +21 -21
- package/skills/pick-ui-library/SKILL.md +85 -85
- package/skills/pick-ui-library/UPSTREAM.md +19 -19
- package/skills/review-animations/LICENSE +21 -21
- package/skills/review-animations/SKILL.md +120 -120
- package/skills/review-animations/STANDARDS.md +187 -187
- package/skills/review-animations/UPSTREAM.md +19 -19
- package/skills/test/SKILL.md +29 -29
- package/skills/test/references/test-method.md +60 -60
- package/skills/write-doc/SKILL.md +115 -115
- package/skills/write-doc/examples/result-report.md +53 -53
- package/skills/write-doc/examples/task-summary.md +45 -45
- package/skills/write-doc/references/terminology.md +147 -147
- package/specs/ask-host-protocol-v1.md +58 -0
- package/specs/design-demo.md +1102 -1102
- package/specs/frontend-immersive.md +28 -28
- package/specs/plugin-install-v2.md +123 -0
- package/specs/plugin-install.md +38 -0
- package/specs/web-modes/explore.md +31 -31
- package/specs/web-modes/risk.md +15 -15
- package/specs/web-modes/verify.md +16 -16
- package/vc-extras.mjs +46 -62
- package/plugins/essrj/context.ts +0 -47
- package/plugins/essrj/data.ts +0 -190
- package/plugins/essrj/index.ts +0 -139
- package/plugins/essrj/package.json +0 -12
- package/plugins/essrj/project-local-owner.ts +0 -106
- package/plugins/essrj/render.ts +0 -217
- package/plugins/essrj/types.ts +0 -40
- package/plugins.json +0 -38
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, matchesGlob, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
export function shouldYieldToProject(extensionUrl, declaration, cwd, projectTrusted) {
|
|
5
|
+
if (projectTrusted !== true) return false;
|
|
6
|
+
const projectRoot = resolve(cwd);
|
|
7
|
+
const emmaRoot = join(projectRoot, ".emma");
|
|
8
|
+
const extensionPath = fileURLToPath(extensionUrl);
|
|
9
|
+
if (isInside(emmaRoot, extensionPath)) return false;
|
|
10
|
+
const manifestPath = join(emmaRoot, "package.json");
|
|
11
|
+
const settingsPath = join(projectRoot, ".pi", "settings.json");
|
|
12
|
+
if (!isRegularOwnedFile(projectRoot, manifestPath) || !isRegularOwnedFile(projectRoot, settingsPath)) return false;
|
|
13
|
+
try {
|
|
14
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
15
|
+
const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
16
|
+
if (manifest?.name !== "vibe-emma-local" || !Array.isArray(manifest.pi?.extensions) || !manifest.pi.extensions.includes(declaration) || !Array.isArray(settings?.packages)) return false;
|
|
17
|
+
const resource = resolve(emmaRoot, declaration.replace(/^\.\//, ""));
|
|
18
|
+
if (!isRegularOwnedFile(emmaRoot, resource)) return false;
|
|
19
|
+
const settingsRoot = dirname(settingsPath);
|
|
20
|
+
return settings.packages.some((entry)=>{
|
|
21
|
+
const source = typeof entry === "string" ? entry : entry?.source;
|
|
22
|
+
if (!source || !packageEntryEnables(entry, declaration, resource)) return false;
|
|
23
|
+
return samePath(resolve(settingsRoot, source.replace(/\\/g, "/")), emmaRoot);
|
|
24
|
+
});
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function packageEntryEnables(entry, declaration, resource) {
|
|
30
|
+
if (typeof entry === "string") return true;
|
|
31
|
+
if (entry.extensions === undefined) return entry.autoload !== false;
|
|
32
|
+
if (!Array.isArray(entry.extensions) || entry.extensions.length === 0 || entry.extensions.some((value)=>typeof value !== "string")) return false;
|
|
33
|
+
const relativePath = normalizeExactPath(declaration);
|
|
34
|
+
const absolutePath = toPosix(resource);
|
|
35
|
+
const fileName = basename(relativePath);
|
|
36
|
+
if (entry.autoload === false) {
|
|
37
|
+
let enabled = false;
|
|
38
|
+
for (const value of entry.extensions){
|
|
39
|
+
const prefix = value[0];
|
|
40
|
+
const exact = prefix === "+" || prefix === "-";
|
|
41
|
+
const pattern = exact || prefix === "!" ? value.slice(1) : value;
|
|
42
|
+
if (exact ? matchesExact(pattern, relativePath, absolutePath) : matchesPattern(pattern, relativePath, fileName, absolutePath)) {
|
|
43
|
+
enabled = prefix !== "-" && prefix !== "!";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return enabled;
|
|
47
|
+
}
|
|
48
|
+
const includes = entry.extensions.filter((value)=>!/^[!+-]/.test(value));
|
|
49
|
+
const excludes = entry.extensions.filter((value)=>value.startsWith("!")).map((value)=>value.slice(1));
|
|
50
|
+
const forceIncludes = entry.extensions.filter((value)=>value.startsWith("+")).map((value)=>value.slice(1));
|
|
51
|
+
const forceExcludes = entry.extensions.filter((value)=>value.startsWith("-")).map((value)=>value.slice(1));
|
|
52
|
+
let enabled = includes.length === 0 || includes.some((pattern)=>matchesPattern(pattern, relativePath, fileName, absolutePath));
|
|
53
|
+
if (excludes.some((pattern)=>matchesPattern(pattern, relativePath, fileName, absolutePath))) enabled = false;
|
|
54
|
+
if (forceIncludes.some((pattern)=>matchesExact(pattern, relativePath, absolutePath))) enabled = true;
|
|
55
|
+
if (forceExcludes.some((pattern)=>matchesExact(pattern, relativePath, absolutePath))) enabled = false;
|
|
56
|
+
return enabled;
|
|
57
|
+
}
|
|
58
|
+
function matchesPattern(pattern, relativePath, fileName, absolutePath) {
|
|
59
|
+
const normalized = toPosix(pattern);
|
|
60
|
+
return [
|
|
61
|
+
relativePath,
|
|
62
|
+
fileName,
|
|
63
|
+
absolutePath
|
|
64
|
+
].some((candidate)=>matchesGlob(candidate, normalized));
|
|
65
|
+
}
|
|
66
|
+
function matchesExact(pattern, relativePath, absolutePath) {
|
|
67
|
+
const normalized = normalizeExactPath(pattern);
|
|
68
|
+
return normalized === relativePath || normalized === absolutePath;
|
|
69
|
+
}
|
|
70
|
+
function normalizeExactPath(value) {
|
|
71
|
+
return toPosix(value).replace(/^\.\//, "");
|
|
72
|
+
}
|
|
73
|
+
function toPosix(value) {
|
|
74
|
+
return value.replace(/\\/g, "/");
|
|
75
|
+
}
|
|
76
|
+
function isRegularOwnedFile(root, file) {
|
|
77
|
+
if (!existsSync(file)) return false;
|
|
78
|
+
try {
|
|
79
|
+
if (!lstatSync(file).isFile()) return false;
|
|
80
|
+
const realRoot = realpathSync(root);
|
|
81
|
+
const realFile = realpathSync(file);
|
|
82
|
+
return isInside(realRoot, realFile);
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function isInside(root, candidate) {
|
|
88
|
+
const value = relative(resolve(root), resolve(candidate));
|
|
89
|
+
return value === "" || !value.startsWith(`..${sep}`) && value !== ".." && !isAbsolute(value);
|
|
90
|
+
}
|
|
91
|
+
function samePath(left, right) {
|
|
92
|
+
const normalize = (value)=>{
|
|
93
|
+
const resolved = resolve(value).replace(/[\\/]+$/, "");
|
|
94
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
95
|
+
};
|
|
96
|
+
return normalize(left) === normalize(right);
|
|
97
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
const EMPTY_GIT = {
|
|
4
|
+
branch: "",
|
|
5
|
+
staged: 0,
|
|
6
|
+
unstaged: 0,
|
|
7
|
+
untracked: 0,
|
|
8
|
+
ahead: 0,
|
|
9
|
+
behind: 0
|
|
10
|
+
};
|
|
11
|
+
const EMPTY_METRICS = {
|
|
12
|
+
cacheHitRate: null,
|
|
13
|
+
tokensPerSecond: null
|
|
14
|
+
};
|
|
15
|
+
const metricsCache = new Map();
|
|
16
|
+
export function collectTranscriptMetrics(transcriptPath) {
|
|
17
|
+
if (!transcriptPath) return EMPTY_METRICS;
|
|
18
|
+
let stat;
|
|
19
|
+
try {
|
|
20
|
+
stat = fs.statSync(transcriptPath);
|
|
21
|
+
if (!stat.isFile()) return EMPTY_METRICS;
|
|
22
|
+
} catch {
|
|
23
|
+
return EMPTY_METRICS;
|
|
24
|
+
}
|
|
25
|
+
const cached = metricsCache.get(transcriptPath);
|
|
26
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
|
|
27
|
+
return cached.metrics;
|
|
28
|
+
}
|
|
29
|
+
let content;
|
|
30
|
+
try {
|
|
31
|
+
content = fs.readFileSync(transcriptPath, "utf8");
|
|
32
|
+
} catch {
|
|
33
|
+
return EMPTY_METRICS;
|
|
34
|
+
}
|
|
35
|
+
const metrics = parseTranscript(content);
|
|
36
|
+
metricsCache.set(transcriptPath, {
|
|
37
|
+
mtimeMs: stat.mtimeMs,
|
|
38
|
+
size: stat.size,
|
|
39
|
+
metrics
|
|
40
|
+
});
|
|
41
|
+
return metrics;
|
|
42
|
+
}
|
|
43
|
+
export function collectCacheHitRate(transcriptPath) {
|
|
44
|
+
return collectTranscriptMetrics(transcriptPath).cacheHitRate;
|
|
45
|
+
}
|
|
46
|
+
export function collectTokenSpeed(transcriptPath) {
|
|
47
|
+
return collectTranscriptMetrics(transcriptPath).tokensPerSecond;
|
|
48
|
+
}
|
|
49
|
+
function parseTranscript(content) {
|
|
50
|
+
let latest = null;
|
|
51
|
+
for (const line of content.split(/\r?\n/)){
|
|
52
|
+
if (!line.trim()) continue;
|
|
53
|
+
let entry;
|
|
54
|
+
try {
|
|
55
|
+
entry = JSON.parse(line);
|
|
56
|
+
} catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!isRecord(entry)) continue;
|
|
60
|
+
const message = isRecord(entry.message) ? entry.message : null;
|
|
61
|
+
if (message?.role !== "assistant") continue;
|
|
62
|
+
const usage = parseUsage(message.usage);
|
|
63
|
+
if (!usage) continue;
|
|
64
|
+
latest = { usage, durationMs: numberValue(message.durationMs) };
|
|
65
|
+
}
|
|
66
|
+
if (!latest) return EMPTY_METRICS;
|
|
67
|
+
const { usage } = latest;
|
|
68
|
+
const cacheTotal = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
69
|
+
const cacheHitRate = cacheTotal > 0 ? usage.cacheRead * 100 / cacheTotal : null;
|
|
70
|
+
const tokensPerSecond = usage.output > 0 && latest.durationMs > 0
|
|
71
|
+
? usage.output * 1000 / latest.durationMs : null;
|
|
72
|
+
return {
|
|
73
|
+
cacheHitRate,
|
|
74
|
+
tokensPerSecond: finiteNonNegative(tokensPerSecond)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function parseUsage(value) {
|
|
78
|
+
if (!isRecord(value)) return null;
|
|
79
|
+
const usage = {
|
|
80
|
+
input: numberValue(value.input) ?? numberValue(value.input_tokens) ?? 0,
|
|
81
|
+
output: numberValue(value.output) ?? numberValue(value.output_tokens) ?? 0,
|
|
82
|
+
cacheRead: numberValue(value.cacheRead) ?? numberValue(value.cache_read_input_tokens) ?? numberValue(value.cache_read) ?? 0,
|
|
83
|
+
cacheWrite: numberValue(value.cacheWrite) ?? numberValue(value.cache_creation_input_tokens) ?? numberValue(value.cache_creation) ?? 0
|
|
84
|
+
};
|
|
85
|
+
if (usage.input === 0 && usage.output === 0 && usage.cacheRead === 0 && usage.cacheWrite === 0) return null;
|
|
86
|
+
return usage;
|
|
87
|
+
}
|
|
88
|
+
function numberValue(value) {
|
|
89
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
90
|
+
}
|
|
91
|
+
function finiteNonNegative(value) {
|
|
92
|
+
return value !== null && Number.isFinite(value) && value >= 0 ? value : null;
|
|
93
|
+
}
|
|
94
|
+
export function collectGit(projectDir) {
|
|
95
|
+
if (!projectDir) return {
|
|
96
|
+
...EMPTY_GIT
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
const branch = git(projectDir, [
|
|
100
|
+
"branch",
|
|
101
|
+
"--show-current"
|
|
102
|
+
]).trim();
|
|
103
|
+
let porcelain = "";
|
|
104
|
+
try {
|
|
105
|
+
porcelain = git(projectDir, [
|
|
106
|
+
"status",
|
|
107
|
+
"--porcelain"
|
|
108
|
+
]);
|
|
109
|
+
} catch {}
|
|
110
|
+
let ahead = 0;
|
|
111
|
+
let behind = 0;
|
|
112
|
+
try {
|
|
113
|
+
const [aheadText, behindText] = git(projectDir, [
|
|
114
|
+
"rev-list",
|
|
115
|
+
"--left-right",
|
|
116
|
+
"--count",
|
|
117
|
+
"HEAD...@{upstream}"
|
|
118
|
+
]).trim().split(/\s+/);
|
|
119
|
+
ahead = Number.parseInt(aheadText ?? "", 10) || 0;
|
|
120
|
+
behind = Number.parseInt(behindText ?? "", 10) || 0;
|
|
121
|
+
} catch {}
|
|
122
|
+
return {
|
|
123
|
+
branch,
|
|
124
|
+
...parsePorcelain(porcelain),
|
|
125
|
+
ahead,
|
|
126
|
+
behind
|
|
127
|
+
};
|
|
128
|
+
} catch {
|
|
129
|
+
return {
|
|
130
|
+
...EMPTY_GIT
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function git(projectDir, args) {
|
|
135
|
+
return execFileSync("git", args, {
|
|
136
|
+
cwd: projectDir,
|
|
137
|
+
timeout: 500,
|
|
138
|
+
encoding: "utf8",
|
|
139
|
+
stdio: [
|
|
140
|
+
"ignore",
|
|
141
|
+
"pipe",
|
|
142
|
+
"ignore"
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function parsePorcelain(porcelain) {
|
|
147
|
+
let staged = 0;
|
|
148
|
+
let unstaged = 0;
|
|
149
|
+
let untracked = 0;
|
|
150
|
+
for (const line of porcelain.split("\n")){
|
|
151
|
+
if (line.length < 2) continue;
|
|
152
|
+
const index = line[0];
|
|
153
|
+
const worktree = line[1];
|
|
154
|
+
if (index === "?" && worktree === "?") {
|
|
155
|
+
untracked++;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (index !== " " && index !== "?") staged++;
|
|
159
|
+
if (worktree !== " " && worktree !== "?") unstaged++;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
staged,
|
|
163
|
+
unstaged,
|
|
164
|
+
untracked
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function isRecord(value) {
|
|
168
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
169
|
+
}
|
|
170
|
+
export function collectGitFast(projectDir) {
|
|
171
|
+
if (!projectDir) return {
|
|
172
|
+
...EMPTY_GIT
|
|
173
|
+
};
|
|
174
|
+
try {
|
|
175
|
+
const output = git(projectDir, [
|
|
176
|
+
"status",
|
|
177
|
+
"--porcelain=v2",
|
|
178
|
+
"--branch",
|
|
179
|
+
"--untracked-files=normal"
|
|
180
|
+
]);
|
|
181
|
+
let branch = "";
|
|
182
|
+
let ahead = 0;
|
|
183
|
+
let behind = 0;
|
|
184
|
+
let staged = 0;
|
|
185
|
+
let unstaged = 0;
|
|
186
|
+
let untracked = 0;
|
|
187
|
+
for (const line of output.split("\n")){
|
|
188
|
+
if (line.startsWith("# branch.head ")) {
|
|
189
|
+
branch = line.slice("# branch.head ".length).trim();
|
|
190
|
+
} else if (line.startsWith("# branch.ab ")) {
|
|
191
|
+
const match = line.match(/\+(\d+)\s+-(\d+)/);
|
|
192
|
+
if (match) {
|
|
193
|
+
ahead = Number.parseInt(match[1], 10) || 0;
|
|
194
|
+
behind = Number.parseInt(match[2], 10) || 0;
|
|
195
|
+
}
|
|
196
|
+
} else if (line.startsWith("? ")) {
|
|
197
|
+
untracked++;
|
|
198
|
+
} else if (line[0] === "1" || line[0] === "2" || line[0] === "u") {
|
|
199
|
+
const index = line[2];
|
|
200
|
+
const worktree = line[3];
|
|
201
|
+
if (index && index !== "." && index !== "?") staged++;
|
|
202
|
+
if (worktree && worktree !== "." && worktree !== "?") unstaged++;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
branch,
|
|
207
|
+
ahead,
|
|
208
|
+
behind,
|
|
209
|
+
staged,
|
|
210
|
+
unstaged,
|
|
211
|
+
untracked
|
|
212
|
+
};
|
|
213
|
+
} catch {
|
|
214
|
+
return {
|
|
215
|
+
...EMPTY_GIT
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
function fg(r, g, b) {
|
|
3
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
4
|
+
}
|
|
5
|
+
function reset() {
|
|
6
|
+
return "\x1b[0m";
|
|
7
|
+
}
|
|
8
|
+
const SIGNATURE = {
|
|
9
|
+
dark: {
|
|
10
|
+
magenta: fg(200, 175, 225),
|
|
11
|
+
pink: fg(240, 160, 180),
|
|
12
|
+
pinkDim: fg(156, 104, 117),
|
|
13
|
+
barGreen: fg(170, 230, 170),
|
|
14
|
+
barGreenDim: fg(85, 120, 85)
|
|
15
|
+
},
|
|
16
|
+
light: {
|
|
17
|
+
magenta: fg(142, 36, 170),
|
|
18
|
+
pink: fg(194, 24, 91),
|
|
19
|
+
pinkDim: fg(224, 178, 197),
|
|
20
|
+
barGreen: fg(46, 125, 50),
|
|
21
|
+
barGreenDim: fg(181, 212, 184)
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function paletteFromTheme(theme, isLight) {
|
|
25
|
+
const semantic = (color)=>theme.getFgAnsi(color);
|
|
26
|
+
const signature = isLight ? SIGNATURE.light : SIGNATURE.dark;
|
|
27
|
+
return {
|
|
28
|
+
white: semantic("text"),
|
|
29
|
+
whiteDim: semantic("muted"),
|
|
30
|
+
contextInfo: semantic("dim"),
|
|
31
|
+
cyan: semantic("accent"),
|
|
32
|
+
green: semantic("success"),
|
|
33
|
+
yellow: semantic("warning"),
|
|
34
|
+
red: semantic("error"),
|
|
35
|
+
magenta: signature.magenta,
|
|
36
|
+
pink: signature.pink,
|
|
37
|
+
pinkDim: signature.pinkDim,
|
|
38
|
+
barGreen: signature.barGreen,
|
|
39
|
+
barGreenDim: signature.barGreenDim
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function plainPalette() {
|
|
43
|
+
return {
|
|
44
|
+
white: "",
|
|
45
|
+
whiteDim: "",
|
|
46
|
+
contextInfo: "",
|
|
47
|
+
cyan: "",
|
|
48
|
+
green: "",
|
|
49
|
+
yellow: "",
|
|
50
|
+
red: "",
|
|
51
|
+
magenta: "",
|
|
52
|
+
pink: "",
|
|
53
|
+
pinkDim: "",
|
|
54
|
+
barGreen: "",
|
|
55
|
+
barGreenDim: ""
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function paint(code, value) {
|
|
59
|
+
return code ? `${code}${value}${reset()}` : value;
|
|
60
|
+
}
|
|
61
|
+
function ansi256ToRgb(n) {
|
|
62
|
+
if (n < 16) {
|
|
63
|
+
const base = [
|
|
64
|
+
[
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
205,
|
|
71
|
+
0,
|
|
72
|
+
0
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
0,
|
|
76
|
+
205,
|
|
77
|
+
0
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
205,
|
|
81
|
+
205,
|
|
82
|
+
0
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
0,
|
|
86
|
+
0,
|
|
87
|
+
238
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
205,
|
|
91
|
+
0,
|
|
92
|
+
205
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
0,
|
|
96
|
+
205,
|
|
97
|
+
205
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
229,
|
|
101
|
+
229,
|
|
102
|
+
229
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
127,
|
|
106
|
+
127,
|
|
107
|
+
127
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
255,
|
|
111
|
+
0,
|
|
112
|
+
0
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
0,
|
|
116
|
+
255,
|
|
117
|
+
0
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
255,
|
|
121
|
+
255,
|
|
122
|
+
0
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
92,
|
|
126
|
+
92,
|
|
127
|
+
255
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
255,
|
|
131
|
+
0,
|
|
132
|
+
255
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
0,
|
|
136
|
+
255,
|
|
137
|
+
255
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
255,
|
|
141
|
+
255,
|
|
142
|
+
255
|
|
143
|
+
]
|
|
144
|
+
];
|
|
145
|
+
return base[n];
|
|
146
|
+
}
|
|
147
|
+
if (n < 232) {
|
|
148
|
+
const i = n - 16;
|
|
149
|
+
const steps = [
|
|
150
|
+
0,
|
|
151
|
+
95,
|
|
152
|
+
135,
|
|
153
|
+
175,
|
|
154
|
+
215,
|
|
155
|
+
255
|
|
156
|
+
];
|
|
157
|
+
return [
|
|
158
|
+
steps[Math.floor(i / 36)],
|
|
159
|
+
steps[Math.floor(i / 6) % 6],
|
|
160
|
+
steps[i % 6]
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
const gray = 8 + (n - 232) * 10;
|
|
164
|
+
return [
|
|
165
|
+
gray,
|
|
166
|
+
gray,
|
|
167
|
+
gray
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
function luminance(rgb) {
|
|
171
|
+
const linear = (channel)=>{
|
|
172
|
+
const value = channel / 255;
|
|
173
|
+
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
174
|
+
};
|
|
175
|
+
return 0.2126 * linear(rgb[0]) + 0.7152 * linear(rgb[1]) + 0.0722 * linear(rgb[2]);
|
|
176
|
+
}
|
|
177
|
+
export function isLightTheme(theme) {
|
|
178
|
+
const code = theme.getFgAnsi("text");
|
|
179
|
+
const truecolor = code.match(/38;2;(\d+);(\d+);(\d+)/);
|
|
180
|
+
if (truecolor) {
|
|
181
|
+
return luminance([
|
|
182
|
+
Number(truecolor[1]),
|
|
183
|
+
Number(truecolor[2]),
|
|
184
|
+
Number(truecolor[3])
|
|
185
|
+
]) < 0.5;
|
|
186
|
+
}
|
|
187
|
+
const indexed = code.match(/38;5;(\d+)/);
|
|
188
|
+
if (indexed) return luminance(ansi256ToRgb(Number(indexed[1]))) < 0.5;
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const ICON = {
|
|
192
|
+
branch: "\u{f126}",
|
|
193
|
+
cache: "\u{e00a}"
|
|
194
|
+
};
|
|
195
|
+
export function renderFooter(data, maxWidth, theme) {
|
|
196
|
+
if (!data) return "";
|
|
197
|
+
const palette = theme ? paletteFromTheme(theme, isLightTheme(theme)) : plainPalette();
|
|
198
|
+
return truncateAnsi(buildLine(data, palette), maxWidth);
|
|
199
|
+
}
|
|
200
|
+
export function buildLine(data, C) {
|
|
201
|
+
const parts = [];
|
|
202
|
+
const projectDir = data.projectDir || data.cwd;
|
|
203
|
+
const projectName = projectDir ? path.basename(projectDir) : "";
|
|
204
|
+
let head = projectName ? paint(C.white, projectName) : "";
|
|
205
|
+
if (data.git.branch) {
|
|
206
|
+
head += paint(C.cyan, `${ICON.branch} ${data.git.branch}`);
|
|
207
|
+
const stats = [];
|
|
208
|
+
if (data.git.ahead > 0) stats.push(paint(C.cyan, `⇡${data.git.ahead}`));
|
|
209
|
+
if (data.git.behind > 0) stats.push(paint(C.cyan, `⇣${data.git.behind}`));
|
|
210
|
+
if (data.git.staged > 0) stats.push(paint(C.green, `+${data.git.staged}`));
|
|
211
|
+
if (data.git.unstaged > 0) stats.push(paint(C.yellow, `!${data.git.unstaged}`));
|
|
212
|
+
if (data.git.untracked > 0) stats.push(paint(C.whiteDim, `?${data.git.untracked}`));
|
|
213
|
+
if (stats.length > 0) {
|
|
214
|
+
head += ` ${paint(C.whiteDim, "(")}${stats.join(" ")}${paint(C.whiteDim, ")")}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (head) parts.push(head);
|
|
218
|
+
const usageParts = [
|
|
219
|
+
`${ICON.cache} ${formatCacheHitRate(data.cacheHitRate)}`
|
|
220
|
+
];
|
|
221
|
+
if (data.context && data.context.window > 0) {
|
|
222
|
+
usageParts.push(`${buildContextBar(data.context.percent, C)} ${formatContextUsage(data.context, C)}`);
|
|
223
|
+
}
|
|
224
|
+
parts.push(usageParts.join(" "));
|
|
225
|
+
parts.push(paint(C.whiteDim, formatTokenSpeed(data.tokensPerSecond)));
|
|
226
|
+
return parts.join(` ${paint(C.contextInfo, "│")} `);
|
|
227
|
+
}
|
|
228
|
+
export function buildContextBar(percent, C, width = 8) {
|
|
229
|
+
const clamped = Math.min(100, Math.max(0, Math.round(percent)));
|
|
230
|
+
const filled = Math.round(clamped * width / 100);
|
|
231
|
+
const color = clamped >= 20 ? C.pink : C.barGreen;
|
|
232
|
+
const emptyColor = clamped >= 20 ? C.pinkDim : C.barGreenDim;
|
|
233
|
+
return paint(color, "█".repeat(filled)) + paint(emptyColor, "░".repeat(width - filled));
|
|
234
|
+
}
|
|
235
|
+
function formatContextUsage(usage, C) {
|
|
236
|
+
const color = usage.percent >= 60 ? C.red : usage.percent >= 40 ? C.yellow : C.green;
|
|
237
|
+
return `${paint(color, `${Math.round(usage.percent)}%`)}${paint(C.whiteDim, `/${formatTokens(usage.window)}`)}`;
|
|
238
|
+
}
|
|
239
|
+
function formatCacheHitRate(rate) {
|
|
240
|
+
return rate === null ? "CH -" : `CH ${rate.toFixed(1)}%`;
|
|
241
|
+
}
|
|
242
|
+
function formatTokenSpeed(speed) {
|
|
243
|
+
return speed === null ? "-to/s" : `${Math.round(speed)}to/s`;
|
|
244
|
+
}
|
|
245
|
+
function formatTokens(value) {
|
|
246
|
+
if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1).replace(/\.0$/, "")}M`;
|
|
247
|
+
if (value >= 1000) return `${(value / 1000).toFixed(value >= 10_000 ? 0 : 1).replace(/\.0$/, "")}k`;
|
|
248
|
+
return String(value);
|
|
249
|
+
}
|
|
250
|
+
const ANSI_SGR = /\x1b\[[0-9;]*m/g;
|
|
251
|
+
const HAS_ANSI = /\x1b\[[0-9;]*m/;
|
|
252
|
+
export function visibleWidth(value) {
|
|
253
|
+
let width = 0;
|
|
254
|
+
for (const char of value.replace(ANSI_SGR, ""))width += charWidth(char);
|
|
255
|
+
return width;
|
|
256
|
+
}
|
|
257
|
+
export function truncateAnsi(value, maxWidth) {
|
|
258
|
+
if (maxWidth <= 0) return "";
|
|
259
|
+
let result = "";
|
|
260
|
+
let width = 0;
|
|
261
|
+
let index = 0;
|
|
262
|
+
while(index < value.length){
|
|
263
|
+
if (value[index] === "\x1b") {
|
|
264
|
+
const match = /^\x1b\[[0-9;]*m/.exec(value.slice(index));
|
|
265
|
+
if (match) {
|
|
266
|
+
result += match[0];
|
|
267
|
+
index += match[0].length;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const codePoint = value.codePointAt(index);
|
|
272
|
+
if (codePoint === undefined) break;
|
|
273
|
+
const char = String.fromCodePoint(codePoint);
|
|
274
|
+
const charColumns = charWidth(char);
|
|
275
|
+
if (width + charColumns > maxWidth) break;
|
|
276
|
+
result += char;
|
|
277
|
+
width += charColumns;
|
|
278
|
+
index += char.length;
|
|
279
|
+
}
|
|
280
|
+
if (index >= value.length) return value;
|
|
281
|
+
return `${result}${HAS_ANSI.test(value) ? reset() : ""}`;
|
|
282
|
+
}
|
|
283
|
+
function charWidth(char) {
|
|
284
|
+
if (!char) return 0;
|
|
285
|
+
if (/^[\u0000-\u001f\u007f-\u009f]$/u.test(char)) return 0;
|
|
286
|
+
if (/^\p{Mark}$/u.test(char)) return 0;
|
|
287
|
+
if (/^\uFE0F$/u.test(char)) return 0;
|
|
288
|
+
const codePoint = char.codePointAt(0) ?? 0;
|
|
289
|
+
if (codePoint >= 0x1100 && codePoint <= 0x115f || codePoint === 0x2329 || codePoint === 0x232a || codePoint >= 0x2e80 && codePoint <= 0xa4cf || codePoint >= 0xac00 && codePoint <= 0xd7a3 || codePoint >= 0xf900 && codePoint <= 0xfaff || codePoint >= 0xfe10 && codePoint <= 0xfe19 || codePoint >= 0xfe30 && codePoint <= 0xfe6f || codePoint >= 0xff00 && codePoint <= 0xff60 || codePoint >= 0xffe0 && codePoint <= 0xffe6 || codePoint >= 0x1f300 && codePoint <= 0x1faff || codePoint >= 0x20000 && codePoint <= 0x3fffd) return 2;
|
|
290
|
+
return 1;
|
|
291
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface GitStatus {
|
|
2
|
+
branch: string;
|
|
3
|
+
ahead: number;
|
|
4
|
+
behind: number;
|
|
5
|
+
staged: number;
|
|
6
|
+
unstaged: number;
|
|
7
|
+
untracked: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ContextUsage {
|
|
11
|
+
used: number;
|
|
12
|
+
window: number;
|
|
13
|
+
percent: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TranscriptMetrics {
|
|
17
|
+
cacheHitRate: number | null;
|
|
18
|
+
tokensPerSecond: number | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Platform-neutral data consumed by the footer renderer. */
|
|
22
|
+
export interface FooterData {
|
|
23
|
+
projectDir: string;
|
|
24
|
+
cwd: string;
|
|
25
|
+
git: GitStatus;
|
|
26
|
+
context: ContextUsage | null;
|
|
27
|
+
cacheHitRate: number | null;
|
|
28
|
+
tokensPerSecond: number | null;
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vc-footer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.19.0"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"core",
|
|
14
|
+
"agents",
|
|
15
|
+
"vc-extras.plugin.json"
|
|
16
|
+
],
|
|
17
|
+
"pi": {
|
|
18
|
+
"extensions": [
|
|
19
|
+
"./agents/pi/index.js"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "vc-extras/plugin",
|
|
3
|
+
"protocolVersion": 1,
|
|
4
|
+
"id": "vc-footer",
|
|
5
|
+
"label": "vc-footer 状态栏",
|
|
6
|
+
"targets": {
|
|
7
|
+
"pi": {
|
|
8
|
+
"kind": "pi-package",
|
|
9
|
+
"entry": "./agents/pi/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"core",
|
|
12
|
+
"agents/pi"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"claude-code": {
|
|
16
|
+
"kind": "claude-statusline",
|
|
17
|
+
"entry": "./agents/claude-code/cli.mjs",
|
|
18
|
+
"files": [
|
|
19
|
+
"core",
|
|
20
|
+
"agents/claude-code"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"codex": {
|
|
24
|
+
"kind": "codex-statusline-mcp",
|
|
25
|
+
"entry": "./agents/codex/mcp.mjs",
|
|
26
|
+
"files": [
|
|
27
|
+
"core",
|
|
28
|
+
"agents/codex"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|