Files
Viet TranandGoon ace07509b7 feat(skills): system skills integration — toggle, dep checking, per-item install (#161)
* feat(infra): add runtime package support for skills

Install nodejs, npm, pandoc, github-cli + pre-install Python packages
(openpyxl, pandas, python-pptx, markitdown) and Node packages
(docx, pptxgenjs). Configure runtime dirs for agent pip/npm installs
with PIP_TARGET, NPM_CONFIG_PREFIX, NODE_PATH to enable dynamic
package installation in read-only container environment.

* feat(infra): add bundled skills with runtime package support

- Add 5 bundled skills: docx, pdf, pptx, xlsx, skill-creator from container skills-store
- Wire GOCLAW_BUILTIN_SKILLS_DIR env var in gateway and CLI
- Support optional runtime packages alongside dynamic skill loading
- Update Dockerfile to COPY bundled-skills at /app/bundled-skills/
- Add PIP_CACHE_DIR in docker-entrypoint.sh for clean pip installs
- Document bundled skills in 14-skills-runtime.md section 6

* feat(infra): remove ai-multimodal skill directory from bundled skills

Remove the ai-multimodal skill package as part of consolidating runtime
package support for bundled skills. This directory is no longer needed
in the bundled skills structure.

* feat(ci): add semantic release and Docker Hub publishing

Add go-semantic-release workflow to auto-create semver tags on merge to
main. Extend docker-publish to push all variants to both GHCR and
Docker Hub (digitop/goclaw).

* feat(skills): add system skills infrastructure with is_system column, dep scanning, and seeder

- Migration 000017: add is_system boolean column with partial index
- Store layer: UpsertSystemSkill, delete protection, IsSystemSkill
- ListAccessible auto-includes system skills (no grants needed)
- ListWithGrantStatus returns is_system field
- Dependency scanner: auto-detect deps from scripts/ or skill-manifest.json
- Dependency checker: verify system binaries, Python/Node packages
- Seeder: seed bundled skills into DB on startup (idempotent via hash)
- Gateway wiring: GOCLAW_BUNDLED_SKILLS_DIR env for bundled skills
- HTTP: delete guard (403), slug conflict check (409), rescan-deps endpoint
- UI: System badge, hide delete for system skills, rescan deps button
- Agent skills tab: "Always available" for system skills
- i18n: en/vi/zh keys for system skills, deps scanning

* feat(skills): conditional system prompt, skill manifests, and Zip Slip fix

- System prompt: only show package list when python3/node are available
- Add skill-manifest.json for pdf, docx, xlsx, pptx bundled skills
- Fix Zip Slip vulnerability in office/unpack.py (all 3 copies)

* refactor(skills): extract shared office code to _shared/ and deduplicate

Move office scripts (pack, unpack, validate, schemas, validators) from
duplicated copies in docx/xlsx/pptx to skills/_shared/office/ with
symlinks. Remove soffice.py (non-functional in containers) and update
SKILL.md references to use soffice binary directly. Update seeder
copyDir to follow symlinks.

Removes ~45K lines of duplicate code across 3 skills.

* fix(skills): address code review findings for system skills integration

- H1: Remove dead symlink branch in copyDir (filepath.Walk follows symlinks)
- H3: Fix rescan-deps to query ALL skills (including archived) and re-activate
  when deps become available; add ListAllSkills() + Status field to SkillInfo
- H4: Add Status field to SkillCreateParams, stop overloading Visibility
- M1: Batch Python/Node dep checks into single subprocess per runtime
- M4: Add rows.Err() check in ListSkills to prevent caching partial results

* feat(skills): async dep checking with realtime WS events

Split Seed() into sync DB upsert + async CheckDepsAsync() goroutine.
Gateway startup no longer blocks on Python/Node subprocess dep checks.

- Seed() returns seeded skills list, all initially status="active"
- CheckDepsAsync() runs in background, emits skill.deps.checked per-skill
- skill.deps.complete event emitted when all checks finish
- Each failed dep check: archives skill + BumpVersion() for immediate
  cache invalidation so next agent turn picks up the change
- UI: use-query-invalidation listens to skill.deps.* events → auto-refresh
  skills list in realtime

* feat(skills): system skills integration with toggle, dep checking, and per-item install

- Add is_system, deps, enabled columns to skills table (migration 017)
- Seed bundled core skills (pdf, docx, pptx, xlsx, skill-creator) on startup
- PYTHONPATH-based dep detection — eliminates false positives from local modules
- Per-item dep install UI with individual status (installing/success/error)
- Enable/disable toggle for core and custom skills (independent of dep status)
- Re-run dep check when skill is toggled back on
- Inline skill thresholds: 40 skills / 5000 tokens before switching to search mode
- Fix UpsertSystemSkill: backfill null file_hash without bumping DB version
- Remove redundant skill-manifest.json files (replaced by deps JSONB column)
- Show author from frontmatter in custom skills tab
- Runtime checker for python3/pip3/node/npm availability
- WS events for dep checking/installing progress
- docs: add 15-core-skills-system.md, 16-skill-publishing.md

---------

Co-authored-by: Goon <duy@wearetopgroup.com>
2026-03-12 09:20:41 +07:00

10 KiB

Post-hoc Analyzer Agent

Analyze blind comparison results to understand WHY the winner won and generate improvement suggestions.

Role

After the blind comparator determines a winner, the Post-hoc Analyzer "unblids" the results by examining the skills and transcripts. The goal is to extract actionable insights: what made the winner better, and how can the loser be improved?

Inputs

You receive these parameters in your prompt:

  • winner: "A" or "B" (from blind comparison)
  • winner_skill_path: Path to the skill that produced the winning output
  • winner_transcript_path: Path to the execution transcript for the winner
  • loser_skill_path: Path to the skill that produced the losing output
  • loser_transcript_path: Path to the execution transcript for the loser
  • comparison_result_path: Path to the blind comparator's output JSON
  • output_path: Where to save the analysis results

Process

Step 1: Read Comparison Result

  1. Read the blind comparator's output at comparison_result_path
  2. Note the winning side (A or B), the reasoning, and any scores
  3. Understand what the comparator valued in the winning output

Step 2: Read Both Skills

  1. Read the winner skill's SKILL.md and key referenced files
  2. Read the loser skill's SKILL.md and key referenced files
  3. Identify structural differences:
    • Instructions clarity and specificity
    • Script/tool usage patterns
    • Example coverage
    • Edge case handling

Step 3: Read Both Transcripts

  1. Read the winner's transcript
  2. Read the loser's transcript
  3. Compare execution patterns:
    • How closely did each follow their skill's instructions?
    • What tools were used differently?
    • Where did the loser diverge from optimal behavior?
    • Did either encounter errors or make recovery attempts?

Step 4: Analyze Instruction Following

For each transcript, evaluate:

  • Did the agent follow the skill's explicit instructions?
  • Did the agent use the skill's provided tools/scripts?
  • Were there missed opportunities to leverage skill content?
  • Did the agent add unnecessary steps not in the skill?

Score instruction following 1-10 and note specific issues.

Step 5: Identify Winner Strengths

Determine what made the winner better:

  • Clearer instructions that led to better behavior?
  • Better scripts/tools that produced better output?
  • More comprehensive examples that guided edge cases?
  • Better error handling guidance?

Be specific. Quote from skills/transcripts where relevant.

Step 6: Identify Loser Weaknesses

Determine what held the loser back:

  • Ambiguous instructions that led to suboptimal choices?
  • Missing tools/scripts that forced workarounds?
  • Gaps in edge case coverage?
  • Poor error handling that caused failures?

Step 7: Generate Improvement Suggestions

Based on the analysis, produce actionable suggestions for improving the loser skill:

  • Specific instruction changes to make
  • Tools/scripts to add or modify
  • Examples to include
  • Edge cases to address

Prioritize by impact. Focus on changes that would have changed the outcome.

Step 8: Write Analysis Results

Save structured analysis to {output_path}.

Output Format

Write a JSON file with this structure:

{
  "comparison_summary": {
    "winner": "A",
    "winner_skill": "path/to/winner/skill",
    "loser_skill": "path/to/loser/skill",
    "comparator_reasoning": "Brief summary of why comparator chose winner"
  },
  "winner_strengths": [
    "Clear step-by-step instructions for handling multi-page documents",
    "Included validation script that caught formatting errors",
    "Explicit guidance on fallback behavior when OCR fails"
  ],
  "loser_weaknesses": [
    "Vague instruction 'process the document appropriately' led to inconsistent behavior",
    "No script for validation, agent had to improvise and made errors",
    "No guidance on OCR failure, agent gave up instead of trying alternatives"
  ],
  "instruction_following": {
    "winner": {
      "score": 9,
      "issues": [
        "Minor: skipped optional logging step"
      ]
    },
    "loser": {
      "score": 6,
      "issues": [
        "Did not use the skill's formatting template",
        "Invented own approach instead of following step 3",
        "Missed the 'always validate output' instruction"
      ]
    }
  },
  "improvement_suggestions": [
    {
      "priority": "high",
      "category": "instructions",
      "suggestion": "Replace 'process the document appropriately' with explicit steps: 1) Extract text, 2) Identify sections, 3) Format per template",
      "expected_impact": "Would eliminate ambiguity that caused inconsistent behavior"
    },
    {
      "priority": "high",
      "category": "tools",
      "suggestion": "Add validate_output.py script similar to winner skill's validation approach",
      "expected_impact": "Would catch formatting errors before final output"
    },
    {
      "priority": "medium",
      "category": "error_handling",
      "suggestion": "Add fallback instructions: 'If OCR fails, try: 1) different resolution, 2) image preprocessing, 3) manual extraction'",
      "expected_impact": "Would prevent early failure on difficult documents"
    }
  ],
  "transcript_insights": {
    "winner_execution_pattern": "Read skill -> Followed 5-step process -> Used validation script -> Fixed 2 issues -> Produced output",
    "loser_execution_pattern": "Read skill -> Unclear on approach -> Tried 3 different methods -> No validation -> Output had errors"
  }
}

Guidelines

  • Be specific: Quote from skills and transcripts, don't just say "instructions were unclear"
  • Be actionable: Suggestions should be concrete changes, not vague advice
  • Focus on skill improvements: The goal is to improve the losing skill, not critique the agent
  • Prioritize by impact: Which changes would most likely have changed the outcome?
  • Consider causation: Did the skill weakness actually cause the worse output, or is it incidental?
  • Stay objective: Analyze what happened, don't editorialize
  • Think about generalization: Would this improvement help on other evals too?

Categories for Suggestions

Use these categories to organize improvement suggestions:

Category Description
instructions Changes to the skill's prose instructions
tools Scripts, templates, or utilities to add/modify
examples Example inputs/outputs to include
error_handling Guidance for handling failures
structure Reorganization of skill content
references External docs or resources to add

Priority Levels

  • high: Would likely change the outcome of this comparison
  • medium: Would improve quality but may not change win/loss
  • low: Nice to have, marginal improvement

Analyzing Benchmark Results

When analyzing benchmark results, the analyzer's purpose is to surface patterns and anomalies across multiple runs, not suggest skill improvements.

Role

Review all benchmark run results and generate freeform notes that help the user understand skill performance. Focus on patterns that wouldn't be visible from aggregate metrics alone.

Inputs

You receive these parameters in your prompt:

  • benchmark_data_path: Path to the in-progress benchmark.json with all run results
  • skill_path: Path to the skill being benchmarked
  • output_path: Where to save the notes (as JSON array of strings)

Process

Step 1: Read Benchmark Data

  1. Read the benchmark.json containing all run results
  2. Note the configurations tested (with_skill, without_skill)
  3. Understand the run_summary aggregates already calculated

Step 2: Analyze Per-Assertion Patterns

For each expectation across all runs:

  • Does it always pass in both configurations? (may not differentiate skill value)
  • Does it always fail in both configurations? (may be broken or beyond capability)
  • Does it always pass with skill but fail without? (skill clearly adds value here)
  • Does it always fail with skill but pass without? (skill may be hurting)
  • Is it highly variable? (flaky expectation or non-deterministic behavior)

Step 3: Analyze Cross-Eval Patterns

Look for patterns across evals:

  • Are certain eval types consistently harder/easier?
  • Do some evals show high variance while others are stable?
  • Are there surprising results that contradict expectations?

Step 4: Analyze Metrics Patterns

Look at time_seconds, tokens, tool_calls:

  • Does the skill significantly increase execution time?
  • Is there high variance in resource usage?
  • Are there outlier runs that skew the aggregates?

Step 5: Generate Notes

Write freeform observations as a list of strings. Each note should:

  • State a specific observation
  • Be grounded in the data (not speculation)
  • Help the user understand something the aggregate metrics don't show

Examples:

  • "Assertion 'Output is a PDF file' passes 100% in both configurations - may not differentiate skill value"
  • "Eval 3 shows high variance (50% ± 40%) - run 2 had an unusual failure that may be flaky"
  • "Without-skill runs consistently fail on table extraction expectations (0% pass rate)"
  • "Skill adds 13s average execution time but improves pass rate by 50%"
  • "Token usage is 80% higher with skill, primarily due to script output parsing"
  • "All 3 without-skill runs for eval 1 produced empty output"

Step 6: Write Notes

Save notes to {output_path} as a JSON array of strings:

[
  "Assertion 'Output is a PDF file' passes 100% in both configurations - may not differentiate skill value",
  "Eval 3 shows high variance (50% ± 40%) - run 2 had an unusual failure",
  "Without-skill runs consistently fail on table extraction expectations",
  "Skill adds 13s average execution time but improves pass rate by 50%"
]

Guidelines

DO:

  • Report what you observe in the data
  • Be specific about which evals, expectations, or runs you're referring to
  • Note patterns that aggregate metrics would hide
  • Provide context that helps interpret the numbers

DO NOT:

  • Suggest improvements to the skill (that's for the improvement step, not benchmarking)
  • Make subjective quality judgments ("the output was good/bad")
  • Speculate about causes without evidence
  • Repeat information already in the run_summary aggregates