Skip to content

fix(skills): remove invalid OpenCode/Codex agent guidance (#825)#804

Closed
hypnwtykvmpr wants to merge 17 commits into
safishamsi:v7from
hypnwtykvmpr:v7
Closed

fix(skills): remove invalid OpenCode/Codex agent guidance (#825)#804
hypnwtykvmpr wants to merge 17 commits into
safishamsi:v7from
hypnwtykvmpr:v7

Conversation

@hypnwtykvmpr
Copy link
Copy Markdown
Contributor

@hypnwtykvmpr hypnwtykvmpr commented May 10, 2026

Summary

Closes #825. The installed OpenCode SKILL.md instructed subagent_type="general-purpose" — an agent type OpenCode does not support — and blocked large-corpus runs on an interactive subfolder prompt. A cross-skill audit (.AUDIT/825-cross-skill-check.py) confirmed the Codex skill had the identical logical bug: it dispatches via spawn_agent(agent_type="worker", ...) but still told users to "re-run with general-purpose agent" on failure — impossible to follow.

This PR fixes both, makes large-corpus handling deterministic, normalizes returned-agent JSON to per-chunk files, and adds a Python validation boundary so untrusted agent payloads can't exhaust disk/memory or escape the chunk directory.

Changes (latest commit, c720f1a)

Skill text (graphify/skill-opencode.md, graphify/skill-codex.md)

  • Large-corpus warns-and-continues instead of blocking for subfolder selection.
  • Recovery text uses platform-native dispatch (@mention for OpenCode, spawn_agent for Codex); removed all Claude subagent_type="general-purpose" / Explore type / "general-purpose agent" guidance.
  • Replaced Claude-specific "MUST use the Agent tool" / "After each Agent call completes" template wording with platform-neutral phrasing pointing at each skill's Step B2.
  • 50%-or-more failure threshold is now explicit; recovery advice points at --max-concurrency 1 (a real CLI flag).
  • Chunk index NN is derived from the dispatcher, never from agent output (path-traversal safety).

Python enforcement boundary (graphify/semantic_cleanup.py)

  • New validate_semantic_fragment(fragment) -> list[str]: ≤ 25 MB payload, ≤ 10,000 nodes, ≤ 100,000 edges, ASCII-only IDs with no path separators (/, \, ..), file_type whitelist (code|document|paper|image).
  • New load_validated_semantic_fragment(path) -> tuple[dict | None, list[str]]: stat().st_size guard runs before read_text() / json.loads(), so oversize chunk files are rejected without allocation. JSON decode errors return as errors instead of raising.
  • Both skill merge snippets now go through the new loader.

Tests

  • 7 new install + source regressions in tests/test_install.py covering OpenCode and Codex (agent-type ban, non-interactive large-corpus, returned-JSON normalization, platform-neutral dispatch language).
  • 10 new tests in tests/test_semantic_cleanup.py (validation + load helper: valid, non-object, oversize, too-many-nodes, too-many-edges, path-traversal ID, invalid file_type, oversize-before-parse, invalid-JSON-no-raise, valid-load).
  • CHANGELOG.md entry under ## Unreleased.

Audit artifact

.AUDIT/825-cross-skill-check.py reads each graphify/skill-*.md and treats platform-override blockquotes as the authoritative dispatch contract. After this PR it exits 0. skill-droid.md and skill-trae.md remain NEEDS-EXTERNAL-VERIFICATION (their Task-tool variants need platform-runtime contract confirmation) and are deliberately out of scope; skill-copilot.md warrants a separate investigation issue because it has no platform-override block.

Validation

  • .venv/bin/python -m pytest -p no:cacheprovider2180 passed in 15 s
  • .venv/bin/python .AUDIT/825-cross-skill-check.py → exit 0
  • rg -n "general-purpose|subagent_type|Explore type|MUST use the Agent tool here|After each Agent call completes|ask which subfolder to run on|wait for the user's answer before proceeding" graphify/skill-opencode.md graphify/skill-codex.md → no matches
  • graphify install --platform codex against the new template → installed SKILL.md verified clean by the same extended grep
  • graphify update . --force → graph regenerated (7443 nodes, 12057 edges, 546 communities)
  • git apply --check was the verification gate during the runbook revision pass

Previously included work (12 prior fork commits on this branch)

The branch also carries 12 fork commits that this PR's #825 fix depends on (notably graphify/semantic_cleanup.py was introduced earlier in this stack and this PR extends it). Brief summary, newest first:

  • fix: restore local graphify fixes after upstream sync
  • feat: callflow HTML offline-ready (vendored Mermaid 11.14.0 with SRI fallback)
  • fix: graph path / parser hardening
  • test: hollow response expectations after upstream rebase
  • ci: install action test dependencies
  • fix: graph rebuild validation and manifest handling
  • test: escape elixir interpolation fixture
  • fix: pypdf for PDF image extraction
  • feat: upstream issue rollup — wiki links, rationale guard, offline viz, PPTX/PDF, GitHub Action, corpus docs
  • fix: security hardening (9 findings from systematic review) — introduces graphify/semantic_cleanup.py
  • feat: bash shell script extraction + ForgeCode install platform support
  • Rollup: deterministic extraction, deduplication hardening, portability, expanded test coverage

If preferred, the prior commits can be split into a separate PR — but a direct cherry-pick of the #825 commit onto upstream/v7 will fail because semantic_cleanup.py doesn't exist there yet.

@hypnwtykvmpr hypnwtykvmpr changed the title Contributions since v0.7.13: hardening, bash support, docs, and offline callflow fix(skills): remove invalid OpenCode/Codex agent guidance (#825) May 14, 2026
@hypnwtykvmpr hypnwtykvmpr force-pushed the v7 branch 4 times, most recently from 4b94d36 to 4f78b3e Compare May 14, 2026 15:01
safishamsi and others added 7 commits May 15, 2026 00:07
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tors

- Add .sh, .bash, .json to CODE_EXTENSIONS in detect.py so files reach extractor
- Fix test_detect_incremental manifest path collision with new .json extension
- Update test_watch to reflect .json/.sh are now watched extensions
- B-1: only emit source imports for paths that exist on disk
- J-1: replace stat()+read() with bounded read to eliminate TOCTOU
- J-3: move pair_count cap inside loop so it is honoured exactly
- J-4: namespace $ref/extends refs with "ref_" prefix to prevent ID collision

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…on graph change

safishamsi#873: Remove blanket dot-prefix exclusion from detect.py and
extract.py collect_files(). Add framework caches (.next, .nuxt,
.turbo, .angular, .idea, .cache, .parcel-cache, .svelte-kit,
.terraform, .serverless, .graphify) to _SKIP_DIRS so they stay
blocked. Meaningful dot dirs (.github, .claude, etc.) are now
indexed.

safishamsi#874: Add _maybe_reload() with mtime+size stat key and threading.Lock
to serve.py. call_tool and read_resource call _maybe_reload() on
every request; the graph reloads automatically when graph.json changes
without restarting the MCP server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
safishamsi and others added 9 commits May 15, 2026 11:25
graphify.exe and python.exe are co-located in the same Scripts\
directory for both uv tool and pipx installs. Use Get-Command graphify
to find that directory and pick up the correct Python instead of
falling through to bare python (which is a different interpreter
that doesn't have graphify).

Also replace all bare `python .graphify_*` invocations throughout
the skill with `& (Get-Content graphify-out\.graphify_python)` so
every step uses the saved interpreter, and fix the bash $(cat ...)
syntax to PowerShell & (Get-Content ...).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hamsi#831)

antigravity install on Windows now installs skill-windows.md instead
of skill.md by redirecting to a new antigravity-windows platform config
at install time via sys.platform check.

Python detection in Find-GraphifyPython now uses uv tool dir (respects
UV_TOOL_DIR) and pipx environment --value PIPX_LOCAL_VENVS (respects
PIPX_HOME) instead of guessing from the shim location. The graphify.exe
shim and python.exe live in different directories for both uv and pipx
on Windows so the previous Get-Command approach was wrong.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move all intermediate data files and temp step scripts from the
project root into graphify-out/ to match the bash skill behaviour.
Also fix the > redirect on detect.json which wrote UTF-16LE in
PowerShell 5.1 - now uses Out-File -Encoding utf8 consistently.

Files moved: .graphify_detect.json, .graphify_ast.json,
.graphify_extract.json, .graphify_semantic.json,
.graphify_analysis.json, .graphify_labels.json,
.graphify_incremental.json, .graphify_old.json,
all .graphify_step_*.py temp scripts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…label normalization

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…merges on short labels (safishamsi#878)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cherry-picked from PR safishamsi#881 (merged into v7) — adds case study artifacts
matching the worked/karpathy-repos/ convention.
@hypnwtykvmpr hypnwtykvmpr deleted the branch safishamsi:v7 May 16, 2026 05:33
@hypnwtykvmpr hypnwtykvmpr deleted the v7 branch May 16, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode integration uses invalid general-purpose agent and blocks on large corpus prompt

2 participants