ylcwf 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +202 -2
- package/dist/index.js +1480 -0
- package/index.js +3 -0
- package/package.json +44 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
|
+
|
|
5
|
+
## 0.1.0
|
|
6
|
+
|
|
7
|
+
首个发布版本。
|
|
8
|
+
|
|
9
|
+
- `init`:交互式首次配置,每端多个仓库用逗号或分号分隔
|
|
10
|
+
- `show`:人类可读摘要(表格)+ 路径存在性检查;`--format json` 供机器消费
|
|
11
|
+
- `get` / `set`:点路径读写,写入前校验、原子替换、自动备份(保留 10 份)
|
|
12
|
+
- `terminal`:`list` / `add` / `set` / `rm`,以及 `repo list|add|rm` 维护单端仓库
|
|
13
|
+
- `resolve`:精确名 → 精确别名 → 归一化名 → 归一化别名,未命中只给候选;多仓库强制 `--pick`
|
|
14
|
+
- `doctor`:schema、路径存在性、终端/别名唯一性、冗余别名、空端口校验
|
|
15
|
+
- `path`:输出配置文件路径,供脚本降级读取
|
|
16
|
+
- 配置结构 `schemaVersion: 2`:`repos.<side>` 为路径数组,支持一端多仓库
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zhanyoulin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,203 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ylcwf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
研发工作流配置 CLI。把「迭代任务文档仓库、开发者标识、默认角色、PRD 终端 → 本地仓库映射」集中到一份用户级 YAML 里,用命令读写、校验、解析,替代把这些事实散落在提示词与对话记忆中的做法。
|
|
4
|
+
|
|
5
|
+
解决的问题:
|
|
6
|
+
|
|
7
|
+
- **事实单一来源**:路径、标识、映射只存一份,不再同时写在 AGENTS.md、Skill 和对话里;
|
|
8
|
+
- **确定性解析**:PRD 里的终端写法(可含中文、别名、空格、全角)解析为本地仓库路径,命中方式明确,未命中只给候选、不猜;
|
|
9
|
+
- **可校验**:`doctor` 检查 schema、路径存在性、映射唯一性、空端口,问题在配置阶段暴露;
|
|
10
|
+
- **可编排**:`--format json` 给脚本与 Agent 消费,退出码区分「未配置 / 用法错 / 校验失败」。
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g ylcwf
|
|
16
|
+
ylcwf --version
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
临时使用:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx ylcwf show
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
要求 Node.js >= 22.12(commander 15 的 engines 约束)。
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
ylcwf init # 交互式首次配置(需真终端)
|
|
31
|
+
ylcwf show # 人类可读摘要 + 路径存在性
|
|
32
|
+
ylcwf resolve 示例终端-A --side frontend --field path
|
|
33
|
+
ylcwf doctor # 严格校验,有 error 退出码 1
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 命令参考
|
|
37
|
+
|
|
38
|
+
### 顶层
|
|
39
|
+
|
|
40
|
+
| 命令 | 说明 |
|
|
41
|
+
| ----------------------------------------- | ---------------------------------------------------- |
|
|
42
|
+
| `ylcwf` | 无参:TTY 输出摘要;非 TTY 输出 `show --format json` |
|
|
43
|
+
| `ylcwf init [--force]` | 交互式首次配置;已存在时需确认,`--force` 跳过确认 |
|
|
44
|
+
| `ylcwf show [--format human\|json]` | 查看配置,附路径存在性检查 |
|
|
45
|
+
| `ylcwf get <dotPath> [--format json]` | 读取单项,默认输出裸值 |
|
|
46
|
+
| `ylcwf set <dotPath> <value> [--dry-run]` | 精确修改,校验通过才写入 |
|
|
47
|
+
| `ylcwf doctor [--format json]` | 严格校验;存在 error 时退出码 1 |
|
|
48
|
+
| `ylcwf path [--exists]` | 输出配置文件绝对路径;`--exists` 输出 true/false |
|
|
49
|
+
|
|
50
|
+
所有子命令都支持 `-c, --config <path>` 覆盖配置文件位置。
|
|
51
|
+
|
|
52
|
+
### 终端映射
|
|
53
|
+
|
|
54
|
+
| 命令 | 说明 |
|
|
55
|
+
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
56
|
+
| `ylcwf terminal list` | 列出全部终端及其两端仓库 |
|
|
57
|
+
| `ylcwf terminal add <终端名> --frontend <p> [--frontend <p>] [--backend <p>] [--alias <a>]` | 新增终端;`--frontend`/`--backend`/`--alias` 均可重复 |
|
|
58
|
+
| `ylcwf terminal set <终端名> --aliases <a,b>` | 整体替换别名 |
|
|
59
|
+
| `ylcwf terminal rm <终端名> [--yes]` | 删除终端 |
|
|
60
|
+
| `ylcwf terminal repo list <终端名> [--side <side>]` | 查看某一端仓库 |
|
|
61
|
+
| `ylcwf terminal repo add <终端名> --side <side> --path <p>` | 追加仓库 |
|
|
62
|
+
| `ylcwf terminal repo rm <终端名> --side <side> --path <p>` | 移除仓库 |
|
|
63
|
+
|
|
64
|
+
### 终端解析
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
ylcwf resolve <终端名> [--side frontend|backend] [--field repos|path|exists|terminal] [--pick <n>] [--all] [--format json]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| 参数 | 说明 |
|
|
71
|
+
| ------------------ | ----------------------------------------------------------- |
|
|
72
|
+
| `--field repos` | 默认。输出两端仓库列表(含存在性) |
|
|
73
|
+
| `--field path` | 输出单个路径裸值,需配合 `--side` |
|
|
74
|
+
| `--field exists` | 输出 `true`/`false`,需配合 `--side` |
|
|
75
|
+
| `--field terminal` | 输出命中的标准终端名 |
|
|
76
|
+
| `--pick <n>` | 该端有多个仓库时显式指定:序号(从 1 起)、完整路径或目录名 |
|
|
77
|
+
| `--all` | 忽略歧义,输出该端全部仓库 |
|
|
78
|
+
|
|
79
|
+
匹配顺序:**精确终端名 → 精确别名 → 归一化终端名 → 归一化别名**。四步都不命中时返回候选并以退出码 3 结束,不自动采用候选。
|
|
80
|
+
|
|
81
|
+
## 配置文件
|
|
82
|
+
|
|
83
|
+
### 位置与优先级
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
--config <path> > 环境变量 YLCWF_CONFIG > ~/.ylcwf/config.yaml
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
配置为单一文件,用户级,不放项目目录、不进业务仓库。每次写入前自动备份到同目录 `backups/`(保留最近 10 份),写入使用临时文件 + rename 原子替换。
|
|
90
|
+
|
|
91
|
+
### 结构(schemaVersion 2)
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
schemaVersion: 2
|
|
95
|
+
|
|
96
|
+
profile: # 我是谁、以什么角色工作
|
|
97
|
+
developer: yourname # 姓名小写全拼,个人文档文件名
|
|
98
|
+
role: fullstack # frontend | backend | fullstack
|
|
99
|
+
|
|
100
|
+
docs: # 文档资源位置
|
|
101
|
+
root: /Users/you/develop/iteration-task-repo
|
|
102
|
+
|
|
103
|
+
terminals: # PRD 终端 → 本地仓库
|
|
104
|
+
示例终端-A:
|
|
105
|
+
aliases: [A端, 示例-A]
|
|
106
|
+
repos:
|
|
107
|
+
frontend:
|
|
108
|
+
- /Users/you/develop/web/web-a
|
|
109
|
+
backend:
|
|
110
|
+
- /Users/you/develop/java/service-a
|
|
111
|
+
- /Users/you/develop/java/service-b
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 字段语义
|
|
115
|
+
|
|
116
|
+
| 字段 | 说明 |
|
|
117
|
+
| ---------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
118
|
+
| `profile.developer` | `^[a-z][a-z0-9]*$`,小写字母开头 |
|
|
119
|
+
| `profile.role` | `frontend` / `backend` / `fullstack`;只影响文档模板与「某端为空」提示,**不限制仓库数量** |
|
|
120
|
+
| `docs.root` | 文档仓库绝对路径,`doctor` 会检查其下是否存在 `skills/iteration-task-docs/` |
|
|
121
|
+
| `terminals.<名>.aliases` | 同一终端的其它写法(省略、缩写、俗称);归一化已覆盖空格/全角/大小写,冗余别名会被 `doctor` 提示 |
|
|
122
|
+
| `terminals.<名>.repos.frontend\|backend` | **路径数组**,见下 |
|
|
123
|
+
|
|
124
|
+
### 一端多仓库
|
|
125
|
+
|
|
126
|
+
`repos.<side>` 是路径数组,与 `role` 无关:
|
|
127
|
+
|
|
128
|
+
- `[]`:未配置;
|
|
129
|
+
- 1 个:唯一,`resolve --field path` 直接输出;
|
|
130
|
+
- ≥2 个:**歧义**。`resolve --field path` 以退出码 3 结束并列出候选,必须用 `--pick <序号|目录名|完整路径>` 明确指定,或加 `--all` 全量输出。
|
|
131
|
+
|
|
132
|
+
CLI 永不自动挑选多个仓库中的某一个。
|
|
133
|
+
|
|
134
|
+
## 退出码
|
|
135
|
+
|
|
136
|
+
| 码 | 含义 |
|
|
137
|
+
| --- | --------------------------------------------------------------------------- |
|
|
138
|
+
| 0 | 成功(`doctor` 仅有 warning 时也是 0) |
|
|
139
|
+
| 1 | 配置校验失败(`doctor` 存在 error) |
|
|
140
|
+
| 2 | 用法错误:参数非法、枚举不合法、非 TTY 下调用 `init` |
|
|
141
|
+
| 3 | 未找到:配置未初始化、字段不存在、终端未命中、某端无仓库、多仓库未 `--pick` |
|
|
142
|
+
|
|
143
|
+
## 归一化与别名
|
|
144
|
+
|
|
145
|
+
归一化规则(只做字符级处理,不做语义猜测):
|
|
146
|
+
|
|
147
|
+
- Unicode NFKC:全角字母/数字/标点 → 半角;
|
|
148
|
+
- 去除所有空白;
|
|
149
|
+
- 各类破折号、连字符、下划线统一为 `-`;
|
|
150
|
+
- 拉丁字母转小写,中文保持原样。
|
|
151
|
+
|
|
152
|
+
因此 `示例终端-A` 会被以下写法命中:`示例终端 - A`、`示例终端-A`、`示例终端-A`。
|
|
153
|
+
|
|
154
|
+
需要额外别名的场景:写法与终端名不是字符差异,例如 `A端`、`示例-A`、带破折号的变体 `示例终端A` 与 `示例终端-A`。
|
|
155
|
+
|
|
156
|
+
## 与 Agent / Skill 的接入
|
|
157
|
+
|
|
158
|
+
推荐三级读取:
|
|
159
|
+
|
|
160
|
+
1. `ylcwf show --format json` 或 `ylcwf get <path>`;
|
|
161
|
+
2. CLI 不可用时直接读 `~/.ylcwf/config.yaml`;
|
|
162
|
+
3. 都拿不到则询问开发者,禁止按路径规律推测。
|
|
163
|
+
|
|
164
|
+
约定建议:
|
|
165
|
+
|
|
166
|
+
- **只读**:Agent 不得自行执行 `set` / `terminal add|set|rm|repo`;
|
|
167
|
+
- 终端解析只用 `exact` / `alias` / `normalized` 三种命中;返回候选时等待人工确认;
|
|
168
|
+
- 多仓库必须询问,禁止自行挑选;
|
|
169
|
+
- 文档中写仓库名(路径最后一段),不写本地绝对路径。
|
|
170
|
+
|
|
171
|
+
## 升级与迁移
|
|
172
|
+
|
|
173
|
+
`schemaVersion 2` 起 `repos.<side>` 为数组(v1 是单值字符串)。旧配置会被明确拒绝:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
✗ error REPOS_NOT_ARRAY [terminals.X.repos.frontend] 该端仓库必须是路径数组,例如 ["/path/to/repo"]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
迁移方式:把 `frontend: /path/a` 改为 `frontend: ["/path/a"]`,或删除后重新 `ylcwf init` / `ylcwf terminal add`。
|
|
180
|
+
|
|
181
|
+
`BACKUPS` 目录中保留了历史配置,可回滚。
|
|
182
|
+
|
|
183
|
+
## 开发
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
pnpm install
|
|
187
|
+
pnpm typecheck # tsc --noEmit
|
|
188
|
+
pnpm test # node:test(tsx 加载 TS),39 个用例
|
|
189
|
+
pnpm build # rslib → dist/index.js
|
|
190
|
+
pnpm verify # typecheck + test + build
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
发布:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm publish # prepublishOnly 会自动跑 pnpm verify
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
本地联调:`npm link` 或 `ln -sfn "$PWD/index.js" ~/.local/bin/ylcwf`。
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|