@double-codeing/flow2spec 3.0.7 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,605 @@
1
+ [中文](./README-命令说明.md) | [English](./commands-reference.en.md)
2
+
3
+ # Workflow and Skill Reference
4
+
5
+ ## 1) Document Curation (stock-docs Pipeline)
6
+
7
+ ### `f2s-doc-arch`
8
+
9
+ **Purpose**: Generates an architecture overview draft based on user descriptions or code scanning. No fixed format required; it should clearly describe the system structure, module relationships, and key decisions.
10
+
11
+ **Use Cases**:
12
+ - A new project needs architecture documentation
13
+ - An existing project needs architecture descriptions supplemented
14
+ - Architecture descriptions need updating after a system refactor
15
+
16
+ **Relationships**:
17
+ - **Prerequisite**: None
18
+ - **Next Step**: `f2s-doc-final` (normalized final draft) or direct use with `f2s-ctx-build`
19
+ - **Output**: `.Knowledge/stock-docs/<Architecture Overview>_draft.md`
20
+
21
+ **Sub-Agent Invocation**:
22
+ - `subAgent: false` (default): The main agent scans the code and generates the output
23
+ - `subAgent: true`: Defaults to **B Mode** (main agent produces inventory + scan contract, sub-agents do parallel read-only table scans, main agent merges and persists); upgraded to **C Mode** (multi-round correction) when any of the following conditions are met: multi-workspace / monorepo, more than 20 source paths, first-round sub-tables have conflicts or gaps, or multi-source narratives have severe contradictions
24
+
25
+ **Responsibility Matrix**:
26
+ | Role | Responsibilities |
27
+ |------|-----------------|
28
+ | Main Agent | Produces inventory (entry points + core module names) and scan contract, aggregates sub-agent deliverables, persists stock-docs draft |
29
+ | Sub-Agent (B/C Mode) | Performs parallel read-only scans per the main agent's written inventory, delivers in a unified YAML schema (`source / scope / cross_refs / pending`), must not self-crop the scope |
30
+
31
+ ---
32
+
33
+ ### `f2s-doc-final`
34
+
35
+ **Purpose**: Converts PDF technical proposals or draft documents into the standardized "Final Draft Template" format, unifying the document structure for subsequent knowledge base ingestion.
36
+
37
+ **Use Cases**:
38
+ - PDF technical proposals need conversion to Markdown
39
+ - Draft documents need normalization for long-term storage
40
+ - External documents need to be incorporated into Flow2Spec management
41
+
42
+ **Relationships**:
43
+ - **Prerequisite**: PDF document or draft document
44
+ - **Next Step**: `f2s-ctx-build` (final draft imported into the knowledge base)
45
+ - **Output**: `.Knowledge/stock-docs/<Document>_final.md`
46
+
47
+ **Sub-Agent Invocation**:
48
+ - `subAgent: false` (default): The main agent completes the full workflow
49
+ - `subAgent: true`: When the PDF exceeds 50 pages or 5MB, sub-agents may be used for template application and layout drafting; sub-agents must not ask the user questions, write process descriptions, or claim final-draft compliance; the main agent identifies format gaps and accepts the finalized draft
50
+
51
+ **Responsibility Matrix**:
52
+ | Role | Responsibilities |
53
+ |------|-----------------|
54
+ | Main Agent | Identifies format gaps, accepts the finalized draft against the template and clarification document |
55
+ | Sub-Agent | Applies templates and produces layout drafts; does not ask users questions or write process descriptions |
56
+
57
+ ---
58
+
59
+ ### `f2s-ctx-build`
60
+
61
+ **Purpose**: Synchronizes documents from `stock-docs/` (architecture, final drafts) into the knowledge base routing system, generating/updating topic files, the index, manifest-routing, and matchers.
62
+
63
+ **Use Cases**:
64
+ - After a final draft is complete, the knowledge base needs to "know about" these documents
65
+ - A new business domain needs routing mappings established
66
+ - Document content has been updated and the knowledge base index needs to be synced
67
+
68
+ **Relationships**:
69
+ - **Prerequisite**: `f2s-doc-arch`, `f2s-doc-final`, or a directly authored final draft
70
+ - **Next Step**: None (ready for use once imported into the knowledge base)
71
+ - **Input**: `.Knowledge/stock-docs/*.md`
72
+ - **Output**:
73
+ - `.Knowledge/topics/<topic>.md`
74
+ - `.Knowledge/index.md`
75
+ - `.Knowledge/manifest-routing.json`
76
+ - `.Knowledge/matchers/*.json`
77
+
78
+ **Sub-Agent Invocation**:
79
+ - `subAgent: false` (default): The main agent processes each document sequentially
80
+ - `subAgent: true`: Enabled when changes exceed thresholds (more than 2 topics added/modified OR more than 1 matcher added OR cross-topic bulk reference adjustments); sub-agent A writes only to `topics/`, sub-agent B writes only to `matchers/`; the main agent handles single-point edits to `manifest-routing.json` and `index.md`; sub-agents must not cross boundaries
81
+
82
+ **Responsibility Matrix**:
83
+ | Role | Responsibilities |
84
+ |------|-----------------|
85
+ | Main Agent | Single-point persist of `manifest-routing.json` and `index.md`, overall acceptance |
86
+ | Sub-Agent (topics) | Writes only topic files under `topics/`, does not touch manifest or index |
87
+ | Sub-Agent (matchers) | Writes only shard files under `matchers/`, does not touch manifest or index |
88
+
89
+ ---
90
+
91
+ ### `f2s-doc-add`
92
+
93
+ **Purpose**: Parses already-implemented capabilities (aggregated from multiple files) into the knowledge base. Suitable when code already exists but lacks documentation, or when multiple documents need to be imported into the knowledge base in a unified manner.
94
+
95
+ **Use Cases**:
96
+ - Existing code needs knowledge base documentation
97
+ - Multiple related documents need aggregated import
98
+ - Bulk import of third-party documents
99
+
100
+ **Relationships**:
101
+ - **Prerequisite**: None (can be triggered directly)
102
+ - **Next Step**: None (ends once imported into the knowledge base)
103
+ - **Flow**: Draft -> Final Draft -> topics/index/manifest
104
+
105
+ **Sub-Agent Invocation**:
106
+ - `subAgent: false` (default): The main agent processes sequentially
107
+ - `subAgent: true`: Enabled when any of the following thresholds are met; defaults to **B Mode** (main agent produces inventory, sub-agents do parallel read-only schema-based table fills, main agent merges and persists); upgraded to **C Mode** (multi-round correction) for multi-workspace / monorepo, first-round sub-table conflicts or gaps, or severe multi-source contradictions
108
+ - Thresholds: 5 or more input paths OR single source exceeds 3000 lines OR total across multiple paths exceeds 10000 lines
109
+
110
+ **Responsibility Matrix**:
111
+ | Role | Responsibilities |
112
+ |------|-----------------|
113
+ | Main Agent | Produces inventory and scan contract, aggregates sub-tables, persists topics/index/manifest |
114
+ | Sub-Agent (B/C Mode) | Performs read-only scans per the main agent's written inventory, delivers tables in schema format (`source / scope / capabilities / cross_refs / pending`); must not self-crop the scope, write manifest or index, or claim "already in the knowledge base" |
115
+
116
+ **Cross-Verification (when `switchAgentVerification: true`)**:
117
+ - Topic files persisted by sub-agents -> Main agent verifies routing mapping completeness and keyword coverage
118
+ - Only effective when `subAgent: true` and sub-tasks are actually dispatched; otherwise all verification happens within the main agent
119
+
120
+ ---
121
+
122
+ ### `f2s-ctx-rm`
123
+
124
+ **Purpose**: Deletes corresponding knowledge topics and index mappings based on `stock-docs` documents. Only removes reference relationships in the knowledge base, not the source documents themselves.
125
+
126
+ **Use Cases**:
127
+ - A document is deprecated and needs removal from the knowledge routing
128
+ - A document was imported by mistake and its routing mapping needs revocation
129
+ - Cleaning up old mappings after document consolidation
130
+
131
+ **Relationships**:
132
+ - **Prerequisite**: A stock-docs document that has already been imported
133
+ - **Next Step**: None
134
+ - **Note**: Only deletes routing mappings, not source documents
135
+
136
+ **Sub-Agent Invocation**:
137
+ - `subAgent: false` (default): The main agent handles the full workflow (single-point deletion has low sub-agent ROI)
138
+ - `subAgent: true`: Sub-agents are used only for **batch deletion of 5 or more topics**; the main agent must control scope confirmation and `fallbackTopic` re-pointing; `manifest-routing.json` and `index.md` are always persisted by the main agent
139
+
140
+ ---
141
+
142
+ ### `f2s-doc-pdf`
143
+
144
+ **Purpose**: Converts PDF technical proposals to Markdown format, saves to `req-docs/`, and can supplement the process description.
145
+
146
+ **Use Cases**:
147
+ - A PDF technical proposal needs to be implemented
148
+ - Historical PDF documents need to be managed
149
+ - Cross-team deliverables are in PDF format and need conversion
150
+
151
+ **Relationships**:
152
+ - **Prerequisite**: PDF document
153
+ - **Output**: `.Knowledge/req-docs/<Proposal>.md`
154
+ - **Next Step**:
155
+ - 1. If it is a requirement to implement: provide the converted proposal path with instructions "implement according to the technical proposal", driven by the `implement-tech-design` rule
156
+ - 2. If it is for knowledge base archival: follow the final-draft conversion flow `f2s-doc-final` -> `f2s-ctx-build`
157
+
158
+ **Sub-Agent Invocation**:
159
+ - `subAgent: false` (default): The main agent completes the full workflow
160
+ - `subAgent: true`: When the PDF exceeds 50 pages or 5MB, sub-agents may be used for the PDF -> MD first draft and persist to `req-docs`; sub-agents must not ask the user questions or supplement process description sections; the main agent handles follow-up questions and process description supplementation
161
+
162
+ **Responsibility Matrix**:
163
+ | Role | Responsibilities |
164
+ |------|-----------------|
165
+ | Main Agent | Asks the user for process description supplements, completes `req-docs` deposition acceptance |
166
+ | Sub-Agent | Only performs PDF -> MD first draft and persists to `req-docs`, does not ask the user questions |
167
+
168
+ ---
169
+
170
+ ## 2) Requirements and Proposals
171
+
172
+ ### `f2s-req-clarify`
173
+
174
+ **Purpose**: Asks clarifying questions against PRDs/requirement documents, using multi-round Q&A to define requirement boundaries, non-goals, and key flows, until the requirements are clear enough for a technical proposal.
175
+
176
+ **Use Cases**:
177
+ - First step after receiving a PRD, ensuring correct understanding
178
+ - When requirement boundaries are fuzzy or acceptance criteria are missing
179
+ - Cross-team collaboration requirements that need clear interface contracts
180
+
181
+ **Relationships**:
182
+ - **Prerequisite**: None (can be triggered directly)
183
+ - **Next Step**: `f2s-req-backend` (generates a technical proposal after clarification)
184
+ - **Output**: Requirement clarification record (optionally saved to `.Knowledge/req-docs/`)
185
+
186
+ **Sub-Agent Invocation**: None (clarification relies on continuous dialogue and immediate user feedback throughout; no sub-agent splitting)
187
+
188
+ ---
189
+
190
+ ### `f2s-req-backend`
191
+
192
+ **Purpose**: Based on clarified requirements and the project knowledge base, generates a backend technical proposal document including API design, data models, flow descriptions, error codes, etc.
193
+
194
+ **Use Cases**:
195
+ - After `f2s-req-clarify` completes, output a proposal based on clarification results
196
+ - When clear requirement documents already exist, directly generate a technical proposal
197
+
198
+ **Relationships**:
199
+ - **Prerequisite**: `f2s-req-clarify` (recommended) or a clear requirement document
200
+ - **Output**: `.Knowledge/req-docs/<Technical Proposal>.md`
201
+ - **Next Step**: Provide the technical proposal path with instructions "implement according to the technical proposal", driven by the `implement-tech-design` rule
202
+
203
+ **Sub-Agent Invocation**:
204
+ - `subAgent: false` (default): The main agent completes the proposal within the session
205
+ - `subAgent: true`: The main agent must first extract a project convention summary (under 80 lines) from topics/stock-docs (covering architecture conventions, API style, data model standards, etc. across 6 categories) as the mandatory sub-agent context, then dispatch sub-agents to write the `req-docs` draft in parallel; the main agent handles contract finalization and acceptance
206
+
207
+ **Responsibility Matrix**:
208
+ | Role | Responsibilities |
209
+ |------|-----------------|
210
+ | Main Agent | Extracts project convention summary, assigns writing tasks, finalizes the draft against the template, and writes to `req-docs` |
211
+ | Sub-Agent | Read-only access to multiple sources (topics / stock-docs / clarified req-docs / templates), writes `req-docs` draft per template; must not expand the read scope on its own |
212
+
213
+ **Cross-Verification (when `switchAgentVerification: true`)**:
214
+ - API/model/flow documents persisted by sub-agents -> Main agent verifies cross-chapter consistency (API signatures align with data models, flows and error handling coverage)
215
+ - Only effective when `subAgent: true` and sub-tasks are actually dispatched; otherwise all verification happens within the main agent
216
+
217
+ ---
218
+
219
+ ### `f2s-req-plan`
220
+
221
+ **Purpose**: Starting from a technical proposal or requirement description, **always creates a task checklist**, then implements the code accordingly. Does not depend on the `changeTracking` configuration; represents the user's explicit need for traceable task management.
222
+
223
+ **Use Cases**:
224
+ - A technical proposal document exists and needs to be broken down into a task list before implementation
225
+ - The requirement description is complex and the user wants to confirm the checklist before starting work
226
+ - The user wants to track implementation progress across sessions
227
+
228
+ **Relationships**:
229
+ - **Prerequisite**: Technical proposal document path (`.Knowledge/req-docs/*.md` or PDF) or requirement/change description
230
+ - **Output**: `.task/active/<task-name>/task.md` + `context.md`; implementation code
231
+ - **Next Step**: Optionally invoke `f2s-kb-sync` to supplement the knowledge base
232
+
233
+ **Sub-Agent Invocation**:
234
+ - `subAgent: false` (default): The main agent completes parsing, confirmation, and implementation in full
235
+ - `subAgent: true`: Step 1 (document parsing) can dispatch sub-agents for parallel read-only; Step 2 (draft confirmation) must be done by the main agent; Step 4 (code implementation) can dispatch sub-agents per module; `todo.json` is always written by the main agent
236
+
237
+ **Responsibility Matrix**:
238
+ | Role | Responsibilities |
239
+ |------|-----------------|
240
+ | Main Agent | Outputs draft, gets user confirmation, writes `todo.json`, aggregates implementation summary |
241
+ | Sub-Agent (parsing) | Read-only document parsing, outputs parsing result summary, does not persist |
242
+ | Sub-Agent (implementation) | Implements code per module, does not touch `.task/` or `.Knowledge/` |
243
+
244
+ ---
245
+
246
+ ## 3) Git Commit
247
+
248
+ ### `f2s-git-commit`
249
+
250
+ **Purpose**: Executes a Git commit after code is written. Automatically checks changed files, compares knowledge base coverage, prompts the user about capabilities not yet imported, and performs the commit after the commit message is confirmed.
251
+
252
+ **Use Cases**:
253
+ - Committing code after each feature implementation or bug fix
254
+ - Wanting reminders about knowledge base coverage at commit time
255
+ - Needing AI help to generate meaningful commit messages
256
+
257
+ **Relationships**:
258
+ - **Prerequisite**: Code has been written (after `implement-tech-design`, `f2s-kb-fix`, `f2s-kb-feat`, etc.)
259
+ - **Next Step**: None (ends when commit completes; does not auto-push)
260
+ - **Bridging**: If the knowledge base is not yet covered, you can first run `f2s-kb-sync` or `f2s-kb-feat` to supplement before committing
261
+
262
+ **Execution Flow**:
263
+ 1. `git status --short` + `git diff HEAD` to classify files into staged / unstaged / untracked; immediately terminates if merge conflict markers are found
264
+ 2. Compare `.Knowledge/topics/` and `stock-docs/` to determine whether the changed capabilities have been imported; skips and notifies if `.Knowledge` does not exist
265
+ 3. If not covered, prompt the user to choose: A) Import first, then commit / B) Commit now, import later / C) Cancel
266
+ 4. Generate a commit message draft based on `git diff` content, wait for user confirmation or changes
267
+ 5. `git add <specific files>` + `git commit`; if a hook fails, prompt for fix, do not skip
268
+ 6. Output the commit hash; if option B was selected, include a reminder about capabilities not yet imported
269
+
270
+ **Constraints**:
271
+ - `git add -A` / `git add .` is forbidden; only add confirmed changed files
272
+ - `--no-verify` is forbidden; hook failures must be fixed and retried
273
+ - Auto-push is forbidden
274
+ - The commit message must be confirmed by the user; silent commits are not allowed
275
+
276
+ **Sub-Agent Invocation**: None (full interactive confirmation, handled within the main agent)
277
+
278
+ ---
279
+
280
+ ## 4) Knowledge Base Maintenance
281
+
282
+ ### `f2s-kb-fix`
283
+
284
+ **Purpose**: Fixes code based on implementation or rule errors reported by the user, and **by default automatically syncs** the knowledge base documents and index.
285
+
286
+ **Use Cases**:
287
+ - Code implementation does not match the technical proposal
288
+ - Rule understanding errors need correction
289
+ - Documentation needs to be synced after bug fixes
290
+
291
+ **Change Tracking**: If `changeTracking.fix: true`, automatically checks `.task/todo.json` before execution, creates a task checklist, and automatically archives upon completion; cross-session continuation via keywords is supported (see `f2s-task` rules).
292
+
293
+ **Relationships**:
294
+ - **Prerequisite**: Problem discovered (code implementation error or rule deviation)
295
+ - **Next Step**: None (ends when fixes and sync are complete)
296
+ - **Feature**: No need for the user to explicitly request "please sync the knowledge base"; it is done automatically
297
+
298
+ **Sub-Agent Invocation**:
299
+ - `subAgent: false` (default): The main agent completes fixes and knowledge base sync
300
+ - `subAgent: true`: Code sub-packages (bug fixes) can be outsourced to sub-agents; documentation sub-packages (rules/skills/topics style-related) default to the main agent writing directly; if sub-agents are used, they only output before/after diff snippets, not full-file rewrites; manifest and index are always persisted by the main agent
301
+
302
+ **Responsibility Matrix**:
303
+ | Role | Responsibilities |
304
+ |------|-----------------|
305
+ | Main Agent | Locates root cause, devises fix plan, persists style-compliant content, verifies knowledge base consistency |
306
+ | Sub-Agent (code) | Responsible for bug fixes in designated modules, outputs changes and reports impact scope |
307
+ | Sub-Agent (documentation, optional) | Only outputs before/after diff snippets, no full-file rewrites, does not touch manifest or index |
308
+
309
+ **Cross-Verification (when `switchAgentVerification: true`)**:
310
+ - Code changes persisted by sub-agents -> Main agent verifies fix correctness and knowledge base consistency
311
+ - Knowledge base sync persisted by the main agent -> Sub-agent reviews topic/manifest consistency (requires `subAgent: true` and sub-tasks actually dispatched; otherwise self-verification within the main agent)
312
+ - The reviewer and the persister must be different agent instances
313
+
314
+ ---
315
+
316
+ ### `f2s-kb-feat`
317
+
318
+ **Purpose**: When adding a new capability, completes both the implementation and the knowledge base; if the capability is already implemented, only syncs the knowledge base.
319
+
320
+ **Use Cases**:
321
+ - New feature development
322
+ - Adding knowledge base documentation for an existing feature
323
+
324
+ **Change Tracking**: If `changeTracking.feat: true`, automatically checks `.task/todo.json` before execution, creates a task checklist, and automatically archives upon completion; cross-session continuation via keywords is supported (see `f2s-task` rules).
325
+
326
+ **Relationships**:
327
+ - **Prerequisite**: None (can be triggered directly)
328
+ - **Next Step**: None (ends when implementation + sync are complete)
329
+ - **Feature**: Knowledge base sync is automatic; no additional user request needed
330
+
331
+ **Sub-Agent Invocation**:
332
+ - `subAgent: false` (default): The main agent completes everything
333
+ - `subAgent: true`: Code sub-packages (new implementation) can be outsourced to sub-agents; documentation sub-packages (rules/skills/topics style-related) default to the main agent writing directly; if sub-agents are used, they only output before/after diff snippets; manifest and index are always persisted by the main agent
334
+
335
+ **Responsibility Matrix**:
336
+ | Role | Responsibilities |
337
+ |------|-----------------|
338
+ | Main Agent | Defines capability boundaries and implementation scope, persists style-compliant content, performs final verification of knowledge base consistency |
339
+ | Sub-Agent (code) | Responsible for code implementation (APIs, logic, data layer), outputs implementation checklist |
340
+ | Sub-Agent (documentation, optional) | Only outputs before/after diff snippets, no full-file rewrites, does not touch manifest or index |
341
+
342
+ **Cross-Verification (when `switchAgentVerification: true`)**:
343
+ - Topics persisted by documentation sub-agents -> Main agent verifies consistency between the capability description and the implementation code
344
+ - Only effective when `subAgent: true` and sub-tasks are actually dispatched; otherwise all verification happens within the main agent
345
+
346
+ ---
347
+
348
+ ### `f2s-kb-sync`
349
+
350
+ **Purpose**: Sinks already-implemented capabilities from the conversation back into the knowledge base. Can accept an explicit capability description or infer with zero input.
351
+
352
+ **Use Cases**:
353
+ - Implementation is complete within the conversation and needs knowledge base documentation
354
+ - Reverse-documenting knowledge from code
355
+ - Periodic knowledge base organization
356
+
357
+ **Relationships**:
358
+ - **Prerequisite**: None (can be triggered directly, or with zero-input inference)
359
+ - **Next Step**: None
360
+ - **Feature**: First outputs a knowledge base update outline, then writes only after user confirmation
361
+ - **Difference from `f2s-ctx-build`**: `ctx-build` is driven from `stock-docs`; `kb-sync` infers from the conversation/code
362
+
363
+ **Sub-Agent Invocation**:
364
+ - `subAgent: false` (default): The main agent completes inference and sync
365
+ - `subAgent: true`: Steps are split -- **Step 1** (aggregation and inference) can dispatch sub-agents for parallel read-only access to conversation history; **Step 2** (user confirmation of the outline) must be done by the main agent; **Step 3** (persist sync) can dispatch sub-agents to write topic/matcher files, but sub-agents must read 2-3 neighboring topic summaries for style alignment before persisting; manifest and index are always persisted by the main agent
366
+
367
+ **Responsibility Matrix**:
368
+ | Role | Responsibilities |
369
+ |------|-----------------|
370
+ | Main Agent | Outputs outline and gets confirmation, single-point persists manifest and index, final acceptance |
371
+ | Sub-Agent (aggregation) | Read-only access to conversation history, infers capability points, generates structured update outline fragments |
372
+ | Sub-Agent (sync) | Writes topic/matcher per outline, loads neighboring topic summaries for style alignment before persisting, does not touch manifest or index |
373
+
374
+ **Cross-Verification (when `switchAgentVerification: true`)**:
375
+ - Topics/matchers persisted by sync sub-agents -> Main agent verifies cross-topic routing completeness and `includeAny` keyword coverage
376
+ - Only effective when `subAgent: true` and sub-tasks are actually dispatched; otherwise all verification happens within the main agent
377
+
378
+ ---
379
+
380
+ ### `f2s-kb-merge`
381
+
382
+ **Purpose**: Resolves editor context conflicts after Git merges. An optional conflict file path can be provided.
383
+
384
+ **Use Cases**:
385
+ - Context conflicts arise after a Git merge/rebase
386
+ - Knowledge base file conflicts caused by multi-person collaboration
387
+ - Need to unify knowledge base state after branch merging
388
+
389
+ **Relationships**:
390
+ - **Prerequisite**: Conflicts generated by a Git merge
391
+ - **Next Step**: None (ends when conflicts are resolved)
392
+ - **Feature**: Implementation-side conflicts are only listed for the user to confirm
393
+
394
+ **Sub-Agent Invocation**:
395
+ - `subAgent: false` (default): The main agent analyzes and resolves conflicts
396
+ - `subAgent: true`: Sub-agents can be dispatched for conflict scanning and classification into a comparison table (`file / category / ours_summary / theirs_summary / recommendation`); sub-agents must not merge files on their own; the main agent persists per strategy, handles implementation-side decisions, and completes acceptance
397
+
398
+ **Responsibility Matrix**:
399
+ | Role | Responsibilities |
400
+ |------|-----------------|
401
+ | Main Agent | Persists merge results per strategy, handles implementation-side conflict decisions, acceptance |
402
+ | Sub-Agent | Only performs conflict scanning and classification, delivers comparison table in the five-field schema, does not merge files on its own |
403
+
404
+ ---
405
+
406
+ ### `f2s-kb-migrate`
407
+
408
+ **Purpose**: Migrates an old-format knowledge base (`docs-index.md` + `rules/` pattern) into the `.Knowledge/` structure organized by topic.
409
+
410
+ **Use Cases**:
411
+ - Upgrading an old project to the new Flow2Spec version
412
+ - An existing knowledge base needs structured reorganization
413
+
414
+ **Relationships**:
415
+ - **Prerequisite**: Old-format knowledge base (`docs-index.md`, `rules/`, `skills/`)
416
+ - **Next Step**: `f2s-kb-upgrade` (**Flow V1**: old knowledge base must migrate first, then upgrade; **Current V2+ knowledge base** (including npm v3.x): see the upgrade skill Step 0)
417
+ - **Flow**:
418
+ 1. Use `docs-index.md` + `rules/main.md(c)` as the primary index
419
+ 2. Process all business `rules/` and business `skills/` in full (excluding `f2s-*` package skills)
420
+ 3. Migrate all `stock-docs`/`req-docs`
421
+ 4. Persist `.Knowledge/migration-report.md`
422
+ 5. Delete migrated old files after user confirmation
423
+
424
+ **Sub-Agent Invocation**:
425
+ - `subAgent: false` (default): The main agent migrates topic by topic
426
+ - `subAgent: true`: Sub-agents only handle migration + draft migration-report fragments (delivered as patches); status files (migration-report.md, deletion execution records) are exclusively persisted by the main agent; the main agent leads the deletion confirmation and closure
427
+
428
+ **Responsibility Matrix**:
429
+ | Role | Responsibilities |
430
+ |------|-----------------|
431
+ | Main Agent | Creates migration plan, consolidates migration results, persists migration-report, leads deletion confirmation and execution closure |
432
+ | Sub-Agent | Handles topic migration and draft fragment generation (patch format) for designated topics; does not write status files or deletion execution records |
433
+
434
+ **Cross-Verification (when `switchAgentVerification: true`)**:
435
+ - Topics migrated and persisted by sub-agents -> Main agent verifies migration completeness (whether old paths are fully covered, whether topic boundaries overlap)
436
+ - Only effective when `subAgent: true` and sub-tasks are actually dispatched; otherwise all verification happens within the main agent
437
+
438
+ ---
439
+
440
+ ### `f2s-kb-upgrade`
441
+
442
+ **Purpose**: Knowledge base template upgrade. Aligns manifest-routing and matchers shards.
443
+
444
+ **Use Cases**:
445
+ - After a `flow2spec` package version upgrade, upgrade the project knowledge base template
446
+ - Upgrade an old project to the latest structure
447
+
448
+ **Relationships**:
449
+ - **Prerequisite**: `f2s-kb-migrate` (V1 flow) or an existing `.Knowledge/`
450
+ - **Includes**: Internally invokes `flow2spec init` for structural alignment
451
+ - **Note**: A standalone `flow2spec init` is **not** an upgrade command
452
+
453
+ **Flow Differences (in-skill routing codes, **not** equivalent to npm major versions)**:
454
+ - **V1**: First `f2s-kb-migrate`, then runs `flow2spec init`
455
+ - **Current Knowledge Base (V2+)**: When `.Knowledge` + `manifest-routing` are already stable, runs `flow2spec init` to align manifest-routing + matchers shards (**includes Flow2Spec npm v3.x, etc.**; see `skills/f2s-kb-upgrade/SKILL.md` Step 0 for details)
456
+
457
+ **Sub-Agent Invocation**:
458
+ - `subAgent: false` (default): The main agent completes the upgrade
459
+ - `subAgent: true`: Sub-agents only handle shell command execution (running `flow2spec init`), not knowledge base content persistence; the following steps must not be delegated by the main agent: version routing (V1 / Current V2+), re-reading SKILL.md after init and determining a full skill re-run, Step 3b index.md consolidation, verification summary output
460
+
461
+ **Responsibility Matrix**:
462
+ | Role | Responsibilities |
463
+ |------|-----------------|
464
+ | Main Agent | Version routing, re-reading and determining re-run after init, Step 3b index.md consolidation, verification summary; persists `manifest-routing.json` and `index.md` |
465
+ | Sub-Agent | Only runs shell commands like `flow2spec init`, does not persist knowledge base content |
466
+
467
+ **Cross-Verification**: This skill is not bound to cross-verification; self-verification by the persisting side.
468
+
469
+ ---
470
+
471
+ ## 5) Rule Descriptions
472
+
473
+ The following are not skill commands but rules activated by trigger words to guide Agent behavior.
474
+
475
+ ### `f2s-task`
476
+
477
+ **Trigger Words**: changeTracking, change tracking, task tracking, continuation, continue last task
478
+
479
+ **Purpose**: Change tracking rules (`alwaysApply`). When the corresponding skill's `changeTracking.*` is set to `true`, automatically creates, progressively updates, and finally archives task checklists under `.task/` before and after skill execution, supporting cross-session continuation.
480
+
481
+ **Scope**:
482
+
483
+ | Config Item | Corresponding Skill |
484
+ |-------------|-------------------|
485
+ | `changeTracking.feat` | `f2s-kb-feat` |
486
+ | `changeTracking.fix` | `f2s-kb-fix` |
487
+ | `changeTracking.implement` | `f2s-implement-tech-design` |
488
+
489
+ **Cross-Session Continuation**: When a new session starts and `.task/todo.json` exists, automatically matches the user's first message against each task's `keywords`; on a match, loads the corresponding `task.md` and `linkedSkill` skill file, displays the remaining checklist, and asks whether to continue; if there is no match, proceeds without interruption.
490
+
491
+ **Rule Location**: `Config Root/rules/f2s-task.*`
492
+
493
+ ---
494
+
495
+ ### `stock-docs-vs-req-docs`
496
+
497
+ **Trigger Words**: stock-docs, req-docs, implemented capability, where to put the technical proposal, PDF final draft
498
+
499
+ **Purpose**: Distinguishes the boundary between the knowledge archival directory and the requirements implementation directory.
500
+
501
+ **Directory Division**:
502
+
503
+ | Directory | Purpose | When It Is Written |
504
+ |-----------|---------|-------------------|
505
+ | `stock-docs/` | Archival of existing knowledge (architecture, final drafts) | `f2s-doc-arch`, `f2s-doc-final`, `f2s-ctx-build` |
506
+ | `req-docs/` | Requirements and technical proposals (driving implementation) | `f2s-req-backend`, `f2s-doc-pdf`, manual placement |
507
+
508
+ **Use Cases**:
509
+ - Unsure where a document should go
510
+ - Need to clarify the division of labor between stock-docs and req-docs
511
+
512
+ ---
513
+
514
+ ### `implement-tech-design`
515
+
516
+ **Trigger Words**: implement according to technical proposal, implement-tech-design, implement per proposal
517
+
518
+ **Purpose**: Implements runnable code based on technical proposal documents in `req-docs/`.
519
+
520
+ **Change Tracking**: If `changeTracking.implement: true`, after outputting the task list in Step 2.5, synchronously writes to `.task/active/<task-name>/task.md`; archives the task in Step 5 during wrap-up.
521
+
522
+ **Use Cases**:
523
+ - Technical proposal is ready and needs to be coded per the proposal
524
+ - After a proposal change, code needs to be updated accordingly
525
+
526
+ **Relationships**:
527
+ - **Prerequisite**: `.Knowledge/req-docs/<Technical Proposal>.md` (via `f2s-req-backend` or manual placement)
528
+ - **Rule Location**:
529
+ - Cursor: `.cursor/rules/f2s-implement-tech-design.mdc`
530
+ - Claude: `.claude/rules/f2s-implement-tech-design.md`
531
+ - Codex: `.codex/AGENTS.md` + `.codex/topics/f2s-implement-tech-design.md`
532
+
533
+ **Execution Flow (mandatory by rules)**:
534
+ 1. Input normalization
535
+ 2. Understand the proposal and context
536
+ 3. **Output the implementation task list** (required, cannot be skipped)
537
+ 4. **Ask questions before implementing** (required, cannot be skipped)
538
+ 5. Implement per task list
539
+ 6. **Output the remaining checklist and post-implementation reminders** (required)
540
+
541
+ **Sub-Agent Invocation**: None (rule-driven coding; the main agent completes the full workflow)
542
+
543
+ ---
544
+
545
+ ## 6) Sub-Agent Configuration
546
+
547
+ Controlled via `flow2spec.config.json` at the project root (all fields default to `false`).
548
+
549
+ ### How Different Products "See" the Configuration (use with the field table below)
550
+
551
+ `subAgent` and similar fields are written to the **on-disk JSON**; products do not guarantee automatic file opening. Therefore, multi-layered hints are provided via **Cursor rules / Claude hooks / Codex AGENTS snapshot table / knowledge base `config-precheck` summary**, but **the authoritative source remains `Read("flow2spec.config.json")`** (design rationale at [design-principles.en.md Sec. 4.5.1](./design-principles.en.md)). **The full path and table are maintained in one place**: [usage-guide.en.md Sec. 1, `f2s-*` and `flow2spec.config.json`](./usage-guide.en.md).
552
+
553
+ ### `subAgent` Field
554
+
555
+ | Value | Behavior |
556
+ |-------|----------|
557
+ | `false` (default) | All `f2s-*` skills complete within the main agent |
558
+ | `true` | Certain skills may use sub-agents per their documentation (large-scale parallel processing scenarios) |
559
+
560
+ ### `switchAgentVerification` Field
561
+
562
+ | Value | Behavior |
563
+ |-------|----------|
564
+ | `false` (default) | Self-verification on the persisting side: whoever persists verifies |
565
+ | `true` | When a skill explicitly states this step, enables cross-verification: sub-agent persists -> main agent verifies; main agent persists -> sub-agent verifies (requires `subAgent: true` and sub-tasks actually dispatched) |
566
+
567
+ ### `changeTracking` Field
568
+
569
+ A nested object, with each skill independently controlled:
570
+
571
+ ```json
572
+ {
573
+ "changeTracking": {
574
+ "feat": false,
575
+ "fix": false,
576
+ "implement": false
577
+ }
578
+ }
579
+ ```
580
+
581
+ | Sub-field | Corresponding Skill | Effect |
582
+ |-----------|---------------------|--------|
583
+ | `feat` | `f2s-kb-feat` | Creates a task checklist before execution, archives on completion, supports cross-session continuation |
584
+ | `fix` | `f2s-kb-fix` | Same as above |
585
+ | `implement` | `f2s-implement-tech-design` | Same as above |
586
+
587
+ > `f2s-req-plan` is not constrained by this configuration; it always creates a task checklist. Legacy boolean values (`"changeTracking": true/false`) are backward-compatible and automatically expand to all three sub-fields on/off.
588
+
589
+ For full principles and design intent, see [architecture.en.md Sec. 4. Agent Execution Model](./architecture.en.md).
590
+
591
+ ---
592
+
593
+ ## 7) Quick Reference
594
+
595
+ For typical work scenarios and full workflows, see [Usage Guide § 3. Typical Workflows](./usage-guide.en.md).
596
+
597
+ For a complete directory description, see [Directory Conventions](./directory-conventions.en.md).
598
+
599
+ ---
600
+
601
+ Related Documents:
602
+ - [Usage Guide](./usage-guide.en.md)
603
+ - [Directory Conventions](./directory-conventions.en.md)
604
+ - [Architecture](./architecture.en.md)
605
+ - [Usage Scenarios](./usage-scenarios.en.md)