From 19d88ce905d89c899ef95bb6daa89bf321549864 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 8 Apr 2026 17:43:39 +0800 Subject: [PATCH] chore: update schema and red team scripts for centralized metadata - registry.schema.json: describe .metadata.json store format (version, entries map with full field set) instead of old registry.yaml format - Red team scripts: add write_store_meta helper, replace sidecar writes with centralized store writes in phase3 (integrity) and phase5 (advanced) --- schemas/registry.schema.json | 81 ++++++++++++++++++++-------- scripts/red_team/_helpers.sh | 22 ++++++++ scripts/red_team/phase3_integrity.sh | 37 +++---------- scripts/red_team/phase5_advanced.sh | 27 ++-------- 4 files changed, 90 insertions(+), 77 deletions(-) diff --git a/schemas/registry.schema.json b/schemas/registry.schema.json index 9d79d96fd..00aaf7ece 100644 --- a/schemas/registry.schema.json +++ b/schemas/registry.schema.json @@ -1,41 +1,43 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://raw.githubusercontent.com/runkids/skillshare/main/schemas/registry.schema.json", - "title": "Skillshare Registry", - "description": "Skill registry for skillshare — tracks installed/tracked skills. Location: ~/.config/skillshare/skills/registry.yaml (global) or .skillshare/registry.yaml (project). Auto-managed by reconciliation; manual edits are preserved.", + "title": "Skillshare Metadata Store", + "description": "Centralized metadata store for skillshare — tracks installed skills and agents. Location: ~/.config/skillshare/skills/.metadata.json (global) or .skillshare/skills/.metadata.json (project). Auto-managed; manual edits are preserved on reconciliation.", "type": "object", "additionalProperties": false, "properties": { - "skills": { - "type": "array", - "description": "Installed/tracked skills.", - "items": { - "$ref": "#/$defs/skillEntry" + "version": { + "type": "integer", + "description": "Schema version. Currently 1.", + "const": 1 + }, + "entries": { + "type": "object", + "description": "Map of skill/agent relative paths to their metadata entries.", + "additionalProperties": { + "$ref": "#/$defs/metadataEntry" } } }, + "required": ["version", "entries"], "$defs": { - "skillEntry": { + "metadataEntry": { "type": "object", - "description": "A managed resource entry tracked in the registry.", - "required": ["name", "source"], - "additionalProperties": false, + "description": "Metadata for an installed skill or agent.", "properties": { - "name": { + "source": { "type": "string", - "description": "Resource name (skill directory name or agent file name).", - "examples": ["pdf", "_team-skills", "tutor"] + "description": "Original source input (GitHub path, local path, etc.).", + "examples": ["github.com/anthropics/skills/skills/pdf", "github.com/team/agents"] }, "kind": { "type": "string", - "description": "Resource kind. Omitted or empty defaults to 'skill'. ('agent' is reserved for a future release.)", - "enum": ["skill", "agent"], - "default": "skill" + "description": "Resource kind. Empty or omitted defaults to 'skill'.", + "enum": ["", "skill", "agent"] }, - "source": { + "type": { "type": "string", - "description": "GitHub path or local path where the resource was installed from.", - "examples": ["anthropics/skills/skills/pdf", "github.com/team/skills"] + "description": "Source type (github, local, git-https, git-ssh, etc.)." }, "tracked": { "type": "boolean", @@ -45,12 +47,45 @@ "group": { "type": "string", "description": "Subdirectory group the resource belongs to (set by --into).", - "examples": ["frontend", "backend"] + "examples": ["frontend", "backend", "team/frontend"] }, "branch": { "type": "string", - "description": "Git branch to clone from. Omit for remote default branch.", - "examples": ["develop", "frontend"] + "description": "Git branch to clone from. Omit for remote default branch." + }, + "into": { + "type": "string", + "description": "Original --into value used during install." + }, + "installed_at": { + "type": "string", + "format": "date-time", + "description": "ISO 8601 timestamp of when the resource was installed." + }, + "repo_url": { + "type": "string", + "description": "Git clone URL for the source repository.", + "examples": ["https://github.com/anthropics/skills.git"] + }, + "subdir": { + "type": "string", + "description": "Subdirectory within the repo (for monorepo installs)." + }, + "version": { + "type": "string", + "description": "Git commit hash at install/update time." + }, + "tree_hash": { + "type": "string", + "description": "Git tree SHA of the subdir at install time." + }, + "file_hashes": { + "type": "object", + "description": "Map of relative file paths to sha256: digests for integrity verification.", + "additionalProperties": { + "type": "string", + "pattern": "^sha256:[0-9a-f]{64}$" + } } } } diff --git a/scripts/red_team/_helpers.sh b/scripts/red_team/_helpers.sh index 9582f57f9..f5aed0e3a 100644 --- a/scripts/red_team/_helpers.sh +++ b/scripts/red_team/_helpers.sh @@ -49,6 +49,28 @@ $content SKILL_EOF } +# Write or merge a skill entry into the centralized .metadata.json store. +# Usage: write_store_meta +# Example: write_store_meta "$SOURCE_DIR" "my-skill" '{"source":"test","file_hashes":{"SKILL.md":"sha256:abc"}}' +write_store_meta() { + local source_dir="$1" + local skill_name="$2" + local entry_json="$3" + local store_path="$source_dir/.metadata.json" + + if [ -f "$store_path" ]; then + # Merge into existing store + local tmp + tmp=$(jq --arg name "$skill_name" --argjson entry "$entry_json" \ + '.entries[$name] = $entry' "$store_path") + echo "$tmp" > "$store_path" + else + # Create new store + jq -n --arg name "$skill_name" --argjson entry "$entry_json" \ + '{version:1, entries:{($name): $entry}}' > "$store_path" + fi +} + # Run skillshare with isolated config. # -g is placed after the subcommand to force global mode, # preventing auto-detection of .skillshare/ in the working directory. diff --git a/scripts/red_team/phase3_integrity.sh b/scripts/red_team/phase3_integrity.sh index 310e1a7eb..b80e9583c 100644 --- a/scripts/red_team/phase3_integrity.sh +++ b/scripts/red_team/phase3_integrity.sh @@ -13,16 +13,8 @@ Safe content for hash verification." SKILL_HASH=$(shasum -a 256 "$INTEGRITY_DIR/SKILL.md" | awk '{print $1}') -cat > "$INTEGRITY_DIR/.skillshare-meta.json" < "$INTEGRITY_DIR/.skillshare-meta.json" < "$INTEGRITY_DIR/.skillshare-meta.json" < "$INTEGRITY_DIR/sneaky.sh" diff --git a/scripts/red_team/phase5_advanced.sh b/scripts/red_team/phase5_advanced.sh index 84c1527b2..2d77a92e7 100644 --- a/scripts/red_team/phase5_advanced.sh +++ b/scripts/red_team/phase5_advanced.sh @@ -13,19 +13,8 @@ Safe content for traversal hardening checks." TRAVERSAL_HASH=$(shasum -a 256 "$TRAVERSAL_DIR/SKILL.md" | awk '{print $1}') echo "TOP SECRET" > "$TMPDIR_ROOT/secret.txt" -cat > "$TRAVERSAL_DIR/.skillshare-meta.json" < "$SYMLINK_DIR/.skillshare-meta.json" < "$TMPDIR_ROOT/outside.txt" ln -s "$TMPDIR_ROOT/outside.txt" "$SYMLINK_DIR/external-link.txt"