mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-20 07:15:25 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c479a0f94 | ||
|
|
18af97688d | ||
|
|
db1c3bb776 | ||
|
|
8cf074fa2e |
+7
-5
@@ -186,11 +186,13 @@ Terminal activity contributes to the workspace status bucket **per `workspaceId`
|
||||
|
||||
Single file, validated with `PersistedConfigSchema`.
|
||||
|
||||
`agents.skills.selection` is the daemon host's orchestration-skill preference. Missing means
|
||||
`{ mode: "all" }`. Installed state is not persisted; the daemon derives it from the shared
|
||||
`~/.agents/skills` and Claude skill directories and keeps config plus filesystem convergence behind
|
||||
one serialized owner. Codex discovers the shared directory. Updates retire unchanged files from
|
||||
Paseo-managed copies in `~/.codex/skills`, preserving user edits and untracked files.
|
||||
`agents.skills.selection` stores the orchestration-skill preference for the daemon host, and a
|
||||
missing value defaults to `{ mode: "all" }`. The daemon does not persist installed state. It
|
||||
derives installed state from `~/.agents/skills`, `~/.claude/skills`, and `~/.gemini/config/skills`,
|
||||
and serializes configuration and filesystem convergence through one owner. Codex and Gemini CLI
|
||||
discover `~/.agents/skills`, while Antigravity discovers `~/.gemini/config/skills`. Updates retire
|
||||
unchanged files from Paseo-managed copies in `~/.codex/skills` and preserve user edits and
|
||||
untracked files.
|
||||
|
||||
`paseo reload` reads and validates this file once inside the daemon. That snapshot drives resolution,
|
||||
classification, application, and reload bookkeeping. `DaemonConfigStore` owns applying runtime-safe
|
||||
|
||||
@@ -22,7 +22,7 @@ type AgentSkillsClient = Pick<
|
||||
"close" | "connect" | "getAgentSkillsStatus" | "saveAgentSkillsSelection"
|
||||
>;
|
||||
|
||||
export type SkillTargetName = "agents" | "claude";
|
||||
export type SkillTargetName = "agents" | "claude" | "antigravity";
|
||||
|
||||
export interface AgentSkillsSandbox {
|
||||
available: string[];
|
||||
@@ -64,6 +64,7 @@ export async function startAgentSkillsSandbox(): Promise<AgentSkillsSandbox> {
|
||||
const targets = {
|
||||
agents: path.join(home, ".agents", "skills"),
|
||||
claude: path.join(home, ".claude", "skills"),
|
||||
antigravity: path.join(home, ".gemini", "config", "skills"),
|
||||
};
|
||||
const codexSkillsDir = path.join(home, ".codex", "skills");
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ export interface SetupHost {
|
||||
/**
|
||||
* An isolated host whose only agent history is the Claude sessions given here, so suggestions
|
||||
* never depend on the machine running the test. Its HOME is a scratch folder, so the skills setup
|
||||
* installs never land in the real ~/.agents, ~/.claude or ~/.codex. `withBrokenProvider` adds a
|
||||
* installs never land in the real ~/.agents, ~/.claude, ~/.codex, or ~/.gemini/config. `withBrokenProvider` adds a
|
||||
* provider that cannot start.
|
||||
*/
|
||||
export async function startSetupHost(
|
||||
|
||||
@@ -2892,7 +2892,8 @@ export const ar: TranslationResources = {
|
||||
updateAvailable: "التحديث متاح",
|
||||
updateTitle: "تحديث مهارات Paseo ؟",
|
||||
uninstallTitle: "إلغاء تثبيت مهارات Paseo ؟",
|
||||
uninstallMessage: "يزيل جميع مهارات تنسيق Paseo من ~/.agents ، ~/.claude ، ~/.codex.",
|
||||
uninstallMessage:
|
||||
"يزيل جميع مهارات تنسيق Paseo من ~/.agents و~/.claude و~/.codex و~/.gemini/config.",
|
||||
choose: "اختيار المهارات",
|
||||
chooseAll: "كل المهارات",
|
||||
chooseAllHint: "أبقِ جميع المهارات المرفقة مثبتة، بما فيها ما يُضاف لاحقًا.",
|
||||
@@ -2900,7 +2901,7 @@ export const ar: TranslationResources = {
|
||||
chooseEmpty: "لا تتضمن هذه النسخة أي مهارات.",
|
||||
removeTitle: "إزالة المهارات غير المحددة؟",
|
||||
removeMessage:
|
||||
"سيتم حذف {{skills}} من ~/.agents و~/.claude و~/.codex. كما يُحذف كل ما أضفته داخل مجلدات المهارات تلك.",
|
||||
"سيتم حذف {{skills}} من ~/.agents و~/.claude و~/.codex و~/.gemini/config. كما يُحذف كل ما أضفته داخل مجلدات المهارات تلك.",
|
||||
saveFailed: "تعذر حفظ اختيار المهارات.",
|
||||
statusFailed: "غير قادر على التحقق من حالة مهارات التنسيق.",
|
||||
updateFailed: "غير قادر على تحديث مهارات التنسيق.",
|
||||
|
||||
@@ -2994,7 +2994,7 @@ export const en = {
|
||||
updateTitle: "Update Paseo skills?",
|
||||
uninstallTitle: "Uninstall Paseo skills?",
|
||||
uninstallMessage:
|
||||
"Removes all Paseo orchestration skills from ~/.agents, ~/.claude, ~/.codex on this host.",
|
||||
"Removes all Paseo orchestration skills from ~/.agents, ~/.claude, ~/.codex, and ~/.gemini/config on this host.",
|
||||
choose: "Choose skills",
|
||||
chooseAll: "All skills",
|
||||
chooseAllHint: "Keep every bundled skill installed, including ones added later.",
|
||||
@@ -3002,7 +3002,7 @@ export const en = {
|
||||
chooseEmpty: "This host bundles no skills.",
|
||||
removeTitle: "Remove deselected skills?",
|
||||
removeMessage:
|
||||
"{{skills}} will be deleted from ~/.agents, ~/.claude, and ~/.codex on this host. Anything you added inside those skill folders is deleted too.",
|
||||
"{{skills}} will be deleted from ~/.agents, ~/.claude, ~/.codex, and ~/.gemini/config on this host. Anything you added inside those skill folders is deleted too.",
|
||||
saveFailed: "Could not save your skill selection.",
|
||||
actions: {
|
||||
update: "Update",
|
||||
|
||||
@@ -2916,7 +2916,7 @@ export const es: TranslationResources = {
|
||||
updateTitle: "¿Actualizar las habilidades dePaseo?",
|
||||
uninstallTitle: "¿Desinstalar las habilidadesPaseo?",
|
||||
uninstallMessage:
|
||||
"Elimina todas las habilidades de orquestaciónPaseode ~/.agents, ~/.claude, ~/.codex.",
|
||||
"Elimina todas las habilidades de orquestación Paseo de ~/.agents, ~/.claude, ~/.codex y ~/.gemini/config.",
|
||||
choose: "Elegir habilidades",
|
||||
chooseAll: "Todas las habilidades",
|
||||
chooseAllHint:
|
||||
@@ -2925,7 +2925,7 @@ export const es: TranslationResources = {
|
||||
chooseEmpty: "Esta versión no incluye habilidades.",
|
||||
removeTitle: "¿Eliminar las habilidades deseleccionadas?",
|
||||
removeMessage:
|
||||
"{{skills}} se eliminarán de ~/.agents, ~/.claude y ~/.codex. También se elimina todo lo que hayas añadido dentro de esas carpetas de habilidades.",
|
||||
"{{skills}} se eliminarán de ~/.agents, ~/.claude, ~/.codex y ~/.gemini/config. También se elimina todo lo que hayas añadido dentro de esas carpetas de habilidades.",
|
||||
saveFailed: "No se pudo guardar tu selección de habilidades.",
|
||||
statusFailed: "No se puede comprobar el estado de las habilidades de orquestación.",
|
||||
updateFailed: "No se pueden actualizar las habilidades de orquestación.",
|
||||
|
||||
@@ -2919,7 +2919,7 @@ export const fr: TranslationResources = {
|
||||
updateTitle: "Mettre à jour les skills Paseo ?",
|
||||
uninstallTitle: "Désinstaller les skills Paseo ?",
|
||||
uninstallMessage:
|
||||
"Supprime tous les skills d’orchestration Paseo de ~/.agents, ~/.claude et ~/.codex sur cet hôte.",
|
||||
"Supprime tous les skills d’orchestration Paseo de ~/.agents, ~/.claude, ~/.codex et ~/.gemini/config sur cet hôte.",
|
||||
choose: "Choisir les skills",
|
||||
chooseAll: "Tous les skills",
|
||||
chooseAllHint:
|
||||
@@ -2928,7 +2928,7 @@ export const fr: TranslationResources = {
|
||||
chooseEmpty: "Cet hôte ne fournit aucun skill.",
|
||||
removeTitle: "Supprimer les skills décochés ?",
|
||||
removeMessage:
|
||||
"{{skills}} seront supprimés de ~/.agents, ~/.claude et ~/.codex sur cet hôte. Tout ce que vous avez ajouté dans ces dossiers de skills sera également supprimé.",
|
||||
"{{skills}} seront supprimés de ~/.agents, ~/.claude, ~/.codex et ~/.gemini/config sur cet hôte. Tout ce que vous avez ajouté dans ces dossiers de skills sera également supprimé.",
|
||||
saveFailed: "Impossible d’enregistrer votre sélection de skills.",
|
||||
statusFailed: "Impossible de vérifier l’état des skills d’orchestration.",
|
||||
updateFailed: "Impossible de mettre à jour les skills d’orchestration.",
|
||||
|
||||
@@ -2884,7 +2884,7 @@ export const ja: TranslationResources = {
|
||||
updateTitle: "Paseoスキルを更新しますか?",
|
||||
uninstallTitle: "Paseoスキルをアンインストールしますか?",
|
||||
uninstallMessage:
|
||||
"~/.agents、~/.claude、~/.codexからすべてのPaseoオーケストレーションスキルを削除します。",
|
||||
"~/.agents、~/.claude、~/.codex、~/.gemini/configからすべてのPaseoオーケストレーションスキルを削除します。",
|
||||
choose: "スキルを選択",
|
||||
chooseAll: "すべてのスキル",
|
||||
chooseAllHint:
|
||||
@@ -2893,7 +2893,7 @@ export const ja: TranslationResources = {
|
||||
chooseEmpty: "このビルドにはスキルが含まれていません。",
|
||||
removeTitle: "選択を外したスキルを削除しますか?",
|
||||
removeMessage:
|
||||
"{{skills}} を ~/.agents、~/.claude、~/.codex から削除します。それらのスキルフォルダー内に追加したものもすべて削除されます。",
|
||||
"{{skills}} を ~/.agents、~/.claude、~/.codex、~/.gemini/config から削除します。それらのスキルフォルダー内に追加したものもすべて削除されます。",
|
||||
saveFailed: "スキルの選択を保存できませんでした。",
|
||||
statusFailed: "オーケストレーションスキルのステータスを確認できません。",
|
||||
updateFailed: "オーケストレーションスキルを更新できません。",
|
||||
|
||||
@@ -2871,7 +2871,7 @@ export const ko: TranslationResources = {
|
||||
updateTitle: "Paseo 스킬을 업데이트할까요?",
|
||||
uninstallTitle: "Paseo 스킬을 제거할까요?",
|
||||
uninstallMessage:
|
||||
"~/.agents, ~/.claude, ~/.codex에서 모든 Paseo 오케스트레이션 스킬을 제거합니다.",
|
||||
"~/.agents, ~/.claude, ~/.codex, ~/.gemini/config에서 모든 Paseo 오케스트레이션 스킬을 제거합니다.",
|
||||
choose: "스킬 선택",
|
||||
chooseAll: "모든 스킬",
|
||||
chooseAllHint: "나중에 추가되는 항목을 포함하여 모든 번들 스킬을 설치된 상태로 유지합니다.",
|
||||
@@ -2879,7 +2879,7 @@ export const ko: TranslationResources = {
|
||||
chooseEmpty: "이 빌드에는 번들 스킬이 없습니다.",
|
||||
removeTitle: "선택 해제한 스킬을 제거할까요?",
|
||||
removeMessage:
|
||||
"{{skills}}는 ~/.agents, ~/.claude 및 ~/.codex에서 삭제됩니다. 해당 스킬 폴더 안에 추가한 모든 항목도 삭제됩니다.",
|
||||
"{{skills}}는 ~/.agents, ~/.claude, ~/.codex 및 ~/.gemini/config에서 삭제됩니다. 해당 스킬 폴더 안에 추가한 모든 항목도 삭제됩니다.",
|
||||
saveFailed: "선택한 스킬을 저장하지 못했습니다.",
|
||||
statusFailed: "오케스트레이션 스킬 상태를 확인할 수 없습니다.",
|
||||
updateFailed: "오케스트레이션 스킬을 업데이트할 수 없습니다.",
|
||||
|
||||
@@ -2897,7 +2897,7 @@ export const ptBR: TranslationResources = {
|
||||
updateTitle: "Atualizar Paseo skills?",
|
||||
uninstallTitle: "Desinstalar Paseo skills?",
|
||||
uninstallMessage:
|
||||
"Remove todas as skills de orquestração do Paseo de ~/.agents, ~/.claude e ~/.codex.",
|
||||
"Remove todas as skills de orquestração do Paseo de ~/.agents, ~/.claude, ~/.codex e ~/.gemini/config.",
|
||||
choose: "Escolher skills",
|
||||
chooseAll: "Todas as skills",
|
||||
chooseAllHint:
|
||||
@@ -2906,7 +2906,7 @@ export const ptBR: TranslationResources = {
|
||||
chooseEmpty: "Esta versão não inclui skills.",
|
||||
removeTitle: "Remover as skills desmarcadas?",
|
||||
removeMessage:
|
||||
"{{skills}} serão excluídas de ~/.agents, ~/.claude e ~/.codex. Tudo o que você adicionou dentro dessas pastas de skills também é excluído.",
|
||||
"{{skills}} serão excluídas de ~/.agents, ~/.claude, ~/.codex e ~/.gemini/config. Tudo o que você adicionou dentro dessas pastas de skills também é excluído.",
|
||||
saveFailed: "Não foi possível salvar sua seleção de skills.",
|
||||
statusFailed: "Não foi possível verificar o status das skills de orquestração.",
|
||||
updateFailed: "Não foi possível atualizar as skills de orquestração.",
|
||||
|
||||
@@ -2909,7 +2909,7 @@ export const ru: TranslationResources = {
|
||||
updateTitle: "Обновить навыки Paseo?",
|
||||
uninstallTitle: "Удалить навыки Paseo?",
|
||||
uninstallMessage:
|
||||
"Удаляет все навыки оркестрации Paseo из ~/.agents, ~/.claude и ~/.codex на этом хосте.",
|
||||
"Удаляет все навыки оркестрации Paseo из ~/.agents, ~/.claude, ~/.codex и ~/.gemini/config на этом хосте.",
|
||||
choose: "Выбрать навыки",
|
||||
chooseAll: "Все навыки",
|
||||
chooseAllHint: "Устанавливать все встроенные навыки, включая добавленные позже.",
|
||||
@@ -2917,7 +2917,7 @@ export const ru: TranslationResources = {
|
||||
chooseEmpty: "На этом хосте нет встроенных навыков.",
|
||||
removeTitle: "Удалить снятые навыки?",
|
||||
removeMessage:
|
||||
"{{skills}} будут удалены из ~/.agents, ~/.claude и ~/.codex на этом хосте. Всё, что вы добавили в эти папки навыков, тоже будет удалено.",
|
||||
"{{skills}} будут удалены из ~/.agents, ~/.claude, ~/.codex и ~/.gemini/config на этом хосте. Всё, что вы добавили в эти папки навыков, тоже будет удалено.",
|
||||
saveFailed: "Не удалось сохранить выбор навыков.",
|
||||
statusFailed: "Не удалось проверить состояние навыков оркестрации.",
|
||||
updateFailed: "Не удалось обновить навыки оркестрации.",
|
||||
|
||||
@@ -2826,7 +2826,8 @@ export const zhCN: TranslationResources = {
|
||||
updateAvailable: "有更新可用",
|
||||
updateTitle: "更新 Paseo skills?",
|
||||
uninstallTitle: "卸载 Paseo skills?",
|
||||
uninstallMessage: "会从 ~/.agents、~/.claude、~/.codex 移除所有 Paseo 编排 skills。",
|
||||
uninstallMessage:
|
||||
"会从 ~/.agents、~/.claude、~/.codex、~/.gemini/config 移除所有 Paseo 编排 skills。",
|
||||
choose: "选择 skills",
|
||||
chooseAll: "全部 skills",
|
||||
chooseAllHint: "保持安装所有内置 skills,包括以后新增的。",
|
||||
@@ -2834,7 +2835,7 @@ export const zhCN: TranslationResources = {
|
||||
chooseEmpty: "此版本未内置 skills。",
|
||||
removeTitle: "移除取消勾选的 skills?",
|
||||
removeMessage:
|
||||
"将从 ~/.agents、~/.claude、~/.codex 中删除 {{skills}}。你在这些 skill 文件夹里添加的内容也会一并删除。",
|
||||
"将从 ~/.agents、~/.claude、~/.codex、~/.gemini/config 中删除 {{skills}}。你在这些 skill 文件夹里添加的内容也会一并删除。",
|
||||
saveFailed: "无法保存你的 skills 选择。",
|
||||
statusFailed: "无法检查编排 skills 状态。",
|
||||
updateFailed: "无法更新编排 skills。",
|
||||
|
||||
@@ -10175,6 +10175,8 @@ test("a sender's start wait follows its prompt across a stale-session retry", as
|
||||
|
||||
test("a sender's start wait follows its prompt when the session is stale before the wait begins", async () => {
|
||||
const workdir = mkdtempSync(join(tmpdir(), "agent-manager-immediate-stale-start-"));
|
||||
const resumeEntered = deferred<void>();
|
||||
const releaseResume = deferred<void>();
|
||||
class StaleStartSession extends TestAgentSession {
|
||||
override async startTurn(): Promise<{ turnId: string }> {
|
||||
throw new StaleProviderSessionError("stale-bridge");
|
||||
@@ -10184,6 +10186,15 @@ test("a sender's start wait follows its prompt when the session is stale before
|
||||
override async createSession(config: AgentSessionConfig): Promise<AgentSession> {
|
||||
return new StaleStartSession(config);
|
||||
}
|
||||
|
||||
override async resumeSession(
|
||||
handle: AgentPersistenceHandle,
|
||||
config?: Partial<AgentSessionConfig>,
|
||||
): Promise<AgentSession> {
|
||||
resumeEntered.resolve();
|
||||
await releaseResume.promise;
|
||||
return await super.resumeSession(handle, config);
|
||||
}
|
||||
}
|
||||
const client = new StaleStartClient();
|
||||
const storage = new AgentStorage(join(workdir, "agents"), logger);
|
||||
@@ -10196,9 +10207,11 @@ test("a sender's start wait follows its prompt when the session is stale before
|
||||
runOptions: { clientMessageId: "immediate-stale-start" },
|
||||
});
|
||||
// The stale start has failed and been cleared before the sender begins waiting.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await resumeEntered.promise;
|
||||
expect(manager.hasInFlightRun(agent.id)).toBe(false);
|
||||
await expect(dispatchStarted(dispatch)).resolves.toBeUndefined();
|
||||
const senderWait = dispatchStarted(dispatch);
|
||||
releaseResume.resolve();
|
||||
await expect(senderWait).resolves.toBeUndefined();
|
||||
await client.waitForRetryStart();
|
||||
expect(manager.getTimeline(agent.id).filter((item) => item.type === "user_message")).toEqual([
|
||||
expect.objectContaining({
|
||||
@@ -10207,6 +10220,7 @@ test("a sender's start wait follows its prompt when the session is stale before
|
||||
}),
|
||||
]);
|
||||
} finally {
|
||||
releaseResume.resolve();
|
||||
manager.prepareForShutdown();
|
||||
await Promise.all(manager.listAgents().map((agent) => manager.closeAgent(agent.id)));
|
||||
await manager.flushForShutdown();
|
||||
|
||||
@@ -22,9 +22,16 @@ import type { SkillSelectionStore } from "./selection-store";
|
||||
import { createSkillsController, type SkillsController } from "./controller";
|
||||
import { beginSkillsTransaction } from "./transaction";
|
||||
|
||||
interface TestSkillTargets extends SkillTargets {
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
antigravityDir: string;
|
||||
installDirs: string[];
|
||||
}
|
||||
|
||||
interface Harness {
|
||||
root: string;
|
||||
targets: SkillTargets;
|
||||
targets: TestSkillTargets;
|
||||
controller: SkillsController;
|
||||
selectionStore: SkillSelectionStore;
|
||||
}
|
||||
@@ -33,11 +40,17 @@ const BUNDLED_SKILLS = ["paseo", "paseo-advisor", "paseo-loop"];
|
||||
|
||||
async function makeHarness(selectionStore?: SkillSelectionStore): Promise<Harness> {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "paseo-skills-controller-"));
|
||||
const targets: SkillTargets = {
|
||||
const agentsDir = path.join(root, "home", ".agents", "skills");
|
||||
const claudeDir = path.join(root, "home", ".claude", "skills");
|
||||
const codexDir = path.join(root, "home", ".codex", "skills");
|
||||
const antigravityDir = path.join(root, "home", ".gemini", "config", "skills");
|
||||
const targets: TestSkillTargets = {
|
||||
sourceDir: path.join(root, "bundle"),
|
||||
agentsDir: path.join(root, "home", ".agents", "skills"),
|
||||
claudeDir: path.join(root, "home", ".claude", "skills"),
|
||||
codexDir: path.join(root, "home", ".codex", "skills"),
|
||||
installDirs: [agentsDir, claudeDir, antigravityDir],
|
||||
agentsDir,
|
||||
claudeDir,
|
||||
codexDir,
|
||||
antigravityDir,
|
||||
};
|
||||
for (const name of BUNDLED_SKILLS) {
|
||||
await mkdir(path.join(targets.sourceDir, name), { recursive: true });
|
||||
@@ -146,17 +159,26 @@ async function installedSkills(dir: string): Promise<string[]> {
|
||||
.sort();
|
||||
}
|
||||
|
||||
async function installedEverywhere(targets: SkillTargets): Promise<string[][]> {
|
||||
return Promise.all([targets.agentsDir, targets.claudeDir, targets.codexDir].map(installedSkills));
|
||||
async function installedEverywhere(targets: TestSkillTargets): Promise<string[][]> {
|
||||
return Promise.all(
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir, targets.antigravityDir].map(
|
||||
installedSkills,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function writeUserFile(
|
||||
targets: SkillTargets,
|
||||
targets: TestSkillTargets,
|
||||
skill: string,
|
||||
relativePath: string,
|
||||
contents: string,
|
||||
): Promise<void> {
|
||||
for (const dir of [targets.agentsDir, targets.claudeDir, targets.codexDir]) {
|
||||
for (const dir of [
|
||||
targets.agentsDir,
|
||||
targets.claudeDir,
|
||||
targets.codexDir,
|
||||
targets.antigravityDir,
|
||||
]) {
|
||||
const file = path.join(dir, skill, relativePath);
|
||||
await mkdir(path.dirname(file), { recursive: true });
|
||||
await writeFile(file, contents);
|
||||
@@ -164,30 +186,33 @@ async function writeUserFile(
|
||||
}
|
||||
|
||||
async function readUserFile(
|
||||
targets: SkillTargets,
|
||||
targets: TestSkillTargets,
|
||||
skill: string,
|
||||
relativePath: string,
|
||||
): Promise<Array<string | null>> {
|
||||
return Promise.all(
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir].map((dir) =>
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir, targets.antigravityDir].map((dir) =>
|
||||
readFile(path.join(dir, skill, relativePath), "utf8").catch(() => null),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/** Anything the transaction staged and failed to clean up sits beside the skills tree. */
|
||||
async function backupArtifacts(targets: SkillTargets): Promise<string[][]> {
|
||||
async function backupArtifacts(targets: TestSkillTargets): Promise<string[][]> {
|
||||
return Promise.all(
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir].map(async (dir) => {
|
||||
const parentEntries = await readdir(path.dirname(dir)).catch(() => []);
|
||||
const rootEntries = await readdir(dir).catch(() => []);
|
||||
return [
|
||||
...parentEntries.filter(
|
||||
(entry) => entry !== path.basename(dir) && !entry.startsWith(".paseo-skills-recovered-"),
|
||||
),
|
||||
...rootEntries.filter((entry) => entry.startsWith(".paseo-skills-transaction-")),
|
||||
].sort();
|
||||
}),
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir, targets.antigravityDir].map(
|
||||
async (dir) => {
|
||||
const parentEntries = await readdir(path.dirname(dir)).catch(() => []);
|
||||
const rootEntries = await readdir(dir).catch(() => []);
|
||||
return [
|
||||
...parentEntries.filter(
|
||||
(entry) =>
|
||||
entry !== path.basename(dir) && !entry.startsWith(".paseo-skills-recovered-"),
|
||||
),
|
||||
...rootEntries.filter((entry) => entry.startsWith(".paseo-skills-transaction-")),
|
||||
].sort();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,14 +228,14 @@ async function waitForTransactionDirectory(parent: string): Promise<void> {
|
||||
}
|
||||
|
||||
/** Puts a regular file where the agents skills tree goes, so convergence fails with ENOTDIR. */
|
||||
async function blockAgentsDir(targets: SkillTargets): Promise<void> {
|
||||
async function blockAgentsDir(targets: TestSkillTargets): Promise<void> {
|
||||
await rm(targets.agentsDir, { recursive: true, force: true });
|
||||
await mkdir(path.dirname(targets.agentsDir), { recursive: true });
|
||||
await writeFile(targets.agentsDir, "not a directory");
|
||||
}
|
||||
|
||||
async function isInstalled(targets: SkillTargets, name: string): Promise<boolean> {
|
||||
const dirs = [targets.agentsDir, targets.claudeDir];
|
||||
async function isInstalled(targets: TestSkillTargets, name: string): Promise<boolean> {
|
||||
const dirs = [targets.agentsDir, targets.claudeDir, targets.antigravityDir];
|
||||
const present = await Promise.all(
|
||||
dirs.map((dir) =>
|
||||
access(path.join(dir, name))
|
||||
@@ -251,7 +276,7 @@ describe("skills controller", () => {
|
||||
selection: { mode: "custom", skills: ["paseo", "paseo-loop"] },
|
||||
},
|
||||
);
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
let harness: Harness;
|
||||
@@ -299,6 +324,7 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -455,13 +481,15 @@ describe("skills controller", () => {
|
||||
["paseo", "paseo-loop"],
|
||||
["paseo", "paseo-loop"],
|
||||
["paseo-loop"],
|
||||
["paseo", "paseo-loop"],
|
||||
]);
|
||||
expect(await readUserFile(readOnly.targets, "paseo-loop", "notes/mine.md")).toEqual([
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
]);
|
||||
expect(await backupArtifacts(readOnly.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(readOnly.targets)).toEqual([[], [], [], []]);
|
||||
await rm(readOnly.root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
@@ -482,6 +510,7 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
await rm(readOnly.root, { recursive: true, force: true });
|
||||
});
|
||||
@@ -506,6 +535,7 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
await rm(readOnly.root, { recursive: true, force: true });
|
||||
});
|
||||
@@ -534,11 +564,13 @@ describe("skills controller", () => {
|
||||
"restore this",
|
||||
"restore this",
|
||||
"restore this",
|
||||
"restore this",
|
||||
]);
|
||||
expect(await readUserFile(readOnly.targets, "paseo-loop", "notes/concurrent.md")).toEqual([
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
await rm(readOnly.root, { recursive: true, force: true });
|
||||
});
|
||||
@@ -562,6 +594,7 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
expect(await isInstalled(harness.targets, "paseo-loop")).toBe(true);
|
||||
});
|
||||
@@ -580,6 +613,7 @@ describe("skills controller", () => {
|
||||
harness.targets.agentsDir,
|
||||
harness.targets.claudeDir,
|
||||
harness.targets.codexDir,
|
||||
harness.targets.antigravityDir,
|
||||
].map((root) => path.join(root, "paseo-loop"));
|
||||
for (const live of livePaths) await chmod(live, 0o700);
|
||||
const before = await Promise.all(livePaths.map(lstat));
|
||||
@@ -591,7 +625,7 @@ describe("skills controller", () => {
|
||||
|
||||
const after = await Promise.all(livePaths.map(lstat));
|
||||
expect(after.map((entry) => entry.ino)).toEqual(before.map((entry) => entry.ino));
|
||||
expect(after.map((entry) => entry.mode & 0o777)).toEqual([0o700, 0o700, 0o700]);
|
||||
expect(after.map((entry) => entry.mode & 0o777)).toEqual([0o700, 0o700, 0o700, 0o700]);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -622,8 +656,9 @@ describe("skills controller", () => {
|
||||
"paseo-loop-v1",
|
||||
"paseo-loop-v1",
|
||||
null,
|
||||
"paseo-loop-v1",
|
||||
]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({ selection: previous });
|
||||
});
|
||||
|
||||
@@ -656,8 +691,9 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
null,
|
||||
"keep this",
|
||||
]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({ selection: previous });
|
||||
});
|
||||
|
||||
@@ -693,7 +729,7 @@ describe("skills controller", () => {
|
||||
expect(
|
||||
await readFile(path.join(harness.targets.codexDir, recovered!, "notes", "mine.md"), "utf8"),
|
||||
).toBe("staged notes");
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({ selection: previous });
|
||||
});
|
||||
|
||||
@@ -732,8 +768,9 @@ describe("skills controller", () => {
|
||||
null,
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({ selection: previous });
|
||||
});
|
||||
|
||||
@@ -775,7 +812,7 @@ describe("skills controller", () => {
|
||||
|
||||
expect(await readFile(entry!.livePath, "utf8")).toBe("external replacement");
|
||||
expect(await readFile(path.join(recovered, "notes", "mine.md"), "utf8")).toBe("captured notes");
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it("preserves a directory that replaces a captured file before recovery", async () => {
|
||||
@@ -806,7 +843,7 @@ describe("skills controller", () => {
|
||||
expect(
|
||||
await readFile(path.join(path.dirname(harness.targets.agentsDir), recovered!), "utf8"),
|
||||
).toBe("captured file");
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it.skipIf(process.platform !== "linux")(
|
||||
@@ -815,6 +852,7 @@ describe("skills controller", () => {
|
||||
const crossFilesystemRoot = await mkdtemp("/dev/shm/paseo-skills-controller-");
|
||||
try {
|
||||
harness.targets.claudeDir = path.join(crossFilesystemRoot, "skills");
|
||||
harness.targets.installDirs[1] = harness.targets.claudeDir;
|
||||
const previous: SkillSelection = {
|
||||
mode: "custom",
|
||||
skills: ["paseo", "paseo-loop"],
|
||||
@@ -926,6 +964,7 @@ describe("skills controller", () => {
|
||||
readOnly.targets.agentsDir,
|
||||
readOnly.targets.claudeDir,
|
||||
readOnly.targets.codexDir,
|
||||
readOnly.targets.antigravityDir,
|
||||
]) {
|
||||
const notes = path.join(root, "paseo-loop", "notes");
|
||||
await mkdir(notes, { recursive: true });
|
||||
@@ -946,6 +985,7 @@ describe("skills controller", () => {
|
||||
readOnly.targets.agentsDir,
|
||||
readOnly.targets.claudeDir,
|
||||
readOnly.targets.codexDir,
|
||||
readOnly.targets.antigravityDir,
|
||||
]) {
|
||||
const restored = path.join(root, "paseo-loop", "notes", "latest.md");
|
||||
expect((await lstat(restored)).isSymbolicLink()).toBe(true);
|
||||
@@ -970,6 +1010,7 @@ describe("skills controller", () => {
|
||||
readOnly.targets.agentsDir,
|
||||
readOnly.targets.claudeDir,
|
||||
readOnly.targets.codexDir,
|
||||
readOnly.targets.antigravityDir,
|
||||
]) {
|
||||
await chmod(path.join(root, "paseo-loop", "hooks", "run.sh"), 0o751);
|
||||
}
|
||||
@@ -987,6 +1028,7 @@ describe("skills controller", () => {
|
||||
readOnly.targets.agentsDir,
|
||||
readOnly.targets.claudeDir,
|
||||
readOnly.targets.codexDir,
|
||||
readOnly.targets.antigravityDir,
|
||||
]) {
|
||||
const restored = await lstat(path.join(root, "paseo-loop", "hooks", "run.sh"));
|
||||
expect(restored.mode & 0o777).toBe(0o751);
|
||||
@@ -998,7 +1040,7 @@ describe("skills controller", () => {
|
||||
it("leaves no backup artifacts behind after a successful save", async () => {
|
||||
await harness.controller.save({ mode: "custom", skills: ["paseo"] });
|
||||
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
@@ -1025,7 +1067,7 @@ describe("skills controller", () => {
|
||||
expect(outcome.ok).toBe(true);
|
||||
expect(await gated.store.get()).toEqual(next);
|
||||
await blocked.controller.status();
|
||||
expect(await backupArtifacts(blocked.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(blocked.targets)).toEqual([[], [], [], []]);
|
||||
await rm(blocked.root, { recursive: true, force: true });
|
||||
},
|
||||
);
|
||||
@@ -1061,6 +1103,7 @@ describe("skills controller", () => {
|
||||
harness.targets.agentsDir,
|
||||
harness.targets.claudeDir,
|
||||
harness.targets.codexDir,
|
||||
harness.targets.antigravityDir,
|
||||
]) {
|
||||
await rm(path.join(root, "paseo-loop"), { recursive: true, force: true });
|
||||
}
|
||||
@@ -1071,8 +1114,9 @@ describe("skills controller", () => {
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it("does not roll back an interrupted transaction after the selection committed", async () => {
|
||||
@@ -1092,6 +1136,7 @@ describe("skills controller", () => {
|
||||
harness.targets.agentsDir,
|
||||
harness.targets.claudeDir,
|
||||
harness.targets.codexDir,
|
||||
harness.targets.antigravityDir,
|
||||
]) {
|
||||
await rm(path.join(root, "paseo-loop"), { recursive: true, force: true });
|
||||
}
|
||||
@@ -1101,7 +1146,7 @@ describe("skills controller", () => {
|
||||
|
||||
expect(snapshot.selection).toEqual(next);
|
||||
expect(await isInstalled(harness.targets, "paseo-loop")).toBe(false);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it("asks for confirmation naming the directories a save would delete", async () => {
|
||||
@@ -1119,6 +1164,7 @@ describe("skills controller", () => {
|
||||
["paseo", "paseo-advisor", "paseo-loop"],
|
||||
["paseo", "paseo-advisor", "paseo-loop"],
|
||||
["paseo-advisor"],
|
||||
["paseo", "paseo-advisor", "paseo-loop"],
|
||||
]);
|
||||
expect(result.selection).toEqual({ mode: "custom", skills: ["paseo", "paseo-loop"] });
|
||||
});
|
||||
@@ -1134,7 +1180,12 @@ describe("skills controller", () => {
|
||||
|
||||
expect(result.confirmationRequired).toBeNull();
|
||||
expect(result.selection).toEqual({ mode: "custom", skills: ["paseo"] });
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([["paseo"], ["paseo"], []]);
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([
|
||||
["paseo"],
|
||||
["paseo"],
|
||||
[],
|
||||
["paseo"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("asks again when another directory appears before the retry", async () => {
|
||||
@@ -1154,6 +1205,7 @@ describe("skills controller", () => {
|
||||
["paseo", "paseo-advisor", "paseo-chat", "paseo-loop"],
|
||||
["paseo", "paseo-advisor", "paseo-chat", "paseo-loop"],
|
||||
["paseo-chat"],
|
||||
["paseo", "paseo-advisor", "paseo-chat", "paseo-loop"],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1175,6 +1227,7 @@ describe("skills controller", () => {
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
"hand written",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1182,7 +1235,12 @@ describe("skills controller", () => {
|
||||
const result = await harness.controller.save({ mode: "custom", skills: ["paseo"] });
|
||||
|
||||
expect(result.confirmationRequired).toBeNull();
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([["paseo"], ["paseo"], []]);
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([
|
||||
["paseo"],
|
||||
["paseo"],
|
||||
[],
|
||||
["paseo"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("preserves a regular file at a skill path when save convergence fails", async () => {
|
||||
@@ -1195,6 +1253,131 @@ describe("skills controller", () => {
|
||||
expect(await readFile(collision, "utf8")).toBe("keep this file");
|
||||
});
|
||||
|
||||
it("rolls back earlier targets when writing to Antigravity fails", async () => {
|
||||
await mkdir(harness.targets.antigravityDir, { recursive: true });
|
||||
const collision = path.join(harness.targets.antigravityDir, "paseo");
|
||||
await writeFile(collision, "keep this file");
|
||||
|
||||
await expect(harness.controller.save({ mode: "custom", skills: ["paseo"] })).rejects.toThrow();
|
||||
|
||||
expect(await readFile(collision, "utf8")).toBe("keep this file");
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([[], [], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it("rolls back cleanly without locking later calls when an Antigravity parent is a file", async () => {
|
||||
const geminiConfig = path.dirname(harness.targets.antigravityDir);
|
||||
await mkdir(path.dirname(geminiConfig), { recursive: true });
|
||||
await writeFile(geminiConfig, "not a directory");
|
||||
|
||||
await expect(harness.controller.save({ mode: "custom", skills: ["paseo"] })).rejects.toThrow();
|
||||
|
||||
expect(await readFile(geminiConfig, "utf8")).toBe("not a directory");
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([[], [], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({
|
||||
state: "not-installed",
|
||||
selection: { mode: "all" },
|
||||
});
|
||||
await expect(harness.controller.uninstall()).resolves.toMatchObject({
|
||||
state: "not-installed",
|
||||
});
|
||||
});
|
||||
|
||||
it.skipIf(process.platform === "win32" || process.getuid?.() === 0)(
|
||||
"rolls back cleanly and still updates other targets when ~/.gemini is unwritable",
|
||||
async () => {
|
||||
const geminiHome = path.dirname(path.dirname(harness.targets.antigravityDir));
|
||||
await mkdir(geminiHome, { recursive: true });
|
||||
await chmod(geminiHome, 0o000);
|
||||
try {
|
||||
await expect(
|
||||
harness.controller.save({ mode: "custom", skills: ["paseo"] }),
|
||||
).rejects.toThrow();
|
||||
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([[], [], [], []]);
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
await expect(harness.controller.status()).resolves.toMatchObject({
|
||||
state: "not-installed",
|
||||
selection: { mode: "all" },
|
||||
});
|
||||
} finally {
|
||||
await chmod(geminiHome, 0o755);
|
||||
}
|
||||
|
||||
// Install v1 everywhere, remove ~/.gemini/config so ~/.gemini (0555) blocks
|
||||
// Antigravity writes with EACCES, then upgrade bundle to v2 and autoUpdate.
|
||||
await harness.controller.install();
|
||||
await rm(path.dirname(harness.targets.antigravityDir), { recursive: true, force: true });
|
||||
for (const name of BUNDLED_SKILLS) {
|
||||
await writeFile(path.join(harness.targets.sourceDir, name, "SKILL.md"), `${name}-v2`);
|
||||
}
|
||||
await chmod(geminiHome, 0o555);
|
||||
try {
|
||||
await expect(harness.controller.autoUpdate()).rejects.toThrow();
|
||||
for (const root of [harness.targets.agentsDir, harness.targets.claudeDir]) {
|
||||
for (const name of BUNDLED_SKILLS) {
|
||||
expect(await readFile(path.join(root, name, "SKILL.md"), "utf8")).toBe(`${name}-v2`);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await chmod(geminiHome, 0o755);
|
||||
}
|
||||
|
||||
// With ~/.gemini unreadable (0000), uninstall still removes every skill from healthy targets.
|
||||
await chmod(geminiHome, 0o000);
|
||||
try {
|
||||
await expect(harness.controller.uninstall()).rejects.toThrow();
|
||||
expect(await installedSkills(harness.targets.agentsDir)).toEqual([]);
|
||||
expect(await installedSkills(harness.targets.claudeDir)).toEqual([]);
|
||||
} finally {
|
||||
await chmod(geminiHome, 0o755);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("recovers a pre-upgrade transaction manifest that recorded codex at root index 2", async () => {
|
||||
const previous: SkillSelection = { mode: "custom", skills: ["paseo"] };
|
||||
const next: SkillSelection = { mode: "all" };
|
||||
await harness.controller.save(previous);
|
||||
|
||||
const transactionDir = path.join(
|
||||
path.dirname(harness.targets.agentsDir),
|
||||
".paseo-skills-transaction-legacy-codex-index",
|
||||
);
|
||||
const codexBackup = path.join(transactionDir, "backup", "2", "paseo");
|
||||
await mkdir(path.join(codexBackup, "notes"), { recursive: true });
|
||||
await writeFile(path.join(codexBackup, "notes", "codex.md"), "restored codex note");
|
||||
await writeFile(
|
||||
path.join(transactionDir, "transaction.json"),
|
||||
`${JSON.stringify(
|
||||
{
|
||||
owner: "paseo-skills-transaction",
|
||||
version: 1,
|
||||
phase: "converging",
|
||||
previousSelection: previous,
|
||||
nextSelection: next,
|
||||
entries: [
|
||||
{
|
||||
livePath: path.join(harness.targets.codexDir, "paseo"),
|
||||
kind: "update",
|
||||
backupPath: path.join("backup", "2", "paseo"),
|
||||
},
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
|
||||
await harness.controller.status();
|
||||
|
||||
expect(
|
||||
await readFile(path.join(harness.targets.codexDir, "paseo", "notes", "codex.md"), "utf8"),
|
||||
).toBe("restored codex note");
|
||||
expect(await backupArtifacts(harness.targets)).toEqual([[], [], [], []]);
|
||||
});
|
||||
|
||||
it("serializes startup convergence with an interactive save", async () => {
|
||||
await harness.controller.install();
|
||||
// Startup finds drift it wants to repair while the user narrows the
|
||||
@@ -1214,7 +1397,12 @@ describe("skills controller", () => {
|
||||
]);
|
||||
|
||||
expect(saved.selection).toEqual({ mode: "custom", skills: ["paseo"] });
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([["paseo"], ["paseo"], []]);
|
||||
expect(await installedEverywhere(harness.targets)).toEqual([
|
||||
["paseo"],
|
||||
["paseo"],
|
||||
[],
|
||||
["paseo"],
|
||||
]);
|
||||
expect(await harness.controller.status()).toEqual({
|
||||
state: "up-to-date",
|
||||
ops: [],
|
||||
@@ -1247,6 +1435,7 @@ describe("skills controller", () => {
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
"keep this",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,18 +21,31 @@ function only(...skills: string[]): SkillSelection {
|
||||
return { mode: "custom", skills };
|
||||
}
|
||||
|
||||
interface TestSkillTargets extends SkillTargets {
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
antigravityDir: string;
|
||||
installDirs: string[];
|
||||
}
|
||||
|
||||
interface Sandbox {
|
||||
root: string;
|
||||
targets: SkillTargets;
|
||||
targets: TestSkillTargets;
|
||||
}
|
||||
|
||||
async function makeSandbox(): Promise<Sandbox> {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "paseo-skills-"));
|
||||
const targets: SkillTargets = {
|
||||
const agentsDir = path.join(root, "home", ".agents", "skills");
|
||||
const claudeDir = path.join(root, "home", ".claude", "skills");
|
||||
const codexDir = path.join(root, "home", ".codex", "skills");
|
||||
const antigravityDir = path.join(root, "home", ".gemini", "config", "skills");
|
||||
const targets: TestSkillTargets = {
|
||||
sourceDir: path.join(root, "bundle"),
|
||||
agentsDir: path.join(root, "home", ".agents", "skills"),
|
||||
claudeDir: path.join(root, "home", ".claude", "skills"),
|
||||
codexDir: path.join(root, "home", ".codex", "skills"),
|
||||
installDirs: [agentsDir, claudeDir, antigravityDir],
|
||||
agentsDir,
|
||||
claudeDir,
|
||||
codexDir,
|
||||
antigravityDir,
|
||||
};
|
||||
await fs.mkdir(targets.sourceDir, { recursive: true });
|
||||
return { root, targets };
|
||||
@@ -63,7 +76,7 @@ async function writeOnDiskSkill(
|
||||
}
|
||||
|
||||
async function writeOnDiskSkillToAllTargets(
|
||||
targets: SkillTargets,
|
||||
targets: TestSkillTargets,
|
||||
name: string,
|
||||
files: Record<string, string>,
|
||||
): Promise<void> {
|
||||
@@ -71,6 +84,7 @@ async function writeOnDiskSkillToAllTargets(
|
||||
writeOnDiskSkill(targets.agentsDir, name, files),
|
||||
writeOnDiskSkill(targets.claudeDir, name, files),
|
||||
writeOnDiskSkill(targets.codexDir, name, files),
|
||||
writeOnDiskSkill(targets.antigravityDir, name, files),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -86,9 +100,9 @@ async function pathExists(p: string): Promise<boolean> {
|
||||
.catch(() => false);
|
||||
}
|
||||
|
||||
async function installedIn(targets: SkillTargets, name: string): Promise<boolean[]> {
|
||||
async function installedIn(targets: TestSkillTargets, name: string): Promise<boolean[]> {
|
||||
return Promise.all(
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir].map((dir) =>
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir, targets.antigravityDir].map((dir) =>
|
||||
pathExists(path.join(dir, name)),
|
||||
),
|
||||
);
|
||||
@@ -196,6 +210,10 @@ describe("getSkillsStatus", () => {
|
||||
"SKILL.md": "paseo-v1",
|
||||
"hooks/guard.sh": "user guard",
|
||||
});
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo", {
|
||||
"SKILL.md": "paseo-v1",
|
||||
"notes/local.md": "user notes",
|
||||
});
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
@@ -212,6 +230,7 @@ describe("getSkillsStatus", () => {
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "paseo", { "SKILL.md": "stale" });
|
||||
await writeOnDiskSkill(sandbox.targets.claudeDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.codexDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkillToAllTargets(sandbox.targets, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
@@ -228,6 +247,8 @@ describe("getSkillsStatus", () => {
|
||||
await writeOnDiskSkill(sandbox.targets.claudeDir, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.codexDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.codexDir, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
@@ -235,6 +256,35 @@ describe("getSkillsStatus", () => {
|
||||
expect(status.ops).toEqual([{ kind: "update", name: "paseo" }]);
|
||||
});
|
||||
|
||||
it("returns drift when Antigravity is missing or stale", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.claudeDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.claudeDir, "paseo-loop", { "SKILL.md": "loop-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo", { "SKILL.md": "stale" });
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
expect(status.state).toBe("drift");
|
||||
expect(status.ops).toEqual([
|
||||
{ kind: "update", name: "paseo" },
|
||||
{ kind: "add", name: "paseo-loop" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns not-installed when only user-personal skills exist in Antigravity", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "my-agy-skill", {
|
||||
"SKILL.md": "user-agy",
|
||||
});
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
expect(status.state).toBe("not-installed");
|
||||
expect(status.installed).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns drift with add ops for the bundled skills missing from disk", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await writeOnDiskSkillToAllTargets(sandbox.targets, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
@@ -262,6 +312,7 @@ describe("getSkillsStatus", () => {
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "paseo", { "SKILL.md": "stale" });
|
||||
await writeOnDiskSkill(sandbox.targets.claudeDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.codexDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "paseo", { "SKILL.md": "paseo-v1" });
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "paseo-chat", { "SKILL.md": "chat-old" });
|
||||
|
||||
const status = await getSkillsStatus(sandbox.targets, ALL_SKILLS);
|
||||
@@ -299,9 +350,14 @@ describe("custom skill selection", () => {
|
||||
available: ["paseo", "paseo-advisor", "paseo-loop"],
|
||||
installed: ["paseo", "paseo-loop"],
|
||||
});
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([true, true, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([true, true, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-advisor")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([true, true, false, true]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([true, true, false, true]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-advisor")).toEqual([
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports up-to-date while an unselected bundled skill is absent", async () => {
|
||||
@@ -323,9 +379,14 @@ describe("custom skill selection", () => {
|
||||
const status = await installSkills(sandbox.targets, only("paseo"));
|
||||
|
||||
expect(status.state).toBe("up-to-date");
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([true, true, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-advisor")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([true, true, false, true]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([false, false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-advisor")).toEqual([
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports a delete op for a deselected skill before it is applied", async () => {
|
||||
@@ -339,12 +400,21 @@ describe("custom skill selection", () => {
|
||||
|
||||
it("leaves unrelated user skills untouched", async () => {
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "unslop", { "SKILL.md": "user-unslop" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "custom-agy", {
|
||||
"SKILL.md": "user-agy",
|
||||
});
|
||||
|
||||
await installSkills(sandbox.targets, only("paseo"));
|
||||
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.agentsDir, "unslop", "SKILL.md"), "utf-8"),
|
||||
).toBe("user-unslop");
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(sandbox.targets.antigravityDir, "custom-agy", "SKILL.md"),
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("user-agy");
|
||||
});
|
||||
|
||||
it("treats an empty custom selection as no managed skills installed", async () => {
|
||||
@@ -358,8 +428,8 @@ describe("custom skill selection", () => {
|
||||
available: ["paseo", "paseo-advisor", "paseo-loop"],
|
||||
installed: [],
|
||||
});
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([false, false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-loop")).toEqual([false, false, false, false]);
|
||||
});
|
||||
|
||||
it("ignores selected names that the bundle does not ship", async () => {
|
||||
@@ -371,7 +441,7 @@ describe("custom skill selection", () => {
|
||||
available: ["paseo", "paseo-advisor", "paseo-loop"],
|
||||
installed: ["paseo"],
|
||||
});
|
||||
expect(await installedIn(sandbox.targets, "not-a-skill")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "not-a-skill")).toEqual([false, false, false, false]);
|
||||
});
|
||||
|
||||
it("still deletes legacy skill names that are not selectable", async () => {
|
||||
@@ -381,7 +451,12 @@ describe("custom skill selection", () => {
|
||||
|
||||
await installSkills(sandbox.targets, only("paseo"));
|
||||
|
||||
expect(await installedIn(sandbox.targets, "paseo-orchestrator")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-orchestrator")).toEqual([
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -396,9 +471,12 @@ describe("installSkills / updateSkills", () => {
|
||||
await fs.rm(sandbox.root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("installs into shared and Claude roots without duplicating Codex discovery", async () => {
|
||||
it("installs into shared, Claude, and Antigravity roots without duplicating Codex discovery", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, "unslop", { "SKILL.md": "user-unslop" });
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "custom-agy", {
|
||||
"SKILL.md": "user-agy",
|
||||
});
|
||||
|
||||
const status = await installSkills(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
@@ -409,15 +487,25 @@ describe("installSkills / updateSkills", () => {
|
||||
installed: ["paseo", "paseo-loop"],
|
||||
});
|
||||
for (const name of ["paseo", "paseo-loop"]) {
|
||||
const expected = name === "paseo" ? "paseo-v1" : "loop-v1";
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.agentsDir, name, "SKILL.md"), "utf-8"),
|
||||
).toBe(name === "paseo" ? "paseo-v1" : "loop-v1");
|
||||
).toBe(expected);
|
||||
expect(await pathExists(path.join(sandbox.targets.codexDir, name, "SKILL.md"))).toBe(false);
|
||||
expect(await pathExists(path.join(sandbox.targets.claudeDir, name))).toBe(true);
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.antigravityDir, name, "SKILL.md"), "utf-8"),
|
||||
).toBe(expected);
|
||||
}
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.agentsDir, "unslop", "SKILL.md"), "utf-8"),
|
||||
).toBe("user-unslop");
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(sandbox.targets.antigravityDir, "custom-agy", "SKILL.md"),
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("user-agy");
|
||||
});
|
||||
|
||||
it("retires unchanged managed Codex copies while preserving personal files", async () => {
|
||||
@@ -469,14 +557,23 @@ describe("installSkills / updateSkills", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ alias: "codex", target: "agents" },
|
||||
{ alias: "codex", target: "claude" },
|
||||
{ alias: "claude", target: "codex" },
|
||||
{ alias: "codex", target: "agents", expected: [true, true, true, true] },
|
||||
{ alias: "codex", target: "claude", expected: [true, true, true, true] },
|
||||
{ alias: "claude", target: "codex", expected: [true, true, true, true] },
|
||||
{ alias: "codex", target: "antigravity", expected: [true, true, true, true] },
|
||||
{ alias: "antigravity", target: "codex", expected: [true, true, true, true] },
|
||||
{ alias: "antigravity", target: "agents", expected: [true, true, false, true] },
|
||||
{ alias: "antigravity", target: "claude", expected: [true, true, false, true] },
|
||||
] as const)(
|
||||
"keeps installed skills when the $alias root links to the $target root",
|
||||
async ({ alias, target }) => {
|
||||
async ({ alias, target, expected }) => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
const rootOf = { agents: "agentsDir", claude: "claudeDir", codex: "codexDir" } as const;
|
||||
const rootOf = {
|
||||
agents: "agentsDir",
|
||||
claude: "claudeDir",
|
||||
codex: "codexDir",
|
||||
antigravity: "antigravityDir",
|
||||
} as const;
|
||||
const aliasRoot = sandbox.targets[rootOf[alias]];
|
||||
const targetRoot = sandbox.targets[rootOf[target]];
|
||||
await fs.mkdir(targetRoot, { recursive: true });
|
||||
@@ -488,12 +585,36 @@ describe("installSkills / updateSkills", () => {
|
||||
|
||||
expect(installed.state).toBe("up-to-date");
|
||||
expect(updated.state).toBe("up-to-date");
|
||||
expect((await fs.lstat(aliasRoot)).isSymbolicLink()).toBe(true);
|
||||
for (const name of ["paseo", "paseo-loop"]) {
|
||||
expect(await installedIn(sandbox.targets, name)).toEqual([true, true, true]);
|
||||
expect(await installedIn(sandbox.targets, name)).toEqual([...expected]);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps an installed skill when its Antigravity directory links to the shared copy", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await fs.mkdir(path.join(sandbox.targets.agentsDir, "paseo"), { recursive: true });
|
||||
await fs.mkdir(sandbox.targets.antigravityDir, { recursive: true });
|
||||
await fs.symlink(
|
||||
path.join(sandbox.targets.agentsDir, "paseo"),
|
||||
path.join(sandbox.targets.antigravityDir, "paseo"),
|
||||
"dir",
|
||||
);
|
||||
|
||||
const installed = await installSkills(sandbox.targets, ALL_SKILLS);
|
||||
const updated = await autoUpdateInstalledSkills(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
expect(installed.state).toBe("up-to-date");
|
||||
expect(updated.state).toBe("up-to-date");
|
||||
expect(
|
||||
(await fs.lstat(path.join(sandbox.targets.antigravityDir, "paseo"))).isSymbolicLink(),
|
||||
).toBe(true);
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.antigravityDir, "paseo", "SKILL.md"), "utf8"),
|
||||
).toBe("paseo-v1");
|
||||
});
|
||||
|
||||
it("keeps an installed skill when its Codex directory links to the shared copy", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await fs.mkdir(path.join(sandbox.targets.agentsDir, "paseo"), { recursive: true });
|
||||
@@ -604,6 +725,15 @@ describe("installSkills / updateSkills", () => {
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.claudeDir, "paseo-loop", "SKILL.md"), "utf-8"),
|
||||
).toBe("loop-v1");
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.antigravityDir, "paseo", "SKILL.md"), "utf-8"),
|
||||
).toBe("paseo-v1");
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(sandbox.targets.antigravityDir, "paseo-loop", "SKILL.md"),
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("loop-v1");
|
||||
});
|
||||
|
||||
it("auto-updates drifted installed skills", async () => {
|
||||
@@ -626,6 +756,9 @@ describe("installSkills / updateSkills", () => {
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("user guard");
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.antigravityDir, "paseo", "SKILL.md"), "utf-8"),
|
||||
).toBe("paseo-v1");
|
||||
});
|
||||
|
||||
it("does not auto-install skills on a clean machine", async () => {
|
||||
@@ -642,7 +775,7 @@ describe("installSkills / updateSkills", () => {
|
||||
available: ["paseo", "paseo-loop"],
|
||||
installed: [],
|
||||
});
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo")).toEqual([false, false, false, false]);
|
||||
});
|
||||
|
||||
it("is idempotent — running install twice keeps state at up-to-date", async () => {
|
||||
@@ -667,24 +800,51 @@ describe("uninstallSkills", () => {
|
||||
await fs.rm(sandbox.root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("removes every Paseo skill from all three targets and preserves user dirs", async () => {
|
||||
it("removes every Paseo skill from all targets and preserves user dirs and symlinks", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
await installSkills(sandbox.targets, ALL_SKILLS);
|
||||
for (const name of ["unslop", "tdd", "devbox"]) {
|
||||
await writeOnDiskSkill(sandbox.targets.agentsDir, name, { "SKILL.md": `user-${name}` });
|
||||
}
|
||||
await writeOnDiskSkill(sandbox.targets.antigravityDir, "user-agy-skill", {
|
||||
"SKILL.md": "user-agy",
|
||||
});
|
||||
const linkedSource = path.join(sandbox.root, "external-user-skill");
|
||||
await writeFiles(linkedSource, { "SKILL.md": "linked-user-skill" });
|
||||
await fs.symlink(
|
||||
linkedSource,
|
||||
path.join(sandbox.targets.antigravityDir, "linked-user-skill"),
|
||||
"dir",
|
||||
);
|
||||
|
||||
const status = await uninstallSkills(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
expect(status.state).toBe("not-installed");
|
||||
for (const name of ["paseo", "paseo-loop", ...LEGACY_SKILL_NAMES]) {
|
||||
expect(await installedIn(sandbox.targets, name)).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, name)).toEqual([false, false, false, false]);
|
||||
}
|
||||
for (const name of ["unslop", "tdd", "devbox"]) {
|
||||
expect(
|
||||
await fs.readFile(path.join(sandbox.targets.agentsDir, name, "SKILL.md"), "utf-8"),
|
||||
).toBe(`user-${name}`);
|
||||
}
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(sandbox.targets.antigravityDir, "user-agy-skill", "SKILL.md"),
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("user-agy");
|
||||
expect(
|
||||
(
|
||||
await fs.lstat(path.join(sandbox.targets.antigravityDir, "linked-user-skill"))
|
||||
).isSymbolicLink(),
|
||||
).toBe(true);
|
||||
expect(
|
||||
await fs.readFile(
|
||||
path.join(sandbox.targets.antigravityDir, "linked-user-skill", "SKILL.md"),
|
||||
"utf-8",
|
||||
),
|
||||
).toBe("linked-user-skill");
|
||||
});
|
||||
|
||||
it("is a no-op when nothing is installed", async () => {
|
||||
@@ -695,12 +855,13 @@ describe("uninstallSkills", () => {
|
||||
expect(status.state).toBe("not-installed");
|
||||
});
|
||||
|
||||
it("cleans up legacy skill names that linger in agents, claude, and codex", async () => {
|
||||
it("cleans up legacy skill names that linger in agents, claude, codex, and antigravity", async () => {
|
||||
await writeCurrentBundle(sandbox.targets.sourceDir);
|
||||
for (const dir of [
|
||||
sandbox.targets.agentsDir,
|
||||
sandbox.targets.claudeDir,
|
||||
sandbox.targets.codexDir,
|
||||
sandbox.targets.antigravityDir,
|
||||
]) {
|
||||
await writeOnDiskSkill(dir, "paseo-chat", { "SKILL.md": "chat-old" });
|
||||
}
|
||||
@@ -708,6 +869,6 @@ describe("uninstallSkills", () => {
|
||||
const status = await uninstallSkills(sandbox.targets, ALL_SKILLS);
|
||||
|
||||
expect(status.state).toBe("not-installed");
|
||||
expect(await installedIn(sandbox.targets, "paseo-chat")).toEqual([false, false, false]);
|
||||
expect(await installedIn(sandbox.targets, "paseo-chat")).toEqual([false, false, false, false]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,8 +35,12 @@ export interface SkillsStatus {
|
||||
|
||||
export interface SkillTargets {
|
||||
sourceDir: string;
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
/**
|
||||
* Ordered active install roots. Append new roots to the end so transaction
|
||||
* backup indices remain stable across daemon upgrades.
|
||||
*/
|
||||
installDirs: readonly string[];
|
||||
/** Legacy dedicated Codex root, retired on sync unless it aliases an install root. */
|
||||
codexDir: string;
|
||||
}
|
||||
|
||||
@@ -163,13 +167,11 @@ export async function getSkillsStatus(
|
||||
): Promise<SkillsStatus> {
|
||||
const available = await listBundledSkills(targets.sourceDir);
|
||||
const names = managedSkillNames(available);
|
||||
const [bundle, agentsDisk, claudeDisk, codexDisk] = await Promise.all([
|
||||
const [bundle, codexDisk, ...disks] = await Promise.all([
|
||||
hashSkills(targets.sourceDir, available),
|
||||
hashSkills(targets.agentsDir, names),
|
||||
hashSkills(targets.claudeDir, names),
|
||||
hashSkills(targets.codexDir, names),
|
||||
...targets.installDirs.map((root) => hashSkills(root, names)),
|
||||
]);
|
||||
const disks = [agentsDisk, claudeDisk];
|
||||
const desired = resolveDesiredSkills(selection, available);
|
||||
const ops = diff(bundle, disks, names, desired);
|
||||
for (const name of codexDisk.keys()) {
|
||||
@@ -203,8 +205,7 @@ async function applySkills(
|
||||
if (writes.length > 0) {
|
||||
await syncSkills({
|
||||
sourceDir: targets.sourceDir,
|
||||
agentsDir: targets.agentsDir,
|
||||
claudeDir: targets.claudeDir,
|
||||
installDirs: targets.installDirs,
|
||||
codexDir: targets.codexDir,
|
||||
skillNames: writes,
|
||||
});
|
||||
@@ -213,8 +214,7 @@ async function applySkills(
|
||||
for (const op of status.ops) {
|
||||
if (op.kind !== "delete") continue;
|
||||
await removeSkill(op.name, {
|
||||
agentsDir: targets.agentsDir,
|
||||
claudeDir: targets.claudeDir,
|
||||
installDirs: targets.installDirs,
|
||||
codexDir: targets.codexDir,
|
||||
});
|
||||
}
|
||||
@@ -259,12 +259,21 @@ export async function uninstallSkills(
|
||||
selection: SkillSelection,
|
||||
): Promise<SkillsStatus> {
|
||||
const available = await listBundledSkills(targets.sourceDir);
|
||||
let hasError = false;
|
||||
let firstError: unknown = null;
|
||||
for (const name of managedSkillNames(available)) {
|
||||
await removeSkill(name, {
|
||||
agentsDir: targets.agentsDir,
|
||||
claudeDir: targets.claudeDir,
|
||||
codexDir: targets.codexDir,
|
||||
});
|
||||
try {
|
||||
await removeSkill(name, {
|
||||
installDirs: targets.installDirs,
|
||||
codexDir: targets.codexDir,
|
||||
});
|
||||
} catch (error) {
|
||||
if (!hasError) {
|
||||
hasError = true;
|
||||
firstError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError) throw firstError;
|
||||
return getSkillsStatus(targets, selection);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,11 @@ describe("orchestration skill paths", () => {
|
||||
const home = os.homedir();
|
||||
|
||||
expect(resolveSkillTargets()).toMatchObject({
|
||||
agentsDir: path.join(home, ".agents", "skills"),
|
||||
claudeDir: path.join(home, ".claude", "skills"),
|
||||
installDirs: [
|
||||
path.join(home, ".agents", "skills"),
|
||||
path.join(home, ".claude", "skills"),
|
||||
path.join(home, ".gemini", "config", "skills"),
|
||||
],
|
||||
codexDir: path.join(home, ".codex", "skills"),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,8 +17,13 @@ export function resolveBundledSkillsDir(moduleUrl: string | URL = import.meta.ur
|
||||
export function resolveSkillTargets(home: string = os.homedir()): SkillTargets {
|
||||
return {
|
||||
sourceDir: resolveBundledSkillsDir(),
|
||||
agentsDir: path.join(home, ".agents", "skills"),
|
||||
claudeDir: path.join(home, ".claude", "skills"),
|
||||
// Append new install roots to the end — transaction backups reference roots
|
||||
// by index, so existing positions must remain stable across upgrades.
|
||||
installDirs: [
|
||||
path.join(home, ".agents", "skills"),
|
||||
path.join(home, ".claude", "skills"),
|
||||
path.join(home, ".gemini", "config", "skills"),
|
||||
],
|
||||
codexDir: path.join(home, ".codex", "skills"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ interface Sandbox {
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
codexDir: string;
|
||||
antigravityDir: string;
|
||||
installDirs: string[];
|
||||
}
|
||||
|
||||
async function makeSandbox(): Promise<Sandbox> {
|
||||
@@ -18,8 +20,10 @@ async function makeSandbox(): Promise<Sandbox> {
|
||||
const agentsDir = path.join(root, "home", ".agents", "skills");
|
||||
const claudeDir = path.join(root, "home", ".claude", "skills");
|
||||
const codexDir = path.join(root, "home", ".codex", "skills");
|
||||
const antigravityDir = path.join(root, "home", ".gemini", "config", "skills");
|
||||
const installDirs = [agentsDir, claudeDir, antigravityDir];
|
||||
await fs.mkdir(sourceDir, { recursive: true });
|
||||
return { root, sourceDir, agentsDir, claudeDir, codexDir };
|
||||
return { root, sourceDir, agentsDir, claudeDir, codexDir, antigravityDir, installDirs };
|
||||
}
|
||||
|
||||
async function writeBundleSkill(
|
||||
@@ -57,8 +61,7 @@ describe("syncSkills", () => {
|
||||
|
||||
const result = await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -75,6 +78,11 @@ describe("syncSkills", () => {
|
||||
"utf-8",
|
||||
);
|
||||
expect(claudeContent).toBe("new paseo content");
|
||||
const antigravityContent = await fs.readFile(
|
||||
path.join(sandbox.antigravityDir, "paseo", "SKILL.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(antigravityContent).toBe("new paseo content");
|
||||
await expect(fs.stat(path.join(sandbox.codexDir, "paseo", "SKILL.md"))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
@@ -88,8 +96,7 @@ describe("syncSkills", () => {
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo-committee"],
|
||||
});
|
||||
@@ -115,6 +122,15 @@ describe("syncSkills", () => {
|
||||
expect(await fs.readFile(path.join(claudeSkillDir, "references", "roles.md"), "utf-8")).toBe(
|
||||
"roles content",
|
||||
);
|
||||
|
||||
const antigravitySkillDir = path.join(sandbox.antigravityDir, "paseo-committee");
|
||||
expect((await fs.lstat(antigravitySkillDir)).isDirectory()).toBe(true);
|
||||
expect(await fs.readFile(path.join(antigravitySkillDir, "SKILL.md"), "utf-8")).toBe(
|
||||
"committee content",
|
||||
);
|
||||
expect(
|
||||
await fs.readFile(path.join(antigravitySkillDir, "references", "roles.md"), "utf-8"),
|
||||
).toBe("roles content");
|
||||
});
|
||||
|
||||
it("leaves on-disk skills not in the bundle untouched", async () => {
|
||||
@@ -122,16 +138,21 @@ describe("syncSkills", () => {
|
||||
const customSkill = path.join(sandbox.agentsDir, "user-custom-skill");
|
||||
await fs.mkdir(customSkill, { recursive: true });
|
||||
await fs.writeFile(path.join(customSkill, "SKILL.md"), "user content");
|
||||
const antigravityCustomSkill = path.join(sandbox.antigravityDir, "user-antigravity-skill");
|
||||
await fs.mkdir(antigravityCustomSkill, { recursive: true });
|
||||
await fs.writeFile(path.join(antigravityCustomSkill, "SKILL.md"), "antigravity user content");
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
|
||||
expect(await fs.readFile(path.join(customSkill, "SKILL.md"), "utf-8")).toBe("user content");
|
||||
expect(await fs.readFile(path.join(antigravityCustomSkill, "SKILL.md"), "utf-8")).toBe(
|
||||
"antigravity user content",
|
||||
);
|
||||
});
|
||||
|
||||
it("removes stale files previously written to managed skill dirs", async () => {
|
||||
@@ -143,8 +164,7 @@ describe("syncSkills", () => {
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -154,8 +174,7 @@ describe("syncSkills", () => {
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -163,6 +182,12 @@ describe("syncSkills", () => {
|
||||
expect(await fs.readFile(path.join(onDiskSkill, "SKILL.md"), "utf-8")).toBe("new");
|
||||
await expect(fs.access(path.join(onDiskSkill, "references", "stale.md"))).rejects.toThrow();
|
||||
await expect(fs.access(path.join(onDiskSkill, "references"))).rejects.toThrow();
|
||||
const antigravitySkill = path.join(sandbox.antigravityDir, "paseo");
|
||||
expect(await fs.readFile(path.join(antigravitySkill, "SKILL.md"), "utf-8")).toBe("new");
|
||||
await expect(
|
||||
fs.access(path.join(antigravitySkill, "references", "stale.md")),
|
||||
).rejects.toThrow();
|
||||
await expect(fs.access(path.join(antigravitySkill, "references"))).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("preserves user-added files in managed skill dirs", async () => {
|
||||
@@ -172,11 +197,14 @@ describe("syncSkills", () => {
|
||||
await fs.writeFile(path.join(onDiskSkill, "SKILL.md"), "old");
|
||||
await fs.writeFile(path.join(onDiskSkill, "my-context.md"), "user context");
|
||||
await fs.writeFile(path.join(onDiskSkill, "references", "notes.md"), "user notes");
|
||||
const antigravitySkill = path.join(sandbox.antigravityDir, "paseo");
|
||||
await fs.mkdir(path.join(antigravitySkill, "references"), { recursive: true });
|
||||
await fs.writeFile(path.join(antigravitySkill, "SKILL.md"), "old");
|
||||
await fs.writeFile(path.join(antigravitySkill, "my-context.md"), "antigravity user context");
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -188,6 +216,10 @@ describe("syncSkills", () => {
|
||||
expect(await fs.readFile(path.join(onDiskSkill, "references", "notes.md"), "utf-8")).toBe(
|
||||
"user notes",
|
||||
);
|
||||
expect(await fs.readFile(path.join(antigravitySkill, "SKILL.md"), "utf-8")).toBe("new");
|
||||
expect(await fs.readFile(path.join(antigravitySkill, "my-context.md"), "utf-8")).toBe(
|
||||
"antigravity user context",
|
||||
);
|
||||
});
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
@@ -208,8 +240,39 @@ describe("syncSkills", () => {
|
||||
await expect(
|
||||
syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
}),
|
||||
).rejects.toThrow("Cannot sync through symbolic link");
|
||||
|
||||
expect(await fs.readFile(path.join(onDiskSkill, "SKILL.md"), "utf-8")).toBe("old skill");
|
||||
expect(await fs.readFile(path.join(externalReferences, "guide.md"), "utf-8")).toBe(
|
||||
"external guide",
|
||||
);
|
||||
expect((await fs.lstat(path.join(onDiskSkill, "references"))).isSymbolicLink()).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"rejects managed paths that would write through a symlink in Antigravity",
|
||||
async () => {
|
||||
await writeBundleSkill(sandbox.sourceDir, "paseo", {
|
||||
"SKILL.md": "new skill",
|
||||
"references/guide.md": "new guide",
|
||||
});
|
||||
const onDiskSkill = path.join(sandbox.antigravityDir, "paseo");
|
||||
const externalReferences = path.join(sandbox.root, "external-antigravity-references");
|
||||
await fs.mkdir(onDiskSkill, { recursive: true });
|
||||
await fs.mkdir(externalReferences, { recursive: true });
|
||||
await fs.writeFile(path.join(onDiskSkill, "SKILL.md"), "old skill");
|
||||
await fs.writeFile(path.join(externalReferences, "guide.md"), "external guide");
|
||||
await fs.symlink(externalReferences, path.join(onDiskSkill, "references"), "dir");
|
||||
|
||||
await expect(
|
||||
syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
}),
|
||||
@@ -231,8 +294,7 @@ describe("syncSkills", () => {
|
||||
|
||||
const first = await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -240,8 +302,7 @@ describe("syncSkills", () => {
|
||||
|
||||
const second = await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
@@ -255,8 +316,7 @@ describe("syncSkills", () => {
|
||||
const errors: Array<{ name: string; error: unknown }> = [];
|
||||
const result = await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo", "paseo-removed"],
|
||||
onSkillError: (name, error) => errors.push({ name, error }),
|
||||
@@ -278,8 +338,7 @@ describe("syncSkills", () => {
|
||||
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo", "paseo-deprecated"],
|
||||
});
|
||||
@@ -293,8 +352,7 @@ describe("syncSkills", () => {
|
||||
const errors: string[] = [];
|
||||
const result = await syncSkills({
|
||||
sourceDir: missingSourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
onSkillError: (skillName) => errors.push(skillName),
|
||||
@@ -313,8 +371,7 @@ describe("syncSkills", () => {
|
||||
const errors: string[] = [];
|
||||
const result = await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
onSkillError: (skillName) => errors.push(skillName),
|
||||
@@ -336,32 +393,30 @@ describe("removeSkill", () => {
|
||||
await fs.rm(sandbox.root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("removes the skill from all three targets when present", async () => {
|
||||
it("removes the skill from all targets when present", async () => {
|
||||
await writeBundleSkill(sandbox.sourceDir, "paseo", { "SKILL.md": "content" });
|
||||
await syncSkills({
|
||||
sourceDir: sandbox.sourceDir,
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
skillNames: ["paseo"],
|
||||
});
|
||||
|
||||
await removeSkill("paseo", {
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
});
|
||||
|
||||
await expect(fs.access(path.join(sandbox.agentsDir, "paseo"))).rejects.toThrow();
|
||||
await expect(fs.access(path.join(sandbox.claudeDir, "paseo"))).rejects.toThrow();
|
||||
await expect(fs.access(path.join(sandbox.codexDir, "paseo"))).rejects.toThrow();
|
||||
await expect(fs.access(path.join(sandbox.antigravityDir, "paseo"))).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("does not throw when targets are missing", async () => {
|
||||
await expect(
|
||||
removeSkill("does-not-exist", {
|
||||
agentsDir: sandbox.agentsDir,
|
||||
claudeDir: sandbox.claudeDir,
|
||||
installDirs: sandbox.installDirs,
|
||||
codexDir: sandbox.codexDir,
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
|
||||
@@ -4,8 +4,7 @@ import path from "node:path";
|
||||
|
||||
export interface SkillSyncOptions {
|
||||
sourceDir: string;
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
installDirs: readonly string[];
|
||||
codexDir: string;
|
||||
skillNames: readonly string[];
|
||||
onSkillError?: (skillName: string, error: unknown) => void;
|
||||
@@ -171,20 +170,29 @@ async function syncDirectoryFiles(srcDir: string, dstDir: string): Promise<numbe
|
||||
}
|
||||
|
||||
export interface RemoveSkillTargets {
|
||||
agentsDir: string;
|
||||
claudeDir: string;
|
||||
installDirs: readonly string[];
|
||||
codexDir: string;
|
||||
}
|
||||
|
||||
export async function removeSkill(skillName: string, targets: RemoveSkillTargets): Promise<void> {
|
||||
const paths = [
|
||||
path.join(targets.agentsDir, skillName),
|
||||
path.join(targets.claudeDir, skillName),
|
||||
path.join(targets.codexDir, skillName),
|
||||
];
|
||||
const paths = [...targets.installDirs, targets.codexDir].map((root) =>
|
||||
path.join(root, skillName),
|
||||
);
|
||||
let hasError = false;
|
||||
let firstError: unknown = null;
|
||||
for (const p of paths) {
|
||||
await fs.rm(p, { recursive: true, force: true });
|
||||
try {
|
||||
await fs.rm(p, { recursive: true, force: true });
|
||||
} catch (error) {
|
||||
// If an ancestor is a regular file, no skill directory can exist below it.
|
||||
if ((error as NodeJS.ErrnoException).code === "ENOTDIR") continue;
|
||||
if (!hasError) {
|
||||
hasError = true;
|
||||
firstError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError) throw firstError;
|
||||
}
|
||||
|
||||
async function isSameDirectory(a: string, b: string): Promise<boolean> {
|
||||
@@ -194,7 +202,7 @@ async function isSameDirectory(a: string, b: string): Promise<boolean> {
|
||||
|
||||
/**
|
||||
* Codex also discovers .agents/skills, so its dedicated copy is a leftover. When
|
||||
* the Codex skill directory resolves to the shared or Claude copy, it is that
|
||||
* the Codex skill directory resolves to an active install target, it is that
|
||||
* copy, and retiring it would delete the install.
|
||||
*/
|
||||
export async function isLegacyCodexCopy(
|
||||
@@ -202,7 +210,7 @@ export async function isLegacyCodexCopy(
|
||||
targets: RemoveSkillTargets,
|
||||
): Promise<boolean> {
|
||||
const codexSkillDir = path.join(targets.codexDir, skillName);
|
||||
for (const root of [targets.agentsDir, targets.claudeDir]) {
|
||||
for (const root of targets.installDirs) {
|
||||
if (await isSameDirectory(codexSkillDir, path.join(root, skillName))) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -234,6 +242,8 @@ async function retireManagedSkill(dstDir: string): Promise<number> {
|
||||
export async function syncSkills(options: SkillSyncOptions): Promise<SkillSyncResult> {
|
||||
let changedFiles = 0;
|
||||
let processedSkills = 0;
|
||||
let hasError = false;
|
||||
let firstError: unknown = null;
|
||||
|
||||
for (const skillName of options.skillNames) {
|
||||
const bundleSkillDir = path.join(options.sourceDir, skillName);
|
||||
@@ -241,28 +251,47 @@ export async function syncSkills(options: SkillSyncOptions): Promise<SkillSyncRe
|
||||
const bundleStat = await fs.stat(bundleSkillDir).catch(() => null);
|
||||
if (!bundleStat?.isDirectory()) continue;
|
||||
|
||||
try {
|
||||
changedFiles += await syncDirectoryFiles(
|
||||
bundleSkillDir,
|
||||
path.join(options.agentsDir, skillName),
|
||||
);
|
||||
let skillFailed = false;
|
||||
let skillError: unknown = null;
|
||||
|
||||
changedFiles += await syncDirectoryFiles(
|
||||
bundleSkillDir,
|
||||
path.join(options.claudeDir, skillName),
|
||||
);
|
||||
|
||||
// Retain user edits to the old dedicated Codex copy.
|
||||
if (await isLegacyCodexCopy(skillName, options)) {
|
||||
changedFiles += await retireManagedSkill(path.join(options.codexDir, skillName));
|
||||
// Attempt every install root for every skill before throwing so one
|
||||
// unwritable target does not stop updates from reaching healthy targets.
|
||||
for (const installDir of options.installDirs) {
|
||||
try {
|
||||
changedFiles += await syncDirectoryFiles(bundleSkillDir, path.join(installDir, skillName));
|
||||
} catch (error) {
|
||||
if (!skillFailed) {
|
||||
skillFailed = true;
|
||||
skillError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skillFailed) {
|
||||
try {
|
||||
// Retain user edits to the old dedicated Codex copy.
|
||||
if (await isLegacyCodexCopy(skillName, options)) {
|
||||
changedFiles += await retireManagedSkill(path.join(options.codexDir, skillName));
|
||||
}
|
||||
} catch (error) {
|
||||
skillFailed = true;
|
||||
skillError = error;
|
||||
}
|
||||
}
|
||||
|
||||
if (skillFailed) {
|
||||
if (options.onSkillError) {
|
||||
options.onSkillError(skillName, skillError);
|
||||
} else if (!hasError) {
|
||||
hasError = true;
|
||||
firstError = skillError;
|
||||
}
|
||||
} else {
|
||||
processedSkills++;
|
||||
} catch (error) {
|
||||
if (!options.onSkillError) throw error;
|
||||
options.onSkillError(skillName, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasError) throw firstError;
|
||||
|
||||
return { changedFiles, processedSkills };
|
||||
}
|
||||
|
||||
@@ -128,13 +128,28 @@ function selectionsEqual(left: SkillSelection, right: SkillSelection): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordered roots for transaction capture and recovery. Pre-0.17 manifests
|
||||
* recorded `[agents, claude, codex]` at indices 0–2, so `codexDir` stays at
|
||||
* index 2 and newer install roots follow at index 3+.
|
||||
*/
|
||||
function skillRoots(targets: SkillTargets): string[] {
|
||||
const [agentsDir, claudeDir, ...additionalInstallDirs] = targets.installDirs;
|
||||
return [
|
||||
...(agentsDir ? [agentsDir] : []),
|
||||
...(claudeDir ? [claudeDir] : []),
|
||||
targets.codexDir,
|
||||
...additionalInstallDirs,
|
||||
];
|
||||
}
|
||||
|
||||
async function validateEntries(
|
||||
targets: SkillTargets,
|
||||
transactionDir: string,
|
||||
entries: CapturedDirectory[],
|
||||
): Promise<boolean> {
|
||||
const names = new Set(await listManagedSkillNames(targets.sourceDir));
|
||||
const roots = [targets.agentsDir, targets.claudeDir, targets.codexDir];
|
||||
const roots = skillRoots(targets);
|
||||
return entries.every((entry) => {
|
||||
const rootIndex = roots.findIndex((root) => path.dirname(entry.livePath) === root);
|
||||
if (rootIndex === -1) return false;
|
||||
@@ -409,6 +424,10 @@ async function restore(
|
||||
continue;
|
||||
}
|
||||
const liveInfo = await lstat(entry.livePath).catch(() => null);
|
||||
// An add entry with no backup and no readable live path wrote nothing here
|
||||
// (absent, under a file, or under an unreadable parent). Skipping avoids
|
||||
// failing rollback with ENOTDIR/EACCES and leaving a stuck transaction.
|
||||
if (liveInfo === null && backup === null) continue;
|
||||
if (liveInfo !== null && !(await isDirectory(entry.livePath))) {
|
||||
// Add/update rollback has the same conflict state as delete rollback. A
|
||||
// recreated file or file symlink belongs to the external writer; preserve
|
||||
@@ -441,11 +460,7 @@ async function restore(
|
||||
}
|
||||
|
||||
function transactionParents(targets: SkillTargets): string[] {
|
||||
return [
|
||||
...new Set(
|
||||
[targets.agentsDir, targets.claudeDir, targets.codexDir].map((root) => path.dirname(root)),
|
||||
),
|
||||
];
|
||||
return [...new Set(skillRoots(targets).map((root) => path.dirname(root)))];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,7 +508,7 @@ export async function beginSkillsTransaction(
|
||||
nextSelection: SkillSelection,
|
||||
ops: readonly SkillOp[],
|
||||
): Promise<SkillsTransaction> {
|
||||
const roots = [targets.agentsDir, targets.claudeDir, targets.codexDir];
|
||||
const roots = skillRoots(targets);
|
||||
const seenRoots = new Set<string>();
|
||||
const uniqueRoots: Array<{ root: string; rootIndex: number }> = [];
|
||||
for (const [rootIndex, root] of roots.entries()) {
|
||||
|
||||
Reference in New Issue
Block a user