fix(install): handle 8.3 source paths, bound plugin delegation, check skill contracts
Sync-ManagedDestination and Copy-Directory cut relative paths by the length of $Source. With an 8.3 short path such as JULIAN~1, Get-ChildItem returned long paths, so files landed under a truncated directory name. Both now expand $Source with Get-Item first. PowerShell tests now pass -ExecutionPolicy Bypass, tolerate non-UTF-8 console output, and give the Git Bash quick update 300 seconds. The orchestration rule now covers plugin workflows. A plugin default alone never authorizes subagents, per-task reviews stay proportional, parallel writers get disjoint files, and plugin agents keep to their specialty inside the shared handoff format. doctor warns when an installed Impeccable or Apple Design skill no longer names the commands and sections plugin-workflow relies on. Prompt budget baselines are refreshed to the current values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abc9ae8e1b
commit
b8b4438275
15 files changed
+146
-28
No files matched your search
@@ -69,6 +69,7 @@ New-Item $output -ItemType Directory | Out-Null
|
||||
|
||||
function Copy-Directory($source, $destination) {
|
||||
New-Item $destination -ItemType Directory -Force | Out-Null
|
||||
$source = (Get-Item -LiteralPath $source).FullName # expand 8.3 short paths so the prefix cut lines up
|
||||
Get-ChildItem $source -File -Recurse | ForEach-Object {
|
||||
$relative = $_.FullName.Substring($source.Length).TrimStart([char[]]@('\','/'))
|
||||
$target = Join-Path $destination $relative
|
||||
|
||||
@@ -56,6 +56,10 @@ if ($python) {
|
||||
$qmdChecks = Invoke-DoctorCommand -Command $python.Path -Arguments (@($python.Arguments) + @((Join-Path $root 'scripts/lib/qmd.py'), 'doctor', '--root', $root, '--home', $homePath))
|
||||
if ($qmdChecks.ExitCode -ne 0) { Result 'WARN' "QMD checks failed: $($qmdChecks.Output -join ' ')" }
|
||||
else { foreach ($line in $qmdChecks.Output) { if ("$line" -match '^(PASS|WARN|FAIL) (.+)$') { Result $Matches[1] $Matches[2] } } }
|
||||
# Upstream skill updates can rename what plugin-workflow coordinates; reports nothing when neither skill is installed.
|
||||
$contractChecks = Invoke-DoctorCommand -Command $python.Path -Arguments (@($python.Arguments) + @((Join-Path $root 'scripts/lib/skill-contracts.py'), '--home', $homePath))
|
||||
if ($contractChecks.ExitCode -ne 0) { Result 'WARN' "Skill contract checks failed: $($contractChecks.Output -join ' ')" }
|
||||
else { foreach ($line in $contractChecks.Output) { if ("$line" -match '^(PASS|WARN|FAIL) (.+)$') { Result $Matches[1] $Matches[2] } } }
|
||||
}
|
||||
|
||||
$sourceAgentCount = @(Get-ChildItem (Join-Path $root 'shared/agents') -Directory -ErrorAction SilentlyContinue).Count
|
||||
|
||||
@@ -64,6 +64,14 @@ if resolve_python; then
|
||||
else
|
||||
result WARN "QMD checks failed: ${qmd_output//$'\n'/ }"
|
||||
fi
|
||||
# Upstream skill updates can rename what plugin-workflow coordinates; reports nothing when neither skill is installed.
|
||||
if contract_output=$(run_python "$root/scripts/lib/skill-contracts.py" --home "$home_path" 2>&1); then
|
||||
while IFS= read -r line; do
|
||||
case "$line" in PASS\ *|WARN\ *|FAIL\ *) result "${line%% *}" "${line#* }" ;; esac
|
||||
done <<< "$contract_output"
|
||||
else
|
||||
result WARN "Skill contract checks failed: ${contract_output//$'\n'/ }"
|
||||
fi
|
||||
fi
|
||||
|
||||
source_agent_count=$(find "$root/shared/agents" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
|
||||
|
||||
@@ -221,6 +221,8 @@ function Invoke-ManagedSync {
|
||||
|
||||
# Plan every change before writing anything, so the journal can describe the whole run.
|
||||
$plan = New-Object System.Collections.ArrayList
|
||||
# Get-ChildItem returns long paths; expand an 8.3 short $Source (such as JULIAN~1) so the prefix cut below lines up.
|
||||
$Source = (Get-Item -LiteralPath $Source).FullName
|
||||
Get-ChildItem $Source -File -Recurse | ForEach-Object {
|
||||
$relative = $_.FullName.Substring($Source.Length).TrimStart([char[]]@('\','/')).Replace('\','/')
|
||||
if ((Split-Path $Destination -Leaf) -eq '.codex' -and $relative.StartsWith('skills/')) { return }
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Doctor check: installed upstream skills still offer what plugin-workflow's UI section names."""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
# Keep in sync with the Impeccable and Apple Design section of shared/skills/plugin-workflow/SKILL.md.
|
||||
CONTRACTS = {
|
||||
'impeccable': ('Impeccable', ['critique', 'audit', 'harden', 'adapt', 'clarify', 'layout', 'typeset', 'polish',
|
||||
'shape', 'craft-floor', 'Operate', 'Persuade']),
|
||||
'apple-design': ('Apple Design', ['Always load', 'Lens 1', 'Lens 5', 'Critical', 'Design improvement mode',
|
||||
'cross-platform']),
|
||||
}
|
||||
|
||||
|
||||
def installed_skill_files(home, skill):
|
||||
candidates = [home / '.claude/skills' / skill / 'SKILL.md', home / '.agents/skills' / skill / 'SKILL.md',
|
||||
home / '.codex/skills' / skill / 'SKILL.md']
|
||||
cache = home / '.claude/plugins/cache' / skill / skill
|
||||
if cache.is_dir():
|
||||
versions = sorted((p for p in cache.iterdir() if (p / 'skills' / skill / 'SKILL.md').is_file()),
|
||||
key=lambda p: tuple(int(part) if part.isdigit() else 0 for part in p.name.split('.')))
|
||||
if versions:
|
||||
candidates.append(versions[-1] / 'skills' / skill / 'SKILL.md')
|
||||
return [path for path in candidates if path.is_file()]
|
||||
|
||||
|
||||
def check(home):
|
||||
results = []
|
||||
for skill, (name, tokens) in CONTRACTS.items():
|
||||
for path in installed_skill_files(home, skill):
|
||||
text = path.read_text(encoding='utf-8', errors='replace')
|
||||
missing = [token for token in tokens if token not in text]
|
||||
if missing:
|
||||
results.append(('WARN', f'{name} at {path.parent} no longer mentions {", ".join(missing)}; '
|
||||
'review the UI section of plugin-workflow'))
|
||||
else:
|
||||
results.append(('PASS', f'{name} at {path.parent} matches the plugin-workflow coordination'))
|
||||
return results
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--home', required=True)
|
||||
for status, message in check(Path(parser.parse_args().home)):
|
||||
print(f'{status} {message}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -243,7 +243,7 @@ class InstallOptionsTests(unittest.TestCase):
|
||||
environment = dict(os.environ, OPTION_SOURCE=str(source), OPTION_DESTINATION=str(destination))
|
||||
for enabled in (False, True):
|
||||
if kind == 'powershell':
|
||||
command = [executable, '-NoProfile', '-Command',
|
||||
command = [executable, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
||||
"$ErrorActionPreference='Stop'; . ./scripts/lib/manifest.ps1; "
|
||||
"Sync-ManagedDestination -Source $env:OPTION_SOURCE -Destination $env:OPTION_DESTINATION "
|
||||
"-Stamp test -AiConfigRoot root -ShellCommand bash -PowerShellCommand pwsh "
|
||||
@@ -254,7 +254,7 @@ class InstallOptionsTests(unittest.TestCase):
|
||||
'sync_managed_destination "$OPTION_SOURCE" "$OPTION_DESTINATION" test root bash pwsh false true '
|
||||
+ str(enabled).lower()]
|
||||
environment.update(OPTION_SOURCE=source.as_posix(), OPTION_DESTINATION=destination.as_posix())
|
||||
result = subprocess.run(command, cwd=ROOT, env=environment, capture_output=True, text=True, timeout=20)
|
||||
result = subprocess.run(command, cwd=ROOT, env=environment, capture_output=True, text=True, errors='replace', timeout=20)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
installed = json.loads((destination / 'settings.json').read_text(encoding='utf-8-sig'))
|
||||
self.assertEqual('Stop' in installed['hooks'], enabled)
|
||||
@@ -315,11 +315,11 @@ class InstallOptionsTests(unittest.TestCase):
|
||||
environment = dict(os.environ, HOME=home.as_posix(), TEST_INSTALL_HOME=str(home))
|
||||
for name, quick, answers in [('install', False, 'n\nn\nn\n'), ('update', True, '')]:
|
||||
entry = str(commands / (name + '.' + suffix))
|
||||
command = ([executable, '-NoProfile', '-File', entry, '-Shell', 'Bash', '-Client', 'Both', '-Summary']
|
||||
command = ([executable, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', entry, '-Shell', 'Bash', '-Client', 'Both', '-Summary']
|
||||
if kind == 'powershell' else [executable, entry, '--shell', 'bash', '--client', 'both', '--summary'])
|
||||
if quick:
|
||||
command.append('-Quick' if kind == 'powershell' else '--quick')
|
||||
result = subprocess.run(command, env=environment, input=answers, capture_output=True, text=True, timeout=25)
|
||||
result = subprocess.run(command, env=environment, input=answers, capture_output=True, text=True, errors='replace', timeout=25)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertNotIn('CLI-MOCK', result.stdout)
|
||||
if quick:
|
||||
|
||||
@@ -118,7 +118,7 @@ class PersonalInstructionTests(unittest.TestCase):
|
||||
def sync(client, dry=False):
|
||||
self.environment['TEST_CLIENT'] = client
|
||||
if shell == 'powershell':
|
||||
return self.run_command(str(executable), '-NoProfile', '-Command',
|
||||
return self.run_command(str(executable), '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
||||
". ./scripts/lib/manifest.ps1; Sync-ManagedDestination -Source $env:TEST_SOURCE "
|
||||
"-Destination (Join-Path $env:TEST_HOME ('.' + $env:TEST_CLIENT)) -Stamp test -Summary "
|
||||
+ ('-DryRun' if dry else ''))
|
||||
@@ -129,7 +129,7 @@ class PersonalInstructionTests(unittest.TestCase):
|
||||
|
||||
def change(action):
|
||||
if shell == 'powershell':
|
||||
self.run_command(str(executable), '-NoProfile', '-File', str(ROOT / f'scripts/commands/{action}-instruction.ps1'),
|
||||
self.run_command(str(executable), '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(ROOT / f'scripts/commands/{action}-instruction.ps1'),
|
||||
'-Client', 'Both', '-Instruction', 'Use English.', '-HomePath', str(self.home))
|
||||
else:
|
||||
self.run_command(str(executable), '-c',
|
||||
|
||||
@@ -114,7 +114,7 @@ class SelectionTests(unittest.TestCase):
|
||||
if not shell:
|
||||
self.skipTest('PowerShell unavailable')
|
||||
environment = dict(os.environ, TEST_SELECTION_HOME=str(self.home), TEST_REPOSITORY_ROOT=str(ROOT))
|
||||
save = subprocess.run([shell, '-NoProfile', '-Command',
|
||||
save = subprocess.run([shell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
||||
"$ErrorActionPreference = 'Stop'; . (Join-Path $env:TEST_REPOSITORY_ROOT 'scripts/lib/selection-state.ps1'); "
|
||||
"Save-UpdateSelection -HomePath $env:TEST_SELECTION_HOME -RepositoryRoot $env:TEST_REPOSITORY_ROOT "
|
||||
"-Shell PowerShell -Client Both -Flashbang $false -StatusLine $false -Plugins @{ Selected = @([pscustomobject]@{name='Superpowers'}); Deselected = @() }"],
|
||||
@@ -128,15 +128,15 @@ class SelectionTests(unittest.TestCase):
|
||||
stream.write(source)
|
||||
entry = Path(stream.name)
|
||||
self.addCleanup(entry.unlink)
|
||||
result = subprocess.run([shell, '-NoProfile', '-File', str(entry), '-Quick', '-DryRun'],
|
||||
env=environment, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=90)
|
||||
result = subprocess.run([shell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(entry), '-Quick', '-DryRun'],
|
||||
env=environment, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=300) # Git Bash on Windows needs ~3 min
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertNotIn('Select plugins', result.stdout)
|
||||
self.assertIn('DRYRUN ensure codex plugin: Superpowers', result.stdout)
|
||||
self.assertNotIn('DRYRUN ensure codex plugin: Context7', result.stdout)
|
||||
self.assertEqual(self.path.read_bytes(), original)
|
||||
self.assertFalse((self.home / '.codex').exists())
|
||||
failed = subprocess.run([shell, '-NoProfile', '-File', str(entry), '-Quick'], env=environment,
|
||||
failed = subprocess.run([shell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(entry), '-Quick'], env=environment,
|
||||
stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=10)
|
||||
self.assertNotEqual(failed.returncode, 0)
|
||||
self.assertEqual(self.path.read_bytes(), original)
|
||||
@@ -158,7 +158,7 @@ class SelectionTests(unittest.TestCase):
|
||||
original = self.path.read_bytes()
|
||||
environment = dict(os.environ, HOME=self.home.as_posix())
|
||||
result = subprocess.run([shell, str(ROOT / 'scripts/commands/update.sh'), '--quick', '--dry-run'],
|
||||
env=environment, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=90)
|
||||
env=environment, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=300) # Git Bash on Windows needs ~3 min
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertNotIn('Select plugins', result.stdout)
|
||||
self.assertIn('DRYRUN ensure codex plugin: Superpowers', result.stdout)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SPEC = importlib.util.spec_from_file_location('contracts', ROOT / 'scripts/lib/skill-contracts.py')
|
||||
CONTRACTS = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(CONTRACTS)
|
||||
|
||||
|
||||
class SkillContractTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
self.home = Path(directory.name)
|
||||
|
||||
def write(self, relative, text):
|
||||
path = self.home / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding='utf-8')
|
||||
|
||||
def test_reports_nothing_when_skills_are_absent(self):
|
||||
self.assertEqual([], CONTRACTS.check(self.home))
|
||||
|
||||
def test_passes_complete_skill_and_warns_on_missing_names(self):
|
||||
self.write('.claude/skills/apple-design/SKILL.md', ' '.join(CONTRACTS.CONTRACTS['apple-design'][1]))
|
||||
self.write('.agents/skills/impeccable/SKILL.md', 'critique audit')
|
||||
results = dict((message.split(' at ')[0], status) for status, message in CONTRACTS.check(self.home))
|
||||
self.assertEqual({'Apple Design': 'PASS', 'Impeccable': 'WARN'}, results)
|
||||
|
||||
def test_uses_highest_cached_plugin_version(self):
|
||||
tokens = ' '.join(CONTRACTS.CONTRACTS['impeccable'][1])
|
||||
self.write('.claude/plugins/cache/impeccable/impeccable/4.10.0/skills/impeccable/SKILL.md', tokens)
|
||||
self.write('.claude/plugins/cache/impeccable/impeccable/4.9.2/skills/impeccable/SKILL.md', 'old')
|
||||
[(status, message)] = CONTRACTS.check(self.home)
|
||||
self.assertEqual('PASS', status)
|
||||
self.assertIn('4.10.0', message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user