LearnNewsExamplesServices
Frontmatter
id8309
titleFeat: Neural Link - Get Method Source
stateClosed
labels
enhancementaiarchitecture
assigneestobiu
createdAtJan 4, 2026, 1:54 PM
updatedAtJan 4, 2026, 2:07 PM
githubUrlhttps://github.com/neomjs/neo/issues/8309
authortobiu
commentsCount1
parentIssue8169
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 4, 2026, 2:07 PM

Feat: Neural Link - Get Method Source

Closed v11.18.0 enhancementaiarchitecture
tobiu
tobiu commented on Jan 4, 2026, 1:54 PM

Context: To safely hot-patch code (Issue #8190), agents need to read the current implementation of a method. This is critical for "read-modify-write" workflows and works across all environments (dev, dist/esm, prod) by retrieving the actual runtime source via Function.toString().

Scope:

  1. Client (RuntimeService.mjs):
    • Implement getMethodSource({className, methodName}).
    • Logic: Neo.ns(className).prototype[methodName].toString().
  2. Server (MCP):
    • Expose get_method_source tool.
    • Update OpenAPI definition.

Goal: Enable agents to see the code they are about to patch.

tobiu added the enhancement label on Jan 4, 2026, 1:54 PM
tobiu added the ai label on Jan 4, 2026, 1:54 PM
tobiu added the architecture label on Jan 4, 2026, 1:54 PM
tobiu added parent issue #8169 on Jan 4, 2026, 1:55 PM
tobiu assigned to @tobiu on Jan 4, 2026, 1:55 PM
tobiu referenced in commit e23f496 - "feat(ai): Implement Get Method Source & Refine Hot-Patching (#8309) on Jan 4, 2026, 2:05 PM
tobiu referenced in commit 206b172 - "feat(ai): Expose Get Method Source Tool (Remaining Files) (#8309) on Jan 4, 2026, 2:05 PM
tobiu
tobiu Jan 4, 2026, 2:06 PM

Input from Gemini 3 pro:

✦ Implemented get_method_source tool.

Key Implementation Details:

  • Robust Type Detection: The client-side implementation in RuntimeService.mjs uses Neo.typeOf(cls) to correctly differentiate between NeoClass (using cls.prototype) and NeoInstance (using cls.constructor.prototype). This ensures it works for both standard classes and singletons (like Neo.worker.App).
  • Source Retrieval: Uses Function.prototype.toString() to retrieve the exact runtime source code of the method.
  • Workflow: This tool is explicitly documented in OpenAPI as the prerequisite step for the patch_code tool, enabling a safe "read-modify-write" hot-patching cycle.
  • Full Stack: Exposed via Neo.ai.Client mapping and the Neural Link MCP Server proxy.
tobiu closed this issue on Jan 4, 2026, 2:07 PM