What:新增 tools/stage-report.sh 與 references/stage-report.md,四支階段技能各加一步收尾回報:模型能力標籤判定、工作日誌連結、所有寫入的 wiki 連結;實作階段再加工作目錄與來源、工作、目標三條分支。 Why:階段跑完該交代什麼是固定的,寫在內文靠模型自己記,少一項看不出來。沒寫工作日誌更是如此——內容只留在對話裡,換一個工作階段就沒了。 How:彙整搬到程式層。頁名換絕對網址、commit 數與推送狀態由 git 現查、來源分支在不在遠端也由腳本判定;模型閘門那一列只轉述 sdlc-gate.sh report,不自評。沒有工作日誌就警告使用者檢查,並把內容交給 jsc-log 的暫存區,下次寫日誌一併寫入。結束碼 1 是警告不是阻擋,提前停下來也要回報。 Who:跑 SDLC 四階段的人,以及接手看紀錄的人。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
12 KiB
name: implement description: SDLC implementation stage. Gate on capability tags enforced in code by sdlc-gate (implement requires coding), then confirm the analysis page's source branch - it is both the worktree base and the PR target. An unmerged work package PR is a hard gate enforced in code by tools/wp-gate.sh: it reads every PR comment, sub agents fix them in the original worktree, and no next package starts until that PR merges. Claim a ready work package from ANALYZE_CONTENTS with a work ticket, confirm a delivery package's content type, then complete its TDD todos one at a time inside a worktree built from origin/{source-branch}, updating the wiki after every item, closing with jsc-review code-review, one PR back to the source branch, the chosen delivery document, an optional MAINTAIN_CONTENTS entry, and a tools/stage-report.sh report covering the model tag verdict, the worklog link, every wiki link written, the worktree and the three branches. Use when analysis is done and code must be written; not for planning or analysis.
implement
Goal: complete the analysis page's todos one by one; update the wiki status immediately after every completed item.
All wiki reads and writes go through jsc-gitea:wiki.
Steps
-
Model gate and stage lock — run
jsc-cli/tools/model-tags.sh sync, thenjsc-hooks/hooks/sdlc-gate.sh lock implement. This stage requires thecodingcapability tag. Rules:references/model-gate.md. Completion condition: the script exited 0, and you have reported the stage, the required tag, the actual model id it read from the transcript, and the verdict. -
Confirm the source branch — it is also this stage's PR target:
- Run
git fetch --prune origin, then read the source branch from the analysis page and report it, along with the current branch and whether the working tree is clean. - Ask per
jsc-ask:askrules to confirm thatorigin/{source-branch}is both the worktree's base and the PR target for every work package in this analysis. State the impact scope: each finished work package merges back into the source branch, and that branch as a whole reachesdeveloplater as its own separate PR. - A source branch missing from the remote is a stop-and-report condition, never a silent fallback. That rule (section 「來源分支在遠端找不到」), the remote-only basis and the uncommitted-changes rules:
references/branch.md. - Completion condition: the user has confirmed the source branch explicitly, and it is recorded on the analysis page next to the work ticket.
- Run
-
Generate a work ticket: format
TICKET_{yyyyMMdd}_{HHmmss}_{HASH}.{HASH}= the shared wiki hash for{owner}/{repo}, computed byjsc-gitea/tools/hash-id(seejsc-gitea:wiki). Rename the current session to the ticket name; skip the rename only when the CLI exposes no rename command. Completion condition: the ticket string exists, and you have reported it together with which branch applied — renamed, or skipped because this CLI has no rename command. -
Settle the previous work package's PR before picking anything — the gate lives in code, not in this text:
- Read the analysis page's PR column. For every work package holding a PR that is not marked merged, run
jsc-sdlc/tools/wp-gate.sh check {owner}/{repo} {index} --since {the comment timestamp recorded in that PR column}. Drop--sincewhen that package has no recorded timestamp yet. - Exit 0 (
status=merged) clears that package: remove its worktree (references/branch.md) and mark the package done on the analysis page. - Exit 1 (
status=openorstatus=closed-unmerged) blocks. Fix every comment the script printed — issue comments, review verdicts and inline comments alike. Each round of fixes MUST run as a sub agent inside the original worktree, pushing to the same work branch, so the PR updates itself. Never open a second PR for the same package, and never ask whether to fix or wait: the gate already decided. - Give every printed comment an outcome — fixed, no fix needed, or cannot fix. Ignore what you cannot fix, plus pure discussion and praise: do not reply on the PR and do not stop the flow, and list each ignored comment with its reason in your final report.
- Write the script's
latest=value into that work package's PR column, appended after the existing PR link as#{index} 已處理留言 {ISO time}, and save the page back to the wiki. Next run passes it as--since, so handled comments stay handled. Reuse the existing PR column; the analysis page's columns belong toanalyze. - Exit 3 means the gate could not decide (a missing dependency, or the PR could not be found). Report it and stop — an undecidable gate never counts as merged.
- Completion condition: no work package holds an unmerged PR; stop here otherwise.
- Read the analysis page's PR column. For every work package holding a PR that is not marked merged, run
-
Read
ANALYZE_CONTENTSviajsc-gitea:wikiand list what is unfinished: plan name, HASH, work package number, count of open items. A selectable work package must satisfy all three: unfinished, dependency-free (or all dependencies done), and not holding a work ticket. Completion condition: you have listed every selectable work package, or reported that none is selectable and stopped. -
Step 4's gate comes first: while
wp-gate.sh checkexits 1, no work package may be picked. Let the user pick a work package perjsc-ask:askrules (options state open-item count and estimated effort). List delivery packages (交付是) first — the analysis page makesWP-01the standalone delivery package, so keep that order in the options. Write the ticket into that work package's ticket column (the zh-TW field 「工作證」) on the analysis page and save it back to the wiki. Completion condition: the ticket is saved on the wiki; only then may you proceed. -
A delivery/handover package confirms its content before its first todo:
- Ask per
jsc-ask:askrules what this delivery must contain. The options are fixed: 1. API 文件 and 2. 由使用者輸入. State the impact scope on each. Never assume the type, and never skip this — the answer decides what the whole package produces. - Required fields, sample-data order and the new-versus-existing parameter marking:
references/deliver-formats.md. - Completion condition: the confirmed type is written into the analysis page's 交付型別 column and saved back to the wiki before the first todo starts.
- Ask per
-
Create the worktree — before touching any code. Run
git fetch --prune origin, read the source branch and the repositories involved from the analysis page, then ask perjsc-ask:askrules how to handle the branch. Path layout, the twogit worktree addoptions, quoting,.git/info/excludeand the reporting duty:references/branch.md. Completion condition: every repository the analysis page names has a worktree built fromorigin/{source-branch}, and you have reported each worktree's path, checked-out branch, source branch and starting commit sha. -
Complete the work package's open items one at a time. Every item MUST run as a sub agent, working inside the worktree:
- One sub agent takes one item and follows the TDD loop: red before green, one vertical slice. Rules and anti-patterns:
references/tdd.md(refactoring belongs to the review stage). - The main agent keeps only the wiki bookkeeping: when the sub agent reports the item done, flip its
[ ]to[x]on the analysis page and save to the wiki. - Completion condition: every item of the package shows
[x]on the saved analysis page, and each save happened before the next item's sub agent started.
- One sub agent takes one item and follows the TDD loop: red before green, one vertical slice. Rules and anti-patterns:
-
When all items are done, call
jsc-review:code-reviewand wait for the verdict. Each round of fixes MUST run as a sub agent inside the same worktree. Completion condition: the review passes. -
One work package finished → commit, push, PR back to the source branch. Then stop and wait for that PR:
- Call
jsc-git:prfrom inside the worktree, passing{source-branch}as the base branch. One package, one PR; the branch rules behind that are inreferences/branch.md. - Write the PR URL and number into that work package's PR column on the analysis page and save it back to the wiki, so the next run of this skill can find it (step 4).
- Run
jsc-sdlc/tools/wp-gate.sh lock {owner}/{repo} {index}. The lock is what makes step 4's gate hold across work sessions — a new session starts blocked until that PR merges. - Do not start another work package. Completion condition: the PR exists, its URL is saved on the analysis page and reported to the user, the lock exists (
status=locked), and the skill has stopped.
- Call
-
Delivery document — a finished work package is a delivery, so always ask before producing it; never pick a format silently and never skip this step:
- Ask per
jsc-ask:askrules which format to produce. The options are fixed: aDELIVER_{HASH}wiki page or a Gitea issue comment. State the impact scope on each (the wiki page lives beside the plan and analysis pages; the issue comment reaches whoever follows that issue). - Both formats use the same structure —
templates/deliver-page.md, in Traditional Chinese. Only the destination differs. Sample values and personal-data handling:references/deliver-formats.md. - Wiki page: write
DELIVER_{HASH}throughjsc-gitea:wiki, where{HASH}comes fromjsc-gitea/tools/hash-idover{owner}/{repo}plus the work package number (for exampleplugins/sdlc#WP-01), so each work package gets its own page instead of overwriting the previous one. A new page is added toDELIVER_CONTENTSpertemplates/deliver-contents.md. - Issue comment: confirm the issue number with the user (propose the one referenced by the work package or the PR; never guess), then post via
jsc-gitea/tools/gitea.sh api POST /repos/{owner}/{repo}/issues/{n}/commentswith the body passed in as a UTF-8 file — real newlines, never a literal\n. - Completion condition: the chosen format has actually been produced, and you have reported where it landed (wiki page name, or the comment URL).
- Ask per
-
Ask per
jsc-ask:askrules whether to register this project for maintenance: append toMAINTAIN_CONTENTSwithtemplates/maintain-contents.md. Required: repository{owner}/{repo}, maintenance method, start date. Optional: end date (NULL = maintain forever), last-maintained time. Completion condition: the user has answered, and a chosen registration is saved on the wiki. -
Stage report — the last thing this stage does, including every early stop (the work package gate blocked, no work package was selectable, the source branch was missing from the remote). Run
tools/stage-report.sh implementwith:- one
--page TYPE:{page}per wiki page this run wrote —ANALYZE_{HASH},DELIVER_{HASH}andDELIVER_CONTENTS,MAINTAIN_CONTENTS; --worklogand--worklog-headingwhen a work log entry exists; otherwise write this stage's log content to a file and pass--pending-file {file} --log-hash {HASH}, which holds it for the nextjsc-log:worklogrun;--worktree {path} --source-branch {name} --work-branch {name} --pr {url}— the script reads the commit count, the push state and whether the source branch exists on the remote by itself, so pass the names, not your own count.
Rules and exit codes:
references/stage-report.md. Exit 1 is a warning, never a block. Completion condition: the script's output is reported to the user verbatim, and it names the worktree, all three branches and every wiki page this run wrote. - one
Rules
- The work ticket is a mutex: always skip work packages that already hold a ticket; never take one over.
- Never batch wiki updates across items; one item, one update.
- Sample data written into code or fixtures follows the analysis page's 資料來源 column, under the rules in
references/deliver-formats.md. - Everything the skill writes out (wiki content, commit messages, PR descriptions) stays Traditional Chinese per the STE100 rule.