name: f2s-kb-feat description: Complete implementation and knowledge-base sync when adding a capability; if already implemented, only sync the knowledge base; triggers: f2s-kb-feat、新增能力、add capability、new feature
Execution scope:
f2s-kb-featsyncs.Knowledgeby default; the user does not need to separately ask "please sync the knowledge base".
Orchestration (main / sub-agent)
- The meaning of
subAgentandswitchAgentVerificationuses the unified entry as the only source of truth: Cursor/Claude read the configuration-rootrules/f2s-flow2spec-unified-entry.*; Codex reads.codex/topics/f2s-flow2spec-unified-entry.md(same source, mirrored byflow2spec init). Do not repeat those definitions here. - Code subpackage (new / modified implementation code): when
subAgent=true, it may be delegated to a sub-agent. - Documentation subpackage (style-sensitive changes to rules / skills / topics / stock-docs): by default, do not split; the main agent writes them to preserve writing constraints such as "current truth wins", length limits, and no stacked historical negation.
- If documentation changes must be delegated: the sub-agent only outputs an "in-place replacement diff" (small before / after snippets) and must not rewrite whole files; the main agent merges and writes the result.
- Write-authority hard rule:
manifest-routing.json/.Knowledge/index.mdare always written by the main agent; sub-agents must not touch them. - The writing side verifies its own work.
Add Capability (f2s-kb-feat)
Input
- The user describes the new capability, scenario, boundaries, and optional paths.
Steps
Step 0: Change Tracking (only when changeTracking.feat: true)
Before execution, read flow2spec.config.json. If changeTracking.feat: true:
- Check whether
.task/todo.jsonhas an active task, and match the user description againstkeywords. - Match -> load the corresponding
task.md, show the remaining checklist, and continue in the existing task. - No match -> create a new task (see the
f2s-taskrule), and write steps 1-4 intotask.mdas a task checklist. - Mandatory in-progress writes: every time a step in
task.mdis completed, immediatelyEditthat step from[ ]to[x]in the same session; do not accumulate checkmarks until the "closing/archive" step, and do not use verbal completion instead of writing to disk (seef2s-task"interruption and session end" and "archive gate"). - User todos: whenever the user must change a repository, configure an environment, click a platform, or handle similar items, append them in the same session to
.task/active/<task-name>/user-todos.md(seef2s-task); when creating a new task and there are no todos yet, still create this file (a placeholder is allowed).
- Determine capability status: not implemented / partially implemented / already implemented.
- Complete code implementation (skip this step if already implemented).
- Sync the knowledge base (default behavior):
.Knowledge/stock-docs/: capability description and usage..Knowledge/topics/: add or revise topic rules and workflows..Knowledge/index.md: topic index.- Routing manifest: minimally update it when routing, dependencies, or
topicMetadatachange. - Authoring-side guideline: if this step adds or modifies topics,
topicMetadata, ortopicDependencies, first Read the fullrules/f2s-topic-authoring.*(Cursor/Claude:rules/f2s-topic-authoring.mdc; Codex:.codex/topics/f2s-topic-authoring.md) before writing.
- Output a summary (capability points, implementation, knowledge-base changes).
Output Summary Format (Recommended)
## New Capability: <capability name>
### Scope
- <capability point 1>
- <capability point 2>
### Implementation
- <file path>: <change description> (if no code changed, write "existing implementation")
### Knowledge Base
- .Knowledge/stock-docs/<file>.md: <new/revised description>
- .Knowledge/topics/<topic>.md: <new/revised description>
- .Knowledge/index.md: <update description>
- .Knowledge/manifest-routing.json: <whether updated and why>
- .Knowledge/matchers/<id>.json: <whether includeAny was updated and why>
Complex Scenario Example
The user asks to "add a failure retry queue capability", and the code already contains a partial implementation.
- First classify it as "partially implemented" and fill the code gaps instead of rebuilding the whole module.
- Add or revise
topics/retry-queue.md, and update theindexentry description. - If the capability needs to be matched by task routing (for example, "retry queue refactor"), supplement
manifest.taskToTopicRules.
Constraints
- When there is a conflict with an old convention: rewrite to the current truth; do not create additional historical-negation sentences such as "(no longer related to X)".
- Prefer in-place updates for overlapping existing topics.
- At least one knowledge-base update must be written, avoiding "code exists but cannot be retrieved".
- Do not modify the configuration-root
rules/skills. - Documentation subpackages are not split by default; when delegation is necessary, the sub-agent only outputs before/after diff snippets, and the main agent merges and writes them.
manifest-routing.json/.Knowledge/index.mdare always written by the main agent (write-authority hard rule).
Knowledge-Base Writing Style (Required, Anti-Redundancy)
When writing stock-docs / topics / index, follow these rules:
- Minimal increment: only append or rewrite text directly related to this capability; do not use "sync the knowledge base" as a reason to restate background, requirements, or tutorial-style setup unrelated to the implementation.
- Affirmative wording first (see the unified entry "knowledge-base writing style"): state the correct description directly; do not communicate the new convention by negating the old one, except for mutually exclusive choices.
- Avoid duplicate narration: do not write a long version of the same fact in both
stock-docsandtopics; make the executable convention clear in one place, and use a short paragraph + link in the other, or only list key points and reference paths. - Prefer structured writing:
topicsshould focus on rules, boundaries, steps, errors, and configuration points; use lists/tables instead of long paragraphs when possible. - Length limit (soft constraint): in one sync, new body text added to the same file should generally not exceed about 80 lines (excluding code-block lines); if it exceeds that, split into a new topic or write "summary + see code path / another doc" first. Do not stack repeated explanation in one file.
index.md: only modify rows/table items related to this topic; do not refresh the whole table or section by copy-paste.- Forbidden: repeatedly explain Flow2Spec directory responsibilities, paste the full user conversation, or add long "historical review" sections unrelated to this diff.
Completion Self-Check
- Capability description matches the code implementation.
- The new capability can be retrieved through a topic.
indexandmanifestwere synced.- If
topicMetadatawas written: every key exists intopicPaths;primary/tags/confidenceare valid; no topic was created, renamed, or split just for classification. - Knowledge-base changes cannot be compressed further without losing the rules and links after removing unrelated boilerplate.
- No "negate old version / no longer related to something" redundant phrasing remains; if the current rule is clear, such sentences should be deleted or moved into a user-requested migration section.
- No sub-agent rewrote documentation whole-file; manifest / index were written by the main agent only.
- If
changeTracking.feat: true: only archive.task/active/<task-name>/tocompleted/and remove the correspondingtodo.jsonentry after alltask.md"steps" are[x](or canceled items are noted); do not move the directory while[ ]remains (same as thef2s-taskarchive gate). - If
changeTracking.feat: true:user-todos.mdexists; when user todos exist, its content matches the session conclusion.