flower-trellis 0.4.0 → 0.4.2
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/README.md +91 -2
- package/enhancements/0.6/overrides/skills/trellis-finish-work.md +1 -3
- package/enhancements/0.6/overrides/workflow-states/in_progress-inline.md +5 -2
- package/enhancements/0.6/overrides/workflow-states/in_progress.md +4 -1
- package/enhancements/0.6/overrides/workflow-states/no_task.md +1 -1
- package/enhancements/0.6/overrides/workflow-states/planning-inline.md +1 -1
- package/enhancements/0.6/overrides/workflow-states/planning.md +1 -1
- package/enhancements/0.6/overrides/workflow.md +21 -15
- package/enhancements/MANIFEST.json +2 -2
- package/package.json +1 -1
- package/src/assets/flower_update_hook.py +135 -0
- package/src/cli.js +27 -0
- package/src/commands/self-check.js +19 -0
- package/src/commands/self-update.js +108 -0
- package/src/commands/update-check.js +86 -0
- package/src/lib/apply-enhancements.js +12 -2
- package/src/lib/claude-tweaks.js +98 -0
- package/src/lib/codex-tweaks.js +41 -18
- package/src/lib/flower-assets.js +29 -0
- package/src/lib/manifest.js +87 -2
- package/src/lib/self-check.js +352 -0
package/README.md
CHANGED
|
@@ -52,6 +52,15 @@ flower-trellis init -u <your-name> -y
|
|
|
52
52
|
# 升级 Trellis 并按新版本重新叠加强化包
|
|
53
53
|
flower-trellis update
|
|
54
54
|
|
|
55
|
+
# 检查当前项目是否需要更新(稳定 JSON,供 AI / hook 使用)
|
|
56
|
+
flower-trellis self-check --json --target .
|
|
57
|
+
|
|
58
|
+
# 执行受控自更新:升级 flower-trellis,再默认 --force 重叠加当前项目
|
|
59
|
+
flower-trellis self-update --target . --yes
|
|
60
|
+
|
|
61
|
+
# 管理启动更新检查策略
|
|
62
|
+
flower-trellis update-check get --target .
|
|
63
|
+
|
|
55
64
|
# 交互管理通用技能,并查看工作流强化包
|
|
56
65
|
flower-trellis skill
|
|
57
66
|
|
|
@@ -70,6 +79,9 @@ flower-trellis -v
|
|
|
70
79
|
|------|------|
|
|
71
80
|
| `init` | 安装 Trellis 并叠加强化包(默认命令,裸跑等同 `init`) |
|
|
72
81
|
| `update` | 升级 Trellis,并按新版本重新叠加强化包 |
|
|
82
|
+
| `self-check` | 输出启动更新检查 JSON,供 Codex / Claude Code hook 和 AI 自动化读取 |
|
|
83
|
+
| `self-update` | 受控升级 flower-trellis 并对目标项目执行完整 `flower-trellis update` 重叠加 |
|
|
84
|
+
| `update-check` | 管理 `.trellis/.flower-manifest.json` 内的启动更新检查策略 |
|
|
73
85
|
| `skill` | 打开交互菜单:启用或停用通用技能,只读查看工作流强化包 |
|
|
74
86
|
| `uninstall` | 移除 Trellis 本体并清理强化包残留(支持 `-y` / `--dry-run`) |
|
|
75
87
|
| `<其它命令>` | 原样透传给 Trellis,覆盖其现有及未来子命令 |
|
|
@@ -99,16 +111,93 @@ flower-trellis -v
|
|
|
99
111
|
- **非交互**(`-y` 或非 TTY):仅打印一行升级提示,不弹确认、不阻塞。
|
|
100
112
|
- **跳过检测**:经 `npx` 运行(本就是最新版)、或显式 `--no-update-check` / `FLOWER_NO_UPDATE_CHECK=1` 时不检测。
|
|
101
113
|
|
|
114
|
+
### 启动更新检查
|
|
115
|
+
|
|
116
|
+
运行 `flower-trellis init` / `flower-trellis update` 后,目标项目会安装轻量启动 hook:
|
|
117
|
+
|
|
118
|
+
- Codex:向 `.codex/hooks.json` 的 `SessionStart` 追加 `.trellis/scripts/flower_update_hook.py`。
|
|
119
|
+
- Claude Code:只向 `.claude/settings.json` 的 `SessionStart` `startup` matcher 追加该 hook,不挂 `clear` / `compact`。
|
|
120
|
+
|
|
121
|
+
启动 hook 不会直接安装 npm 包,也不会直接改项目文件。它只调用:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
flower-trellis self-check --json --target .
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
发现可更新或项目已铺版本不一致时,向 AI 注入 `<flower-update>` 上下文。无更新、离线、关闭检查、npx 临时运行时默认不打扰。
|
|
128
|
+
|
|
129
|
+
检查分两层:
|
|
130
|
+
|
|
131
|
+
- **本地一致性检查**:每次启动都会比对当前安装的 `flower-trellis` / 捆绑 Trellis 版本与项目 `.trellis/.flower-manifest.json` / `.trellis/.version`;不受 `intervalHours` 限制。
|
|
132
|
+
- **远程版本探测**:访问 npm registry 读取 `flower-trellis` dist-tags;受 `intervalHours` 节流,带超时,失败静默。
|
|
133
|
+
|
|
134
|
+
策略和缓存统一保存在 `.trellis/.flower-manifest.json` 的 `updateCheck`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"updateCheck": {
|
|
139
|
+
"enabled": true,
|
|
140
|
+
"policy": "ask",
|
|
141
|
+
"intervalHours": 24,
|
|
142
|
+
"lastCheckedAt": "2026-07-07T00:00:00.000Z",
|
|
143
|
+
"lastRemote": { "latest": "0.4.2", "beta": null },
|
|
144
|
+
"lastStatus": "update_available",
|
|
145
|
+
"lastErrorCode": null
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`policy` 可选:
|
|
151
|
+
|
|
152
|
+
| policy | 行为 |
|
|
153
|
+
|--------|------|
|
|
154
|
+
| `off` | 不做启动更新检查,也不联网 |
|
|
155
|
+
| `notify` | 只注入提示和手动命令,AI 不主动询问或执行 |
|
|
156
|
+
| `ask` | 默认值;AI 发现可更新后先询问用户 |
|
|
157
|
+
| `auto` | 安全条件满足时 AI 可执行 `self-update`;dirty 工作区或活跃任务等情况会降级为 `ask` |
|
|
158
|
+
|
|
159
|
+
管理策略:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
flower-trellis update-check get --target .
|
|
163
|
+
flower-trellis update-check set --policy auto --interval-hours 12 --target .
|
|
164
|
+
flower-trellis update-check disable --target . # 只设置 enabled=false,不改 policy
|
|
165
|
+
flower-trellis update-check enable --target . # 只设置 enabled=true,沿用原 policy
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
执行更新:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# 预览,不写入
|
|
172
|
+
flower-trellis self-update --target . --dry-run
|
|
173
|
+
|
|
174
|
+
# 执行:先升级全局 flower-trellis,再对项目执行完整 update
|
|
175
|
+
flower-trellis self-update --target . --yes
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
项目重叠加阶段默认等价于 Trellis 交互里的 **Apply Overwrite to all**:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
flower-trellis update --target . --no-update-check --force
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
如需改用其它上游冲突策略,在 `--` 后透传:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
flower-trellis self-update --target . --yes -- --skip-all
|
|
188
|
+
flower-trellis self-update --target . --yes -- --create-new
|
|
189
|
+
```
|
|
190
|
+
|
|
102
191
|
## 工作原理
|
|
103
192
|
|
|
104
193
|
`init` 的执行流程:
|
|
105
194
|
|
|
106
195
|
```
|
|
107
|
-
flower banner → 平台多选菜单 → Trellis 原生交互(模板 / monorepo / 冲突)→ 叠加强化包 →
|
|
196
|
+
flower banner → 平台多选菜单 → Trellis 原生交互(模板 / monorepo / 冲突)→ 叠加强化包 → 平台后处理
|
|
108
197
|
```
|
|
109
198
|
|
|
110
199
|
- **统一品牌头部**:Trellis 子进程在伪终端(`node-pty`)中运行,其原生的模板 / monorepo / 冲突等交互完整保留,但重复打印的启动 banner 被过滤,全程只呈现一个 flower banner。
|
|
111
|
-
- **按平台铺设技能**:Claude 铺到 `.claude/skills`,Codex / Gemini 等铺到 `.agents/skills
|
|
200
|
+
- **按平台铺设技能**:Claude 铺到 `.claude/skills`,Codex / Gemini 等铺到 `.agents/skills`;并做平台后处理:Codex 兼容清理旧 `config.toml` 的 `[features.multi_agent_v2]`,在保留上游 hooks 的基础上补全 `SessionStart`;Claude Code 只在 `startup` SessionStart 挂载启动更新检查。
|
|
112
201
|
- **幂等执行**:`workflow.md` 注入前先按 `BEGIN/END` 标记清除旧块再重注入(块数恒定,不会翻倍,首次注入前备份到 `.trellis/.backup-flower/`);技能文件覆盖式铺设,并通过 `.trellis/.flower-manifest.json` 记录已铺路径,升级时删除已淘汰项。
|
|
113
202
|
- **上线事项账本**:强化包通过 finish-work skill override 在归档前智能识别 SQL、配置、批处理 / 部署脚本 / 数据修复、外部系统 / 依赖平台等上线事项,必要时写入任务 `release.md`;`trellis-release` 可在正式上线前核对任务文档、`release.md` 和 git 证据,生成 `YYYY-MM-DD-<release-slug>.md` 格式的版本 / 批次操作单。
|
|
114
203
|
- **安全中止**:`Ctrl+C` 取消后不会继续叠加。
|
|
@@ -22,7 +22,7 @@ If no `release.md` exists:
|
|
|
22
22
|
- High-confidence no release work exists after re-reading task files and git evidence: do not create `release.md`; mention in the final finish-work report that no release operations were identified.
|
|
23
23
|
- Signals are uncertain but release risk exists: write `<task>/release.md` and mark the conclusion as `Needs human review`.
|
|
24
24
|
|
|
25
|
-
Release-operation signals
|
|
25
|
+
Release-operation signals, with the `release.md` section each maps to: SQL or migrations (`SQL Changes`); configuration, environment variables, feature flags, permissions, secrets, or external endpoints (`Configuration Changes`); deployment scripts, one-off commands, data repair, scheduled task triggers, background job reruns, or other batch operations (`Batch / Deployment Scripts / Data Repair`); and external systems or dependent platforms outside the current repository that must be released or coordinated, such as H0 API relay / gateway platforms, messaging platforms, or third-party admin consoles (`External Systems / Dependent Platforms`).
|
|
26
26
|
|
|
27
27
|
When writing or updating `release.md`, use this structure:
|
|
28
28
|
|
|
@@ -64,8 +64,6 @@ Rollback code only.
|
|
|
64
64
|
Verify according to task acceptance criteria.
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Classify deployment scripts, one-off commands, data repairs, scheduled task triggers, and job reruns under `Batch / Deployment Scripts / Data Repair`. Classify systems outside the current repository that need coordinated release, such as H0 API relay platforms, under `External Systems / Dependent Platforms`.
|
|
68
|
-
|
|
69
67
|
Do not write `None`, `No release operations identified`, or `Rollback code only` out of habit. Use those defaults only after checking the task files and git evidence. If the task changed deployment scripts, configuration, SQL, external platforms, permissions, scheduled jobs, or data, record the concrete item and source.
|
|
70
68
|
|
|
71
69
|
If multiple tasks will be archived in the same finish-work run, process the active task at minimum. Process extra archived tasks only when Step 1 provides enough local context to infer safely; do not add per-task confirmation prompts.
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
HIGHEST PRIORITY SKILL-GARDEN STATE GUARD (in_progress-inline):
|
|
3
3
|
This state block is a breadcrumb; the top-level skill-garden hub is the source of truth for route details.
|
|
4
4
|
Before the first implement route, read `<task>/brief.md` if present and restate the task brief in chat. If it is missing, read the task artifacts and suggest backfilling brief; do not silently rely on memory.
|
|
5
|
-
|
|
5
|
+
For new implementation work not plainly covered by the active task title/brief,
|
|
6
|
+
stop before route or edits: recommend a new task; if declined, confirm
|
|
7
|
+
untracked work; if it belongs here, update task artifacts first.
|
|
8
|
+
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py "<intended action>"`; read high-confidence matches before acting; skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
|
|
6
9
|
Inline workflow-state is not an inline route decision. At Phase 2.1/2.2, reuse only an explicit target-matched `route_decision`; otherwise MUST load/read/use `trellis-route(implement|check)` (or its local `SKILL.md`) to resolve session runtime state/prefs, write the resolved decision, or show numbered fallback and wait.
|
|
7
10
|
Plain preferences, ordinary summaries, `codex-mode`, raw `.runtime` files, and empty/old prefs are not route evidence by themselves; only `trellis-route` may validate runtime route state.
|
|
8
11
|
User reselect/override/use-X-this-time/clear-default wins over remembered route evidence, runtime state, and prefs.
|
|
9
12
|
Ignore lower Active Task Routing shortcuts that start editing/checking directly. Do not default to inline just because this state is inline or the helper is unavailable. Dispatch subagents only when the resolved route selected subagent.
|
|
10
13
|
After `trellis-check` / `trellis-check-all`, stop and report; point the user to Phase 3.4 `trellis-push` (or commit-only when needed). Do not run `/trellis:finish-work` unless the user explicitly asks after Phase 3.4 is complete.
|
|
11
14
|
This guard overrides any lower `Flow: ... -> /trellis:finish-work` line in this state block.
|
|
12
|
-
At Phase 3.4, code commit/push
|
|
15
|
+
At Phase 3.4, code commit/push goes through `trellis-push` (commit-only mode for commit-without-push); never bare `git commit`/`git push` on code (hub: Code Commit Confirmation Gate).
|
|
13
16
|
Push snapshot recovery: follow the hub; use `push_snapshot.py status --json` only when needed.
|
|
14
17
|
<!-- END skill-garden workflow-state in_progress_inline v0.6 -->
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
HIGHEST PRIORITY SKILL-GARDEN STATE GUARD (in_progress):
|
|
3
3
|
This state block is a breadcrumb; the top-level skill-garden hub is the source of truth for route details.
|
|
4
4
|
Before the first implement route, read `<task>/brief.md` if present and restate the task brief in chat. If it is missing, read the task artifacts and suggest backfilling brief; do not silently rely on memory.
|
|
5
|
-
|
|
5
|
+
For new implementation work not plainly covered by the active task title/brief,
|
|
6
|
+
stop before route or edits: recommend a new task; if declined, confirm
|
|
7
|
+
untracked work; if it belongs here, update task artifacts first.
|
|
8
|
+
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py "<intended action>"`; read high-confidence matches before acting; skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
|
|
6
9
|
At Phase 2.1/2.2, reuse only an explicit target-matched `route_decision`; otherwise MUST load/read/use `trellis-route(implement|check)` (or its local `SKILL.md`) to resolve session runtime state/prefs, write the resolved decision, or show numbered fallback and wait.
|
|
7
10
|
Plain preferences, ordinary summaries, `codex-mode`, raw `.runtime` files, and empty/old prefs are not route evidence by themselves; only `trellis-route` may validate runtime route state.
|
|
8
11
|
User reselect/override/use-X-this-time/clear-default wins over remembered route evidence, runtime state, and prefs.
|
|
@@ -3,7 +3,7 @@ HIGHEST PRIORITY SKILL-GARDEN STATE GUARD (no_task):
|
|
|
3
3
|
Creating or resuming a task is not implementation permission.
|
|
4
4
|
After PRD is ready and the task is started, the next implementation action is Phase 2.1 `trellis-route(implement)` unless a valid current-task implement route decision already exists.
|
|
5
5
|
If no active task exists, use `push_snapshot.py status --json` once per session; if it returns candidates, relay them and suggest rebinding before resuming.
|
|
6
|
-
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py
|
|
6
|
+
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py "<intended action>"`; read high-confidence matches before acting; skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
|
|
7
7
|
Do NOT call the harness built-in plan mode (`EnterPlanMode` / `ExitPlanMode`) for Trellis planning. It is not a substitute for Trellis task-creation consent, Trellis planning, or the route gate. For complex work, classify the turn, ask for task-creation consent, then use `trellis-brainstorm`.
|
|
8
8
|
If the turn is a meta edit to Trellis itself and Trellis tracking would be overkill, say so and ask to skip Trellis; never silently swap built-in plan mode in for the consent gate.
|
|
9
9
|
<!-- END skill-garden workflow-state no_task v0.6 -->
|
|
@@ -4,6 +4,6 @@ Planning is not implementation permission.
|
|
|
4
4
|
Complete prd.md + required context first.
|
|
5
5
|
If the active workflow later routes to sub-agent execution, required context includes real curated entries in both `implement.jsonl` and `check.jsonl`; the seed `_example` row alone is not ready.
|
|
6
6
|
Before `task.py start`, use `trellis-task-brief` to refresh `brief.md` from the latest task artifacts and display it in chat for review.
|
|
7
|
-
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py
|
|
7
|
+
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py "<intended action>"`; read high-confidence matches before acting; skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
|
|
8
8
|
After status becomes in_progress, next action = `trellis-route(implement)`, not direct edits.
|
|
9
9
|
<!-- END skill-garden workflow-state planning_inline v0.6 -->
|
|
@@ -4,6 +4,6 @@ Planning is not implementation permission.
|
|
|
4
4
|
Complete prd.md + required context first.
|
|
5
5
|
For sub-agent-dispatch platforms, required context includes real curated entries in both `implement.jsonl` and `check.jsonl`; the seed `_example` row alone is not ready.
|
|
6
6
|
Before `task.py start`, use `trellis-task-brief` to refresh `brief.md` from the latest task artifacts and display it in chat for review.
|
|
7
|
-
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py
|
|
7
|
+
At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py "<intended action>"`; read high-confidence matches before acting; skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
|
|
8
8
|
After status becomes in_progress, next action = `trellis-route(implement)`, not direct edits.
|
|
9
9
|
<!-- END skill-garden workflow-state planning v0.6 -->
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
**Priority**: This hub overrides any conflicting Trellis workflow, skill, or command text for the scoped behaviors below.
|
|
8
8
|
|
|
9
|
-
**Scope**:
|
|
9
|
+
**Scope**: the behaviors covered by the sections below. State blocks should keep one short skill-garden sentinel; long-form rules live here.
|
|
10
10
|
|
|
11
11
|
**Mechanical rule**: use this hub as the source of truth. Do not add separate top-level skill-garden override sections or multiple skill-garden sentinels inside the same `workflow-state:*` block.
|
|
12
12
|
|
|
13
13
|
#### Project Knowledge Discovery
|
|
14
14
|
|
|
15
15
|
Before choosing an approach for non-trivial project work, run project knowledge
|
|
16
|
-
discovery when project-local SOPs, package conventions, workflow rules,
|
|
17
|
-
config/state contracts, release/publish/deploy steps, git history actions,
|
|
18
|
-
data changes, cross-layer design, generated artifacts,
|
|
19
|
-
or destructive operations may affect the correct approach:
|
|
16
|
+
discovery when project-local SOPs, package conventions, workflow rules (CI, hooks),
|
|
17
|
+
config/state contracts, release/publish/deploy/rollback steps, git history actions,
|
|
18
|
+
data changes or fixes (including migrations), cross-layer design, generated artifacts,
|
|
19
|
+
install/sync pipelines, or destructive operations may affect the correct approach:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
python3 ./.trellis/scripts/spec_router.py "<short query describing the intended action>"
|
|
@@ -24,8 +24,7 @@ python3 ./.trellis/scripts/spec_router.py "<short query describing the intended
|
|
|
24
24
|
|
|
25
25
|
Build the query from the current user request plus relevant immediate context:
|
|
26
26
|
the intended action, commands about to run, files or systems involved, package/layer,
|
|
27
|
-
and domain words
|
|
28
|
-
hooks, rollback, data fix, generated artifact, install/sync pipeline, or destructive command.
|
|
27
|
+
and domain words matching the trigger list above.
|
|
29
28
|
|
|
30
29
|
Read high-confidence matches before acting. For medium-confidence matches, read only
|
|
31
30
|
when the path, heading, index description, or reason clearly fits the intended change.
|
|
@@ -43,6 +42,16 @@ Before Phase 1.4 `task.py start`, use `trellis-task-brief` to refresh `<task>/br
|
|
|
43
42
|
|
|
44
43
|
Before the first implement route, restate existing `<task>/brief.md` in chat. If missing, read task artifacts and suggest backfilling brief; do not invent one from memory.
|
|
45
44
|
|
|
45
|
+
#### Active Task Scope Guard
|
|
46
|
+
|
|
47
|
+
When a session already has an active task, do not treat unrelated new implementation
|
|
48
|
+
requests as permission to implement under that task. If the work is not plainly
|
|
49
|
+
covered by the active task title/brief, recommend creating a new Trellis task
|
|
50
|
+
and stop before `trellis-route` or file edits. If the user explicitly declines
|
|
51
|
+
task tracking, confirm untracked work first and do not use active-task artifacts
|
|
52
|
+
or progress for that work. If the user says it belongs to the active task,
|
|
53
|
+
update that task's artifacts before implementation.
|
|
54
|
+
|
|
46
55
|
#### Routing Gate
|
|
47
56
|
|
|
48
57
|
Phase 2.1 implement and Phase 2.2 check/check-all require route evidence before execution.
|
|
@@ -50,11 +59,10 @@ Phase 2.1 implement and Phase 2.2 check/check-all require route evidence before
|
|
|
50
59
|
At each route boundary:
|
|
51
60
|
|
|
52
61
|
1. Reuse only an explicit, target-matched `route_decision` already present in the current context.
|
|
53
|
-
2. Otherwise you MUST
|
|
54
|
-
3. If the
|
|
55
|
-
4. If the route helper cannot ask through `AskUserQuestion` / `request_user_input`, ask the same numbered choices from `trellis-route` in normal chat and wait.
|
|
62
|
+
2. Otherwise you MUST invoke `trellis-route(target=implement|check)` before deciding; if the platform cannot invoke skills directly, read the local `trellis-route/SKILL.md` copy and follow its numbered fallback choices in normal chat and wait. `trellis-route` owns session runtime recovery, `.route-prefs.tmp`, fallback choices, runtime-state writes, and dispatch mapping.
|
|
63
|
+
3. If the route helper cannot ask through `AskUserQuestion` / `request_user_input`, ask the same numbered choices from `trellis-route` in normal chat and wait.
|
|
56
64
|
|
|
57
|
-
Plain user preference, ordinary compact/SessionStart
|
|
65
|
+
Plain user preference, ordinary summaries (compact/SessionStart or otherwise), replacement history, historical bare numeric replies, `codex-mode`, empty/old prefs, and raw `.trellis/.runtime/sessions/*` `route_decisions` content that has not been validated by `trellis-route` are not route evidence by themselves; numbered fallback validity is governed by `trellis-route`.
|
|
58
66
|
|
|
59
67
|
User reselect/override/use-X-this-time/clear-default wins over remembered route evidence, runtime state, and personal prefs.
|
|
60
68
|
|
|
@@ -62,9 +70,7 @@ At Phase 2.1/2.2, this gate overrides lower "Active Task Routing" rows that say
|
|
|
62
70
|
|
|
63
71
|
#### Post-Check Stop Gate
|
|
64
72
|
|
|
65
|
-
After `trellis-check` or `trellis-check-all` finishes, stop and report the result
|
|
66
|
-
|
|
67
|
-
If checks pass, the next allowed workflow steps are Phase 3.3 `trellis-update-spec` and Phase 3.4 `trellis-push`/commit confirmation. `/trellis:finish-work` is explicit-only: run it only after Phase 3.4 is complete and the user asks to wrap up, archive, or finish the task.
|
|
73
|
+
After `trellis-check` or `trellis-check-all` finishes, stop and report the result. If checks pass, the next allowed workflow steps are Phase 3.3 `trellis-update-spec` and Phase 3.4 `trellis-push`/commit confirmation (commit-only when needed); do not archive the task or imply it is ready to wrap up solely because checks passed. `/trellis:finish-work` is explicit-only: run it only after Phase 3.4 is complete and the user asks to wrap up, archive, or finish the task.
|
|
68
74
|
|
|
69
75
|
During a running `trellis-auto-loop`, the runner's `record` + `next` replaces the post-check stop gate: after a check pass, record the result, then continue to spec update / commit-only according to `.trellis/scripts/auto_loop.py`. Outside auto-loop, keep the normal stop gate.
|
|
70
76
|
|
|
@@ -84,7 +90,7 @@ This exception does not apply to ordinary `trellis-push`. If the plan contains u
|
|
|
84
90
|
|
|
85
91
|
#### Bookkeeping Auto-commit Scope
|
|
86
92
|
|
|
87
|
-
`session_auto_commit` only governs the bookkeeping commits `task.py archive` / `add_session.py` make for their own `.trellis/tasks/**` and `.trellis/workspace/**` files
|
|
93
|
+
`session_auto_commit` only governs the bookkeeping commits `task.py archive` / `add_session.py` make for their own `.trellis/tasks/**` and `.trellis/workspace/**` files. When `false`, those archive/journal writes stay disk-only (no compensating `git commit`).
|
|
88
94
|
|
|
89
95
|
#### Push Progress Recovery / Snapshot
|
|
90
96
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"syncedAt": "2026-07-
|
|
2
|
+
"syncedAt": "2026-07-07T06:26:20.520Z",
|
|
3
3
|
"syncedFrom": "vendor/skill-garden",
|
|
4
|
-
"sourceCommit": "
|
|
4
|
+
"sourceCommit": "5fdebe60e923c91ba912461b99413b5c8e11a38c",
|
|
5
5
|
"common": {
|
|
6
6
|
"codexSkills": [
|
|
7
7
|
"craft-rpa",
|
package/package.json
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""SessionStart 启动更新检查 hook。
|
|
4
|
+
|
|
5
|
+
脚本只做只读检查和上下文注入:调用 `flower-trellis self-check --json`,
|
|
6
|
+
发现可执行更新时输出 `<flower-update>` 块。失败、离线、无更新或关闭检查时静默退出,
|
|
7
|
+
避免影响 Codex / Claude Code 正常启动。
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
ACTIONABLE_STATUSES = {"update_available", "project_out_of_sync"}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _debug(message: str) -> None:
|
|
23
|
+
"""在显式调试时输出简短错误。"""
|
|
24
|
+
if os.environ.get("FLOWER_UPDATE_HOOK_DEBUG"):
|
|
25
|
+
print(f"flower_update_hook: {message}", file=sys.stderr)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _project_dir(hook_input: dict) -> Path:
|
|
29
|
+
"""从平台环境变量或 hook stdin 解析项目目录。"""
|
|
30
|
+
for name in (
|
|
31
|
+
"CLAUDE_PROJECT_DIR",
|
|
32
|
+
"CODEX_PROJECT_DIR",
|
|
33
|
+
"CURSOR_PROJECT_DIR",
|
|
34
|
+
"GEMINI_PROJECT_DIR",
|
|
35
|
+
"QODER_PROJECT_DIR",
|
|
36
|
+
"CODEBUDDY_PROJECT_DIR",
|
|
37
|
+
"TRAE_PROJECT_DIR",
|
|
38
|
+
):
|
|
39
|
+
value = os.environ.get(name)
|
|
40
|
+
if value:
|
|
41
|
+
return Path(value).resolve()
|
|
42
|
+
return Path(str(hook_input.get("cwd") or ".")).resolve()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _run_self_check(project_dir: Path) -> dict | None:
|
|
46
|
+
"""执行 flower-trellis self-check 并解析 JSON。"""
|
|
47
|
+
try:
|
|
48
|
+
result = subprocess.run(
|
|
49
|
+
[
|
|
50
|
+
"flower-trellis",
|
|
51
|
+
"self-check",
|
|
52
|
+
"--json",
|
|
53
|
+
"--target",
|
|
54
|
+
str(project_dir),
|
|
55
|
+
],
|
|
56
|
+
capture_output=True,
|
|
57
|
+
text=True,
|
|
58
|
+
encoding="utf-8",
|
|
59
|
+
errors="replace",
|
|
60
|
+
timeout=8,
|
|
61
|
+
cwd=str(project_dir),
|
|
62
|
+
)
|
|
63
|
+
except (subprocess.TimeoutExpired, FileNotFoundError, PermissionError) as exc:
|
|
64
|
+
_debug(str(exc))
|
|
65
|
+
return None
|
|
66
|
+
if result.returncode != 0:
|
|
67
|
+
_debug(result.stderr.strip() or f"退出码 {result.returncode}")
|
|
68
|
+
return None
|
|
69
|
+
try:
|
|
70
|
+
data = json.loads(result.stdout)
|
|
71
|
+
except json.JSONDecodeError as exc:
|
|
72
|
+
_debug(f"JSON 解析失败:{exc}")
|
|
73
|
+
return None
|
|
74
|
+
return data if isinstance(data, dict) else None
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _format_context(data: dict) -> str:
|
|
78
|
+
"""把 self-check JSON 转成给 AI 读取的短上下文块。"""
|
|
79
|
+
current = data.get("current") or {}
|
|
80
|
+
project = data.get("project") or {}
|
|
81
|
+
remote = data.get("remote") or {}
|
|
82
|
+
ai = data.get("ai") or {}
|
|
83
|
+
safety = data.get("safety") or {}
|
|
84
|
+
lines = [
|
|
85
|
+
"<flower-update>",
|
|
86
|
+
f"status: {data.get('status')}",
|
|
87
|
+
f"policy: {data.get('policy')}",
|
|
88
|
+
f"current_flower: {current.get('flowerVersion')}",
|
|
89
|
+
f"project_flower: {project.get('flowerVersion')}",
|
|
90
|
+
f"bundled_trellis: {current.get('bundledTrellisVersion')}",
|
|
91
|
+
f"project_trellis: {project.get('trellisVersion')}",
|
|
92
|
+
]
|
|
93
|
+
if remote.get("tags"):
|
|
94
|
+
lines.append(f"remote: {json.dumps(remote.get('tags'), ensure_ascii=False)}")
|
|
95
|
+
command = (data.get("commands") or {}).get("recommended") or ai.get("command")
|
|
96
|
+
if command:
|
|
97
|
+
lines.append(f"recommended_command: {command}")
|
|
98
|
+
if safety.get("reasons"):
|
|
99
|
+
lines.append(f"safety_reasons: {', '.join(safety.get('reasons') or [])}")
|
|
100
|
+
if ai.get("instruction"):
|
|
101
|
+
lines.append(f"ai_instruction: {ai.get('instruction')}")
|
|
102
|
+
lines.append("</flower-update>")
|
|
103
|
+
return "\n".join(lines)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _emit_context(context: str) -> None:
|
|
107
|
+
"""同时兼容 Codex / Claude Code / Cursor 风格的 hook JSON 输出。"""
|
|
108
|
+
result = {
|
|
109
|
+
"suppressOutput": True,
|
|
110
|
+
"systemMessage": "flower-trellis update context injected",
|
|
111
|
+
"hookSpecificOutput": {
|
|
112
|
+
"hookEventName": "SessionStart",
|
|
113
|
+
"additionalContext": context,
|
|
114
|
+
},
|
|
115
|
+
"additional_context": context,
|
|
116
|
+
}
|
|
117
|
+
print(json.dumps(result, ensure_ascii=False), flush=True)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def main() -> None:
|
|
121
|
+
try:
|
|
122
|
+
hook_input = json.loads(sys.stdin.read() or "{}")
|
|
123
|
+
if not isinstance(hook_input, dict):
|
|
124
|
+
hook_input = {}
|
|
125
|
+
except json.JSONDecodeError:
|
|
126
|
+
hook_input = {}
|
|
127
|
+
|
|
128
|
+
data = _run_self_check(_project_dir(hook_input))
|
|
129
|
+
if not data or data.get("status") not in ACTIONABLE_STATUSES:
|
|
130
|
+
return
|
|
131
|
+
_emit_context(_format_context(data))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if __name__ == "__main__":
|
|
135
|
+
main()
|
package/src/cli.js
CHANGED
|
@@ -66,6 +66,9 @@ function printHelp() {
|
|
|
66
66
|
用法:
|
|
67
67
|
flower-trellis [init] [trellis flags] [flower flags] 安装 + 叠加强化包(默认命令)
|
|
68
68
|
flower-trellis update [trellis flags] [flower flags] 升级 + 按新版本重新叠加
|
|
69
|
+
flower-trellis self-check --json [--target <dir>] 输出启动更新检查 JSON
|
|
70
|
+
flower-trellis self-update --target <dir> --yes 自更新 + 项目重叠加
|
|
71
|
+
flower-trellis update-check <get|set|disable|enable> 管理启动更新策略
|
|
69
72
|
flower-trellis skill [flower flags] 交互管理通用技能
|
|
70
73
|
flower-trellis uninstall [-y | --dry-run] 卸载 + 清理强化残留
|
|
71
74
|
flower-trellis <其它命令> [...] 透传给 trellis(面向未来)
|
|
@@ -79,6 +82,12 @@ flower 自有 flag:
|
|
|
79
82
|
--target <dir> 目标目录(默认当前目录)
|
|
80
83
|
--no-update-check 本次跳过 flower-trellis 新版本检测(等价 FLOWER_NO_UPDATE_CHECK=1)
|
|
81
84
|
|
|
85
|
+
启动更新检查:
|
|
86
|
+
self-check --json 稳定输出检查 JSON
|
|
87
|
+
self-update --yes [--dry-run] 执行或预览全局更新与项目 update
|
|
88
|
+
update-check set --policy <off|notify|ask|auto> [--interval-hours <n>]
|
|
89
|
+
update-check disable|enable 只切换 enabled,不覆盖已选 policy
|
|
90
|
+
|
|
82
91
|
命令别名:flower-trellis 可简写为 ftl 或 ft(三者完全等价)。
|
|
83
92
|
init / update 启动时会顺带检测 flower-trellis 自身是否有新版(联网、带超时,失败静默)。
|
|
84
93
|
skill 可启用或停用通用技能,并只读展示工作流强化包。
|
|
@@ -99,9 +108,17 @@ function parse(argv) {
|
|
|
99
108
|
let updateCheck = true;
|
|
100
109
|
const skills = [];
|
|
101
110
|
const passthrough = [];
|
|
111
|
+
const forwarded = [];
|
|
102
112
|
|
|
103
113
|
for (let i = 0; i < argv.length; i++) {
|
|
104
114
|
const a = argv[i];
|
|
115
|
+
if (a === "--") {
|
|
116
|
+
forwarded.push(...argv.slice(i + 1));
|
|
117
|
+
if (command !== "self-update") {
|
|
118
|
+
passthrough.push(...argv.slice(i + 1));
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
105
122
|
// 第一个非 flag token 视为子命令
|
|
106
123
|
if (command === null && !a.startsWith("-")) {
|
|
107
124
|
command = a;
|
|
@@ -143,6 +160,7 @@ function parse(argv) {
|
|
|
143
160
|
skills,
|
|
144
161
|
variant,
|
|
145
162
|
updateCheck,
|
|
163
|
+
forwarded,
|
|
146
164
|
},
|
|
147
165
|
};
|
|
148
166
|
}
|
|
@@ -179,6 +197,15 @@ async function main() {
|
|
|
179
197
|
} else if (cmd === "update") {
|
|
180
198
|
const { update } = await import("./commands/update.js");
|
|
181
199
|
await update(ctx);
|
|
200
|
+
} else if (cmd === "self-check") {
|
|
201
|
+
const { selfCheck } = await import("./commands/self-check.js");
|
|
202
|
+
await selfCheck(ctx);
|
|
203
|
+
} else if (cmd === "self-update") {
|
|
204
|
+
const { selfUpdate } = await import("./commands/self-update.js");
|
|
205
|
+
await selfUpdate(ctx);
|
|
206
|
+
} else if (cmd === "update-check") {
|
|
207
|
+
const { updateCheck } = await import("./commands/update-check.js");
|
|
208
|
+
await updateCheck(ctx);
|
|
182
209
|
} else if (cmd === "skill") {
|
|
183
210
|
const { skill } = await import("./commands/skill.js");
|
|
184
211
|
await skill(ctx);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildSelfCheck } from "../lib/self-check.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* flower-trellis self-check:输出结构化启动更新检查结果。
|
|
5
|
+
*
|
|
6
|
+
* 供 Codex / Claude Code SessionStart hook 和 AI 自动化读取。无论是否发现更新,
|
|
7
|
+
* 都稳定输出 JSON,避免 hook 侧靠空 stdout 猜状态。
|
|
8
|
+
*
|
|
9
|
+
* @param {object} ctx 见 cli.js 的 parse()
|
|
10
|
+
* @returns {Promise<void>}
|
|
11
|
+
*/
|
|
12
|
+
export async function selfCheck(ctx) {
|
|
13
|
+
const forceRemote = ctx.passthrough.includes("--force-remote");
|
|
14
|
+
if (ctx.updateCheck === false) {
|
|
15
|
+
process.env.FLOWER_NO_UPDATE_CHECK = "1";
|
|
16
|
+
}
|
|
17
|
+
const result = await buildSelfCheck(ctx.target, { forceRemote });
|
|
18
|
+
console.log(JSON.stringify(result, null, 2));
|
|
19
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import {
|
|
3
|
+
buildSelfCheck,
|
|
4
|
+
projectUpdateCommand,
|
|
5
|
+
projectUpdateForwardArgs,
|
|
6
|
+
safetyState,
|
|
7
|
+
} from "../lib/self-check.js";
|
|
8
|
+
|
|
9
|
+
/** 判断参数里是否包含指定 flag。 */
|
|
10
|
+
function hasFlag(args, name) {
|
|
11
|
+
return args.includes(name);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 执行命令并在失败时给出统一错误。 */
|
|
15
|
+
function runCommand(command, args, cwd, failureMessage) {
|
|
16
|
+
const res = spawnSync(command, args, {
|
|
17
|
+
cwd,
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
shell: process.platform === "win32",
|
|
20
|
+
});
|
|
21
|
+
if (res.status !== 0) {
|
|
22
|
+
const reason = res.error ? res.error.message : `退出码 ${res.status ?? 1}`;
|
|
23
|
+
throw new Error(`${failureMessage}(${reason})`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* flower-trellis self-update:执行受控自更新与项目重叠加。
|
|
29
|
+
*
|
|
30
|
+
* 默认项目 update 阶段追加 `--force`,等价 Trellis 交互里的 Apply Overwrite to all。
|
|
31
|
+
* 用户可通过 `--` 透传 `--skip-all` / `--create-new` 等上游冲突策略覆盖默认。
|
|
32
|
+
*
|
|
33
|
+
* @param {object} ctx 见 cli.js 的 parse()
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
export async function selfUpdate(ctx) {
|
|
37
|
+
const dryRun = hasFlag(ctx.passthrough, "--dry-run");
|
|
38
|
+
const yes = hasFlag(ctx.passthrough, "--yes") || hasFlag(ctx.passthrough, "-y");
|
|
39
|
+
const projectOnly = hasFlag(ctx.passthrough, "--project-only");
|
|
40
|
+
const forwarded = ctx.forwarded || [];
|
|
41
|
+
const projectArgs = [
|
|
42
|
+
"update",
|
|
43
|
+
"--target",
|
|
44
|
+
ctx.target,
|
|
45
|
+
"--no-update-check",
|
|
46
|
+
...projectUpdateForwardArgs(forwarded),
|
|
47
|
+
];
|
|
48
|
+
const check = await buildSelfCheck(ctx.target, {
|
|
49
|
+
writeCache: !dryRun,
|
|
50
|
+
forceRemote: !projectOnly,
|
|
51
|
+
});
|
|
52
|
+
const shouldInstallFlower = !projectOnly && check.status === "update_available" && check.recommendation;
|
|
53
|
+
const effectiveSafety = check.safety || safetyState(
|
|
54
|
+
ctx.target,
|
|
55
|
+
projectOnly ? "project_out_of_sync" : check.status,
|
|
56
|
+
projectUpdateCommand(ctx.target, forwarded),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (dryRun) {
|
|
60
|
+
console.log("self-update dry-run:");
|
|
61
|
+
if (shouldInstallFlower) {
|
|
62
|
+
console.log(` · 全局升级:${check.recommendation.command}`);
|
|
63
|
+
} else {
|
|
64
|
+
console.log(" · 全局升级:跳过");
|
|
65
|
+
}
|
|
66
|
+
console.log(` · 项目更新:${projectUpdateCommand(ctx.target, forwarded)}`);
|
|
67
|
+
console.log(` · 当前状态:${check.status}`);
|
|
68
|
+
console.log(` · 目标:${ctx.target}`);
|
|
69
|
+
console.log(` · 当前 flower:${check.current?.flowerVersion || "unknown"}`);
|
|
70
|
+
console.log(` · 项目 flower:${check.project?.flowerVersion || "unknown"}`);
|
|
71
|
+
console.log(` · 捆绑 Trellis:${check.current?.bundledTrellisVersion || "unknown"}`);
|
|
72
|
+
console.log(` · 项目 Trellis:${check.project?.trellisVersion || "unknown"}`);
|
|
73
|
+
console.log(
|
|
74
|
+
` · 安全检查:${effectiveSafety.safe ? "通过" : `需确认(${effectiveSafety.reasons.join(", ") || "无可用结果"})`}`,
|
|
75
|
+
);
|
|
76
|
+
console.log(` · 写入:否`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!yes) {
|
|
81
|
+
throw new Error("self-update 执行写入前需要 --yes;如需预览请使用 --dry-run");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!shouldInstallFlower && !projectOnly && check.status !== "project_out_of_sync") {
|
|
85
|
+
console.log(` · 当前状态:${check.status},无需执行 self-update`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (shouldInstallFlower) {
|
|
90
|
+
runCommand(
|
|
91
|
+
"npm",
|
|
92
|
+
["i", "-g", `flower-trellis@${check.recommendation.tag}`],
|
|
93
|
+
ctx.target,
|
|
94
|
+
"全局 flower-trellis 升级失败",
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
console.log(" · 跳过全局 flower-trellis 升级");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
runCommand(
|
|
101
|
+
"flower-trellis",
|
|
102
|
+
projectArgs,
|
|
103
|
+
ctx.target,
|
|
104
|
+
"目标项目重叠加失败,请手动运行:" + projectUpdateCommand(ctx.target, forwarded),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
console.log(`\n🌸 flower-trellis self-update 完成 → ${ctx.target}`);
|
|
108
|
+
}
|