Skip to content

feat: add complete Qoder IDE platform integration#831

Open
MeloMei wants to merge 1 commit into
mksglu:mainfrom
MeloMei:feat/qoder-hook-scripts-clean
Open

feat: add complete Qoder IDE platform integration#831
MeloMei wants to merge 1 commit into
mksglu:mainfrom
MeloMei:feat/qoder-hook-scripts-clean

Conversation

@MeloMei

@MeloMei MeloMei commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Add first-class Qoder IDE platform support as a single, complete integration PR. Qoder is a VS Code-based agentic IDE developed by Alibaba Group. This replaces the previously split PRs #798 and #799.

What

Adapter core (src/adapters/qoder/)

  • QoderAdapter class implementing HookAdapter with json-stdio paradigm
  • Parse/format for PreToolUse, PostToolUse, Stop, UserPromptSubmit
  • Tool name mapping: run_in_terminal→Bash, read_file→Read, create_file→Write, search_replace→Edit
  • Hook config management via .qoder/settings.json (read/write/configure/validate)
  • Session ID extraction chain: session_idQODER_SESSION_ID env → pid-${ppid} fallback

Platform detection (src/adapters/detect.ts)

  • QODER_AGENT env var checked before VSCODE_PID (Qoder inherits it as a VS Code fork)
  • ~/.qoder/ config directory as medium-confidence fallback
  • Lazy-load adapter via dynamic import()

Hook scripts (hooks/qoder/)

  • pretooluse.mjs — Full routing: stdin → routePreToolUseformatDecision → stdout
  • posttooluse.mjs — Passthrough (session event capture, no routing decision)
  • stop.mjs — Passthrough (exit 0)
  • userpromptsubmit.mjs — Passthrough with future route-injection hook point

Formatter (hooks/core/formatters.mjs)

  • qoder formatter entry with hookSpecificOutput wire format (compatible with Claude Code)
  • Bash redirect→deny conversion
  • typeof guard on updatedInput before in operator to prevent TypeError

Config templates (configs/qoder/)

  • QODER.md — Routing instructions (Bash curl/wget → ctx_fetch_and_index, etc.)
  • mcp.json — MCP server registration template
  • settings.json — Hook configuration reference (all 4 event types)

Documentation (docs/platform-support.md)

  • Platform count: 16 → 17
  • Qoder column added to all comparison tables (Main, Capability Matrix, Hook Response Format, CLI Dispatcher)
  • Detailed Qoder platform section with correct capability labeling (Context Injection, not Output Modification)

CLI dispatch (src/cli.ts)

  • Hook dispatcher entry for qoder (pretooluse, posttooluse, userpromptsubmit, stop)

Other modifications

  • src/adapters/types.ts — Add qoder to PlatformId union
  • src/adapters/client-map.ts — Add MCP client name mapping (qoder/Qoder)
  • hooks/session-helpers.mjs — Add QODER_OPTS (configDir, projectDirEnv, sessionIdEnv)

Design Decisions

  1. Independent adapter (not extending ClaudeCodeAdapter) — Different tool names, config paths, and detection logic. Independent adapter avoids fragile coupling.
  2. Detection priorityQODER_AGENT before VSCODE_PID because Qoder is a VS Code fork and always sets VSCODE_PID.
  3. Wire format reuse — Qoder uses the same hookSpecificOutput JSON structure as Claude Code. The formatter includes the same Bash redirect-to-deny logic.
  4. Passthrough for Stop/UserPromptSubmit — These events don't require routing decisions.

Testing

  • 37 unit tests in tests/adapters/qoder.test.ts:
    • Capabilities verification
    • PreToolUse parsing (5 scenarios)
    • PostToolUse parsing (4 scenarios: fixture, non-string, undefined, null)
    • PreToolUse response formatting (6 scenarios: allow, deny, deny+reason, arg mod, context injection, Bash redirect deny)
    • PostToolUse response formatting (2 scenarios)
    • Config path resolution (4 scenarios)
    • Hook config management (5 scenarios: generate, configure, validate, idempotent no-write, missing settings)
    • Stop hook (3 scenarios)
    • Config template validation (5 tests: mcp.json schema, settings.json schema, matcher, consistency with generateHookConfig, command format)
  • All adapter + hook tests pass (1456/1457, 1 pre-existing OMP build failure unrelated)

Notes

Copilot AI review requested due to automatic review settings June 15, 2026 06:20
@MeloMei

MeloMei commented Jun 15, 2026

Copy link
Copy Markdown
Author

@ken-jo @mksglu Thanks for the review. I've combined both PRs into a single PR that covers the complete Qoder integration:

  • Adapter detection/config-dir logic
  • Plugin install/config files (added configs/qoder/mcp.json and configs/qoder/settings.json)
  • Hook scripts (hooks/qoder/*.mjs)
  • Formatter/docs
  • Targeted tests (37 unit tests including config template validation)

Regarding live Qoder CLI validation: I was unable to perform a model-backed qodercli smoke test in this environment due to lack of Qoder login credentials. The static validation (unit tests, config template schema checks) covers the adapter and config surface. Full behavioral verification will require authenticated Qoder CLI access.

Note: qodercli plugin validate on configs/qoder/ should now detect the MCP server registration and hook configuration templates.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds first-class Qoder platform support (detection, adapter, hooks, and templates) so context-mode can run as a JSON-stdio hook integration inside the Qoder IDE.

Changes:

  • Introduces QoderAdapter with parsing/formatting, hook config generation, and diagnostics.
  • Adds Qoder hook scripts + config templates (configs/qoder/*) and extends CLI hook dispatch mapping.
  • Extends platform detection, client mapping, docs, and test suites to include qoder.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/adapters/qoder/index.ts New Qoder adapter implementation (parsing, responses, config/diagnostics).
src/adapters/qoder/hooks.ts Qoder hook constants + hook command helpers/validators.
hooks/qoder/*.mjs Hook entrypoints for Qoder (pretooluse, posttooluse, userpromptsubmit, stop).
hooks/core/formatters.mjs Adds Qoder response formatter for formatDecision().
src/adapters/detect.ts Adds Qoder detection (env var, config dir) + adapter factory branch.
src/cli.ts Adds Qoder hook dispatch map entries.
src/adapters/types.ts Adds "qoder" to PlatformId.
src/adapters/client-map.ts Maps MCP clientInfo.name values to qoder.
hooks/session-helpers.mjs Adds QODER_OPTS for session/project dir env resolution.
configs/qoder/* Adds Qoder settings + MCP templates and instructions (QODER.md).
docs/platform-support.md Documents Qoder support and updates comparison/capability matrices.
tests/adapters/qoder.test.ts Adds adapter-focused unit tests and config template consistency checks.
tests/adapters/detect*.test.ts Updates detection tests to account for QODER_AGENT and qoder platform.
tests/fixtures/qoder/*.json Adds Qoder hook payload fixtures used by tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/adapters/qoder/index.ts Outdated
Comment thread hooks/core/formatters.mjs Outdated
Comment thread src/adapters/qoder/hooks.ts
Comment thread hooks/qoder/posttooluse.mjs Outdated
Comment thread hooks/qoder/userpromptsubmit.mjs
Add first-class support for Qoder IDE (VS Code-based agentic IDE by
Alibaba Group) with json-stdio hook paradigm and hookSpecificOutput wire
format compatible with Claude Code.

Adapter core (src/adapters/qoder/):
- QoderAdapter class with full HookAdapter implementation
- Parse/format PreToolUse, PostToolUse, Stop, UserPromptSubmit events
- Tool name mapping (run_in_terminal→Bash, create_file→Write, etc.)
- Hook config management via .qoder/settings.json
- Session ID extraction: session_id → QODER_SESSION_ID → pid fallback

Platform detection (src/adapters/detect.ts):
- QODER_AGENT env var checked before VSCODE_PID (Qoder is a VS Code fork)
- ~/.qoder/ config dir as medium-confidence fallback
- Lazy-load adapter via dynamic import

Hook scripts (hooks/qoder/):
- pretooluse.mjs: stdin → routePreToolUse → formatDecision → stdout
- posttooluse.mjs: passthrough (session capture, no routing)
- stop.mjs: passthrough (exit 0)
- userpromptsubmit.mjs: passthrough with future route-injection point

Formatter (hooks/core/formatters.mjs):
- 'qoder' formatter with hookSpecificOutput wire format
- Bash redirect→deny conversion (same as claude-code/cursor)
- typeof guard on updatedInput before 'in' operator

Config templates (configs/qoder/):
- QODER.md: routing instructions for Qoder users
- mcp.json: MCP server registration template
- settings.json: hook configuration reference (4 events)

Documentation (docs/platform-support.md):
- Platform count: 16 → 17
- Qoder column in all comparison tables
- Detailed Qoder platform section with capability labeling

CLI dispatch (src/cli.ts):
- Hook dispatcher entry for qoder (pretooluse, posttooluse, etc.)

Tests:
- 37 unit tests (tests/adapters/qoder.test.ts)
- Config template validation tests (mcp.json, settings.json schema)
- Test isolation: clear QODER_AGENT in detect tests
- Address Copilot review: type-safe cmd coercion, event-aware isContextModeHook, passthrough comment clarity

fix: address Copilot review feedback on Qoder integration
@MeloMei MeloMei force-pushed the feat/qoder-hook-scripts-clean branch from bcb3bba to 3291b0d Compare June 15, 2026 09:41
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.

2 participants