Skip to content

Add node: protocol support and improve Node.js error messages#262

Merged
Stasshe merged 6 commits intomainfrom
copilot/fix-dirname-issues-in-nodejs
Jan 13, 2026
Merged

Add node: protocol support and improve Node.js error messages#262
Stasshe merged 6 commits intomainfrom
copilot/fix-dirname-issues-in-nodejs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

  • 1. Add node: protocol support: Make require('node:fs'), import { createServer } from 'node:http' work
    • Updated ModuleResolver.isBuiltInModule() to handle node: prefix
    • Updated NodeRuntime.resolveBuiltInModule() to handle node: prefix
    • Updated ModuleLoader with centralized isBuiltInModule() function
    • Added more built-in modules: timers, console, module, process, etc.
  • 2. Improve __dirname and __filename handling: Already correctly provided in sandbox
  • 3. Enhance error messages: Better Node.js-like stack traces and error formatting
    • Moved error utilities from runtimeLogger.ts to new nodeErrors.ts file
    • runtimeLogger.ts is now only for Output panel (Pyxis-wide errors)
    • nodeErrors.ts contains Node.js-specific error formatting
  • 4. Unified process object: Created createProcessObject() method to avoid duplication
    • Both createGlobals() and resolveBuiltInModule() now use the same process object
  • 5. Handle shebang for imports: Already handled by commenting out #!/usr/bin/env node
  • 6. normalizeCjsEsm improvements: Handle node: protocol in imports/requires (dependencies preserved)
  • Fix outdated tests to reflect current synchronous require() behavior
  • Address code review feedback

Security Summary

No security vulnerabilities were discovered during this implementation.

Original prompt

This section details on the original issue you should resolve

<issue_title>__dirname nodejs</issue_title>
<issue_description>nodejsの再現がまだ全然できてない。__dirnameとか。エラーメッセージも。

nodejs,jsの区別も良い感じに。

#!/usr/bin/env node
や、import { createServer } from "node:http";
こういう、node:の書き方できるように。(いま既にできてるのかもしれんけど。)

</issue_description>

<agent_instructions>リポジトリ全体をみて、特にruntimeの扱いについても注意し、俯瞰してから取り掛かって。本格実装。その場しのぎでない、根本的解決。カスコードは書くな。</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
…tant

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix __dirname issues and improve Node.js handling Add node: protocol support and improve Node.js error messages Jan 13, 2026
Copilot AI requested a review from Stasshe January 13, 2026 05:23
@Stasshe
Copy link
Copy Markdown
Owner

Stasshe commented Jan 13, 2026

@copilot
runtimeloggerを勘違いしてる。これは、VSCodeの、outputのパネルに当たる出力のところで、ランタイムとはまた別のもの。
全然役割が違う。ランタイムのエラーというか、pyxis全体のエラーなので。
あと、process{}の環境変数宣言って、また別のところでもやってたはず。統一できるなら、統一して。ズレるし。

…t creation

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
@Stasshe Stasshe temporarily deployed to copilot/fix-dirname-issues-in-nodejs - pyxis-code PR #262 January 13, 2026 05:49 — with Render Destroyed
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot
runtimeloggerを勘違いしてる。これは、VSCodeの、outputのパネルに当たる出力のところで、ランタイムとはまた別のもの。
全然役割が違う。ラン...

Fixed in 2591877:

  1. runtimeLogger.ts の分離: Node.js用のエラーフォーマットユーティリティを新しい nodeErrors.ts に移動しました。runtimeLogger.ts はOutputパネル用のPyxis全体のログ機能のみに戻しました。

  2. processオブジェクトの統一: createProcessObject() メソッドを新設し、createGlobals()resolveBuiltInModule() の両方で同じprocessオブジェクトを使用するようにしました。環境変数(TERM, COLORTERM, FORCE_COLOR等)も統一されています。

@Stasshe Stasshe marked this pull request as ready for review January 13, 2026 12:50
@Stasshe Stasshe merged commit c24e83b into main Jan 13, 2026
@Stasshe Stasshe deleted the copilot/fix-dirname-issues-in-nodejs branch January 13, 2026 12:50
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.

__dirname nodejs

2 participants