Template-driven file and directory generator for project workflows
Project description
sprout CLI (v0.1)
sprout 是一个项目内模板驱动的文件/目录生成 CLI,面向 Agent 协同开发场景。
核心特性
- 发现规则:从当前目录向上查找首个
.sprout/(类似.git) - 命令包目录:
.sprout/commands/<command>/ - 默认 authoring 格式:YAML(便于注释、示例和值说明)
- 输入模式:默认参数输入;
-i/--interactive才进入交互 - 基础类型:
string/number/enum(number支持可选min/max) - 插值语法:
{{name}}(仅纯文本替换,不支持逻辑流) - 冲突策略:
fail/overwrite/skip/rename init支持自定义骨架、可选示例命令包,并生成项目内sprout-authoringSkill 文档- 运行时兼容
yaml/yml/toml/json配置与 manifest
快速开始
# 0) 可选:安装 YAML 支持(推荐)
uv add --optional yaml
# 或使用 pip: pip install pyyaml
# 1) 初始化
sprout init --with-examples
# 2) 查看命令
sprout list --all
# 3) 执行命令(默认参数模式,使用 = 连接键值)
sprout new issue name=my-task type=bug
# 4) 交互模式(程序会提示输入缺失的参数)
sprout new issue -i
# 程序提示: name:
# 你输入: my-task
# 程序提示: type choices=['bug', 'feat', 'refactor'] [default=bug]:
# 你输入: bug (或直接回车使用默认值)
# 5) 预览模式(不实际创建文件)
sprout new issue name=test type=feat --dry-run
命令
sprout init [--profile minimal|docs] [--profile-file ./profile.json] [--with-examples]
sprout list [--all]
sprout doctor
sprout new <command> [key=value ...] [--set key=value] [-i|--interactive] [--conflict fail|overwrite|skip|rename]
.sprout/ 结构
.sprout/
config.yaml
commands/
issue/
manifest.yaml
issue.md
skills/
sprout-authoring/
SKILL.md
如何填写 .sprout/config.yaml
# sprout project defaults
version: 1
# Default conflict policy for generated assets.
# Allowed: fail | overwrite | skip | rename
conflict: fail
字段说明:
version:整数,当前固定为1conflict:项目级默认冲突策略;可选fail/overwrite/skip/rename
如何填写 manifest.yaml
name: issue
description: Create issue
# Optional per-command conflict override.
# If omitted, sprout uses `.sprout/config.yaml`.
conflict: fail
inputs:
- name: name
type: string
required: true
description: Issue slug
- name: type
type: enum
enum:
- bug
- feat
- refactor
default: bug
description: Issue category
- name: priority
type: number
required: false
min: 1
max: 5
default: 3
description: Optional priority
assets:
- type: dir
path: issues
- type: file
path: issues/{{YY}}-{{MM}}-{{DD}}_{{name}}.md
template: issue.md
字段说明
inputs[*]
name:必填,且在同一命令内唯一type:string/number/enumrequired:可选,默认truedescription:可选,但建议填写,方便 Agent 理解用途default:可选默认值enum:当type: enum时必填min/max:仅number类型可用
assets[*]
type:dir或filepath:项目内相对路径template:文件资产引用的模板文件,路径相对当前命令目录content:简单文件可直接内联内容;与template二选一即可
变量上下文
除了输入变量,内置时间变量:
YYYY,YY,MM,DDhh,mm,ssdate,time,datetime,timestamp
冲突策略说明
当生成的文件或目录已存在时,sprout 会根据冲突策略处理:
fail(默认):报错并停止skip:跳过已存在的文件overwrite:覆盖已存在的文件rename:重命名新文件(添加_02、_03等后缀)
目录特殊处理:目录被视为容器而非内容,已存在的目录会自动复用(REUSE),不受冲突策略影响。只有文件冲突才会应用冲突策略。
示例:
# 第一次执行
sprout new issue name=test type=bug
# 输出:
# + CREATE issues
# + CREATE issues/26-04-11_test.md
# 第二次执行(目录已存在)
sprout new issue name=another type=feat
# 输出:
# = REUSE issues # 目录自动复用
# + CREATE issues/26-04-11_another.md
# 第三次执行(文件冲突)
sprout new issue name=another type=feat
# 输出:
# Error: Target already exists: issues/26-04-11_another.md
# Hint: Use --conflict=skip or --conflict=overwrite
Agent authoring 建议
如果让 Agent 帮你写 .sprout,先让它读取:
.sprout/skills/sprout-authoring/SKILL.md
然后先对齐:
- 命令目的
- 输入字段及类型
- 输出文件/目录
- 冲突策略
不要一上来直接让 Agent 写 manifest。
常见问题
- 找不到项目模板根:确认当前目录或父目录存在
.sprout/ - 命令不可用:执行
sprout doctor检查 invalid/conflict 报告 - YAML 无法读取:安装
PyYAML,或继续使用 TOML / JSON
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sprout_files-0.2.1.tar.gz.
File metadata
- Download URL: sprout_files-0.2.1.tar.gz
- Upload date:
- Size: 158.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b68218bc23dc82338e4ebd8e64ee21ea50378dd8fc31b0e215440f9e3871b0d
|
|
| MD5 |
1141f9f19304bab1cada6c4ffaa62f35
|
|
| BLAKE2b-256 |
03ca91a34e78b0191c67cb54e94b0fc21c314e5253d261b2f4c4abbfe46153de
|
File details
Details for the file sprout_files-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sprout_files-0.2.1-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c526a44e17e96713e08257c63d36c7d047ebd8c9c51e28da225f6bd3bc79a231
|
|
| MD5 |
a4ee1b069a6ceba898a72a6e22913a8b
|
|
| BLAKE2b-256 |
505490803bad72c4fc174369d7243e2cc461341cd44eb3ea7f2b394b0456bc9f
|