flower-trellis 0.4.0-beta.5 → 0.4.1

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.
@@ -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 include SQL or migrations; configuration, environment variables, feature flags, permissions, secrets, or external endpoints; deployment scripts, one-off commands, data repair, scheduled task triggers, background job reruns, or other batch operations; and external systems or dependent platforms that must be released or coordinated, such as H0 API relay / gateway platforms, messaging platforms, or third-party admin consoles.
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
- At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py` with a short query describing the intended action; read high-confidence matches before acting and skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
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 still goes through `trellis-push` (commit-only for commit-without-push); never bare `git commit`/`git push` on code (hub: Code Commit Confirmation Gate).
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
- At project-local knowledge decision boundaries, run `.trellis/scripts/spec_router.py` with a short query describing the intended action; read high-confidence matches before acting and skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
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` with a short query describing the intended action; read high-confidence matches before acting and skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
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` with a short query describing the intended action; read high-confidence matches before acting and skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
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` with a short query describing the intended action; read high-confidence matches before acting and skip pure Q&A, simple read-only inspection, opening local tools, or trivial edits unless local conventions may affect the approach.
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**: project knowledge discovery at project-local knowledge decision boundaries, Phase 1.4 task brief handoff, Phase 2.1 implement routing, Phase 2.2 check/check-all routing, current-task route reuse, post-check stop, auto-loop commit-only preauthorization, Phase 3.4 trellis-push, explicit Phase 3.5 finish-work bookkeeping, and push-progress recovery. State blocks should keep one short skill-garden sentinel; long-form rules live here.
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, install/sync pipelines,
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 such as release, publish, deploy, migration, config, CI, workflow,
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 load/read/use `trellis-route(target=implement|check)` before deciding. `trellis-route` owns session runtime recovery, `.route-prefs.tmp`, fallback choices, runtime-state writes, and dispatch mapping.
54
- 3. If the platform cannot invoke skills directly, open the local `trellis-route/SKILL.md` copy first, then follow its numbered fallback choices in normal chat and wait.
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 summary, ordinary summary, 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`.
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; point the user to Phase 3.4 `trellis-push` (or commit-only when needed). Do not run `/trellis:finish-work`, do not archive the task, and do not imply the task is ready to wrap up solely because checks passed.
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 — never code (gated above). When `false`, those archive/journal writes stay disk-only (no compensating `git commit`).
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,14 +1,13 @@
1
1
  {
2
- "syncedAt": "2026-07-02T01:39:38.800Z",
2
+ "syncedAt": "2026-07-06T15:58:44.168Z",
3
3
  "syncedFrom": "vendor/skill-garden",
4
- "sourceCommit": "39a09335cc3e2878c1e1121137dd55524882b13f",
4
+ "sourceCommit": "5fdebe60e923c91ba912461b99413b5c8e11a38c",
5
5
  "common": {
6
6
  "codexSkills": [
7
7
  "craft-rpa",
8
8
  "craft-slides",
9
9
  "humanize-writing",
10
10
  "open-idea",
11
- "sub2api-account-json-fix",
12
11
  "torrent-analyze"
13
12
  ],
14
13
  "claudeSkills": [
@@ -16,7 +15,6 @@
16
15
  "craft-slides",
17
16
  "humanize-writing",
18
17
  "open-idea",
19
- "sub2api-account-json-fix",
20
18
  "torrent-analyze"
21
19
  ]
22
20
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flower-trellis",
3
- "version": "0.4.0-beta.5",
3
+ "version": "0.4.1",
4
4
  "description": "一键安装/升级 Trellis 并自动融合 skill-garden 强化包(默认 Claude + agents)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,7 +40,6 @@ const SKILL_DESCRIPTION_OVERRIDES = {
40
40
  "plan-version": "规划版本任务、波次和分工",
41
41
  push: "提交、推送并同步任务进度",
42
42
  "re-implement": "需求变更后重新实现",
43
- "sub2api-account-json-fix": "批量补全并推送 sub2api 账号 JSON",
44
43
  "sync-prd": "根据代码或需求变化同步 PRD",
45
44
  "torrent-analyze": "解析磁链或种子 hash 并整理信息",
46
45
  "trellis-analyze-task": "深度分析并细化任务",
@@ -1,47 +0,0 @@
1
- ---
2
- name: sub2api-account-json-fix
3
- description: 修正当前项目里的 sub2api 账号导出 JSON,并把这些账号直接推送到 sub2api admin 接口。用于批量推送 `sub2api-account-*.json` 到远端 sub2api,尤其适合先同步模板里的 `model_mapping`、`allow_overages`,再按指定 group_ids 创建账号。
4
- argument-hint: <template-json> [target-json...]
5
- disable-model-invocation: true
6
- ---
7
-
8
- # Sub2API 账号推送
9
-
10
- 先确认模板账号,再运行项目内的推送脚本。
11
-
12
- ## 规则
13
-
14
- - 先用模板账号补齐目标账号的 `credentials.model_mapping`。
15
- - 确保目标账号包含 `extra.allow_overages`。
16
- - 把 `name` 改成 `credentials.email`。
17
- - 然后把代理推送到 sub2api,再逐个创建账号。
18
- - 创建账号后默认立刻关闭调度。
19
- - 如果账号带有 `refresh_token`,创建后默认立刻调用一次 refresh,确保远端拿到最新 access token。
20
- - 如果 `.claude/skills/sub2api-account-json-fix/env/push.env` 不存在,继续检查系统环境变量。
21
- - 如果地址或 token 仍未配置,或者 token 还是 `admin-xxxx` 这种示例值,先向用户索要真实值,不要直接推送。
22
-
23
- ## 技能目录配置
24
-
25
- 优先读取:
26
-
27
- - `.claude/skills/sub2api-account-json-fix/env/push.env`
28
-
29
- 支持这些键:
30
-
31
- - `SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL`
32
- - `SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN`
33
- - `SUB2API_ACCOUNT_JSON_FIX_PUSH_GROUP_IDS`
34
- - `SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE`
35
- - `SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE`
36
-
37
- ## 执行方式
38
-
39
- 如果用户给了参数,按“第一个参数是模板文件,后续参数是目标文件”的规则执行;否则先向用户确认模板文件。
40
-
41
- 运行:
42
-
43
- ```bash
44
- bash .claude/skills/sub2api-account-json-fix/scripts/run.sh $ARGUMENTS
45
- ```
46
-
47
- 如果用户没有显式要求写回本地文件,就不要自动加 `--write`;先预览或直接推送内存中的规范化结果即可。
@@ -1,8 +0,0 @@
1
- # Claude Code 项目技能的本地配置示例。
2
- # 把本文件复制为同目录下的 push.env 后再填写真实值。
3
-
4
- SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL=http://127.0.0.1:8080/api/v1/admin
5
- SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN=admin-xxxx
6
- SUB2API_ACCOUNT_JSON_FIX_PUSH_GROUP_IDS=3,7
7
- SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE=false
8
- SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE=true
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
5
- CLAUDE_SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
6
- SKILL_GARDEN_ROOT="$(cd "$CLAUDE_SKILL_DIR/../../.." && pwd -P)"
7
- MAIN_SCRIPT="$SKILL_GARDEN_ROOT/.codex/skills/sub2api-account-json-fix/scripts/fix_exported_account_json.py"
8
- LOCAL_ENV_FILE="$CLAUDE_SKILL_DIR/env/push.env"
9
-
10
- export SUB2API_ACCOUNT_JSON_FIX_ENV_FILE="$LOCAL_ENV_FILE"
11
-
12
- if [[ -f "$LOCAL_ENV_FILE" ]]; then
13
- set -a
14
- # shellcheck disable=SC1090
15
- source "$LOCAL_ENV_FILE"
16
- set +a
17
- fi
18
-
19
- if [[ $# -lt 1 ]]; then
20
- echo "用法: run.sh <template-json> [target-json...]" >&2
21
- exit 2
22
- fi
23
-
24
- TEMPLATE_FILE="$1"
25
- shift
26
-
27
- python "$MAIN_SCRIPT" --template "$TEMPLATE_FILE" "$@" --push
@@ -1,126 +0,0 @@
1
- ---
2
- name: sub2api-account-json-fix
3
- description: 按模板批量补全 sub2api 账号导出 JSON,修复 `accounts[].name` 与 `credentials.email` 不一致、缺失 `credentials.model_mapping`、缺失 `extra.allow_overages` 等问题,并把这些账号直接推送到 sub2api admin 创建接口。用于处理 `sub2api-account-*.json` 这类导出文件,尤其适合“先规范化 JSON,再批量推送到 sub2api 指定分组”的场景。
4
- ---
5
-
6
- # Sub2API 账号 JSON 补全
7
-
8
- ## 概览
9
-
10
- 先确认模板 JSON,再用脚本批量修复目标文件。默认修复三件事:
11
-
12
- - 把每个账号的 `credentials.model_mapping` 同步成模板账号的值
13
- - 确保每个账号都包含 `extra.allow_overages`
14
- - 把 `name` 改成该账号 `credentials.email`
15
-
16
- 脚本只改这些字段,不会删除其他 `credentials`、`extra`、代理、并发、优先级或 token 字段。
17
-
18
- ## 工作流
19
-
20
- 1. 读取模板文件,默认使用模板中的第一个账号。
21
- 2. 确认模板账号里已经有正确的 `credentials.model_mapping` 和 `extra.allow_overages`。
22
- 3. 先用预览模式检查哪些文件会被修改。
23
- 4. 确认预览结果后,再用 `--write` 真正写回文件。
24
- 5. 如果要直推到 sub2api,先检查技能目录里的 `env/push.env`;没有再看系统环境变量;还没有才向用户询问直推地址、token 和目标分组 IDs。
25
- 6. 如果 `env/push.env` 里还是示例值
26
- `SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL=http://127.0.0.1:8080/api/v1/admin`
27
- 和 `SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN=admin-xxxx`,把它视为“未配置”,不要直接直推,先向用户索要真实值。
28
- 7. 创建账号后,默认立刻关闭调度;如果账号带有 `refresh_token`,默认立刻调用一次 refresh。
29
-
30
- ## 快速命令
31
-
32
- 先预览:
33
-
34
- ```bash
35
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
36
- --template sub2api-account-20260316021320.json
37
- ```
38
-
39
- 真正写回:
40
-
41
- ```bash
42
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
43
- --template sub2api-account-20260316021320.json \
44
- --write
45
- ```
46
-
47
- 只检查是否还有待修复项,并用退出码表示结果:
48
-
49
- ```bash
50
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
51
- --template sub2api-account-20260316021320.json \
52
- --check
53
- ```
54
-
55
- 把规范化后的账号直接推送到 `sub2api`:
56
-
57
- ```bash
58
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
59
- --template sub2api-account-20260316021320.json \
60
- --push \
61
- --push-admin-base-url http://127.0.0.1:8080/api/v1/admin \
62
- --push-token 'admin-xxxx' \
63
- --push-group-id 3 \
64
- --push-group-id 7
65
- ```
66
-
67
- 也可以预先设置环境变量,调用时不再重复传参:
68
-
69
- ```bash
70
- export SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL='http://127.0.0.1:8080/api/v1/admin'
71
- export SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN='admin-xxxx'
72
- export SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE='false'
73
- export SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE='true'
74
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
75
- --template sub2api-account-20260316021320.json \
76
- --push
77
- ```
78
-
79
- 更推荐把配置放在技能目录里:
80
-
81
- ```bash
82
- cat > sub2api-account-json-fix/env/push.env <<'EOF'
83
- SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL=http://127.0.0.1:8080/api/v1/admin
84
- SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN=admin-xxxx
85
- SUB2API_ACCOUNT_JSON_FIX_PUSH_GROUP_IDS=3,7
86
- SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE=false
87
- SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE=true
88
- EOF
89
- ```
90
-
91
- 指定部分文件:
92
-
93
- ```bash
94
- python sub2api-account-json-fix/scripts/fix_exported_account_json.py \
95
- --template sub2api-account-20260316021320.json \
96
- sub2api-account-20260316015827.json \
97
- sub2api-account-20260316020213.json \
98
- --write
99
- ```
100
-
101
- ## 规则
102
-
103
- - 把模板账号 `credentials.model_mapping` 原样复制到目标账号。
104
- - 只补齐 `extra.allow_overages`,不要覆盖目标账号 `extra` 里的其他键。
105
- - 只有当 `credentials.email` 是非空字符串时,才把 `name` 改成邮箱。
106
- - 默认处理当前工作目录里匹配 `sub2api-account-*.json` 的文件,并自动跳过模板自身。
107
- - 脚本支持一个文件里有多个 `accounts`,会逐个账号处理。
108
-
109
- ## 直推 sub2api
110
-
111
- - 直推固定走 `POST /api/v1/admin/proxies` 和 `POST /api/v1/admin/accounts`。
112
- - 脚本会先确保 JSON 里的代理存在,再按账号逐个创建到 sub2api。
113
- - 如果配置了 `group_ids`,会在创建账号时直接带上 `group_ids`。
114
- - 创建账号后默认会再调用一次 `POST /api/v1/admin/accounts/:id/schedulable`,把调度显式设为关闭。
115
- - 如果账号带有 `refresh_token`,创建账号后默认会再调用一次 `POST /api/v1/admin/accounts/:id/refresh`。
116
- - 直推参数优先级是:命令行参数 > 技能目录 `env/push.env` > 系统环境变量。
117
- - 技能目录配置文件路径固定是 `sub2api-account-json-fix/env/push.env`。
118
- - 支持的键有 `SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL`、`SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN`、`SUB2API_ACCOUNT_JSON_FIX_PUSH_GROUP_IDS`、`SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE`、`SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE`。
119
- - 如果 `push.env` 仍然保留示例值 `admin-xxxx`,脚本会拒绝直推,并要求先替换为真实配置。
120
- - 如果要直推但命令行、技能目录配置和系统环境变量都没给地址或 token,调用这个技能的代理应先询问用户,再决定是否执行 `--push`。
121
- - `group_ids` 为空时,是否触发 sub2api 默认分组绑定,取决于 sub2api 当前创建接口的行为。
122
-
123
- ## 资源
124
-
125
- - `scripts/fix_exported_account_json.py`:批量补全 JSON 的主脚本。
126
- - `env/push.env`:可选的技能目录本地配置文件;不存在时不会报错。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "Sub2API 账号 JSON 补全"
3
- short_description: "按模板批量补全 sub2api 账号导出 JSON 字段"
4
- default_prompt: "使用 $sub2api-account-json-fix 按模板批量补全当前目录里的 sub2api 账号导出 JSON。"
@@ -1,8 +0,0 @@
1
- # 把本文件复制为同目录下的 push.env 后再填写真实值。
2
- # 如果仍保留 admin-xxxx 这样的示例值,脚本会把它视为未配置并拒绝直推。
3
-
4
- SUB2API_ACCOUNT_JSON_FIX_PUSH_ADMIN_BASE_URL=http://127.0.0.1:8080/api/v1/admin
5
- SUB2API_ACCOUNT_JSON_FIX_PUSH_TOKEN=admin-xxxx
6
- SUB2API_ACCOUNT_JSON_FIX_PUSH_GROUP_IDS=3,7
7
- SUB2API_ACCOUNT_JSON_FIX_PUSH_SCHEDULABLE=false
8
- SUB2API_ACCOUNT_JSON_FIX_PUSH_REFRESH_AFTER_CREATE=true