Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

fix(plugins): keep the Skill sync correct for every commit form

0x094fc36fd155c
diff --git a/lefthook.yml b/lefthook.yml
index 0fa0543..e55a884 100644
--- a/lefthook.yml
+++ b/lefthook.yml
@@ -52,3 +52,14 @@ pre-commit:
run: |
git diff --cached --name-only --diff-filter=ACMR | grep -Eq '^(package/ego-browser/|skills/ego-browser/)' || exit 0
cd package/ego-browser && npm run e2e
+
+post-commit:
+ commands:
+ plugin-skill-index:
+ # `git commit <paths>` commits plugin-skill-sync's copy from a temporary
+ # index, so the real index keeps the old copy. Point it back at HEAD.
+ run: |
+ copy=plugins/ego/skills/ego-browser
+ if git diff --quiet HEAD -- "$copy" && ! git diff --cached --quiet -- "$copy"; then
+ git reset -q -- "$copy"
+ fi
diff --git a/plugins/ego/tests/sync-skills.test.mjs b/plugins/ego/tests/sync-skills.test.mjs
index b27ed9b..2944002 100644
--- a/plugins/ego/tests/sync-skills.test.mjs
+++ b/plugins/ego/tests/sync-skills.test.mjs
@@ -22,10 +22,16 @@ function write(root, path, value) {
writeFileSync(join(root, path), value);
}
+// A commit hook runs these tests with GIT_INDEX_FILE pointing at the commit's
+// index, so the fixture repository must not inherit Git's environment.
+const env = Object.fromEntries(
+ Object.entries(process.env).filter(([key]) => !key.startsWith("GIT_")),
+);
+
test("--staged copies only what the commit stages and stages the copy", () => {
const root = mkdtempSync(join(tmpdir(), "ego-skill-sync-"));
const git = (...args) =>
- execFileSync("git", args, { cwd: root, encoding: "utf8" });
+ execFileSync("git", args, { cwd: root, encoding: "utf8", env });
try {
mkdirSync(join(root, "plugins", "scripts"), { recursive: true });
copyFileSync(script, join(root, "plugins", "scripts", "sync-skills.mjs"));
@@ -43,11 +49,11 @@ test("--staged copies only what the commit stages and stages the copy", () => {
write(root, "skills/demo/SKILL.md", "v3 unstaged\n");
write(root, "skills/demo/draft.md", "untracked\n");
- execFileSync(process.execPath, [
- join(root, "plugins", "scripts", "sync-skills.mjs"),
- "p",
- "--staged",
- ]);
+ execFileSync(
+ process.execPath,
+ [join(root, "plugins", "scripts", "sync-skills.mjs"), "p", "--staged"],
+ { env },
+ );
assert.equal(git("show", ":plugins/p/skills/demo/SKILL.md"), "v2 staged\n");
assert.equal(