vc-extras 0.0.0-stage → 0.1.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 +70 -2
- package/agents/tester.md +23 -0
- package/install-extras.mjs +134 -0
- package/install-menu.mjs +63 -0
- package/install-skills.mjs +112 -0
- package/package.json +26 -4
- package/plugins/config-ui/index.ts +160 -0
- package/plugins/config-ui/lib/arguments.mjs +24 -0
- package/plugins/config-ui/lib/documents.mjs +67 -0
- package/plugins/config-ui/lib/frontmatter.mjs +91 -0
- package/plugins/config-ui/lib/open.mjs +17 -0
- package/plugins/config-ui/lib/ownership.mjs +99 -0
- package/plugins/config-ui/lib/page.mjs +11 -0
- package/plugins/config-ui/lib/patch.mjs +36 -0
- package/plugins/config-ui/lib/paths.mjs +14 -0
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -0
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -0
- package/plugins/config-ui/lib/redaction.mjs +8 -0
- package/plugins/config-ui/lib/registry.mjs +282 -0
- package/plugins/config-ui/lib/secrets.mjs +45 -0
- package/plugins/config-ui/lib/server.mjs +251 -0
- package/plugins/config-ui/lib/sources.mjs +96 -0
- package/plugins/config-ui/lib/state.mjs +157 -0
- package/plugins/config-ui/lib/themes.mjs +113 -0
- package/plugins/config-ui/lib/writer.mjs +691 -0
- package/plugins/config-ui/package.json +12 -0
- package/plugins/config-ui/project-local-owner.ts +106 -0
- package/plugins/config-ui/web/app.mjs +997 -0
- package/plugins/config-ui/web/index.html +342 -0
- package/plugins/essrj/context.ts +47 -0
- package/plugins/essrj/data.ts +190 -0
- package/plugins/essrj/index.ts +139 -0
- package/plugins/essrj/package.json +12 -0
- package/plugins/essrj/project-local-owner.ts +106 -0
- package/plugins/essrj/render.ts +217 -0
- package/plugins/essrj/types.ts +40 -0
- package/plugins.json +38 -0
- package/skills/animate/LICENSE +21 -0
- package/skills/animate/RECIPES.md +324 -0
- package/skills/animate/SKILL.md +208 -0
- package/skills/animate/UPSTREAM.md +19 -0
- package/skills/animation-performance/LICENSE +21 -0
- package/skills/animation-performance/SKILL.md +223 -0
- package/skills/animation-performance/UPSTREAM.md +19 -0
- package/skills/answer-me-with-html/SKILL.md +174 -0
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -0
- package/skills/apple-design/LICENSE +21 -0
- package/skills/apple-design/SKILL.md +291 -0
- package/skills/apple-design/UPSTREAM.md +19 -0
- package/skills/bad-smell/SKILL.md +44 -0
- package/skills/commit/SKILL.md +90 -0
- package/skills/emil-design-eng/LICENSE +21 -0
- package/skills/emil-design-eng/SKILL.md +677 -0
- package/skills/emil-design-eng/UPSTREAM.md +19 -0
- package/skills/find-the-truth/SKILL.md +38 -0
- package/skills/find-the-truth/references/trace-method.md +48 -0
- package/skills/find-the-truth/references/truth-method.md +39 -0
- package/skills/gestures/LICENSE +21 -0
- package/skills/gestures/SKILL.md +107 -0
- package/skills/gestures/UPSTREAM.md +19 -0
- package/skills/humanizer-zh/LICENSE +21 -0
- package/skills/humanizer-zh/SKILL.md +409 -0
- package/skills/humanizer-zh/UPSTREAM.md +7 -0
- package/skills/impeccable/LICENSE +191 -0
- package/skills/impeccable/NOTICE.md +11 -0
- package/skills/impeccable/SKILL.md +90 -0
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +9 -0
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -0
- package/skills/impeccable/reference/adapt.md +318 -0
- package/skills/impeccable/reference/adapt.native.md +58 -0
- package/skills/impeccable/reference/android.md +46 -0
- package/skills/impeccable/reference/animate.md +89 -0
- package/skills/impeccable/reference/audit.md +139 -0
- package/skills/impeccable/reference/audit.native.md +139 -0
- package/skills/impeccable/reference/bolder.md +33 -0
- package/skills/impeccable/reference/clarify.md +94 -0
- package/skills/impeccable/reference/colorize.md +86 -0
- package/skills/impeccable/reference/component-review.md +63 -0
- package/skills/impeccable/reference/craft-floor.md +44 -0
- package/skills/impeccable/reference/craft.md +5 -0
- package/skills/impeccable/reference/critique.md +819 -0
- package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/skills/impeccable/reference/delight.md +70 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/doctor.md +54 -0
- package/skills/impeccable/reference/document.md +416 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/generate.md +101 -0
- package/skills/impeccable/reference/harden.md +362 -0
- package/skills/impeccable/reference/hooks.md +114 -0
- package/skills/impeccable/reference/init.md +131 -0
- package/skills/impeccable/reference/ios.md +51 -0
- package/skills/impeccable/reference/layout.md +84 -0
- package/skills/impeccable/reference/live-setup.md +104 -0
- package/skills/impeccable/reference/live.md +327 -0
- package/skills/impeccable/reference/mode-operate.md +21 -0
- package/skills/impeccable/reference/mode-persuade.md +19 -0
- package/skills/impeccable/reference/mode-read.md +21 -0
- package/skills/impeccable/reference/new-work.md +152 -0
- package/skills/impeccable/reference/onboard.md +234 -0
- package/skills/impeccable/reference/operate.md +61 -0
- package/skills/impeccable/reference/optimize.md +257 -0
- package/skills/impeccable/reference/overdrive.md +127 -0
- package/skills/impeccable/reference/polish.md +105 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/region-map.md +26 -0
- package/skills/impeccable/reference/routing.md +24 -0
- package/skills/impeccable/reference/shape.md +59 -0
- package/skills/impeccable/reference/typeset.md +90 -0
- package/skills/impeccable/reference/visualize.md +47 -0
- package/skills/impeccable/scripts/VERSION +1 -0
- package/skills/impeccable/scripts/command-metadata.json +98 -0
- package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/impeccable/scripts/data/font-index.json +1 -0
- package/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/skills/impeccable/scripts/impeccable +249 -0
- package/skills/impeccable/scripts/impeccable.cmd +278 -0
- package/skills/impeccable/scripts/live-browser-dom.js +320 -0
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
- package/skills/impeccable/scripts/live-browser-session.js +183 -0
- package/skills/impeccable/scripts/live-browser.js +13862 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/improve-animations/AUDIT.md +115 -0
- package/skills/improve-animations/LICENSE +21 -0
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -0
- package/skills/improve-animations/SKILL.md +110 -0
- package/skills/improve-animations/UPSTREAM.md +19 -0
- package/skills/pick-ui-library/LICENSE +21 -0
- package/skills/pick-ui-library/SKILL.md +85 -0
- package/skills/pick-ui-library/UPSTREAM.md +19 -0
- package/skills/review-animations/LICENSE +21 -0
- package/skills/review-animations/SKILL.md +120 -0
- package/skills/review-animations/STANDARDS.md +187 -0
- package/skills/review-animations/UPSTREAM.md +19 -0
- package/skills/test/SKILL.md +29 -0
- package/skills/test/references/test-method.md +60 -0
- package/skills/write-doc/SKILL.md +115 -0
- package/skills/write-doc/examples/result-report.md +53 -0
- package/skills/write-doc/examples/task-summary.md +45 -0
- package/skills/write-doc/references/terminology.md +147 -0
- package/specs/design-demo.md +1102 -0
- package/specs/frontend-immersive.md +28 -0
- package/specs/web-modes/explore.md +31 -0
- package/specs/web-modes/risk.md +15 -0
- package/specs/web-modes/verify.md +16 -0
- package/vc-extras.mjs +78 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { shouldYieldToProject } from "./project-local-owner.ts";
|
|
5
|
+
import { collectSnapshot, renderSnapshot } from "./context.ts";
|
|
6
|
+
import type { EmmaData, FooterSnapshot } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
function workflowProject(cwd: string): string {
|
|
9
|
+
const start = path.resolve(cwd);
|
|
10
|
+
for (let current = start; ; current = path.dirname(current)) {
|
|
11
|
+
if (existsSync(path.join(current, ".emma", "package.json")) || existsSync(path.join(current, ".git"))) return current;
|
|
12
|
+
if (path.dirname(current) === current) return start;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function reportError(stage: string, error: unknown): void {
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
console.error(`vibe-emma ESSRJ ${stage} failed: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function essrjExtension(pi: ExtensionAPI): void {
|
|
22
|
+
let snapshot: FooterSnapshot | null = null;
|
|
23
|
+
let footerInstalled = false;
|
|
24
|
+
let startupTimer: ReturnType<typeof setTimeout> | undefined;
|
|
25
|
+
let requestRender = () => {};
|
|
26
|
+
let activeContext: ExtensionContext | null = null;
|
|
27
|
+
|
|
28
|
+
const snapshotFor = (context: ExtensionContext): FooterSnapshot => {
|
|
29
|
+
const request: { cwd: string; piSessionId: string; result?: EmmaData } = {
|
|
30
|
+
cwd: workflowProject(context.cwd), piSessionId: context.sessionManager?.getSessionId() || "",
|
|
31
|
+
};
|
|
32
|
+
pi.events?.emit("emma:status.v1", request);
|
|
33
|
+
return collectSnapshot(context, request.result ?? undefined, request.cwd);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const refresh = (context: ExtensionContext): void => {
|
|
37
|
+
activeContext = context;
|
|
38
|
+
try {
|
|
39
|
+
snapshot = snapshotFor(context);
|
|
40
|
+
requestRender();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
reportError("refresh", error);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onWorkflowChanged = (event: unknown, context: ExtensionContext): void => {
|
|
47
|
+
if (!event || typeof event !== "object") return;
|
|
48
|
+
const change = event as {
|
|
49
|
+
projectDir?: unknown;
|
|
50
|
+
piSessionId?: unknown;
|
|
51
|
+
sessionId?: unknown;
|
|
52
|
+
stage?: unknown;
|
|
53
|
+
};
|
|
54
|
+
if (typeof change.projectDir !== "string" || path.relative(workflowProject(context.cwd), change.projectDir) || change.piSessionId !== context.sessionManager.getSessionId()) return;
|
|
55
|
+
if (typeof change.sessionId !== "string" || typeof change.stage !== "string") return;
|
|
56
|
+
const validStages = new Set(["ready", "no_session", "shape", "hunt", "build", "stashed", "completed", "released"]);
|
|
57
|
+
if (!validStages.has(change.stage)) return;
|
|
58
|
+
if (snapshot) {
|
|
59
|
+
snapshot.emma = { sessionId: change.sessionId, workflowStatus: change.stage };
|
|
60
|
+
} else snapshot = snapshotFor(context);
|
|
61
|
+
requestRender();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const installFooter = (context: ExtensionContext): void => {
|
|
65
|
+
if (context.mode !== "tui" || shouldYieldToProject(import.meta.url, "./runtime/essrj/index.ts", context.cwd ?? process.cwd(), context.isProjectTrusted?.() === true)) return;
|
|
66
|
+
activeContext = context;
|
|
67
|
+
snapshot = snapshotFor(context);
|
|
68
|
+
context.ui.setFooter((tui, theme, footerData) => {
|
|
69
|
+
requestRender = () => tui.requestRender();
|
|
70
|
+
const unsubscribe = footerData.onBranchChange(() => refresh(context));
|
|
71
|
+
return {
|
|
72
|
+
dispose() {
|
|
73
|
+
try {
|
|
74
|
+
unsubscribe();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
reportError("dispose", error);
|
|
77
|
+
}
|
|
78
|
+
requestRender = () => {};
|
|
79
|
+
},
|
|
80
|
+
invalidate() {},
|
|
81
|
+
render(width: number): string[] {
|
|
82
|
+
try {
|
|
83
|
+
const output = renderSnapshot(snapshot, width, theme);
|
|
84
|
+
return output
|
|
85
|
+
? output.split("\n")
|
|
86
|
+
: [];
|
|
87
|
+
} catch (error) {
|
|
88
|
+
reportError("render", error);
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
footerInstalled = true;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
pi.on("session_start", () => {
|
|
98
|
+
if (startupTimer) clearTimeout(startupTimer);
|
|
99
|
+
startupTimer = undefined;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
pi.on("resources_discover", (_event, context) => {
|
|
103
|
+
if (startupTimer) clearTimeout(startupTimer);
|
|
104
|
+
startupTimer = setTimeout(() => {
|
|
105
|
+
startupTimer = undefined;
|
|
106
|
+
try {
|
|
107
|
+
installFooter(context);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
reportError("install", error);
|
|
110
|
+
}
|
|
111
|
+
}, 0);
|
|
112
|
+
startupTimer.unref?.();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
pi.on("before_agent_start", (_event, context) => refresh(context));
|
|
116
|
+
pi.on("turn_end", (_event, context) => refresh(context));
|
|
117
|
+
pi.on("tool_execution_end", (_event, context) => refresh(context));
|
|
118
|
+
pi.on("model_select", (_event, context) => refresh(context));
|
|
119
|
+
pi.on("thinking_level_select", (_event, context) => refresh(context));
|
|
120
|
+
pi.on("session_info_changed", (_event, context) => refresh(context));
|
|
121
|
+
pi.on("session_compact", (_event, context) => refresh(context));
|
|
122
|
+
pi.events?.on("emma:workflow_changed.v1", (event: unknown) => {
|
|
123
|
+
try {
|
|
124
|
+
if (activeContext) onWorkflowChanged(event, activeContext);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
reportError("workflow-event", error);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
pi.on("session_shutdown", (_event, context) => {
|
|
131
|
+
if (startupTimer) clearTimeout(startupTimer);
|
|
132
|
+
startupTimer = undefined;
|
|
133
|
+
if (context.mode === "tui" && footerInstalled) context.ui.setFooter(undefined);
|
|
134
|
+
snapshot = null;
|
|
135
|
+
activeContext = null;
|
|
136
|
+
footerInstalled = false;
|
|
137
|
+
requestRender = () => {};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vibe-essrj",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ESSRJ status footer for Pi and the Emma workflow",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": ["pi-package"],
|
|
8
|
+
"engines": { "node": ">=22.19.0" },
|
|
9
|
+
"files": ["index.ts", "context.ts", "data.ts", "render.ts", "types.ts", "project-local-owner.ts"],
|
|
10
|
+
"peerDependencies": { "@earendil-works/pi-tui": "*" },
|
|
11
|
+
"pi": { "extensions": ["./index.ts"] }
|
|
12
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
|
|
5
|
+
export function shouldYieldToProject(extensionUrl: string, declaration: string, cwd: string, projectTrusted: boolean): boolean {
|
|
6
|
+
if (projectTrusted !== true) return false;
|
|
7
|
+
const projectRoot = resolve(cwd);
|
|
8
|
+
const emmaRoot = join(projectRoot, ".emma");
|
|
9
|
+
const extensionPath = fileURLToPath(extensionUrl);
|
|
10
|
+
if (isInside(emmaRoot, extensionPath)) return false;
|
|
11
|
+
|
|
12
|
+
const manifestPath = join(emmaRoot, "package.json");
|
|
13
|
+
const settingsPath = join(projectRoot, ".pi", "settings.json");
|
|
14
|
+
if (!isRegularOwnedFile(projectRoot, manifestPath) || !isRegularOwnedFile(projectRoot, settingsPath)) return false;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
18
|
+
const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
19
|
+
if (manifest?.name !== "vibe-emma-local" || !Array.isArray(manifest.pi?.extensions) ||
|
|
20
|
+
!manifest.pi.extensions.includes(declaration) || !Array.isArray(settings?.packages)) return false;
|
|
21
|
+
const resource = resolve(emmaRoot, declaration.replace(/^\.\//, ""));
|
|
22
|
+
if (!isRegularOwnedFile(emmaRoot, resource)) return false;
|
|
23
|
+
const settingsRoot = dirname(settingsPath);
|
|
24
|
+
return settings.packages.some((entry: string | { source?: string; extensions?: string[] }) => {
|
|
25
|
+
const source = typeof entry === "string" ? entry : entry?.source;
|
|
26
|
+
if (!source || !packageEntryEnables(entry, declaration, resource)) return false;
|
|
27
|
+
return samePath(resolve(settingsRoot, source.replace(/\\/g, "/")), emmaRoot);
|
|
28
|
+
});
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function packageEntryEnables(entry: string | { autoload?: boolean; extensions?: string[] }, declaration: string, resource: string): boolean {
|
|
35
|
+
if (typeof entry === "string") return true;
|
|
36
|
+
if (entry.extensions === undefined) return entry.autoload !== false;
|
|
37
|
+
if (!Array.isArray(entry.extensions) || entry.extensions.length === 0 || entry.extensions.some(value => typeof value !== "string")) return false;
|
|
38
|
+
const relativePath = normalizeExactPath(declaration);
|
|
39
|
+
const absolutePath = toPosix(resource);
|
|
40
|
+
const fileName = basename(relativePath);
|
|
41
|
+
if (entry.autoload === false) {
|
|
42
|
+
// Pi treats an autoload-disabled entry as a delta, applied in order.
|
|
43
|
+
let enabled = false;
|
|
44
|
+
for (const value of entry.extensions) {
|
|
45
|
+
const prefix = value[0];
|
|
46
|
+
const exact = prefix === "+" || prefix === "-";
|
|
47
|
+
const pattern = exact || prefix === "!" ? value.slice(1) : value;
|
|
48
|
+
if (exact ? matchesExact(pattern, relativePath, absolutePath) : matchesPattern(pattern, relativePath, fileName, absolutePath)) {
|
|
49
|
+
enabled = prefix !== "-" && prefix !== "!";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return enabled;
|
|
53
|
+
}
|
|
54
|
+
const includes = entry.extensions.filter((value) => !/^[!+-]/.test(value));
|
|
55
|
+
const excludes = entry.extensions.filter((value) => value.startsWith("!")).map((value) => value.slice(1));
|
|
56
|
+
const forceIncludes = entry.extensions.filter((value) => value.startsWith("+")).map((value) => value.slice(1));
|
|
57
|
+
const forceExcludes = entry.extensions.filter((value) => value.startsWith("-")).map((value) => value.slice(1));
|
|
58
|
+
let enabled = includes.length === 0 || includes.some((pattern) => matchesPattern(pattern, relativePath, fileName, absolutePath));
|
|
59
|
+
if (excludes.some((pattern) => matchesPattern(pattern, relativePath, fileName, absolutePath))) enabled = false;
|
|
60
|
+
if (forceIncludes.some((pattern) => matchesExact(pattern, relativePath, absolutePath))) enabled = true;
|
|
61
|
+
if (forceExcludes.some((pattern) => matchesExact(pattern, relativePath, absolutePath))) enabled = false;
|
|
62
|
+
return enabled;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function matchesPattern(pattern: string, relativePath: string, fileName: string, absolutePath: string): boolean {
|
|
66
|
+
const normalized = toPosix(pattern);
|
|
67
|
+
return [relativePath, fileName, absolutePath].some((candidate) => matchesGlob(candidate, normalized));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function matchesExact(pattern: string, relativePath: string, absolutePath: string): boolean {
|
|
71
|
+
const normalized = normalizeExactPath(pattern);
|
|
72
|
+
return normalized === relativePath || normalized === absolutePath;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function normalizeExactPath(value: string): string {
|
|
76
|
+
return toPosix(value).replace(/^\.\//, "");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function toPosix(value: string): string {
|
|
80
|
+
return value.replace(/\\/g, "/");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isRegularOwnedFile(root: string, file: string): boolean {
|
|
84
|
+
if (!existsSync(file)) return false;
|
|
85
|
+
try {
|
|
86
|
+
if (!lstatSync(file).isFile()) return false;
|
|
87
|
+
const realRoot = realpathSync(root);
|
|
88
|
+
const realFile = realpathSync(file);
|
|
89
|
+
return isInside(realRoot, realFile);
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isInside(root: string, candidate: string): boolean {
|
|
96
|
+
const value = relative(resolve(root), resolve(candidate));
|
|
97
|
+
return value === "" || (!value.startsWith(`..${sep}`) && value !== ".." && !isAbsolute(value));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function samePath(left: string, right: string): boolean {
|
|
101
|
+
const normalize = (value: string) => {
|
|
102
|
+
const resolved = resolve(value).replace(/[\\/]+$/, "");
|
|
103
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
104
|
+
};
|
|
105
|
+
return normalize(left) === normalize(right);
|
|
106
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { EmmaData, FooterSnapshot, GitData, PiPayload } from "./types.ts";
|
|
4
|
+
|
|
5
|
+
function fg(r: number, g: number, b: number): string {
|
|
6
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
7
|
+
}
|
|
8
|
+
function dim(): string { return "\x1b[2m"; }
|
|
9
|
+
function reset(): string { return "\x1b[0m"; }
|
|
10
|
+
|
|
11
|
+
export type SemanticColor =
|
|
12
|
+
| "text"
|
|
13
|
+
| "muted"
|
|
14
|
+
| "dim"
|
|
15
|
+
| "accent"
|
|
16
|
+
| "success"
|
|
17
|
+
| "warning"
|
|
18
|
+
| "error";
|
|
19
|
+
|
|
20
|
+
export interface ThemeLike {
|
|
21
|
+
getFgAnsi(color: SemanticColor): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Palette {
|
|
25
|
+
white: string;
|
|
26
|
+
whiteDim: string;
|
|
27
|
+
contextInfo: string;
|
|
28
|
+
cyan: string;
|
|
29
|
+
green: string;
|
|
30
|
+
yellow: string;
|
|
31
|
+
red: string;
|
|
32
|
+
magenta: string;
|
|
33
|
+
pink: string;
|
|
34
|
+
pinkDim: string;
|
|
35
|
+
barGreen: string;
|
|
36
|
+
barGreenDim: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const SIGNATURE = {
|
|
40
|
+
dark: {
|
|
41
|
+
magenta: fg(200, 175, 225),
|
|
42
|
+
pink: fg(240, 160, 180),
|
|
43
|
+
pinkDim: fg(156, 104, 117),
|
|
44
|
+
barGreen: fg(170, 230, 170),
|
|
45
|
+
barGreenDim: fg(85, 120, 85),
|
|
46
|
+
},
|
|
47
|
+
light: {
|
|
48
|
+
magenta: fg(142, 36, 170),
|
|
49
|
+
pink: fg(194, 24, 91),
|
|
50
|
+
pinkDim: fg(224, 178, 197),
|
|
51
|
+
barGreen: fg(46, 125, 50),
|
|
52
|
+
barGreenDim: fg(181, 212, 184),
|
|
53
|
+
},
|
|
54
|
+
} as const;
|
|
55
|
+
|
|
56
|
+
function paletteFromTheme(theme: ThemeLike, isLight: boolean): Palette {
|
|
57
|
+
const semantic = (color: SemanticColor): string => theme.getFgAnsi(color);
|
|
58
|
+
const signature = isLight ? SIGNATURE.light : SIGNATURE.dark;
|
|
59
|
+
return {
|
|
60
|
+
white: semantic("text"),
|
|
61
|
+
whiteDim: semantic("muted"),
|
|
62
|
+
contextInfo: semantic("dim"),
|
|
63
|
+
cyan: semantic("accent"),
|
|
64
|
+
green: semantic("success"),
|
|
65
|
+
yellow: semantic("warning"),
|
|
66
|
+
red: semantic("error"),
|
|
67
|
+
magenta: signature.magenta,
|
|
68
|
+
pink: signature.pink,
|
|
69
|
+
pinkDim: signature.pinkDim,
|
|
70
|
+
barGreen: signature.barGreen,
|
|
71
|
+
barGreenDim: signature.barGreenDim,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function ansi256ToRgb(n: number): [number, number, number] {
|
|
76
|
+
if (n < 16) {
|
|
77
|
+
const base: Array<[number, number, number]> = [
|
|
78
|
+
[0, 0, 0], [205, 0, 0], [0, 205, 0], [205, 205, 0],
|
|
79
|
+
[0, 0, 238], [205, 0, 205], [0, 205, 205], [229, 229, 229],
|
|
80
|
+
[127, 127, 127], [255, 0, 0], [0, 255, 0], [255, 255, 0],
|
|
81
|
+
[92, 92, 255], [255, 0, 255], [0, 255, 255], [255, 255, 255],
|
|
82
|
+
];
|
|
83
|
+
return base[n];
|
|
84
|
+
}
|
|
85
|
+
if (n < 232) {
|
|
86
|
+
const i = n - 16;
|
|
87
|
+
const steps = [0, 95, 135, 175, 215, 255];
|
|
88
|
+
return [steps[Math.floor(i / 36)], steps[Math.floor(i / 6) % 6], steps[i % 6]];
|
|
89
|
+
}
|
|
90
|
+
const gray = 8 + (n - 232) * 10;
|
|
91
|
+
return [gray, gray, gray];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function luminance(rgb: [number, number, number]): number {
|
|
95
|
+
const linear = (channel: number): number => {
|
|
96
|
+
const value = channel / 255;
|
|
97
|
+
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
98
|
+
};
|
|
99
|
+
return 0.2126 * linear(rgb[0]) + 0.7152 * linear(rgb[1]) + 0.0722 * linear(rgb[2]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function isLightTheme(theme: ThemeLike): boolean {
|
|
103
|
+
const code = theme.getFgAnsi("text");
|
|
104
|
+
const truecolor = code.match(/38;2;(\d+);(\d+);(\d+)/);
|
|
105
|
+
if (truecolor) {
|
|
106
|
+
return luminance([Number(truecolor[1]), Number(truecolor[2]), Number(truecolor[3])]) < 0.5;
|
|
107
|
+
}
|
|
108
|
+
const indexed = code.match(/38;5;(\d+)/);
|
|
109
|
+
if (indexed) return luminance(ansi256ToRgb(Number(indexed[1]))) < 0.5;
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const SEPARATOR = ` ${dim()}│${reset()} `;
|
|
114
|
+
const ICON = {
|
|
115
|
+
branch: "",
|
|
116
|
+
session: "",
|
|
117
|
+
shape: "",
|
|
118
|
+
hunt: "",
|
|
119
|
+
build: "\u{f13af}",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
function emmaStage(status: string, C: Palette): { icon: string; label: string; color: string } {
|
|
123
|
+
if (status === "shape") return { icon: ICON.shape, label: "SHAPE", color: C.cyan };
|
|
124
|
+
if (status === "hunt") return { icon: ICON.hunt, label: "HUNT", color: C.red };
|
|
125
|
+
if (status === "build") return { icon: ICON.build, label: "BUILD", color: C.yellow };
|
|
126
|
+
return { icon: "", label: status.toUpperCase(), color: C.magenta };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function renderFooter(snapshot: FooterSnapshot, maxWidth: number, theme: ThemeLike): string {
|
|
130
|
+
const C = paletteFromTheme(theme, isLightTheme(theme));
|
|
131
|
+
const line1 = truncateToWidth(buildLine1(snapshot.stdin, snapshot.extra.git, snapshot.emma, C), maxWidth, "");
|
|
132
|
+
const line2 = truncateToWidth(buildLine2(snapshot.emma, C), maxWidth, "");
|
|
133
|
+
return line1 && line2 ? `${line1}\n${line2}` : line1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function buildLine1(stdin: PiPayload, git: GitData, emma: EmmaData, C: Palette): string {
|
|
137
|
+
const parts: string[] = [];
|
|
138
|
+
|
|
139
|
+
const projectDir = stdin.workspace.project_dir || stdin.cwd;
|
|
140
|
+
let projectGit = projectDir ? `${C.white}${path.basename(projectDir)}${reset()}` : "";
|
|
141
|
+
if (git.branch) {
|
|
142
|
+
projectGit += `${projectGit ? " " : ""}${C.cyan}${ICON.branch} ${git.branch}${reset()}`;
|
|
143
|
+
const stats: string[] = [];
|
|
144
|
+
if (git.ahead > 0) stats.push(`${C.cyan}⇡${git.ahead}${reset()}`);
|
|
145
|
+
if (git.behind > 0) stats.push(`${C.cyan}⇣${git.behind}${reset()}`);
|
|
146
|
+
if (git.staged > 0) stats.push(`${C.green}+${git.staged}${reset()}`);
|
|
147
|
+
if (git.unstaged > 0) stats.push(`${C.yellow}!${git.unstaged}${reset()}`);
|
|
148
|
+
if (git.untracked > 0) stats.push(`${C.whiteDim}?${git.untracked}${reset()}`);
|
|
149
|
+
if (stats.length > 0) {
|
|
150
|
+
projectGit += `${C.whiteDim} (${reset()}${stats.join(" ")}${C.whiteDim})${reset()}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (projectGit) parts.push(projectGit);
|
|
154
|
+
|
|
155
|
+
const usage = calculateContextUsage(stdin.context_window);
|
|
156
|
+
if (usage) {
|
|
157
|
+
const percentColor = usage.percent >= 60 ? C.red : usage.percent >= 40 ? C.yellow : C.green;
|
|
158
|
+
parts.push(
|
|
159
|
+
` ${formatCacheHitRate(stdin.context_window.cache_hit_rate)} ${buildContextBar(usage.percent, C)} ${C.whiteDim}${formatUsageTokens(usage.current)}/${formatTokens(usage.total)}`
|
|
160
|
+
+ ` ${percentColor}${usage.percent}%${reset()}`,
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (emma.workflowStatus) {
|
|
165
|
+
const stage = emmaStage(emma.workflowStatus, C);
|
|
166
|
+
parts.push(`${stage.color}${stage.icon ? `${stage.icon} ` : ""}${stage.label}${reset()}`);
|
|
167
|
+
}
|
|
168
|
+
return parts.join(SEPARATOR);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function buildLine2(emma: EmmaData, C: Palette): string {
|
|
172
|
+
if (!emma.sessionId) return "";
|
|
173
|
+
return `${C.contextInfo}${ICON.session} ${C.cyan}${emma.sessionId}${reset()}`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function buildContextBar(percent: number, C: Palette, width = 8): string {
|
|
177
|
+
const clamped = Math.min(100, Math.max(0, Math.round(percent)));
|
|
178
|
+
const filled = Math.round((clamped * width) / 100);
|
|
179
|
+
const color = clamped >= 20 ? C.pink : C.barGreen;
|
|
180
|
+
const emptyColor = clamped >= 20 ? C.pinkDim : C.barGreenDim;
|
|
181
|
+
return color + "█".repeat(filled) + dim() + emptyColor + "░".repeat(width - filled) + reset();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function calculateContextUsage(contextWindow: PiPayload["context_window"]): {
|
|
185
|
+
current: number;
|
|
186
|
+
total: number;
|
|
187
|
+
percent: number;
|
|
188
|
+
} | null {
|
|
189
|
+
const usage = contextWindow.current_usage;
|
|
190
|
+
const current = usage.input_tokens
|
|
191
|
+
+ (usage.cache_creation_input_tokens ?? 0)
|
|
192
|
+
+ (usage.cache_read_input_tokens ?? 0);
|
|
193
|
+
const total = contextWindow.context_window_size || 200000;
|
|
194
|
+
if (current > 0 && total > 0) {
|
|
195
|
+
return { current, total, percent: Math.round((current * 100) / total) };
|
|
196
|
+
}
|
|
197
|
+
if (contextWindow.used_percentage !== null) {
|
|
198
|
+
const percent = Math.round(contextWindow.used_percentage);
|
|
199
|
+
return { current: Math.round((total * percent) / 100), total, percent };
|
|
200
|
+
}
|
|
201
|
+
return { current: 0, total, percent: 0 };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function formatCacheHitRate(rate: number | null): string {
|
|
205
|
+
return rate === null ? "CH -" : `CH ${rate.toFixed(1)}%`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function formatUsageTokens(value: number): string {
|
|
209
|
+
if (value >= 1000) return (value / 1000).toFixed(value >= 10_000 ? 0 : 1).replace(/\.0$/, "");
|
|
210
|
+
return String(value);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function formatTokens(value: number): string {
|
|
214
|
+
if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1).replace(/\.0$/, "")}M`;
|
|
215
|
+
if (value >= 1000) return `${(value / 1000).toFixed(value >= 10_000 ? 0 : 1).replace(/\.0$/, "")}k`;
|
|
216
|
+
return String(value);
|
|
217
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface EmmaData {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
workflowStatus: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface GitData {
|
|
7
|
+
branch: string;
|
|
8
|
+
staged: number;
|
|
9
|
+
unstaged: number;
|
|
10
|
+
untracked: number;
|
|
11
|
+
ahead: number;
|
|
12
|
+
behind: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PiPayload {
|
|
16
|
+
model: { display_name: string };
|
|
17
|
+
context_window: {
|
|
18
|
+
used_percentage: number | null;
|
|
19
|
+
context_window_size: number;
|
|
20
|
+
cache_hit_rate: number | null;
|
|
21
|
+
current_usage: {
|
|
22
|
+
input_tokens: number;
|
|
23
|
+
cache_creation_input_tokens?: number;
|
|
24
|
+
cache_read_input_tokens?: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
workspace: { project_dir: string };
|
|
28
|
+
cwd: string;
|
|
29
|
+
transcript_path: string;
|
|
30
|
+
effort: { level: string };
|
|
31
|
+
thinking: { enabled: boolean };
|
|
32
|
+
session_id: string;
|
|
33
|
+
session_name: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface FooterSnapshot {
|
|
37
|
+
stdin: PiPayload;
|
|
38
|
+
extra: { git: GitData };
|
|
39
|
+
emma: EmmaData;
|
|
40
|
+
}
|
package/plugins.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"essrj": {
|
|
3
|
+
"source": "./plugins/essrj",
|
|
4
|
+
"label": "ESSRJ 状态栏",
|
|
5
|
+
"note": "Use only one custom Pi footer at a time."
|
|
6
|
+
},
|
|
7
|
+
"config-ui": {
|
|
8
|
+
"source": "./plugins/config-ui",
|
|
9
|
+
"label": "Config UI(/config)",
|
|
10
|
+
"dependencies": true,
|
|
11
|
+
"note": "Browser configuration editor for Pi. For manual installation from the checkout, first run: npm --prefix ./plugins/config-ui install --omit=dev --omit=peer --ignore-scripts"
|
|
12
|
+
},
|
|
13
|
+
"pi-fff": {
|
|
14
|
+
"source": "npm:@ff-labs/pi-fff",
|
|
15
|
+
"note": "Fast file search. Review the upstream home-directory scanning default before using it."
|
|
16
|
+
},
|
|
17
|
+
"pi-claude-code": {
|
|
18
|
+
"source": "npm:pi-claude-code",
|
|
19
|
+
"note": "Claude Code-style Pi TUI. Choose either its custom footer or ESSRJ's; do not apply pi-cc-extensions settings to this package automatically."
|
|
20
|
+
},
|
|
21
|
+
"pi-mcp-adapter": {
|
|
22
|
+
"source": "npm:pi-mcp-adapter",
|
|
23
|
+
"note": "MCP adapter. Configure and approve servers separately."
|
|
24
|
+
},
|
|
25
|
+
"pi-btw": {
|
|
26
|
+
"source": "npm:@narumitw/pi-btw",
|
|
27
|
+
"note": "Side conversations in Pi."
|
|
28
|
+
},
|
|
29
|
+
"pi-blackhole": {
|
|
30
|
+
"source": "npm:pi-blackhole",
|
|
31
|
+
"note": "Changes compaction behavior. Review other compaction integrations before enabling it."
|
|
32
|
+
},
|
|
33
|
+
"pi-jev-auto-mode": {
|
|
34
|
+
"source": "npm:pi-jev-auto-mode",
|
|
35
|
+
"label": "pi-jev-auto-mode(若已由 vc 管理,不必选)",
|
|
36
|
+
"note": "Command review. If using vc, let vc manage its existing Jev registration and policy; this catalogue does not replace or weaken that policy."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Emil Kowalski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|