Skip to content

feat(reasonix): add permissions, hooks, and commands adapters - #2101

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2035-reasonix-permissions-hooks-commands
Jul 1, 2026
Merged

feat(reasonix): add permissions, hooks, and commands adapters#2101
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2035-reasonix-permissions-hooks-commands

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Follow-up for Reasonix upstream updates (#2035). Implements the maintainer's own prioritized slice from the triage comment: permissions first (highest value/lowest effort — same TOML the MCP adapter writes), then hooks/commands modeled on claudecode-*. rules/skills/.mcp.json parity are explicitly NOT implemented, per the maintainer's own deferral.

1. reasonix-permissions.ts

[permissions] table in the shared reasonix.toml (project) / ~/.reasonix/config.toml (global) — the same file reasonix-mcp.ts already writes. Maps canonical permission.<category> onto Reasonix's Tool(specifier) syntax (SPEC.md confirms this is explicitly "Claude Code-style"), mirroring claudecode-permissions.ts. mode and [[plugins]] and other sibling TOML tables survive round-trip untouched. Registered both scopes.

2. reasonix-hooks.ts

.reasonix/settings.json (project) / ~/.reasonix/settings.json (global) — a separate file from the TOML. Fact-check correction: the actual schema (found in docs/DESKTOP_HOOKS.zh-CN.md, not linked by the issue) is FLAT per event ({ "PreToolUse": [{ match, command, description, timeout }] }, no Claude-style matcher/hooks wrapper), and the timeout field is literally timeout in milliseconds, not timeoutMs. Maps preToolUse/postToolUse/beforeSubmitPrompt/stopPreToolUse/PostToolUse/UserPromptSubmit/Stop, converting canonical seconds ↔ milliseconds. Registered both scopes.

Note: the same doc shows Reasonix also has SessionStart/SessionEnd/PostLLMCall/SubagentStop/Notification/PreCompact events not mapped here (out of the scoped 4-event set) — a good fast-follow candidate.

3. reasonix-command.ts

Markdown files under .reasonix/commands/ (project) / ~/.reasonix/commands/ (global), frontmatter description/argument-hint, confirmed identical to claudecode-command.ts's model. Registered both scopes.

4. Bonus fix: trusted_read_only_tools round-trip

Reasonix's [[plugins]] schema has a trusted_read_only_tools field that reasonix-mcp.ts previously dropped on round-trip. Added to the passthrough field list.

Deferred (per maintainer's own triage)

rules ([agent] system_prompt_file), skills ([skills] discovery config), and .mcp.json parity — explicitly out of scope.

Verification

pnpm cicheck fully green: 301 test files, 6705 tests. Full e2e suite 638/639 (the one failure is pre-existing on main, verified via git stash, unrelated).

References

Closes #2035

cm-dyoshikawa and others added 2 commits June 30, 2026 20:27
Extends the reasonix target beyond MCP-only to three new native surfaces, per the maintainer's own triage priority order in #2035:

- reasonix-permissions.ts: maps rulesync's canonical permission.<category> model onto Reasonix's Claude-Code-style Tool(specifier)/:* rule syntax in the [permissions] table of the same reasonix.toml / ~/.reasonix/config.toml the MCP adapter already reads/writes, preserving [[plugins]] and other sibling keys on round-trip (mode is left untouched, since it has no canonical equivalent).

- reasonix-hooks.ts: maps preToolUse/postToolUse/beforeSubmitPrompt/stop to Reasonix's PreToolUse/PostToolUse/UserPromptSubmit/Stop events in the standalone .reasonix/settings.json (project) / ~/.reasonix/settings.json (global), using Reasonix's flat per-event hook-object array (no Claude-style matcher/hooks wrapper) and converting the canonical timeout (seconds) to Reasonix's documented milliseconds field.

- reasonix-command.ts: Markdown slash commands under .reasonix/commands/ (project) / ~/.reasonix/commands/ (global), directly analogous to claudecode-command.ts (description/argument-hint frontmatter, $ARGUMENTS/$1..$N body placeholders).

- reasonix-mcp.ts: round-trips the trusted_read_only_tools field on [[plugins]] entries, which was previously dropped on import/export.

Both project and global scope are registered for all three features in their respective processors and tool-target tuples. rules/skills/.mcp.json parity remain explicitly out of scope, per the maintainer's own note that those need a separate design pass.

Fixes #2035.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address PR review (high): reasonix.toml/~/.reasonix/config.toml became a 2-writer shared file (mcp + permissions) but neither generation step declared it in writesSharedFile, so assertSharedFilesOrdered() could not protect the invariant that mcp must run before permissions. Currently safe only because permissions already depends on mcp for unrelated reasons; a future refactor could silently drop this ordering. Add the 'reasonix-config' token to both steps, mirroring the existing vibe-config/devin-config pattern.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dyoshikawa
dyoshikawa merged commit 006f88c into main Jul 1, 2026
8 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2035-reasonix-permissions-hooks-commands branch July 1, 2026 03:49
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.

Follow up Reasonix upstream updates: rules/commands/skills/hooks/permissions surfaces and .mcp.json

2 participants