mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 08:02:31 +00:00
* Add safe skill freshness detection * Accept observed copy-mode rail outcomes * chore(skills): regenerate snapshot artifacts for the merged guide content The rebase onto main picked up the reviewed guide fixes (#8624), so the current manifest hashes and a new appended snapshot generation must match those bytes; the registry keeps all prior snapshots so existing installs classify as outdated rather than unrecognized. * fix(skills): canonicalize snapshot file order and guard released history Historical snapshots kept git ls-tree byte-order while the working-tree walk and runtime observation use the sorted depth-first order, so any future multi-file skill would misclassify older installs as unrecognized and churn spurious registry revisions; all producers now share one canonical order (no digest changes for today's single-file packages). Also rejects executable files from shipped skills (Windows observation cannot see execute bits, which would misclassify pristine Windows installs) and adds an explicit append-only invariant for released snapshots so a generation-logic change cannot rewrite them silently. * fix(skills): throttle focus rescans and correct self-blocked placement copy Every window focus re-read and re-hashed all installed packages, and the nudge and panel each forced their own trailing rescan for one event; a 15s cooldown plus a shared invalidation latch keep one bounded scan per event while install-change events stay immediate. Bundle artifacts are now loaded once per run instead of re-parsed on every scan. A read-only or otherwise unsupported outdated placement now explains that it blocks itself instead of blaming a phantom sibling placement; the supported topology set moved to shared so eligibility and copy cannot drift. * feat(skills): move freshness surfacing to a lingering toast and update modal The Skills page has been unreachable since its toolbox menu entry was removed (#4535), so surfacing freshness there buried the feature behind its own nudge. The nudge now lingers until acted on (ignoring it records nothing; only the explicit close persists dismissal keys) and opens an update modal hosting the pre-filled editable terminal, an honest current/blocked summary, and the per-placement rows in a collapsed Details section. A compact 'Check for skill updates' row in CLI settings is the manual re-entry point. Skills page restored to main; design-doc surfacing section records the venue decision. * fix(skills): mount update dialog inside the link-routing provider and fold freshness into the setup rails The dialog hosts a live terminal pane that requires the link-routing preference context; mounted outside the provider it crashed the renderer the moment an eligible update existed (caught by live QA — unit tests mock the terminal). It now mounts inside the provider behind its own recoverable boundary. The separate 'Check for skill updates' settings button is gone: the setup rails' own pill now carries freshness (Update available / Up to date, falling back to Installed for blocked or unrecognized copies and for non-local runtimes the local-only scan cannot vouch for), and Re-check refreshes both installation detection and the freshness inventory. Wired for the CLI, Orchestration, Computer Use, and Per-Workspace Environments rails. * fix(skills): use the sleek scrollbar style in the update dialog * chore(skills): regenerate manifest for merged main (v1.4.142-rc.1) Main advanced to 1.4.142-rc.1 with a v1.4.141 release, so the embedded appVersion and release mapping were stale on the PR's merged tree. Only appVersion and the new release entry change; no snapshot digests move (released history preserved). * fix(skills): bound and batch freshness work * fix(skills): harden freshness integrity checks * fix(skills): accept observed copy topology outcomes * chore(skills): regenerate manifest for current main * fix(skills): preserve update terminal lifecycle * chore(skills): regenerate manifest for current main * fix(skills): fail closed on stale freshness scans * chore(skills): regenerate manifest for current main * fix(skills): preserve freshness safety under focus churn * feat(skills): group the update modal by skill with plain-language status The Update skills modal now lists only skills that will update or that can't (with why), grouped by skill with their install locations nested underneath — no more one row per placement. - Statuses collapse to "Update available" / "Can't update" at the skill level. - A location's problem is a chip (Duplicate, Unrecognized, Inaccessible, Read only, In a repo, External/Broken link, Plugin cache) with a hover tooltip that explains what it means for the user and what to do. - Up-to-date, unrecognized-only, and unreadable-only skills are hidden; a current/unrecognized/etc. location only appears when it explains a shown skill. - Copy is de-jargoned (drops "copy"/"placement"/"snapshot"/"official copy") and names the mechanism as the npx skills update command, not "Orca's update". - Rename the section to "Update details"; drop the unreachable newer-known state. Renderer-only: derivation is a pure module (groupSkillFreshness) with unit tests; no IPC or main-process change. Locales updated for all five languages. * chore(skills): regenerate manifest for current main (v1.4.143-rc.0) * feat(skills): don't let a duplicate block the update; clearer skipped copy - Eligibility: a clean standalone duplicate no longer poisons the whole name — the canonical copy still updates and the duplicate is flagged; a duplicate-only skill stays unoffered. - Update modal: "Can't update" -> "Skipped" with a reason-specific sentence (edited/read-only/in-a-repo/plugin/link); chips describe only the location state; footer "Check now" -> "Re-check". - Settings sidebar nav pills go amber "Update available" when a skill is updatable, matching the setup cards. - Localized new strings across en/es/ja/ko/zh. * chore(skills): regenerate manifest for merged main (v1.4.144-rc.1)
250 lines
9.3 KiB
JavaScript
250 lines
9.3 KiB
JavaScript
import { execFileSync } from 'node:child_process'
|
|
import {
|
|
chmod,
|
|
cp,
|
|
lstat,
|
|
mkdir,
|
|
mkdtemp,
|
|
readFile,
|
|
realpath,
|
|
rm,
|
|
symlink,
|
|
writeFile
|
|
} from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import path from 'node:path'
|
|
import process from 'node:process'
|
|
import { collectPackageFiles, packageDigest } from './generate-skill-bundle-manifest.mjs'
|
|
|
|
function option(name) {
|
|
return process.argv.find((value) => value.startsWith(`--${name}=`))?.slice(name.length + 3)
|
|
}
|
|
|
|
const cliVersion = option('cli')
|
|
const autocrlf = option('autocrlf')
|
|
const shape = option('shape')
|
|
// Why: PR branch names are untrusted workflow input. Keep them out of the
|
|
// generated shell command and pass them to Node through the environment.
|
|
const source = option('source') ?? process.env.SKILL_UPDATE_SOURCE
|
|
const ref = option('ref') ?? process.env.SKILL_UPDATE_REF
|
|
if (
|
|
!cliVersion ||
|
|
(autocrlf !== 'true' && autocrlf !== 'false') ||
|
|
(shape !== 'symlink' && shape !== 'copy') ||
|
|
!source ||
|
|
!ref ||
|
|
!/^[^/\s]+\/[^/\s]+$/.test(source)
|
|
) {
|
|
throw new Error(
|
|
'Usage: verify-skill-update-roundtrip.mjs --cli=<version> --autocrlf=true|false --shape=symlink|copy --source=<owner/repo> --ref=<git-ref>'
|
|
)
|
|
}
|
|
|
|
const sandbox = await mkdtemp(path.join(tmpdir(), 'orca-skill-update-roundtrip-'))
|
|
const home = path.join(sandbox, 'home')
|
|
const stateHome = path.join(home, '.state')
|
|
const fakeBin = path.join(sandbox, 'bin')
|
|
const targetName = 'orca-cli'
|
|
const controlName = 'orchestration'
|
|
const manifest = JSON.parse(await readFile('resources/skills/current-manifest.json', 'utf8'))
|
|
const registry = JSON.parse(await readFile('resources/skills/snapshot-registry.json', 'utf8'))
|
|
const releaseMapping = JSON.parse(await readFile('resources/skills/release-mapping.json', 'utf8'))
|
|
|
|
function currentSkill(name) {
|
|
const skill = manifest.skills.find((entry) => entry.name === name)
|
|
if (!skill) {
|
|
throw new Error(`Current manifest is missing ${name}`)
|
|
}
|
|
return skill
|
|
}
|
|
|
|
function historicalRelease(name) {
|
|
const current = currentSkill(name)
|
|
for (const release of releaseMapping.releases.toReversed()) {
|
|
const revision = release.skills[name]
|
|
if (typeof revision !== 'number' || revision >= current.releaseRevision) {
|
|
continue
|
|
}
|
|
const snapshot = registry.skills[name]?.find((entry) => entry.releaseRevision === revision)
|
|
if (snapshot) {
|
|
return { tag: `v${release.appVersion}`, snapshot }
|
|
}
|
|
}
|
|
throw new Error(`No historical released snapshot is available for ${name}`)
|
|
}
|
|
|
|
async function materializePackage(name, tag, destination) {
|
|
const prefix = `skills/${name}/`
|
|
const entries = execFileSync('git', ['ls-tree', '-r', '-z', tag, '--', `skills/${name}`])
|
|
.toString('utf8')
|
|
.split('\0')
|
|
.filter(Boolean)
|
|
if (entries.length === 0) {
|
|
throw new Error(`${tag} does not contain ${name}`)
|
|
}
|
|
for (const entry of entries) {
|
|
const match = /^(\d+) (\w+) ([a-f0-9]+)\t(.+)$/.exec(entry)
|
|
if (!match || match[2] !== 'blob') {
|
|
throw new Error(`Unsupported historical tree entry: ${entry}`)
|
|
}
|
|
const relativePath = match[4].slice(prefix.length)
|
|
const destinationPath = path.join(destination, ...relativePath.split('/'))
|
|
await mkdir(path.dirname(destinationPath), { recursive: true })
|
|
await writeFile(destinationPath, execFileSync('git', ['cat-file', 'blob', match[3]]))
|
|
if (process.platform !== 'win32' && match[1] === '100755') {
|
|
await chmod(destinationPath, 0o755)
|
|
}
|
|
}
|
|
}
|
|
|
|
async function seedPlacement(name, tag) {
|
|
const canonical = path.join(home, '.agents', 'skills', name)
|
|
await materializePackage(name, tag, canonical)
|
|
const providerRoot = path.join(home, '.claude', 'skills')
|
|
const provider = path.join(providerRoot, name)
|
|
await mkdir(providerRoot, { recursive: true })
|
|
await (shape === 'copy'
|
|
? cp(canonical, provider, { recursive: true })
|
|
: symlink(canonical, provider, process.platform === 'win32' ? 'junction' : 'dir'))
|
|
}
|
|
|
|
async function installFakeAgentCommands() {
|
|
await mkdir(fakeBin, { recursive: true })
|
|
for (const name of ['codex', 'claude']) {
|
|
const executable = path.join(fakeBin, process.platform === 'win32' ? `${name}.cmd` : name)
|
|
await writeFile(
|
|
executable,
|
|
process.platform === 'win32' ? '@exit /b 0\r\n' : '#!/bin/sh\nexit 0\n'
|
|
)
|
|
if (process.platform !== 'win32') {
|
|
await chmod(executable, 0o755)
|
|
}
|
|
}
|
|
}
|
|
|
|
async function packageDigestAt(pathValue) {
|
|
return packageDigest(await collectPackageFiles(pathValue))
|
|
}
|
|
|
|
async function assertCurrentCanonical(name) {
|
|
const expected = currentSkill(name).packageDigest
|
|
const canonical = path.join(home, '.agents', 'skills', name)
|
|
if ((await packageDigestAt(canonical)) !== expected) {
|
|
throw new Error(`${name} canonical placement did not update to the PR content`)
|
|
}
|
|
}
|
|
|
|
function execSkills(args) {
|
|
const executable = process.platform === 'win32' ? (process.env.ComSpec ?? 'cmd.exe') : 'npx'
|
|
const cliArgs = ['--yes', `skills@${cliVersion}`, ...args]
|
|
execFileSync(
|
|
executable,
|
|
process.platform === 'win32' ? ['/d', '/s', '/c', 'npx.cmd', ...cliArgs] : cliArgs,
|
|
{
|
|
cwd: process.cwd(),
|
|
env: {
|
|
...process.env,
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
CODEX_HOME: path.join(home, '.codex'),
|
|
CLAUDE_CONFIG_DIR: path.join(home, '.claude'),
|
|
XDG_STATE_HOME: stateHome,
|
|
GIT_CONFIG_COUNT: '1',
|
|
GIT_CONFIG_KEY_0: 'core.autocrlf',
|
|
GIT_CONFIG_VALUE_0: autocrlf,
|
|
PATH: `${fakeBin}${path.delimiter}${process.env.PATH ?? ''}`,
|
|
CI: '1'
|
|
},
|
|
stdio: 'inherit'
|
|
}
|
|
)
|
|
}
|
|
|
|
try {
|
|
const targetHistorical = historicalRelease(targetName)
|
|
const controlHistorical = historicalRelease(controlName)
|
|
await installFakeAgentCommands()
|
|
await mkdir(path.join(home, '.codex'), { recursive: true })
|
|
await mkdir(path.join(home, '.claude'), { recursive: true })
|
|
await seedPlacement(targetName, targetHistorical.tag)
|
|
await seedPlacement(controlName, controlHistorical.tag)
|
|
const targetProvider = path.join(home, '.claude', 'skills', targetName)
|
|
const controlCanonical = path.join(home, '.agents', 'skills', controlName)
|
|
const controlProvider = path.join(home, '.claude', 'skills', controlName)
|
|
const targetProviderBefore = await packageDigestAt(await realpath(targetProvider))
|
|
const controlBefore = await packageDigestAt(controlCanonical)
|
|
const controlProviderBefore = await packageDigestAt(await realpath(controlProvider))
|
|
|
|
const timestamp = new Date().toISOString()
|
|
const lock = {
|
|
version: 3,
|
|
skills: {
|
|
[targetName]: {
|
|
source,
|
|
sourceType: 'github',
|
|
sourceUrl: `https://github.com/${source}.git`,
|
|
ref,
|
|
skillPath: `skills/${targetName}/SKILL.md`,
|
|
skillFolderHash: targetHistorical.snapshot.gitTreeSha,
|
|
installedAt: timestamp,
|
|
updatedAt: timestamp
|
|
},
|
|
[controlName]: {
|
|
source,
|
|
sourceType: 'github',
|
|
sourceUrl: `https://github.com/${source}.git`,
|
|
ref,
|
|
skillPath: `skills/${controlName}/SKILL.md`,
|
|
skillFolderHash: controlHistorical.snapshot.gitTreeSha,
|
|
installedAt: timestamp,
|
|
updatedAt: timestamp
|
|
}
|
|
}
|
|
}
|
|
const lockPath = path.join(stateHome, 'skills', '.skill-lock.json')
|
|
await mkdir(path.dirname(lockPath), { recursive: true })
|
|
await writeFile(lockPath, `${JSON.stringify(lock, null, 2)}\n`)
|
|
|
|
// Why: this is the exact user-visible rail. A bare update would include
|
|
// unrelated vendors, while this command must leave the control skill alone.
|
|
execSkills(['update', targetName, '--global'])
|
|
await assertCurrentCanonical(targetName)
|
|
const targetProviderAfter = await packageDigestAt(await realpath(targetProvider))
|
|
const targetProviderStat = await lstat(targetProvider)
|
|
if (shape === 'symlink' && !targetProviderStat.isSymbolicLink()) {
|
|
throw new Error(`${targetName} provider alias was replaced with an independent copy`)
|
|
}
|
|
if (shape === 'symlink' && targetProviderAfter !== currentSkill(targetName).packageDigest) {
|
|
throw new Error(`${targetName} provider alias did not converge with the canonical update`)
|
|
}
|
|
if (
|
|
shape === 'copy' &&
|
|
targetProviderAfter !== targetProviderBefore &&
|
|
targetProviderAfter !== currentSkill(targetName).packageDigest
|
|
) {
|
|
throw new Error('Independent provider copy changed to an unexpected package identity')
|
|
}
|
|
if (shape === 'copy') {
|
|
// Why: hosted 1.5.17 replaces copies with aliases while equivalent local runs
|
|
// retain the copy. Both prove this input topology must remain ineligible.
|
|
const outcome = targetProviderStat.isSymbolicLink()
|
|
? 'converged to an alias'
|
|
: targetProviderAfter === targetProviderBefore
|
|
? 'remained a historical copy'
|
|
: 'converged as a copy'
|
|
console.log(`[skill-update-roundtrip] independent copy ${outcome}`)
|
|
}
|
|
if ((await packageDigestAt(controlCanonical)) !== controlBefore) {
|
|
throw new Error('Targeted update changed the non-targeted control skill')
|
|
}
|
|
if ((await packageDigestAt(await realpath(controlProvider))) !== controlProviderBefore) {
|
|
throw new Error('Targeted update changed the non-targeted control provider placement')
|
|
}
|
|
const controlProviderStat = await lstat(controlProvider)
|
|
if (shape === 'symlink' && !controlProviderStat.isSymbolicLink()) {
|
|
throw new Error('Targeted update changed the non-targeted control topology')
|
|
}
|
|
} finally {
|
|
await rm(sandbox, { recursive: true, force: true })
|
|
}
|