Skip to content

增强 Deno 兼容性,添加降级处理逻辑以支持在无法执行原生命令时返回基础数据,同时更新文档以反映这些更改。#44

Merged
SunilWang merged 10 commits intodevelopfrom
003-fix-deno-compat
Apr 7, 2026
Merged

增强 Deno 兼容性,添加降级处理逻辑以支持在无法执行原生命令时返回基础数据,同时更新文档以反映这些更改。#44
SunilWang merged 10 commits intodevelopfrom
003-fix-deno-compat

Conversation

@SunilWang
Copy link
Copy Markdown
Owner

Background

  • Describe the motivation, business context, and expected impact.

Key Changes

  • Summarize core implementations, refactors, or fixes.
  • Highlight affected modules and outline potential risks.

Test Matrix

Platform Command Result
macOS npm run build ✅/❌
macOS npm run test:unit ✅/❌
Other npm run test:linux / windows (if applicable) ✅/❌
Lint npm run lint:check ✅/❌

Related Issues

  • Close #

Platform & Permissions

  • Note any platform constraints or additional permission requirements.

Documentation

  • Updated README.md / README-zh.md
  • No documentation changes required (explain why)

Additional Notes

  • Provide debugging tips, rollback plans, or follow-up actions.

SunilWang and others added 10 commits April 7, 2026 18:07
test/deno/smoke-test.ts 使用 import.meta.url,仅供 Deno 直接运行,
不应纳入 CommonJS 模式的 tsc 编译范围。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deno 在未声明模块类型时默认将 .js 文件视为 ESM,
即使通过 createRequire 加载也会走 loadESMFromCJS 路径并抛出
"exports is not defined"。显式声明 "type": "commonjs" 后
Deno 可正确识别并加载 CommonJS 格式的 dist 产物。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deno 的 --allow-read 默认不授权读取 /proc/meminfo,
原先直接 throw 导致 memory.info() 返回 failure。
现改为降级到 os.totalmem()/os.freemem() 并发出 warnDegradation,
与 CPU 和 Windows 适配器的处理策略保持一致。

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>
- 添加 "type": "commonjs" 声明,解决 Deno 加载 CJS 产物失败
- Linux/macOS 适配器在 /proc/meminfo 不可读时降级到 os 模块
- CommandExecutor 处理 Deno 兼容层抛出的非对象异常
- 修复 getNetworkStats 静默返回空数组的错误行为
- cpu.average() 标记为 @deprecated,引导迁移到 cpu.usage()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SunilWang SunilWang merged commit 0890405 into develop Apr 7, 2026
5 checks passed
@SunilWang SunilWang deleted the 003-fix-deno-compat branch April 7, 2026 10:48
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.

1 participant