feat(狀態回報): 收尾寫一筆 skill-end 事件
現行紀錄只記「被叫用」,沒有成敗也沒有結束碼。跑完整輪的技能與開場就 中止的技能,在紀錄裡長得一模一樣。 start 由技能用量 hook 順手發,不必改技能文件。end 只能由技能自己在收尾 步驟寫——hook 接在技能工具呼叫上,而實際工作發生在之後的模型輪次,它在 原理上看不到成敗。有 start 沒有配對的 end,就是那一輪中止了。 status 五選一,每支技能各自寫明什麼情況選哪一個。找不到回報腳本就安靜 跳過,回報失敗一律不改變技能自己的結論。
This commit is contained in:
@@ -19,6 +19,21 @@ The link is the only input. The output is one file that opens anywhere, with no
|
||||
Completion condition: the markdown and the document title are in hand, exactly one kind key is chosen with the reason that produced it, the layout, style and source are reported, and the user has confirmed one output path.
|
||||
4. **Prepare the markdown — this step MUST run as a sub agent.** Links are written as `[text](absolute URL)`, so pages that follow the current rule need no conversion. An older page can still carry a wiki-internal link: turn it into an absolute URL from `wiki-url`, because the renderer does not resolve it and it would ship as literal brackets. Strip personal data — an exported file travels further than the page it came from. Leave everything else exactly as written; this step never rewrites the content. Completion condition: every link in the file is `[text](absolute URL)`, and the diff against the source is limited to link conversion and personal-data removal.
|
||||
5. Render: `tools/html-render.sh --markdown {file} --title {title} --layout {layout} --style {style} --source-url {absolute URL} --out {path}`. Route every exit code: 0 → the path it printed is the finished file; 1 → Gitea's renderer or the write failed, so report it and stop, with no half-rendered file left behind; 2 → a usage error or a missing markdown file, so fix the arguments and call again; 4 → the layout or style template file is gone, so report which pair was asked for and send the user to `jsc-gitea:html-style` rather than editing the configuration by hand. Completion condition: the file exists, and the report names its path, the layout, the style and where that pair came from.
|
||||
6. **Record how the run ended.** This is the last thing this skill does, and it runs on every path out of the skill — including the ones that stop at step 1. Call
|
||||
|
||||
`jsc-hooks/tools/report-status.sh skill-end jsc-gitea:html-export {status} {exit code} [detail]`
|
||||
|
||||
`{exit code}` is the exit code of whatever decided the outcome, and `0` when nothing failed. `{detail}` is one short line, no more than 200 characters. **If the script is not on this machine, skip this step in silence and finish the run as it stood** — missing infrastructure is not a failure, and a reporting call may never change what this skill returns or reports.
|
||||
|
||||
| status | When this skill uses it |
|
||||
| --- | --- |
|
||||
| `ok` | The file was rendered and the report names its path, layout, style and source |
|
||||
| `blocked` | The host gate of step 2 stopped the run: `GITEA_HOST` holds no value and the user gave none, so nothing was read and nothing was rendered |
|
||||
| `failed` | The work started and broke: `wiki-get` returned 7 or 8, `issue.sh show` returned 1, or `html-render.sh` returned 1, 2 or 4. Nothing usable came out |
|
||||
| `degraded` | The file was rendered, but part of the run did not hold — track B could not read the labels (exit 1) so the template was picked without them, and the export used a template the configuration did not choose |
|
||||
| `aborted` | The premise did not hold, so the skill stopped on its own: the request carried no wiki or issue link, or `gitea-link.sh parse` returned 3. Also used when the user stops the run at step 3's destination question |
|
||||
|
||||
Completion condition: exactly one `skill-end` line was recorded for this run, or the script was absent and the run finished without it.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -15,6 +15,21 @@ One kind of page, one layout, one style. `jsc-gitea:html-export` reads what this
|
||||
4. **Pick the scope.** Ask per `jsc-ask:ask` rules: `--project` writes `./.jsc/html-styles`, which only applies inside this working directory and is committed with the repository; `--global` writes `$JSC_HOME/html-styles.conf`, which follows the user across every project on this machine. State that the project file wins whenever both hold the same key. Completion condition: the user has picked one scope.
|
||||
5. Write it: `tools/html-style.sh set {key} {layout} {style} [--project|--global]`. Route every exit code: 0 → the file it printed now holds the pair; 1 → the settings file's directory could not be created, so report the path and stop, since nothing was written; 2 → a usage error, such as a missing name or a scope flag that is neither `--project` nor `--global`, so fix the arguments and call again; 4 → the layout or style name has no template file, so go back to step 2 or step 3 rather than editing the settings file by hand. Completion condition: the script exits 0 and prints the file it wrote.
|
||||
6. Read it back with `tools/html-style.sh get {key}` and report the resolved layout, style and source. Completion condition: the source column shows `project` or `global`, matching the scope chosen in step 4.
|
||||
7. **Record how the run ended.** This is the last thing this skill does, and it runs on every path out of the skill, the ones that stop at step 2 included. Call
|
||||
|
||||
`jsc-hooks/tools/report-status.sh skill-end jsc-gitea:html-style {status} {exit code} [detail]`
|
||||
|
||||
`{exit code}` is the exit code of whatever decided the outcome, and `0` when nothing failed. `{detail}` is one short line, no more than 200 characters. **If the script is not on this machine, skip this step in silence and finish the run as it stood** — missing infrastructure is not a failure, and a reporting call may never change what this skill returns or reports.
|
||||
|
||||
| status | When this skill uses it |
|
||||
| --- | --- |
|
||||
| `ok` | `set` exited 0 and step 6 read the pair back with the source column matching the scope that was chosen |
|
||||
| `blocked` | The template directory is missing, so `layouts` or `styles` listed nothing. There is no name to offer and no pair to write, so the run stops before any question and the settings file is untouched |
|
||||
| `failed` | The write itself broke: `set` returned 1 because the settings directory could not be created, 2 on a malformed call, or 4 because the layout or style has no template file. Nothing was written |
|
||||
| `degraded` | `set` exited 0, but step 6 read back a different source than the scope chosen in step 4 — usually a project file holding the same key and winning over a global write. The pair is on disk, yet the export will still resolve to another one |
|
||||
| `aborted` | The user stopped at one of the four questions — the kind key, the layout, the style or the scope — so nothing was written |
|
||||
|
||||
Completion condition: exactly one `skill-end` line was recorded for this run, or the script was absent and the run finished without it.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -16,3 +16,18 @@ description: Batch-sync all readable repos of a chosen Gitea owner into the work
|
||||
|
||||
Done when every repo's sub agent has returned one of those outcomes; one repo failing never cancels the others.
|
||||
5. Report the sync result for every repo: cloned, updated, PR table row, or the failure reason. Done when every `{repo}` from step 3 carries one of those four results, and all PR rows share one table when more than one PR exists.
|
||||
6. **Record how the run ended.** This is the last thing this skill does, and it runs on every path out of the skill, the ones that stop at step 1 included. Call
|
||||
|
||||
`jsc-hooks/tools/report-status.sh skill-end jsc-gitea:repo-sync {status} {exit code} [detail]`
|
||||
|
||||
`{exit code}` is the exit code of whatever decided the outcome, and `0` when nothing failed. `{detail}` is one short line, no more than 200 characters — the repo counts fit there, the per-repo list does not. **If the script is not on this machine, skip this step in silence and finish the run as it stood** — missing infrastructure is not a failure, and a reporting call may never change what this skill returns or reports.
|
||||
|
||||
| status | When this skill uses it |
|
||||
| --- | --- |
|
||||
| `ok` | Every repo from step 3 came back `cloned`, `updated`, or dirty with its PR opened |
|
||||
| `blocked` | Nothing could be listed, so no repo was touched: `GITEA_HOST` or `GITEA_TOKEN` was required and the user gave none, or `owners` exited 0 with no owner this key can read |
|
||||
| `failed` | The listing broke mid-run — `owners` or `repos` returned 7 or 8 — or every repo in step 4 came back `failed`. No repo reached the working directory |
|
||||
| `degraded` | Some repos synced and some did not: at least one `failed {reason}` next to at least one `cloned`, `updated` or PR row. One repo failing never cancels the others, so the run finishes with part of the workspace missing |
|
||||
| `aborted` | The user named no owner at step 2, or stopped the run before step 4 started |
|
||||
|
||||
Completion condition: exactly one `skill-end` line was recorded for this run, or the script was absent and the run finished without it.
|
||||
|
||||
@@ -24,6 +24,22 @@ The wiki link is the only input. Everything else — repository, page name, host
|
||||
4. **Project board.** Track C returned a board list: let the user pick one per `jsc-ask:ask` rules, attach it, and report the failure verbatim if the attach call is refused. Track C exited 3: say plainly that this Gitea has no board API, and hand the user the board URL the script printed so they can drag the issue in themselves. Completion condition: the issue is either attached to a board, or the report states in one line that the board link is still outstanding and who has to do it.
|
||||
5. Create the issue: `tools/issue.sh create {repo} {title} {body-file} [--labels {ids}]`. The script asks for confirmation before it writes, so expect that prompt and hand the user the title, the labels and the board it is about to apply. Exit 0: report the `index=` and `url=` it prints. Exit 1 means no issue was created — report that plainly, and hand back the path of the drafted body file so the draft is not lost. Exit 2 is a usage error, usually a body file that is not there — fix the arguments and call again. Completion condition: the issue URL is reported to the user together with the labels applied and the board status from step 4, or the report states that no issue was created and where the draft is.
|
||||
|
||||
6. **Record how the run ended.** This is the last thing this skill does, and it runs on every path out of the skill, the ones that stop at step 1 included. Call
|
||||
|
||||
`jsc-hooks/tools/report-status.sh skill-end jsc-gitea:wiki-to-issue {status} {exit code} [detail]`
|
||||
|
||||
`{exit code}` is the exit code of whatever decided the outcome, and `0` when nothing failed. `{detail}` is one short line, no more than 200 characters — the issue index fits there, the issue body does not. **If the script is not on this machine, skip this step in silence and finish the run as it stood** — missing infrastructure is not a failure, and a reporting call may never change what this skill returns or reports.
|
||||
|
||||
| status | When this skill uses it |
|
||||
| --- | --- |
|
||||
| `ok` | `issue.sh create` exited 0, and the report carries the issue URL, the labels applied and a board that is attached |
|
||||
| `blocked` | The host gate stopped the run: `GITEA_HOST` holds no value and the user gave none, so the page was never read and no issue was drafted |
|
||||
| `failed` | The work started and broke: `wiki-get` returned 4, 7 or 8, `issue.sh labels` returned 1 so no label could be picked without inventing one, or `issue.sh create` returned 1 and no issue exists. Report the draft path in `{detail}` when the create failed |
|
||||
| `degraded` | The issue was created, but part of it stays outstanding — track C exited 3 because this Gitea has no board API, or the attach call was refused, so the report hands the board link back to the user to drag in by hand. The issue is real, its place on the board is not |
|
||||
| `aborted` | The premise did not hold, so the skill stopped on its own: the request carried no wiki link, `gitea-link.sh parse` returned 3, or the link parsed as `kind=issue`. Also used when the user refuses the confirmation `issue.sh create` asks for, so nothing was written |
|
||||
|
||||
Completion condition: exactly one `skill-end` line was recorded for this run, or the script was absent and the run finished without it.
|
||||
|
||||
## Rules
|
||||
|
||||
- One wiki page, one issue. Splitting a page into several issues is analysis work, not conversion — hand that to `jsc-sdlc:analyze`.
|
||||
|
||||
@@ -74,6 +74,26 @@ Every code below gets its own branch. Nothing here is retried unchanged.
|
||||
| | 2 | usage error, including an unconfigured CONTENTS repo | fix the arguments or set `JSC_WIKI_REPO_CONTENTS`, then call again |
|
||||
| | 3 | something needs manual handling: an orphan page, a page that links to a moved page without being moved itself, or a destination page that already holds content | report those lists and hand them to the user; guess no key, and rewrite no link the script left alone |
|
||||
|
||||
## Close the run
|
||||
|
||||
**Record how the run ended.** This is the last thing this skill does, and it runs on every path out of the skill, the ones that stop at the host gate included. Call
|
||||
|
||||
`jsc-hooks/tools/report-status.sh skill-end jsc-gitea:wiki {status} {exit code} [detail]`
|
||||
|
||||
`{exit code}` is the exit code of whatever decided the outcome — the `gitea.sh`, `link-check.sh` or `wiki-contents.sh` call that ruled the run — and `0` when nothing failed. `{detail}` is one short line, no more than 200 characters; put the page name there, never the page content. **If the script is not on this machine, skip this step in silence and finish the run as it stood** — missing infrastructure is not a failure, and a reporting call may never change what this skill returns to its caller.
|
||||
|
||||
This skill is called by almost every other one, so its status is what the caller reads back. Report the status of this wiki operation only, never the caller's own outcome.
|
||||
|
||||
| status | When this skill uses it |
|
||||
| --- | --- |
|
||||
| `ok` | The read returned the page, or the write landed: `link-check.sh` exited 0, the confirmation was given, and `wiki-put` exited 0 |
|
||||
| `blocked` | The location could not be resolved, so nothing was read and nothing was written: `GITEA_HOST` holds no value and the user gave none, or `wiki-repo` exited 3 and the user supplied no `{owner}/{repo}` for that page type |
|
||||
| `failed` | The operation ran and broke. **Exit 7 belongs here**: the key is invalid or lacks permission, so the whole operation stopped, and that is a failure, never an absent page. Exit 8, a `wiki-put` that did not land, a `link-check.sh` exit 1 that refused the write, and a `hash-id` or `page-name.sh` rejection all sit here too |
|
||||
| `degraded` | The content page landed and the contents page did not — `wiki-put` on `{TYPE}_{HASH}` exited 0, then `wiki-contents.sh upsert` exited 3 with no CONTENTS repo configured, or exited 1 on a page holding no markdown table. The record exists but nothing indexes it, so the next reader will not find it. A migration that moved some pages and left orphans or occupied destinations behind sits here as well |
|
||||
| `aborted` | The premise did not hold or the user stopped it: `write-confirm.sh` was refused before a write or a delete, or the caller asked for a page type outside the allowed list and the run stopped at `wiki-repo` exit 2 |
|
||||
|
||||
Completion condition: exactly one `skill-end` line was recorded for this run, or the script was absent and the run finished without it.
|
||||
|
||||
## Rules
|
||||
|
||||
1. Page names must follow the wiki naming table in the skill guidelines (see `jsc-meta/references/guidelines.md`). Check any page name you build with `tools/page-name.sh check {page}` before it reaches an API call.
|
||||
|
||||
Reference in New Issue
Block a user