@agentskit/cross-platform

中文文档
0.3.0发布于 2026/10/10MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2.1万

One place for OS and runtime portability in the AgentsKit ecosystem: spawn, paths, line endings and filesystem that behave the same on Windows, macOS and Linux under Node, Bun and Deno.

原始使用文档
文档目录13 节
  1. Verified proof
  2. How this fits the ecosystem
  3. Install
  4. Quick example
  5. Features
  6. Test helpers
  7. Guardrail
  8. Ecosystem
  9. Contributors
  10. License
  11. Docs
  12. Maturity and compatibility
  13. Contributing

@agentskit/cross-platform

Profile: concise-package

AgentsKit

One place for OS and runtime portability in the AgentsKit ecosystem: spawn processes, handle paths, line endings and files the same way on Windows, macOS and Linux, under Node, Bun and Deno.

npm version npm downloads bundle size license stability GitHub stars

Tags: agentskit · ai-agents · cross-platform · windows · spawn · bun · deno · node

Verified proof

  • Package metadata, unit tests and the runtime smoke test live under packages/cross-platform/.
  • CI matrix: Linux, macOS and Windows × Node, Bun and Deno (.github/workflows/cross-platform.yml).
  • Decision record: ADR-0036.
  • Stability map: docs/STABILITY.md

How this fits the ecosystem

Every AgentsKit repository used to fix the same Windows bugs by hand: .cmd shims failing with ENOENT, prompts cut at the first newline, \ vs / in paths, CRLF breaking hashes, EBUSY on rename, orphaned child processes. @agentskit/cross-platform owns those fixes, and the libraries behind them, so the rest of the ecosystem imports one package instead of re-implementing them.

  • AgentsKit: @agentskit/cli, @agentskit/adapters, @agentskit/tools and @agentskit/sandbox spawn through it.
  • Registry: ready agents and templates at registry.agentskit.io.
  • Playbook: production patterns at playbook.agentskit.io.

Docs: package guide · agent handoff

Install

npm install @agentskit/cross-platform

Quick example

import { runCommand, splitLines, toPosix } from '@agentskit/cross-platform'

// `npx` is `npx.cmd` on Windows: resolved without `shell: true`.
// The multi-line prompt goes through stdin, so cmd.exe cannot truncate it.
const result = await runCommand('npx', ['--yes', 'prettier', '--stdin-filepath', 'notes.md'], {
  input: '# Notes\n\n*  formatted on any OS and any runtime\n',
  timeoutMs: 60_000,
})

console.log(splitLines(result.stdout).length, 'lines')
console.log(toPosix('C:\\repo\\src\\index.ts'))

Features

AreaAPIReplaces
ProcessesspawnProcess, runCommand, spawnShell, runShell, spawnNodeChild, killProcessTree, findExecutable, commandExists, safeEnvchild_process + shell: process.platform === 'win32', prompts in argv, child.kill() leaving grandchildren, process.kill(-pid)
PathstoPosix, relativePosix, joinPosix, samePath, isPathInside, fileUrlToPath, moduleDir, isMainModulereplace(/\\/g, '/') copies, new URL(import.meta.url).pathname
TextnormalizeEol, splitLines, splitFrontmatter, hashTextsplit('\n'), /^---\n/, hashes that differ under core.autocrlf
FilesystemremovePath, renamePath, writeFileAtomic, createSymlink, copyPath, setFileModeEBUSY/EPERM retry loops, EXDEV temp files, symlink privilege errors
RuntimegetRuntimeInfo, isWindows, isBun, isDenoad-hoc process.platform checks
Guardrailagentskit-cross-platform checkWindows regressions found only on a Windows laptop
  • Native adapter per runtime: node:child_process on Node, Bun.spawn on Bun, Deno.Command on Deno. stdout/stderr are web ReadableStreams everywhere.
  • Browser/edge subset: @agentskit/cross-platform/pure (paths, text, runtime detection) has no node: imports.
  • Deno permissions: a missing --allow-* flag raises AK_PLATFORM_PERMISSION_DENIED naming the flag. It never prompts.
  • Built on: cross-spawn (Windows command resolution and cmd.exe escaping), tree-kill, pathe, std-env, graceful-fs, which.

Test helpers

Import createFetchStub, jsonResponse, and withTempDir from @agentskit/cross-platform/testing. The subpath has no test-runner dependency; withTempDir uses this package's OS temp-directory lookup and retrying cleanup.

Guardrail

npx agentskit-cross-platform check --init   # record today's findings as a baseline
npx agentskit-cross-platform check          # fail on any new finding
npx agentskit-cross-platform check --update # lower the baseline after a fix

The baseline is a ratchet: counts only go down. Allow a justified exception with a cross-platform-ignore: <reason> comment on the line or the line above. A <rule-id>-ignore: <reason> comment suppresses only that rule.

Repository guardrails can reuse the exported runCli with custom rules and an optional filter to apply the shared scan and baseline logic to a narrower source set.

Ecosystem

PackageRole
@agentskit/coreAgentsKitError, the base of CrossPlatformError
@agentskit/adaptersCLI providers (claude, codex) spawned portably
@agentskit/sandboxLocal process runtimes

Contributors

AgentsKit contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: beta — see docs/STABILITY.md. Not 1.0.
  • Node.js 20+ (20.19+), Bun 1.2+, Deno 2+, and TypeScript strict mode
  • Windows, macOS and Linux
  • Published as @agentskit/cross-platform

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.

版本与发布记录

@agentskit/cross-platform 共发布 7 个版本,首次发布于 2026/09/28;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.0latest2026/10/1026 天前
0.2.12026/10/031 个月前
0.2.02026/10/031 个月前
0.1.22026/09/291 个月前
0.1.12026/09/281 个月前
0.1.02026/09/281 个月前

其他发布通道:bootstrap → 0.0.0。

关于 @agentskit/cross-platform 的常见问题

@agentskit/cross-platform 是什么?

One place for OS and runtime portability in the AgentsKit ecosystem: spawn, paths, line endings and filesystem that behave the same on Windows, macOS and Linux under Node, Bun and Deno.

如何安装 @agentskit/cross-platform?

在项目目录运行 npm install @agentskit/cross-platform,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 agentskit-cross-platform,可以用 npx agentskit-cross-platform 直接运行。

@agentskit/cross-platform 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentskit/cross-platform 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agentskit/cross-platform 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agentskit/cross-platform 可以商用吗?

@agentskit/cross-platform 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentskit/cross-platform 的下载量有多少?

根据 npm 官方下载统计,@agentskit/cross-platform 在 2026/10/05 – 2026/11/03 这 30 天内被下载 21,346 次,日均约 712 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentskit/cross-platform 还在维护吗?

最新版本 0.3.0 发布于 2026/10/10(26 天前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/09/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。