Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
13 KiB
13 KiB
name: implement description: SDLC implementation stage. Gate on capability tags enforced in code by sdlc-gate (implement requires coding), confirm the analysis page's source branch (which is both the worktree base and the PR target), claim a ready work package from ANALYZE_CONTENTS with a work ticket, create a worktree from origin/{來源分支} under .worktree/{分析頁 HASH}/{repo}, and complete its TDD todos one by one inside it, updating the wiki after every item. Every finished work package gets its own commit, push and PR back to the source branch, then the stage stops: no further package may start until that PR merges, and each check of it also reads the PR comments and asks the user whether to fix accordingly. A delivery package confirms its content type (API document or user-defined) before its first todo, and at the end you ask which delivery-document format to produce (DELIVER_{HASH} wiki page or Gitea issue comment) before optionally registering the project in MAINTAIN_CONTENTS. 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 (capability tags, enforced in code — never self-assessed):
- Run
jsc-cli/tools/model-tags.sh syncto refresh$JSC_HOME/model-tags.tsvfromjsc-cli/references/model-tags.md. - Run
jsc-hooks/hooks/sdlc-gate.sh lock implement. The script reads the actual model id from the transcript, compares it against this stage's required tags (coding), and locks the stage only when they match. - Never claim a capability tag you have not verified with that script, and never substitute your own judgement for its verdict. Non-zero exit = blocked: relay the script's message verbatim, stop the skill, do nothing else this turn. Do not run
unlockto get past the gate; only the user may decide that. - Exit 0 means the stage is locked. From now until the next stage's gate runs, the sdlc-gate hook blocks every prompt whose model stops satisfying the tags.
- Run
- Confirm the source branch — it is also this stage's PR target:
- Run
git fetch --prune originfirst — everyorigin/...reference is stale cache without it. Then read the source branch from the analysis page and report it, along with the current branch and whether the working tree is clean. Branches are always the remote ones; local branches are never the basis. - Ask per
jsc-ask:askrules to confirm thatorigin/{來源分支}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. origin/{來源分支}does not exist on the remote → report and stop. Never fall back todevelopsilently.- Uncommitted changes in the main working directory → warn first and let the user commit or back them up; never discard them. Implementation happens in a worktree (step 7), so the main working directory stays untouched anyway.
- Record the confirmed source branch on the analysis page next to the work ticket. Completion condition: the user has confirmed it explicitly.
- 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). Try to rename the current session to the ticket name (skip when the CLI does not support it). - Before picking anything, settle the previous work package's PR. A work package whose PR is still open blocks the next one — no exceptions:
- Read the analysis page's PR column. Any work package holding a PR that is not merged → run
jsc-gitea/tools/gitea.sh pr-status {owner}/{repo} {index}(prints{state} {merged} {mergeable}). merged=true→ clear the block: remove that package's worktree (git worktree remove {路徑}thengit worktree prune;.worktree/{HASH}/empty → delete it too), mark the package done on the analysis page, and continue.- Not merged → read the comments in the same breath:
jsc-gitea/tools/gitea.sh pr-comments {owner}/{repo} {index}returns issue comments, review verdicts (includingAPPROVED/REQUEST_CHANGESwith no text) and inline code comments, sorted by time. Show them to the user verbatim — author, time, and what they said. - Ask per
jsc-ask:askrules what to do, with the options: fix per the comments (go back into that package's worktree, implement the fix, push to the same working branch — the PR updates itself, no new PR), or leave it and wait. State the impact scope on each. Never decide this yourself, and never open a second PR for the same package. - Closed but not merged → report it and ask the user how to proceed; do not silently treat it as done.
- Only when no unmerged PR remains may you go on. Stop here otherwise.
- Read the analysis page's PR column. Any work package holding a PR that is not 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. - Let the user pick a work package per
jsc-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. Only after the ticket is saved successfully may you proceed. - When the package taken is a delivery/handover package, confirm its content before doing any of its todos:
- Ask per
jsc-ask:askrules what this delivery must contain. The default options are fixed: 1. API 文件 (endpoint path, every input parameter, every output parameter) and 2. 由使用者輸入 (the user states the content themselves). State the impact scope on each. Never assume the type, and never skip this — the answer decides what the whole package produces. - Chose API 文件 → follow
references/deliver-formats.md: all parameters listed (not just the main ones), each with name, type, required flag, example, data source and new-versus-existing status; sample values take real sources first and are labelled真實:{來源}or推論:無來源; an existing endpoint must mark new versus old parameters both ways — the status column (🆕 新增 / ⚠️ 變更 / ❌ 移除 / blank for untouched) and adiffcode block for colour. HTMLstyleattributes get filtered by the wiki, so never rely on them. - Chose 由使用者輸入 → produce exactly what the user described; do not force the API document layout onto it.
- Record the confirmed type in the analysis page's 交付型別 column and save it before starting the todos.
- Ask per
- Create the worktree — before touching any code. Full rules in
references/branch.md:- Run
git fetch --prune origin, then read the source branch and the repositories involved from the analysis page. The worktree is built fromorigin/{來源分支}— never from a local branch of the same name, which may be behind, ahead or diverged. Every code change happens inside the worktree; the main working directory's branch and working tree stay untouched. - Path:
{工作目錄}/.worktree/{分析頁 HASH}/{repo}— the HASH without theANALYZE_prefix, the repo name without its owner. One worktree per repository, all under the same HASH directory. - Ask per
jsc-ask:askrules how to handle the branch, with the two fixed options: create a new working branch off the remote source branch (git worktree add -b {工作分支} {路徑} "origin/{來源分支}"), or check the source branch out with remote tracking (git worktree add --track -b {來源分支} {路徑} "origin/{來源分支}"). State the impact scope on each. Never assume, never skip the question. - Quote every branch name and path: source branches carry Chinese characters, spaces and multiple slashes (for example
feat/一址通/查地址/完整版/P2), and an unquoted argument gets split. - No local clone of that repository → stop and ask the user for its path; never clone on your own initiative and never guess the location.
- Add
.worktree/to that repository's.git/info/exclude— never edit the user's shared.gitignore. - Report the worktree path, the checked-out branch, the source branch and the commit sha
origin/{來源分支}pointed at — that sha is this implementation's starting point and must stay traceable. Completion condition: every involved repository has a worktree and you have reported all of them.
- Run
- List every open item of the work package and implement them one at a time, inside the worktree:
- Follow the TDD loop: red before green, one slice at a time; rules and anti-patterns in
references/tdd.md(refactoring belongs to the review stage). - After each item, flip its
[ ]to[x]on the analysis page and save to the wiki before starting the next item.
- Follow the TDD loop: red before green, one slice at a time; rules and anti-patterns in
- When all items are done, call
jsc-review:code-reviewand wait for the review; on failure, fix and re-review until it passes. - One work package finished → commit, push, PR back to the source branch. Then stop and wait for that PR:
- One work package, one PR. Never let two finished packages share a PR, and never carry a finished package over to the next one — the point of splitting packages is that each lands reviewable on its own.
- Call
jsc-git:prfrom inside the worktree, passing{來源分支}as the base branch. It commits everything (viajsc-git:commit), creates the working branch, pushes, and opens the PR.jsc-git:prfalls back todevelopwhen no base is passed in, so passing it explicitly is what keeps a single work package from merging straight past its feature branch. - 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).
- Keep the worktree. It is removed only after the PR is merged — comments may ask for changes, and rebuilding a worktree to make them is wasted work.
- Do not start another work package. Report the PR URL and stop. The next run picks up at step 4, which checks whether this PR merged and reads its comments.
- 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. - 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
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. - Sample values follow the analysis page's 資料來源 column:
真實:{來源}for real sources,推論:無來源for reasoned ones. Personal data never goes in — keep the field and format, drop the value. - 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
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.
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: real data where a source exists, reasoned values labelled as inferred where none does. Never invent a value and present it as real, and never copy personal data into fixtures — keep the format, drop the identity.
- Everything the skill writes out (wiki content, commit messages, PR descriptions) stays Traditional Chinese per the STE100 rule.