flue init
最后更新 查看 Markdown 源文件
概要
flue init [directory] [--target <node|cloudflare>] [--deploy] [--force]
描述
flue init 会生成一个完整的 Flue 项目骨架:flue.config.ts、package.json、TypeScript 配置、一个 Hello 智能体,以及根据你的选择生成 HTTP 服务器文件。有两个选择会影响骨架:构建目标(node 或 cloudflare)和是否包含 HTTP 服务器设置。传入标志时会直接使用标志值,否则会以交互方式提示。
[directory] 是要初始化的目标目录,相对于当前工作目录解析,不存在时会自动创建(包括父目录)。默认为当前目录。目录的基名(小写并限制为 [a-z0-9-])会成为 package.json 的 name 和(对于 Cloudflare 目标)Worker 名称;如果基名中没有有效字符,则回退为 my-flue-app。
flue init 只写入文件 — 不会安装依赖。打印的后续步骤(以及生成的 README)从 npm install 开始。
选项
| 选项 | 描述 |
|---|---|
--target <target> | 构建目标:node 或 cloudflare。省略时,flue init 会提示选择;如果没有终端环境,省略会报错。其他值会被拒绝:Invalid target: "bogus". Supported targets: node, cloudflare。 |
--deploy | 包含 HTTP 服务器设置(vite.config.ts、src/app.ts 以及 Hono 和 Vite 依赖)。对于 node 目标默认关闭。cloudflare 目标始终包含部署,因此 --target cloudflare 隐含 --deploy。 |
--root <path> | 要初始化的目标目录;与位置参数相同。同时传递两者会被拒绝:Pass the directory as an argument or with --root, not both.。 |
--force | 在非空目录中初始化时不提示确认,并覆盖已存在的骨架文件(包括 flue.config.*)。不使用 --force 时,已存在的文件会被保留并报告为 “kept existing”。 |
每个标志最多只能传递一次(--target may only be passed once.)。未知标志、多余的位置参数以及裸 -- 之后的参数会被拒绝。
生成的文件
每个骨架包含:
flue.config.tspackage.jsontsconfig.json.gitignore.envsrc/agents/hello.tsAGENTS.mdREADME.mdvite.config.ts(仅--deploy)src/app.ts(仅--deploy)src/db.ts(仅 Node)src/cloudflare.ts(仅 Cloudflare)
示例
flue init # 提示所有选项,在当前目录初始化
flue init ./my-agent-app # 提示选项,在 ./my-agent-app 初始化(不存在时创建)
flue init --target node # 本地运行骨架,无提示
flue init --target node --deploy # Node 服务器骨架
flue init ./bot --target cloudflare # Cloudflare 骨架(隐含 --deploy)
flue init --target node --force # 在非空目录初始化,覆盖 flue.config.*