360 Secure SkillHub
360 安全技能中心

Perryts

核心功能是将TypeScript直接编译为无VM的原生可执行文件,涵盖编译/运行/开发命令、多平台跨编译(含鸿蒙等10种目标)、perry.toml配置、原生UI、多线程、系统API等。典型场景为用TS开发跨平台原生应用、后端服务等,输入相关命令或代码问题,输出操作指导、示例或配置说明。

zhenyangze
zhenyangze
热度 13.01
最近更新 2026-07-08 02:55:24
分类:开发依赖:纯提示词应用场景:代码生成 / API 集成 / DevOps / 模板

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add perryts-skill
Metadata
name
perryts
description
Perry TypeScript-to-native compiler skill. Use when working with the Perry compiler, Perry projects, or TypeScript code that compiles to native executables. Covers: compile/run/dev commands, cross-compilation targets (macOS/iOS/Android/HarmonyOS/Windows/Linux/Web), perry.toml configuration, Standard Library (npm packages compiled natively), Multi-Threading (parallelMap/spawn), Native UI widgets (VStack/HStack/State), System APIs, Widgets (home screen), Internationalization, Auto-Update, Plugins, and CLI reference. Triggers on: "perry compile", "perry run", perry.toml, perry/ui, perry/system, perry/thread, perry/i18n, perry/media, perry/updater, perry/tui, native UI, cross-compilation, HarmonyOS target, ArkUI codegen.

Perry TypeScript-to-Native Compiler

Perry compiles TypeScript directly to native executables via HIR → LLVM codegen. No VM, no runtime interpreter.

Quick Start

perry init my-app && cd my-app
perry run src/main.ts                     # Compile + run
perry compile src/main.ts -o app          # Build native binary
perry dev src/main.ts                     # Watch mode

Cross-Compilation

perry compile src/main.ts --target ios-simulator -o app
perry compile src/main.ts --target android -o app.apk
perry compile src/main.ts --target harmonyos
perry compile src/main.ts --target web -o dist/

Key Imports

import { VStack, HStack, Text, Button, state } from "perry/ui"
import { parallelMap, spawn } from "perry/thread"
import { openURL, isDarkMode, keychainSave } from "perry/system"
import { i18n } from "perry/i18n"
import { createPlayer, play, setNowPlaying } from "perry/media"
import { Box, Text, render } from "perry/tui"
import { checkForUpdate, installUpdate } from "perry/updater"

Reference Documentation

Load these as needed for detailed API docs, configuration, and examples:

  • CLI & Configuration — All 11 CLI commands, compilation targets, global flags, perry.toml sections, environment variables, CI/CD integration
  • Standard Library — HTTP (fastify/fetch/axios/ws), Database (sqlite/mysql2/pg/mongodb/redis), Crypto (bcrypt/argon2/jwt/ethers), File System, Utilities (lodash/dayjs/uuid/commander), Media (sharp/cheerio/zlib/cron), binary size table
  • Multi-Threading — parallelMap, parallelFilter, spawn, capture rules, safety model, architecture
  • Native UI — Layout widgets, 14+ widget types, inline StyleProps, State & reactivity, events, Canvas, Menus & Dialogs, multi-window, Table, Animation, Geisterhand testing API, platform support matrix
  • Platforms — All 10 targets (macOS/iOS/visionOS/tvOS/watchOS/Android/HarmonyOS/Windows/Linux/Web), per-platform build commands and architecture
  • Internationalization — i18n.t(), CLDR plural rules, format wrappers (Currency/Percent/ShortDate), perry.toml [i18n] config, compile-time validation
  • System APIs — openURL, isDarkMode, preferences, keychain, notifications (local + push), audio capture, media playback, clipboard, environment variables
  • Widgets (Home Screen) — Widget() declaration, entryFields, family-specific rendering, timeline provider, platform notes
  • Plugins & Auto-Update — PluginApi, hook modes (filter/action/waterfall), FFI, plugin discovery, manifest schema v2, Ed25519 signing

Common Patterns

Native App

import { App, VStack, Text, Button, state } from "perry/ui"

const count = state(0)

App({
  body: VStack([
    count.text(),
    Button("+", () => count.set(count.get() + 1))
  ])
})

HTTP Server

import Fastify from "fastify"

const server = Fastify()
server.get("/", async () => ({ hello: "perry" }))
server.listen({ port: 3000 })

Parallel Processing

import { parallelMap } from "perry/thread"

const results = parallelMap([1, 2, 3, 4], (n) => n * 2)
// [2, 4, 6, 8]