From 5f1527e38e55f2ebddac6e27f58558f23510247d Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 28 Nov 2026 10:42:33 +0000 Subject: [PATCH 1/3] CLI: skills install --auto keeps a cua-driver opt-out, and refresh remembers removed folders The afterUpdate pair undid both opt-outs on every CLI update. install --auto always installed cua-driver next to each ardia skill and reset the marker's companions, ignoring "companions": [] from --no-cua and a deleted cua-driver folder. refresh then rewrote skills.json with only the folders still on disk, so a removed ardia folder was skipped once and reinstalled, with cua-driver, on the next update. install --auto now uses refresh's own rule for the companion: put it back only where the marker names it (or predates companions) and ardia's copy is there, or on a fresh install. refresh keeps a recorded folder that is gone, so the "removed after an earlier install" skip lasts. A plain install without --no-cua still installs cua-driver, so opting back in is one command. Refs ardia-browser/ardia#4769 --- plugins/cli/docs/cli.md | 9 ++++++--- plugins/cli/ts/src/skills.ts | 28 ++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/plugins/cli/docs/cli.md b/plugins/cli/docs/cli.md index 74c1a785..f3d0066d 100644 --- a/plugins/cli/docs/cli.md +++ b/plugins/cli/docs/cli.md @@ -72,9 +72,12 @@ that is CPython 3.13 behaviour the program reproduces on purpose (`ts/src/pylib` included, is refused with the folder's path; `--replace` removes that one folder (a link itself, never its target) and installs fresh. Each folder it wrote goes into `$ARDIA_CLI_HOME/skills.json`. `ardia skills refresh` never adopts: it rewrites every marked folder in that list and every marked user-level folder above, prints - `skipped ` for the rest, refuses a linked subfolder, and keeps only our folders in the list. `install.sh` runs it after - each upgrade, so installed copies follow the CLI. Both also install cua-driver's skill next to ours (see Computer - use); `--no-cua` skips it. + `skipped ` for the rest, refuses a linked subfolder, and keeps our folders and the ones the user removed in the + list, so `install --auto` keeps skipping a removed copy after later updates. `install.sh` runs it after each upgrade, + so installed copies follow the CLI. Both also install cua-driver's skill next to ours (see Computer use); `--no-cua` + skips it and records `"companions": []` in the marker. `refresh` and `install --auto` keep to that: they put + cua-driver's skill back only where the marker still names it and ardia's copy is still there, so `--no-cua` once, or + deleting the `cua-driver` folder, keeps it out across updates. A plain `install` without `--no-cua` brings it back. - `ardia skills status` says, for every recorded and user- or project-level copy, whether it is `current` (its stamp is this CLI's skill and its files still hash to it), `stale` (an older CLI wrote it, or a copy from before the stamp), `edited` (its files no longer match its own stamp) or `foreign` (not ardia's), and ends with the shipped version and diff --git a/plugins/cli/ts/src/skills.ts b/plugins/cli/ts/src/skills.ts index 10c83370..535987a8 100644 --- a/plugins/cli/ts/src/skills.ts +++ b/plugins/cli/ts/src/skills.ts @@ -387,7 +387,9 @@ function absolute(path: string): string { return normalized(isAbsolute(path) ? path : join(process.cwd(), path)); } -export async function install(targets: string[], project: boolean, computerUse = true, replace = false): Promise { +export type ComputerUse = boolean | "unless-opted-out"; + +export async function install(targets: string[], project: boolean, computerUse: ComputerUse = true, replace = false): Promise { const written = new Map(); for (const target of new Set(targets)) { const folder = destination(target, project); @@ -400,7 +402,7 @@ export async function install(targets: string[], project: boolean, computerUse = const label = names.join(", "); await stepBoundary(); try { - installInto(folder, computerUse ? undefined : [], true, replace); + installInto(folder, computerUse === false ? [] : undefined, true, replace); } catch (error) { if (!(error instanceof SkillError) && !errnoOf(error)) throw error; out.push(`${label}: error ${osError(error)}`); @@ -409,7 +411,7 @@ export async function install(targets: string[], project: boolean, computerUse = } installed.push(absolute(folder)); out.push(`${label}: ${folder}`); - if (computerUse) { + if (computerUse === true || (computerUse === "unless-opted-out" && wantsCompanion(folder))) { await stepBoundary(); const [line, failed] = await companionLine(companionFolder(folder)); out.push(`${label}: ${line}`); @@ -450,7 +452,7 @@ export async function installDetected(computerUse = true): Promise { ["skills_skipped", detectedTargets().length - targets.length], ]; if (targets.length === 0) return { status: 0, out, counts }; - const done = await install(targets, false, computerUse); + const done = await install(targets, false, computerUse ? "unless-opted-out" : false); return { status: done.status, out: [...out, ...done.out], counts }; } @@ -461,13 +463,24 @@ function mentions(companions: Value, name: string): boolean { throw new TypeError("argument of this type is not iterable"); } +function wantsCompanion(folder: string): boolean { + const companions = readMarker(folder)?.get("companions") ?? undefined; + const cua = companionFolder(folder); + const ours = markedFiles(cua, CUA_SKILL) !== undefined && !isLink(cua); + return (companions === undefined && !present(cua)) || (ours && (companions === undefined || mentions(companions, CUA_SKILL))); +} + export async function refresh(): Promise { const userFolders = Object.keys(TARGETS).map((target) => destination(target, false)); let status = 0; + const recorded = recordedFolders(); const kept: string[] = []; const out: string[] = []; - for (const folder of new Set([...recordedFolders(), ...userFolders])) { - if (!present(folder)) continue; + for (const folder of new Set([...recorded, ...userFolders])) { + if (!present(folder)) { + if (recorded.includes(folder)) kept.push(folder); + continue; + } if (ownedFiles(folder) === undefined) { out.push(`skipped ${folder}: not installed by ardia skills install (no ${MARKER} marker)`); continue; @@ -485,8 +498,7 @@ export async function refresh(): Promise { out.push(`refreshed ${folder}`); const companions = readMarker(folder)?.get("companions") ?? undefined; const cua = companionFolder(folder); - const ours = markedFiles(cua, CUA_SKILL) !== undefined && !isLink(cua); - if ((companions === undefined && !present(cua)) || (ours && (companions === undefined || mentions(companions, CUA_SKILL)))) { + if (wantsCompanion(folder)) { await stepBoundary(); const [line, failed] = await companionLine(cua); out.push(line.startsWith("error") ? line : `refreshed ${cua}`); From 590a82c06916be949c1b668d9fd794bc178115a8 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 28 Nov 2026 11:05:20 +0000 Subject: [PATCH 2/3] CLI skills: refresh never drops a recorded folder, and install --auto records the companion choice refresh kept a recorded folder only when it was ours or gone, so taking a copy over by deleting its marker dropped it from skills.json, and deleting the folder afterwards let the next update reinstall ardia and cua-driver. It now keeps every recorded folder; install --auto already skips one that is gone or not ours. A standalone install --auto next to someone else's cua-driver skill left the marker's companions unset, so removing that skill made the next install --auto put ardia's copy there. It now records the companion the way refresh does. wantsCompanion takes the marker refresh already read and checks for a link before reading through it. --- plugins/cli/docs/cli.md | 15 +++++++++------ plugins/cli/ts/src/skills.ts | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/plugins/cli/docs/cli.md b/plugins/cli/docs/cli.md index f3d0066d..9f820ea0 100644 --- a/plugins/cli/docs/cli.md +++ b/plugins/cli/docs/cli.md @@ -72,12 +72,15 @@ that is CPython 3.13 behaviour the program reproduces on purpose (`ts/src/pylib` included, is refused with the folder's path; `--replace` removes that one folder (a link itself, never its target) and installs fresh. Each folder it wrote goes into `$ARDIA_CLI_HOME/skills.json`. `ardia skills refresh` never adopts: it rewrites every marked folder in that list and every marked user-level folder above, prints - `skipped ` for the rest, refuses a linked subfolder, and keeps our folders and the ones the user removed in the - list, so `install --auto` keeps skipping a removed copy after later updates. `install.sh` runs it after each upgrade, - so installed copies follow the CLI. Both also install cua-driver's skill next to ours (see Computer use); `--no-cua` - skips it and records `"companions": []` in the marker. `refresh` and `install --auto` keep to that: they put - cua-driver's skill back only where the marker still names it and ardia's copy is still there, so `--no-cua` once, or - deleting the `cua-driver` folder, keeps it out across updates. A plain `install` without `--no-cua` brings it back. + `skipped ` for the rest, refuses a linked subfolder, and never drops a folder from the list, so `install --auto` + keeps skipping a copy the user removed, or took over by deleting its marker, after later updates. `install.sh` runs + it after each upgrade, so installed copies follow the CLI. Both also install cua-driver's skill next to ours (see + Computer use); `--no-cua` skips it and records `"companions": []` in the marker. `refresh` and `install --auto` keep + to that: next to an existing copy they put cua-driver's skill back only where ardia's cua-driver copy is still there + and the marker names it (or predates the `companions` field, which also brings back a missing one), and a fresh + folder gets it unless another cua-driver skill is already there. Either way the marker then records the choice, so + `--no-cua` once, or deleting the `cua-driver` folder, keeps it out across updates. A plain `install` without + `--no-cua` brings it back. - `ardia skills status` says, for every recorded and user- or project-level copy, whether it is `current` (its stamp is this CLI's skill and its files still hash to it), `stale` (an older CLI wrote it, or a copy from before the stamp), `edited` (its files no longer match its own stamp) or `foreign` (not ardia's), and ends with the shipped version and diff --git a/plugins/cli/ts/src/skills.ts b/plugins/cli/ts/src/skills.ts index 535987a8..105d923e 100644 --- a/plugins/cli/ts/src/skills.ts +++ b/plugins/cli/ts/src/skills.ts @@ -411,13 +411,17 @@ export async function install(targets: string[], project: boolean, computerUse: } installed.push(absolute(folder)); out.push(`${label}: ${folder}`); - if (computerUse === true || (computerUse === "unless-opted-out" && wantsCompanion(folder))) { + const companions = computerUse === "unless-opted-out" ? readMarker(folder)?.get("companions") ?? undefined : undefined; + if (computerUse === true || (computerUse === "unless-opted-out" && wantsCompanion(folder, companions))) { await stepBoundary(); const [line, failed] = await companionLine(companionFolder(folder)); out.push(`${label}: ${line}`); await stepBoundary(); if (failed) status = 1; else noteCompanions(folder, [...COMPANIONS]); + } else if (computerUse === "unless-opted-out" && companions === undefined) { + await stepBoundary(); + noteCompanions(folder, [...COMPANIONS]); } } await stepBoundary(); @@ -463,10 +467,9 @@ function mentions(companions: Value, name: string): boolean { throw new TypeError("argument of this type is not iterable"); } -function wantsCompanion(folder: string): boolean { - const companions = readMarker(folder)?.get("companions") ?? undefined; +function wantsCompanion(folder: string, companions: Value | undefined): boolean { const cua = companionFolder(folder); - const ours = markedFiles(cua, CUA_SKILL) !== undefined && !isLink(cua); + const ours = !isLink(cua) && markedFiles(cua, CUA_SKILL) !== undefined; return (companions === undefined && !present(cua)) || (ours && (companions === undefined || mentions(companions, CUA_SKILL))); } @@ -474,18 +477,15 @@ export async function refresh(): Promise { const userFolders = Object.keys(TARGETS).map((target) => destination(target, false)); let status = 0; const recorded = recordedFolders(); - const kept: string[] = []; + const remembered: string[] = [...recorded]; const out: string[] = []; for (const folder of new Set([...recorded, ...userFolders])) { - if (!present(folder)) { - if (recorded.includes(folder)) kept.push(folder); - continue; - } + if (!present(folder)) continue; if (ownedFiles(folder) === undefined) { out.push(`skipped ${folder}: not installed by ardia skills install (no ${MARKER} marker)`); continue; } - kept.push(folder); + remembered.push(folder); await stepBoundary(); try { installInto(folder, undefined); @@ -498,7 +498,7 @@ export async function refresh(): Promise { out.push(`refreshed ${folder}`); const companions = readMarker(folder)?.get("companions") ?? undefined; const cua = companionFolder(folder); - if (wantsCompanion(folder)) { + if (wantsCompanion(folder, companions)) { await stepBoundary(); const [line, failed] = await companionLine(cua); out.push(line.startsWith("error") ? line : `refreshed ${cua}`); @@ -511,7 +511,7 @@ export async function refresh(): Promise { if (companions === undefined) noteCompanions(folder, [...COMPANIONS]); } await stepBoundary(); - saveRecord(kept); + saveRecord(remembered); return { status, out }; } From 63294f7481cb550863c50e7e0d98d7309b6d6ed3 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 28 Nov 2026 11:14:22 +0000 Subject: [PATCH 3/3] CLI skills: refresh remembers only the user-level folders install --auto checks Keeping every recorded folder let skills.json grow with project folders that are no longer ardia's; past the 1 MiB read limit the record reads as empty and the opt-outs go with it, and each refresh kept printing "skipped" for them. install --auto only ever looks at the user-level folders, so refresh keeps those it recorded, removed or taken over, and prunes project folders as before. --- plugins/cli/docs/cli.md | 8 ++++---- plugins/cli/ts/src/skills.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/cli/docs/cli.md b/plugins/cli/docs/cli.md index 9f820ea0..3ebf8157 100644 --- a/plugins/cli/docs/cli.md +++ b/plugins/cli/docs/cli.md @@ -72,10 +72,10 @@ that is CPython 3.13 behaviour the program reproduces on purpose (`ts/src/pylib` included, is refused with the folder's path; `--replace` removes that one folder (a link itself, never its target) and installs fresh. Each folder it wrote goes into `$ARDIA_CLI_HOME/skills.json`. `ardia skills refresh` never adopts: it rewrites every marked folder in that list and every marked user-level folder above, prints - `skipped ` for the rest, refuses a linked subfolder, and never drops a folder from the list, so `install --auto` - keeps skipping a copy the user removed, or took over by deleting its marker, after later updates. `install.sh` runs - it after each upgrade, so installed copies follow the CLI. Both also install cua-driver's skill next to ours (see - Computer use); `--no-cua` skips it and records `"companions": []` in the marker. `refresh` and `install --auto` keep + `skipped ` for the rest, refuses a linked subfolder, and keeps our folders in the list plus every user-level one it + recorded, so `install --auto` keeps skipping a copy the user removed, or took over by deleting its marker, after later + updates. `install.sh` runs it after each upgrade, so installed copies follow the CLI. Both also install cua-driver's + skill next to ours (see Computer use); `--no-cua` skips it and records `"companions": []` in the marker. `refresh` and `install --auto` keep to that: next to an existing copy they put cua-driver's skill back only where ardia's cua-driver copy is still there and the marker names it (or predates the `companions` field, which also brings back a missing one), and a fresh folder gets it unless another cua-driver skill is already there. Either way the marker then records the choice, so diff --git a/plugins/cli/ts/src/skills.ts b/plugins/cli/ts/src/skills.ts index 105d923e..0bc61bee 100644 --- a/plugins/cli/ts/src/skills.ts +++ b/plugins/cli/ts/src/skills.ts @@ -477,7 +477,8 @@ export async function refresh(): Promise { const userFolders = Object.keys(TARGETS).map((target) => destination(target, false)); let status = 0; const recorded = recordedFolders(); - const remembered: string[] = [...recorded]; + const userLevel = new Set(userFolders.map(absolute)); + const remembered = recorded.filter((folder) => userLevel.has(folder)); const out: string[] = []; for (const folder of new Set([...recorded, ...userFolders])) { if (!present(folder)) continue;