Deno 运行时专家:安全 TypeScript 开发 - Openclaw Skills
作者:互联网
2026-03-30
什么是 Deno?
此 Deno 技能提供了使用现代 Deno 运行时开发、测试和部署应用程序所需的技术专业知识。它专注于 Deno 独特的安全优先方法,帮助开发人员掌握细粒度的权限系统和基于模块的依赖模型。通过在 Openclaw Skills 中利用此技能,开发人员可以确保其 AI 代理正确处理 TypeScript 扩展、导入映射以及从 Node.js 环境的过渡。
该技能强调生产就绪 Deno 代码的最佳实践,例如避免过度开放的权限标志以及正确管理锁定文件。它弥合了传统 Node.js 开发与 Deno 的 Web 标准 API 之间的差距,使其成为高性能、安全后端和 CLI 开发的必备工具。
下载入口:https://github.com/openclaw/skills/tree/main/skills/ivangdavila/deno
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install deno
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 deno。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
Deno 应用场景
- 为生产环境的 Deno 服务实施细粒度的安全权限。
- 在保持完整的 npm 兼容性的情况下,将现有的 Node.js 项目迁移到 Deno。
- 管理远程依赖项并将其本地化(vendorize)以确保离线稳定性。
- 创建用于跨平台分发的自包含可执行二进制文件。
- 使用原生的 Deno 测试套件编写无泄漏的异步测试。
- 该技能通过寻找 deno.json 或特定的 TypeScript 导入模式来检测 Deno 项目结构。
- 它审计请求的操作以确定所需的特定权限,例如 --allow-net 或 --allow-read。
- 代理配置导入映射和依赖项说明符,以正确解析模块路径。
- 它生成符合 Deno 标准的 TypeScript 代码,遵循严格的扩展要求和 Web 标准 API。
- 它通过管理 Deno 缓存和生成完整性锁定文件来为部署准备环境。
Deno 配置指南
要使用此技能,请确保您的本地计算机上已安装 Deno CLI。Openclaw Skills 需要 Deno 二进制文件来执行任务。
# 在 macOS 或 Linux 上安装 Deno
curl -fsSL https://deno.land/x/install/install.sh | sh
# 在 Windows 上安装 Deno
irm https://deno.land/install.ps1 | iex
通过在终端中运行 deno --version 来验证安装。
Deno 数据架构与分类体系
| 组件 | 用途 |
|---|---|
deno.json |
用于权限、导入和任务的主配置文件。 |
deno.lock |
确保子依赖项的安全性和版本一致性。 |
import_map |
将模块别名映射到 URL 或 npm 包,以实现更简洁的导入。 |
permissions.md |
管理细粒度运行时访问的文档。 |
node-compat.md |
处理 node: 说明符和 polyfill 的参考。 |
name: Deno
slug: deno
version: 1.0.0
description: "Build with Deno runtime avoiding permission gotchas, URL import traps, and Node.js migration pitfalls."
metadata: {"clawdbot":{"emoji":"??","requires":{"bins":["deno"]},"os":["linux","darwin","win32"]}}
When to Use
User needs Deno expertise — secure TypeScript runtime with permissions model. Agent handles permission configuration, dependency management via URLs/npm, and migration from Node.js.
Quick Reference
| Topic | File |
|---|---|
| Permission system | permissions.md |
| Imports and dependencies | imports.md |
| Node.js migration | node-compat.md |
Permission Traps
--allow-allin development — then production crashes because you don't know what permissions you actually need--allow-readwithout path — grants access to entire filesystem, security hole--allow-runwithout list — subprocess can run anything, specify:--allow-run=git,npm--allow-envwithout list — leaks all env vars, specify:--allow-env=API_KEY,DATABASE_URL--allow-netwithout list — can connect anywhere, specify hosts:--allow-net=api.example.com- Missing permission in CI — hangs waiting for prompt that never comes, add
--no-prompt
Import Traps
- Remote URLs in production — network failure = app won't start, vendor dependencies locally
- No lockfile by default — deps can change between runs, always use
deno.lock @^1.0.0semver syntax doesn't exist — use exact URLs or import maps- Import maps in wrong place — must be in
deno.json, not separate file (Deno 2.x) - HTTPS required — HTTP imports blocked by default, most CDNs work but self-hosted may not
- URL typo — no error until runtime when import fails
TypeScript Traps
.tsextension required in imports — model generates extensionless imports that failtsconfig.jsonpaths ignored — Deno uses import maps indeno.json, not tsconfig- Type-only imports — must use
import typeor bundler may fail - Decorators — experimental, different from tsc behavior
///— handled differently than tsc, may be ignored
Deployment Traps
deno compileincludes runtime — binary is 50MB+ minimum--cached-onlyrequires prior cache — fresh server needsdeno cachefirst- Deno Deploy limitations — no filesystem, no subprocess, no FFI
- Environment variables — different API:
Deno.env.get("VAR")notprocess.env.VAR - Signals —
Deno.addSignalListenernotprocess.on("SIGTERM")
Testing Traps
Deno.testdifferent from Jest — nodescribe, different assertions- Async test without await — test passes before promise resolves
- Resource leaks — tests fail if you don't close files/connections
- Permissions in tests — test may need different permissions than main code
- Snapshot testing — format differs from Jest snapshots
npm Compatibility Traps
npm:specifier — works for most packages but native addons failnode:specifier required —import fs from 'fs'fails, needimport fs from 'node:fs'node_modulesoptional — enable with"nodeModulesDir": truein deno.jsonpackage.jsonscripts — not automatically supported, use deno.json tasks- Peer dependencies — handled differently, may get wrong versions
Runtime Differences
Deno.readTextFilevsfs.readFile— different API, different error typesfetchis global — no import needed, unlike Node 18-- Top-level await — works everywhere, no wrapper needed
- Permissions at runtime — can request dynamically but user must approve
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
信号管道:自动化营销情报工具 - Openclaw Skills
技能收益追踪器:监控 Openclaw 技能并实现变现
AI 合规准备就绪度:评估与治理工具 - Openclaw Skills
FOSMVVM ServerRequest 测试生成器:自动化 API 测试 - Openclaw Skills
酒店搜索器:AI 赋能的住宿与位置情报 - Openclaw Skills
Dub 链接 API:程序化链接管理 - Openclaw Skills
IntercomSwap:P2P BTC 与 USDT 跨链兑换 - Openclaw Skills
spotplay:macOS 原生 Spotify 播放控制 - Openclaw Skills
DeepSeek OCR:AI驱动的图像文本识别 - Openclaw Skills
Web Navigator:自动化网页研究与浏览 - Openclaw Skills
AI精选
