What:步驟 9 新增 9.3「註解只寫原因」,原 9.3 順延為 9.4;步驟 10 交給 code-review 前先掃整包 diff。 Why:實作階段手上一直握著工作包編號、分析頁編號、待辦編號、分支名與 PR 編號,這些追蹤資訊很容易被寫進程式碼註解,讓註解變成文件索引。 How:規則正文放在 jsc-review 的 references/comment-scope.md,本技能只寫指引與完成條件,不重複清單;並指向 jsc-hooks 的 comment-scope.sh 當寫檔後的即時警告。 Who:jsc-sdlc 的 implement 技能。
15 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. Every already-open work package's PR comments get triaged via tools/wp-gate.sh check (sub agents fix them in that package's own worktree), but that never blocks a different, unrelated package - independent work packages can proceed in parallel. Picking a candidate is gated per-candidate in code by tools/wp-gate.sh check-deps, which re-reads the analysis page's WBS dependency column and queries Gitea itself: only a candidate whose own declared dependencies are merged may be claimed. 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 every already-open work-package PR's comments — this keeps existing PRs moving, but does not by itself decide which new package may start (that's step 6):
- 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) means that package's own PR is not settled yet. 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 that package's own 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. This does not block picking a different, unrelated work package — SDLC implementation can run several independent packages in parallel; an unmerged PR only holds back packages that depend on it (step 6 checks that specifically), never the whole analysis page. - 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: every work package holding an unmerged PR has had this run's comments triaged (fixed, no fix needed, or cannot fix) and reported; a package left unmerged after this does not block step 5/6 for packages that do not depend on it.
- 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, not holding a work ticket, and — verified by step 6'swp-gate.sh check-deps, never by eyeballing the 相依 column yourself — dependency-free or all dependencies merged. Completion condition: you have listed every selectable work package, or reported that none is selectable and stopped. -
Before picking, the candidate's own dependencies decide — the gate lives in code, not in this text, and it is scoped to that one candidate, never to every open PR on the page:
- For the candidate work package the user is about to choose, run
jsc-sdlc/tools/wp-gate.sh check-deps {owner}/{repo} {wp-number}. It re-reads the analysis page and queries Gitea itself — it does not trust anything you already read or concluded. - Exit 0 (
status=ready) → eligible; proceed to claim it. Exit 1 (status=blocked) → not eligible; report which dependency work package's PR is not merged yet, and offer the user the other eligible candidates instead of this one. Exit 3 (status=missing-dep) is an undecidable gate — report it and stop; never treat an undecidable result as either ready or blocked. - A dependency phrased as text pointing outside this analysis page (another plan, another analysis) cannot be checked by the script; it comes back listed separately as needing manual confirmation. Confirm it with the user before proceeding — an unchecked cross-page dependency is not the same as a cleared one.
- Let the user pick per
jsc-ask:askrules from the eligible candidates only (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:check-depsreturnedstatus=readyfor the picked candidate (any cross-page dependency confirmed with the user), the ticket is saved on the wiki; only then may you proceed.
- For the candidate work package the user is about to choose, run
-
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. - A code comment states why the code is written this way; it never states where the work is documented. The tracking numbers this stage always holds — the work package number, the analysis page number, the TDD todo number, the source branch name and the PR number — stay out of every code comment; write the reason itself into the comment instead. Full list and the allowed exceptions:
jsc-review/references/comment-scope.md.jsc-hooks/hooks/comment-scope.shcompares each file after it is written and prints a warning; fix the flagged line at once, then carry on with the same item. Completion condition: the item's own diff holds no comment line carrying any of those numbers, and every warning the hook printed for this item is fixed. - 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, sweep the work package's whole diff for the comment rule of step 9.3, then 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, and the diff handed to it holds no comment line carrying the work package number, the analysis page number, a TDD todo number, the source branch name or a PR number (full list:jsc-review/references/comment-scope.md). -
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.