@guanlin4924/devflow-pi 0.1.62 → 0.1.64
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.
- package/README.md +1 -36
- package/package.json +1 -1
- package/plugins/devflow-core/extensions/devflow-core.ts +149 -3
- package/plugins/devflow-core/skills/workflow-orchestrator/scripts/test_command_policy.py +42 -5
- package/plugins/devflow-core/skills/workflow-project-context/SKILL.md +62 -787
- package/plugins/devflow-core/skills/workflow-project-context/scripts/validate_initialization_database.py +156 -0
- package/plugins/devflow-intel/extensions/devflow-intel.ts +12 -2
- package/plugins/devflow-intel/skills/workflow-code-index/scripts/adapters/generic_text.py +14 -10
- package/plugins/devflow-intel/skills/workflow-code-index/scripts/adapters/python_ast.py +124 -0
- package/plugins/devflow-intel/skills/workflow-code-index/scripts/adapters/registry.py +11 -2
- package/plugins/devflow-intel/skills/workflow-code-index/scripts/adapters/structured_scope.py +121 -0
- package/plugins/devflow-intel/skills/workflow-code-index/scripts/code_index.py +107 -9
- package/src/cli.ts +12 -2
- package/src/constants.ts +1 -1
- package/src/initialization-store.ts +656 -0
- package/src/paths.ts +9 -0
- package/src/project-context.ts +17 -2
- package/src/project-documents.ts +243 -0
- package/src/project-initializer.ts +251 -0
- package/src/project-migration.ts +66 -0
|
@@ -1,852 +1,127 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: workflow-project-context
|
|
3
|
-
description: "Use when a
|
|
3
|
+
description: "Use when a project needs database-backed initialization, repository discovery, project facts, code indexing, navigation, or initialization recovery."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
## Legacy Command Metadata
|
|
7
|
-
|
|
8
|
-
Original slash-command metadata retained only as workflow invocation guidance.
|
|
9
|
-
|
|
10
|
-
```yaml
|
|
11
|
-
argument-hint: '[--auto]'
|
|
12
|
-
user-invocable: true
|
|
13
|
-
pattern: inversion+generator+reviewer
|
|
14
|
-
resumable: true
|
|
15
|
-
state-file: .planning/STATE.md
|
|
16
|
-
allowed-tools:
|
|
17
|
-
- Read
|
|
18
|
-
- Bash
|
|
19
|
-
- Write
|
|
20
|
-
- Glob
|
|
21
|
-
- Grep
|
|
22
|
-
- ask
|
|
23
|
-
```
|
|
24
|
-
|
|
25
6
|
# Project Initialization
|
|
26
7
|
|
|
27
|
-
Initialize project context only. Do not create requirements,
|
|
28
|
-
|
|
29
|
-
## Outputs
|
|
30
|
-
|
|
31
|
-
Always create or update:
|
|
32
|
-
|
|
33
|
-
- `.planning/PROJECT.md` — project facts, structure, navigation, constraints, and decisions
|
|
34
|
-
- `.planning/STATE.md` — initialization state, project locations, scan status, and next recommended step
|
|
35
|
-
- `.planning/navigation/INDEX.md` — codebase registry: maps each codebase to its navigation file, plus rule package index and downstream read contract
|
|
36
|
-
- `.planning/navigation/{name}.md` — one file per codebase: framework, entries, conventions, commands (name comes from user-provided codebase name)
|
|
37
|
-
- `.planning/code-index/` — machine code intelligence index location; generated by `workflow-code-index` by default unless fast mode skips it
|
|
38
|
-
- `.context/static-runtime-context/` + `.context/static-runtime-context.json` — Core-owned, Git-bound static declarations snapshot; never a production-health or capacity assertion
|
|
39
|
-
- `.context/spec/design/` — conditional frontend design rule package; installed after code-index for projects with frontend codebases
|
|
40
|
-
- `.planning/project-context-run.json` — current-run evidence: run identity, code-index status, dynamically discovered depth specs, source paths, and source fingerprints
|
|
41
|
-
- `.context/spec/index.md` — generated technical specification registry: maps stack profiles and codebase specs
|
|
42
|
-
- `.context/spec/stacks/{stack_key}.md` — deduplicated stack-level technical rules for each detected stack profile
|
|
43
|
-
- `.context/spec/frontend/{name}.md` / `.context/spec/backend/{name}.md` — codebase-specific technical rules generated from explicit rules and observed conventions
|
|
44
|
-
- `.planning/rules/INDEX.md` — project rule index, the first file downstream skills read for project-specific conventions
|
|
45
|
-
- `.planning/execution-contract.md` — layer order, TDD strategy, codegen and verification gates
|
|
46
|
-
- `.planning/toolchain.md` — consolidated build, test, lint, mock, and migration commands
|
|
47
|
-
|
|
48
|
-
Also record existing project rule package locations when found (these are accumulated over time, not created during initialization):
|
|
49
|
-
|
|
50
|
-
- `.planning/lessons/`
|
|
51
|
-
- `.planning/milestones/`
|
|
52
|
-
- `.planning/requirements/`
|
|
53
|
-
- `.context/spec/`
|
|
54
|
-
- `.context/workflow/`
|
|
55
|
-
- `.context/lessons/`
|
|
56
|
-
- root `AGENTS.md`, `CLAUDE.md`, or equivalent instruction files
|
|
57
|
-
|
|
58
|
-
Do not create by default:
|
|
59
|
-
|
|
60
|
-
- `.planning/REQUIREMENTS.md`
|
|
61
|
-
- `.planning/ROADMAP.md`
|
|
62
|
-
- `.planning/research/`
|
|
63
|
-
- `.planning/config.json`
|
|
64
|
-
|
|
65
|
-
## Pattern
|
|
8
|
+
Initialize project context only. Do not create requirements, approved API contracts, prototypes, roadmaps, commits, tags, repositories, or workflow state.
|
|
66
9
|
|
|
67
|
-
|
|
10
|
+
## Authority and ownership
|
|
68
11
|
|
|
69
|
-
|
|
70
|
-
- **Generator**: fill templates from `assets/`.
|
|
71
|
-
- **Reviewer**: check the generated files against `references/navigation-guide.md`.
|
|
12
|
+
The control database under the product data directory is the only machine authority for initialization. `.devflow/project.json` locates project identity. Workspaces, scan configurations, input snapshots, runs, facts, evidence, index references, current pointers, document jobs, and authority revisions are stored through `devflow_project_context`.
|
|
72
13
|
|
|
73
|
-
|
|
14
|
+
Never determine current initialization state from Markdown, file mtimes, or duplicated run markers. Never write `.planning/STATE.md`, execution contracts, workflow artifacts, requirements, approvals, or user instruction files.
|
|
74
15
|
|
|
75
|
-
|
|
76
|
-
resource. Never pass a `skill://` URL to Glob or Grep and never append `*`,
|
|
77
|
-
`**`, or other wildcard syntax to it. First choose a concrete template name
|
|
78
|
-
from the inventory below, then use Read with the complete URL. A generated
|
|
79
|
-
project file such as `.context/spec/frontend/index.md` is an output and is not
|
|
80
|
-
the same thing as a source template under `assets/`.
|
|
16
|
+
Human-readable files are projections. Existing unmanaged files are preserved; the generator writes a `.devflow-pending` sibling when it cannot prove that the current file is its previous output.
|
|
81
17
|
|
|
82
|
-
|
|
18
|
+
## Modes
|
|
83
19
|
|
|
84
|
-
-
|
|
85
|
-
-
|
|
20
|
+
- Full mode is the default. It performs bounded static fact collection and builds, validates, and audits an immutable code-index generation before the context snapshot becomes current.
|
|
21
|
+
- Fast mode is allowed only when the user explicitly requests `--fast` or `--skip-code-index`. Pass a deliberately limited `requiredKinds` list. It records the index as explicitly skipped and never masquerades as full mode.
|
|
22
|
+
- Static initialization never runs discovered build, test, migration, service, network, or database commands. Those strings are facts, not instructions.
|
|
86
23
|
|
|
87
|
-
|
|
88
|
-
- Read `assets/codebase-navigation-template.md` before writing each codebase navigation file.
|
|
89
|
-
- Read `assets/navigation-index-template.md` before writing `.planning/navigation/INDEX.md`.
|
|
90
|
-
- Read `assets/context-spec-index-template.md` before writing `.context/spec/index.md`.
|
|
91
|
-
- Read `assets/stack-spec-template.md` before writing each `.context/spec/stacks/{stack_key}.md`.
|
|
92
|
-
- Read `assets/codebase-backend-spec-template.md` before writing each backend/service `.context/spec/backend/{name}.md`.
|
|
93
|
-
- Read `assets/codebase-frontend-spec-template.md` before writing each frontend `.context/spec/frontend/{name}.md`.
|
|
94
|
-
- Read `assets/spec-templates/backend/{template}.md` before writing each backend depth spec file.
|
|
95
|
-
- Read `assets/spec-templates/frontend/{template}.md` before writing each frontend depth spec file.
|
|
96
|
-
- Read `assets/agents-md-template.md` before writing root `AGENTS.md`.
|
|
97
|
-
- Read `assets/context-domain-index-template.md` before writing `.context/spec/frontend/index.md`, `.context/spec/backend/index.md`, and `.context/spec/design/index.md`.
|
|
98
|
-
- Read `assets/state-template.md` before writing `.planning/STATE.md`.
|
|
99
|
-
- Read `assets/execution-contract-template.md` before writing `.planning/execution-contract.md`.
|
|
100
|
-
- Read `assets/toolchain-template.md` before writing `.planning/toolchain.md`.
|
|
101
|
-
- Read `assets/rules-index-template.md` before writing `.planning/rules/INDEX.md`.
|
|
102
|
-
- Read `assets/run-manifest-template.json` before writing `.planning/project-context-run.json`.
|
|
103
|
-
- Read `references/navigation-guide.md` before scanning code and again before final review.
|
|
104
|
-
- Run `scripts/validate_initialization.py` as the final completion gate.
|
|
24
|
+
## Intake and identity
|
|
105
25
|
|
|
106
|
-
|
|
26
|
+
Collect every codebase with a stable name, local path, and role (`frontend`, `backend`, `shared`, or `other`). Ask only for missing paths or a choice that changes authority. In automatic mode, use the current workspace as one `other` repository and preserve unknown business meaning as unknown.
|
|
107
27
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- `--auto`: non-interactive initialization. If codebase locations are not provided, treat the current workspace as a single codebase, scan boundedly, and mark anything not found as `待确认` or `pending`. Do not block on project-name or business-context questions; infer what is obvious and record missing facts.
|
|
111
|
-
- `--fast` / `--skip-code-index`: fast initialization. Generate project context, navigation, specs, and rules, but skip Step 6.5 (code-index) and mark code-index as skipped in `STATE.md`, `PROJECT.md`, navigation INDEX, and rules INDEX. This is the ONLY condition under which code-index may be skipped. Without this flag, code-index is REQUIRED regardless of whether `.planning/` already exists.
|
|
112
|
-
- `--with-code-index`: compatibility flag for explicit full initialization. This is the default behavior; after navigation generation, run Step 6.5 to build/validate/audit `.planning/code-index/`, then carry its status into the remaining generated context and rule files.
|
|
113
|
-
- Other text may be used as project-name or project-context hint when it is not a path.
|
|
114
|
-
|
|
115
|
-
At invocation start, before scanning or writing:
|
|
116
|
-
|
|
117
|
-
1. Generate a unique `run_id`.
|
|
118
|
-
2. Capture `run_started_at` as an ISO-8601 UTC timestamp.
|
|
119
|
-
3. Set mode to `full`, or `fast` only when one of the explicit skip flags is present.
|
|
120
|
-
4. Carry the same `run_id`, `run_started_at`, `code_index_status`, and skip reason into all templates and `.planning/project-context-run.json`. Use `none` when full mode has no skip reason.
|
|
121
|
-
|
|
122
|
-
In non-auto mode, ask the intake questions below.
|
|
123
|
-
|
|
124
|
-
## Existing Planning Update Policy
|
|
125
|
-
|
|
126
|
-
If `.planning/` already exists:
|
|
127
|
-
|
|
128
|
-
1. Read existing `.planning/PROJECT.md`, `.planning/STATE.md`, and `.planning/navigation/*.md` before writing.
|
|
129
|
-
2. Preserve user-authored business context, constraints, key decisions, and missing information unless the user explicitly asks to replace them.
|
|
130
|
-
3. Refresh only machine-derived fields. This includes: detected paths, frameworks, entries, commands, scan status, navigation index, rule package files (execution-contract.md, toolchain.md, rules/INDEX.md), **all currently discovered depth spec files (Step 7.4)**, **code index (Step 6.5)**, and **static runtime-context (Step 6.5a)**. The presence of existing output files does NOT exempt a step from re-execution — machine-derived fields must be regenerated to reflect current codebase state.
|
|
131
|
-
4. If provided codebase locations differ from existing records, record the change in `STATE.md` under `Change Log`.
|
|
132
|
-
5. Never delete existing planning files during initialization. Preserve user-authored content in execution-contract.md and toolchain.md when refreshing machine-derived fields.
|
|
133
|
-
|
|
134
|
-
## Step 1 — Intake Gate
|
|
135
|
-
|
|
136
|
-
Before any initialization, ask for all codebases in the project:
|
|
28
|
+
Inspect registered workspaces and configuration before scanning:
|
|
137
29
|
|
|
138
30
|
```text
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
- 类型:描述这个代码库的角色(如:C端前端、后台前端、后端服务、定时任务、SDK等)
|
|
142
|
-
- 名称:简短的标识名称,用作导航文件名(如:union-next、saas-admin、union-api)
|
|
143
|
-
|
|
144
|
-
示例(3个代码库的项目):
|
|
145
|
-
1. byn-web/packages/union-next C端前端 union-next 联盟客户侧
|
|
146
|
-
2. byn-web/packages/saas-admin 后台前端 saas-admin 运营后台
|
|
147
|
-
3. union/ 后端服务 union 联盟核心服务
|
|
148
|
-
|
|
149
|
-
如果只有1个代码库,写1行即可。
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Do not proceed until at least one codebase is provided, except in `--auto` mode where the current workspace is used as a single codebase with `待确认` type and name inferred from the directory.
|
|
153
|
-
|
|
154
|
-
Accepted values per codebase:
|
|
155
|
-
- **Path**: local path (`./frontend`, `/path/to/web`), Git URL (`https://...`, `git@...`), current workspace (`当前目录`, `same repo`, `.`)
|
|
156
|
-
- **Type**: freeform text describing the codebase's role. Common values: `C端前端`, `后台前端`, `后端服务`, `定时任务`, `SDK`, `公共组件库`, `移动端` — but these are not hardcoded; use whatever the user provides.
|
|
157
|
-
- **Name**: short identifier safe as a filename segment (letters, digits, hyphens). Used for `.planning/navigation/{name}.md`.
|
|
158
|
-
|
|
159
|
-
If a Git URL is provided, record it. Ask before cloning; do not clone automatically.
|
|
160
|
-
|
|
161
|
-
Record the codebase list for use in Step 3 (scan) and Step 6 (generate navigation files).
|
|
162
|
-
|
|
163
|
-
## Step 2 — Minimal Project Questions
|
|
164
|
-
|
|
165
|
-
Ask only what cannot be inferred from code:
|
|
166
|
-
|
|
167
|
-
1. Project name
|
|
168
|
-
2. What the product/system does
|
|
169
|
-
3. Primary users or business domain
|
|
170
|
-
4. Non-negotiable constraints, if any
|
|
171
|
-
|
|
172
|
-
If the user says these are unknown, continue and mark them as `待确认`.
|
|
173
|
-
|
|
174
|
-
## Step 3 — Structure Scan (Four-Phase)
|
|
175
|
-
|
|
176
|
-
Read `references/navigation-guide.md`. Run the following four phases for EACH codebase from Step 1. Each phase has its own scan depth, output, and gate. Do not skip phases.
|
|
177
|
-
|
|
178
|
-
Exclude generated/dependency directories in all phases: `node_modules`, `dist`, `build`, `.next`, `.nuxt`, `target`, `vendor`, `.git`, `coverage`.
|
|
179
|
-
|
|
180
|
-
### Step 3a — Directory Map (Mandatory)
|
|
181
|
-
|
|
182
|
-
Scan the codebase's top-level and second-level directory layout. This is the factual layer — what directories exist and what they contain.
|
|
183
|
-
|
|
184
|
-
Scan method:
|
|
31
|
+
devflow_project_context(action="workspaces")
|
|
32
|
+
devflow_project_context(action="config")
|
|
185
33
|
```
|
|
186
|
-
1. rg --files from codebase root → extract top-level and second-level directories
|
|
187
|
-
2. Identify key manifest/config files: package.json, go.mod, Makefile, Dockerfile, README
|
|
188
|
-
3. For each directory, infer purpose from file names and README content
|
|
189
|
-
4. Do NOT read source files in depth — only directory names and manifests
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
Output (write to `{name}.md` → `## Structure → ### Directory Map`):
|
|
193
|
-
- ASCII directory tree (top-level + second-level)
|
|
194
|
-
- Table: Directory | Purpose | Notes
|
|
195
|
-
|
|
196
|
-
Gate: every top-level and second-level directory is listed with a purpose (one sentence, inferred from file names is acceptable). Key entry files (main.go, main.ts, router files, handler files) are identified.
|
|
197
|
-
|
|
198
|
-
### Step 3b — Call Chain Map (Mandatory)
|
|
199
|
-
|
|
200
|
-
Trace the call chains through the codebase. This is the connectivity layer — how code connects across directories.
|
|
201
|
-
|
|
202
|
-
**Dual-path routing** (decide before scanning):
|
|
203
|
-
|
|
204
|
-
```
|
|
205
|
-
For each codebase, check if a rule file exists in this order:
|
|
206
|
-
1. .cursorrules within the codebase root
|
|
207
|
-
2. AGENTS.md / CLAUDE.md at project root or codebase root
|
|
208
|
-
|
|
209
|
-
If a rule file EXISTS → Path A: Conventions first
|
|
210
|
-
1. Execute Step 3c first to extract conventions
|
|
211
|
-
2. Use extracted conventions to guide call chain tracing
|
|
212
|
-
(e.g., if convention says "handler→service→repository→dao", follow that pattern)
|
|
213
|
-
|
|
214
|
-
If NO rule file → Path B: Call chain first
|
|
215
|
-
1. Trace call chains from entry points by following imports/method calls
|
|
216
|
-
2. The traced patterns will feed into Step 3c for convention extraction
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
Scan method:
|
|
220
|
-
|
|
221
|
-
**Backend-type codebases** (type contains "后端" or "服务"):
|
|
222
|
-
```
|
|
223
|
-
1. Find handler files (look for route registration patterns):
|
|
224
|
-
- Go: files with RegisterRoutes, gin routes, or echo routes
|
|
225
|
-
- Java: @RestController, @RequestMapping
|
|
226
|
-
- Node: router files, controller files
|
|
227
|
-
2. For each handler, extract registered routes and the methods they call
|
|
228
|
-
3. Follow the call chain: handler method → service method → repository method → dao method
|
|
229
|
-
4. Find job/scheduler files (look for cron patterns, @Scheduled, job registration):
|
|
230
|
-
- Extract cron expression or trigger condition
|
|
231
|
-
- Trace the job's call chain into services
|
|
232
|
-
5. Find external integration packages/directories:
|
|
233
|
-
- Identify outbound HTTP clients, gRPC clients, message queues
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Output (write to `{name}.md` → `## Structure → ### Call Chain Map`):
|
|
237
|
-
- `#### API Modules` table: Route Group | Handler | Routes | Service → Repository → DAO
|
|
238
|
-
- `#### Scheduled Jobs` table: Job | Cron | Trigger Type | Call Chain | Notes
|
|
239
|
-
- `#### External Integrations` table: Integration | Path | Direction | Notes
|
|
240
|
-
|
|
241
|
-
Gate: every handler file identified in 3a has its call chain traced (at minimum: handler→service). Every job file has its trigger and target service identified.
|
|
242
|
-
|
|
243
|
-
**Frontend-type codebases** (type contains "前端"):
|
|
244
|
-
```
|
|
245
|
-
1. Read router configuration → extract all routes with their page components
|
|
246
|
-
2. For each page component, read the file and extract:
|
|
247
|
-
- Imported child components (from page-private and common components)
|
|
248
|
-
- Imported composables/hooks
|
|
249
|
-
- API calls (direct or through composables)
|
|
250
|
-
3. For each composable, extract:
|
|
251
|
-
- API client methods called
|
|
252
|
-
- State shape (reactive/ref/store)
|
|
253
|
-
4. Build the route→component→composable→API call tree
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
Output (write to `{name}.md` → `## Structure → ### Call Chain Map`):
|
|
257
|
-
- `#### Route-Component Map` table: Route | Page Component | Child Components | Composables | API Calls
|
|
258
|
-
- `#### Data Flow` table: Composable / Store | API Client | State Shape | Consumed By
|
|
259
|
-
|
|
260
|
-
Gate: every route has its page component and at least the first-level child components listed. Every composable used by more than one component is in the Data Flow table.
|
|
261
34
|
|
|
262
|
-
|
|
35
|
+
A copied project manifest creates a distinct workspace. Rebind a moved directory only after the user identifies the old workspace:
|
|
263
36
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
**If Path A (rule file existed, 3c was already executed before 3b):**
|
|
267
|
-
- The conventions extracted from .cursorrules / AGENTS.md were used to guide 3b.
|
|
268
|
-
- Now cross-validate: did the actual code follow these conventions? If violations found, note them.
|
|
269
|
-
|
|
270
|
-
**If Path B (no rule file, 3c runs after 3b):**
|
|
271
|
-
- Infer conventions from the patterns observed during 3b call chain tracing.
|
|
272
|
-
- If a pattern is consistent across all modules (e.g., every handler calls a service interface), record it as a convention.
|
|
273
|
-
- If patterns are inconsistent, record the dominant pattern and note the variations.
|
|
274
|
-
|
|
275
|
-
Scan method:
|
|
276
|
-
```
|
|
277
|
-
1. If .cursorrules or AGENTS.md / CLAUDE.md exist, read them and extract:
|
|
278
|
-
- Layer/component hierarchy rules
|
|
279
|
-
- Naming conventions
|
|
280
|
-
- Data conversion rules (VO↔Domain↔Model)
|
|
281
|
-
- Error handling patterns
|
|
282
|
-
- Code generation or documentation rules
|
|
283
|
-
2. If no rule file, infer from 3b observations:
|
|
284
|
-
- Consistent directory patterns → layer convention
|
|
285
|
-
- Consistent method signatures → interface convention
|
|
286
|
-
- Consistent import patterns → dependency direction
|
|
287
|
-
3. Mark any convention as "推断" (inferred) when not backed by an explicit rule file.
|
|
37
|
+
```text
|
|
38
|
+
devflow_project_context(action="rebind-workspace", workspaceId="<old-workspace>")
|
|
288
39
|
```
|
|
289
40
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
**Backend-type**: Table with columns Category | Rule | Source
|
|
293
|
-
Categories: Layer order, Conversion (VO↔Domain↔Model), Interface/DI, Error handling, Naming, Swagger/API docs
|
|
294
|
-
|
|
295
|
-
**Frontend-type**: Table with columns Category | Rule | Source
|
|
296
|
-
Categories: Component hierarchy, Data flow (composable/store), Route naming, Style/theme, API client, State management
|
|
297
|
-
|
|
298
|
-
Source values: `{rule_file_name}` (explicit rule), `代码推断` (inferred from code patterns), or `待确认` (not observed).
|
|
41
|
+
Do not infer move/copy identity from timestamps or similar directory names.
|
|
299
42
|
|
|
300
|
-
|
|
43
|
+
## Legacy input
|
|
301
44
|
|
|
302
|
-
|
|
45
|
+
Legacy `.planning` or `.context` files are never read as current machine facts. On an explicit import request, register selected files as historical material in shadow mode:
|
|
303
46
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
Scan method:
|
|
307
|
-
```
|
|
308
|
-
1. Read detected manifest files from 3a:
|
|
309
|
-
- Frontend/Node: package.json, pnpm-lock.yaml, yarn.lock, package-lock.json
|
|
310
|
-
- Python: pyproject.toml, requirements.txt, poetry.lock, uv.lock
|
|
311
|
-
- Go: go.mod
|
|
312
|
-
- Java/Kotlin: pom.xml, build.gradle, build.gradle.kts
|
|
313
|
-
2. Extract only dependency names and versions needed to identify the stack profile:
|
|
314
|
-
- language/runtime
|
|
315
|
-
- primary framework and major version
|
|
316
|
-
- key libraries that materially change conventions (e.g., Ant Design, Zustand, FastAPI, Pydantic major version, SQLAlchemy vs SQLModel, Gin, GORM, Spring Boot)
|
|
317
|
-
- package manager/build tool
|
|
318
|
-
- test framework if detectable
|
|
319
|
-
3. Compute a stable `stack_key` from:
|
|
320
|
-
language + framework + framework major version + key libraries
|
|
321
|
-
Examples: `python-fastapi-pydantic2-sqlalchemy`, `react-vite-antd`, `go-gin-gorm`
|
|
322
|
-
4. Record manifest path and dependency fingerprint. A hash of the manifest is acceptable; otherwise list key dependency versions.
|
|
47
|
+
```text
|
|
48
|
+
devflow_project_context(action="import-legacy", sources=[".planning/PROJECT.md"], requestId="<stable-request-id>")
|
|
323
49
|
```
|
|
324
50
|
|
|
325
|
-
|
|
326
|
-
- Table: Field | Value | Source
|
|
327
|
-
- Required fields: language/runtime, framework, framework version, key libraries, package manager/build tool, test framework, manifest path, dependency fingerprint, stack_key
|
|
328
|
-
|
|
329
|
-
Rules:
|
|
330
|
-
- Do not merge different major versions or materially different key libraries into the same stack profile.
|
|
331
|
-
- Do not put project-instance conventions into the stack profile. Stack profiles identify technology families; project-specific rules belong in codebase specs.
|
|
332
|
-
- If a manifest exists but versions are ambiguous, record `待确认` for version and keep the manifest path.
|
|
51
|
+
Imported prose remains `historical`, `observed=false`, and `approved=false`. Do not import requirements or design approval merely because text looks final.
|
|
333
52
|
|
|
334
|
-
|
|
53
|
+
## Execute
|
|
335
54
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
After 3a/3b/3c/3d complete for all codebases, identify project-wide sources once:
|
|
339
|
-
- `.planning/rules/`, `.planning/execution-contract.md`, `.planning/toolchain.md`, `.planning/lessons/`
|
|
340
|
-
- `.planning/milestones/`, `.planning/requirements/`
|
|
341
|
-
- `.context/spec/`, `.context/workflow/`, `.context/lessons/`
|
|
342
|
-
- root `AGENTS.md` / `CLAUDE.md`
|
|
343
|
-
|
|
344
|
-
Identify history model locations once:
|
|
345
|
-
- primary: `.planning/milestones/`, `.planning/requirements/`, `.planning/lessons/`, `.planning/*/CONTEXT.md`
|
|
346
|
-
- optional legacy: `features/`, `.context/lessons/`
|
|
347
|
-
|
|
348
|
-
If a codebase location is unavailable or only a Git URL, write what is known and mark scan status as pending.
|
|
349
|
-
|
|
350
|
-
Do not run `git init`.
|
|
351
|
-
|
|
352
|
-
## Unknown Field Policy
|
|
353
|
-
|
|
354
|
-
Avoid filling every table cell with `待确认`.
|
|
355
|
-
|
|
356
|
-
- Required fields may be `待确认`: root, framework, app entry, router/controllers, commands.
|
|
357
|
-
- Optional fields should be omitted from notes or summarized in `Missing Information` when not found.
|
|
358
|
-
- If a whole area does not apply (e.g., frontend-type sections for a backend-only codebase), skip those sections in the codebase navigation file.
|
|
359
|
-
- Each codebase gets its own navigation file regardless of type. There is no limit on the number of codebases.
|
|
360
|
-
|
|
361
|
-
## Step 4 — Generate Base Directories
|
|
362
|
-
|
|
363
|
-
Use this directory contract:
|
|
55
|
+
For full initialization:
|
|
364
56
|
|
|
365
57
|
```text
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
│ ├── {name2}.md # per-codebase navigation (e.g., saas-admin.md)
|
|
374
|
-
│ └── ... # one file for each codebase from Step 1
|
|
375
|
-
└── rules/
|
|
376
|
-
└── INDEX.md # rule source registry
|
|
377
|
-
|
|
378
|
-
.context/
|
|
379
|
-
└── spec/
|
|
380
|
-
├── index.md # generated spec registry and read order
|
|
381
|
-
├── stacks/
|
|
382
|
-
│ └── {stack_key}.md # deduplicated stack-level rules
|
|
383
|
-
├── frontend/
|
|
384
|
-
│ ├── index.md
|
|
385
|
-
│ └── {name}.md # per-frontend codebase rules
|
|
386
|
-
├── backend/
|
|
387
|
-
│ ├── index.md
|
|
388
|
-
│ └── {name}.md # per-backend/service codebase rules
|
|
389
|
-
└── design/
|
|
390
|
-
└── index.md
|
|
58
|
+
devflow_project_context(
|
|
59
|
+
action="scan",
|
|
60
|
+
mode="full",
|
|
61
|
+
repositories=[{"name":"app","path":".","role":"other"}],
|
|
62
|
+
documentMode="template",
|
|
63
|
+
requestId="<stable-request-id>"
|
|
64
|
+
)
|
|
391
65
|
```
|
|
392
66
|
|
|
393
|
-
The
|
|
394
|
-
|
|
395
|
-
Do not create requirement, roadmap, research, config, or `.context/spec/workflow/` directories during initialization unless explicitly requested.
|
|
396
|
-
|
|
397
|
-
## Step 5 — Generate PROJECT.md
|
|
398
|
-
|
|
399
|
-
Load `assets/project-initialization-template.md` and fill every section.
|
|
400
|
-
|
|
401
|
-
Required emphasis:
|
|
402
|
-
|
|
403
|
-
- Project basics
|
|
404
|
-
- Codebase locations (from Step 1)
|
|
405
|
-
- Current structure
|
|
406
|
-
- Links to navigation files (INDEX.md and per-codebase files)
|
|
407
|
-
- Constraints
|
|
408
|
-
- Key decisions
|
|
409
|
-
- Project rule package locations
|
|
410
|
-
- History model locations, with `.planning/milestones/`, `.planning/requirements/`, and `.planning/lessons/` as primary history and `.context/lessons/` / `features/` as optional legacy sources
|
|
411
|
-
- Missing information
|
|
412
|
-
|
|
413
|
-
If a field is unknown, write `待确认` rather than guessing.
|
|
414
|
-
|
|
415
|
-
## Step 5.5 — Generate Root AGENTS.md
|
|
67
|
+
The static collector covers assets, technology, APIs, pages, data models, tasks and integrations, explicit rules and convention candidates, toolchain declarations, evidence provenance, and adapter capabilities. Observed facts require source evidence. Historical material, explicit rules, and model candidates remain distinguishable. Secret values must not enter facts, evidence snippets, model input, or generated documents.
|
|
416
68
|
|
|
417
|
-
|
|
69
|
+
Project initialization does not replace the architecture workflow's **Static Runtime Context Snapshot**. When that separately scoped architecture input is requested, collect it through `devflow_static_runtime_context(action="collect")`; do not treat it as a P0 dependency assessment or silently fold it into initialization facts.
|
|
418
70
|
|
|
419
|
-
|
|
71
|
+
The scan freezes the complete file manifest, including uncommitted and untracked files, then scans again before publication. A modification, addition, deletion, permission failure, unsupported input, or configuration change has its own visible status and is never converted into an absence claim.
|
|
420
72
|
|
|
421
|
-
|
|
422
|
-
- **Codebase count and types**: from Step 1 codebase list.
|
|
423
|
-
- **Rule entry**: `.planning/rules/INDEX.md` as entry point.
|
|
424
|
-
- **Spec entry**: `.context/spec/index.md` if spec files were generated.
|
|
73
|
+
## Index behavior
|
|
425
74
|
|
|
426
|
-
|
|
427
|
-
project-local `.omp/AGENTS.md`; root `AGENTS.md` remains the portable project rule entry.
|
|
75
|
+
Python uses AST scopes. TypeScript, JavaScript, and Ruby use conservative structured scopes with declared inference limits. Other languages use file-level generic extraction. Declarations are not calls. Receiver or dynamic calls stay unresolved unless a supported resolver proves a target. Name uniqueness alone is at most an inference and generic text never becomes an exact method edge.
|
|
428
76
|
|
|
429
|
-
|
|
77
|
+
Every full scan publishes an immutable generation under `.planning/code-index/snapshots/<generation>/`; root index files are compatibility projections. Current queries reject stale committed, modified, deleted, or newly added input. Historical queries name a generation. Relation traversal is cycle-safe and exposes depth, result limits, uncertainty, and truncation.
|
|
430
78
|
|
|
431
|
-
|
|
79
|
+
## Human-readable documents
|
|
432
80
|
|
|
433
|
-
|
|
81
|
+
Program-owned projections are `.planning/PROJECT.md`, `.planning/toolchain.md`, `.planning/navigation/INDEX.md`, `.planning/navigation/{codebase}.md`, `.planning/rules/INDEX.md`, and `.planning/initialization/report.md`.
|
|
434
82
|
|
|
435
|
-
|
|
83
|
+
Template mode is an explicit no-model fallback. A configured low-tier organizer may improve prose, but the program owns exact paths, commands, counts, tables, unknowns, and completion status. Model output containing internal identifiers, database structure, hashes, code blocks, or unsupported machine detail is rejected. Document failure never invalidates an already published data snapshot; retry `generate-docs` for that snapshot.
|
|
436
84
|
|
|
437
|
-
|
|
85
|
+
## Query, refresh, cancellation, and recovery
|
|
438
86
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Fill sections based on the codebase's user-provided type:
|
|
442
|
-
|
|
443
|
-
**All codebases** fill these sections:
|
|
444
|
-
- Identity (name, root, type, role, location, scan status)
|
|
445
|
-
- Stack (framework, runtime, build tool, type-specific libraries, and Stack Profile from Step 3d)
|
|
446
|
-
- Application Entry Points (app entry, and type-specific entries)
|
|
447
|
-
- Commands (install, dev, build, test, lint, codegen)
|
|
448
|
-
- Notes, Missing Information
|
|
449
|
-
|
|
450
|
-
**Frontend-type codebases** (type contains "前端") additionally fill:
|
|
451
|
-
- Stack: UI Library, State Management, Request Library
|
|
452
|
-
- Entry Points: Router, Pages/Views, Layouts, API Client, Auth/Permission, Styles/Theme, Env Config
|
|
453
|
-
- Structure: Directory Map (from 3a), Call Chain Map → Route-Component Map + Data Flow (from 3b), Conventions (from 3c)
|
|
454
|
-
|
|
455
|
-
**Backend-type codebases** (type contains "后端" or "服务") additionally fill:
|
|
456
|
-
- Stack: Database Access, API Style
|
|
457
|
-
- Entry Points: Routes/Controllers, Middleware/Filters, Auth/Permission, Env Config, API Docs
|
|
458
|
-
- Structure: Directory Map (from 3a), Call Chain Map → API Modules + Scheduled Jobs + External Integrations (from 3b), Conventions (from 3c)
|
|
459
|
-
|
|
460
|
-
**Other types**: use the user-provided type to decide which sections to include. Prefer fewer sections with higher confidence over guessing.
|
|
461
|
-
|
|
462
|
-
Rules:
|
|
463
|
-
- Only write what was observed during scan. Do not invent paths or conventions.
|
|
464
|
-
- If a section's data was not found during scan, write `待确认` for required fields or omit optional fields.
|
|
465
|
-
- The `## Requirement-Relevant Areas` section is left with a placeholder `{{requirement_areas}}` — it will be filled by downstream skills as features are mapped to this codebase.
|
|
466
|
-
- The `## Rule Sources` section points to `.planning/rules/INDEX.md` and lists only rule files found within this codebase's root (e.g., `.cursorrules`).
|
|
467
|
-
|
|
468
|
-
## Step 6.5 — Code Index Refresh (REQUIRED)
|
|
469
|
-
|
|
470
|
-
本步骤**必须**执行。仅当用户传入 `--fast` / `--skip-code-index` 时允许跳过,否则初始化视为未完成。已有输出、刷新场景或执行耗时均不构成豁免。
|
|
471
|
-
|
|
472
|
-
In full mode, invoke `workflow-code-index` and run its deterministic implementation:
|
|
87
|
+
Use a fixed `snapshotId` throughout one reasoning chain:
|
|
473
88
|
|
|
474
89
|
```text
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
90
|
+
devflow_project_context(action="query", snapshotId="<snapshot>", kind="api", limit=100)
|
|
91
|
+
devflow_project_context(action="diff", fromSnapshotId="<old>", toSnapshotId="<new>")
|
|
92
|
+
devflow_project_context(action="run-status", runId="<run>")
|
|
478
93
|
```
|
|
479
94
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
- `.planning/code-index/index.sqlite`
|
|
483
|
-
- `.planning/code-index/files.jsonl`
|
|
484
|
-
- `.planning/code-index/symbols.jsonl`
|
|
485
|
-
- `.planning/code-index/relations.jsonl`
|
|
486
|
-
- `.planning/code-index/AUDIT.md`
|
|
487
|
-
|
|
488
|
-
In fast mode, do not run the commands. Set `code_index_status` to `skipped`, record the explicit flag as `code_index_skip_reason`, and write the same current-run marker to `STATE.md`, `PROJECT.md`, navigation INDEX, and rules INDEX.
|
|
489
|
-
|
|
490
|
-
After full-mode commands succeed, set `code_index_status` to `complete`, use skip reason `none`, and update the same marker in PROJECT and navigation INDEX. Rules INDEX and STATE receive it when generated in Steps 8 and 9.
|
|
95
|
+
Follow `nextCursor` until null. A diff with incompatible scan configurations is `comparable=false`; do not interpret it as deletion. Refresh uses `scan` with a new request ID. Repeating one request ID with different input is an error.
|
|
491
96
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
## Step 6.5a — Static Runtime Context Snapshot (REQUIRED)
|
|
495
|
-
|
|
496
|
-
After Step 6.5, collect the separate P1 static-context snapshot:
|
|
97
|
+
Cancellation and expired-lease recovery are explicit:
|
|
497
98
|
|
|
498
99
|
```text
|
|
499
|
-
|
|
500
|
-
|
|
100
|
+
devflow_project_context(action="cancel", runId="<run>")
|
|
101
|
+
devflow_project_context(action="recover", runId="<run>")
|
|
501
102
|
```
|
|
502
103
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
Do not describe this snapshot as production topology, resource health, capacity, or a list of deployed services. Its P1 scope is repository declarations and explicitly supported platform manifests only; unsupported resource bindings, integrations, and jobs remain `unknown` until a later collector can prove them.
|
|
506
|
-
|
|
507
|
-
If the repository has no readable Git commit, retain the generated snapshot with incomplete coverage and record the limitation. Do not invent a working-tree baseline or silently skip the collection.
|
|
104
|
+
A cancelled run never auto-publishes. A recovered stale worker receives a new lease and the old lease cannot write.
|
|
508
105
|
|
|
509
|
-
##
|
|
106
|
+
## Authority, backup, and rollback
|
|
510
107
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
1. Determine applicability from the Step 1 codebase types and Step 3 scan evidence:
|
|
514
|
-
- If at least one local/scannable codebase is frontend-type, this step is required.
|
|
515
|
-
- If no frontend-type codebase exists, do not install UI recommendation assets; record `design_rule_pack.status: not_applicable` and reason `no_frontend_codebase` in the run manifest.
|
|
516
|
-
2. For an applicable project, run the design-rule installer without overwriting project-local decisions or the project-context-owned index:
|
|
108
|
+
Shadow import does not alter current pointers. Switch only after the database snapshot, index reference, and document conflicts have been reviewed:
|
|
517
109
|
|
|
518
110
|
```text
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
3. Verify these installed assets exist:
|
|
523
|
-
- `.context/spec/design/tokens/project-tokens.md`
|
|
524
|
-
- `.context/spec/design/recommendations/accessibility.md`
|
|
525
|
-
- `.context/spec/design/recommendations/component-library.md`
|
|
526
|
-
- `.context/spec/design/tools/ui-ux-pro-max/SKILL.md`
|
|
527
|
-
4. Record `design_rule_pack.status: installed`, source `skill://workflow-design-rule-pack/assets/design/`, and the verified asset paths in `.planning/project-context-run.json`.
|
|
528
|
-
5. Never use `--overwrite` during ordinary initialization. Existing confirmed project tokens and intentional local overrides take precedence. If an existing shared recommendation must be refreshed, require explicit user authorization and record it as a separate maintenance action.
|
|
529
|
-
|
|
530
|
-
`--fast` only skips code-index generation. It does not skip this step for frontend projects.
|
|
531
|
-
|
|
532
|
-
## Step 7 — Generate Context Spec Package
|
|
533
|
-
|
|
534
|
-
Create `.context/spec/` after navigation files exist. Context specs are generated rule documents, not source-code indexes.
|
|
535
|
-
|
|
536
|
-
### 7.1 Generate stack specs
|
|
537
|
-
|
|
538
|
-
Use all Step 3d stack profiles, group by `stack_key`, and generate one `.context/spec/stacks/{stack_key}.md` per unique stack profile.
|
|
539
|
-
|
|
540
|
-
Rules:
|
|
541
|
-
- Deduplicate by `stack_key`, not by framework name alone.
|
|
542
|
-
- If two codebases share the same framework but differ in major framework version or key libraries, generate separate stack specs.
|
|
543
|
-
- Stack specs contain technology-stack guidance only. Do not include one codebase's local directory names, local naming habits, or route/module names as stack rules.
|
|
544
|
-
- Stack specs must fill `## Per-Layer Rules` with stack-level guidance for every listed layer. Use `NOT_APPLICABLE` for layers that do not apply to the stack.
|
|
545
|
-
- Each stack spec must include version metadata: generation date, source manifests, key dependency versions, dependency fingerprint, and regeneration triggers.
|
|
546
|
-
|
|
547
|
-
### 7.2 Generate codebase specs
|
|
548
|
-
|
|
549
|
-
For EACH frontend-type codebase, load `assets/codebase-frontend-spec-template.md` and write `.context/spec/frontend/{name}.md`.
|
|
550
|
-
|
|
551
|
-
For EACH backend/service-type codebase, load `assets/codebase-backend-spec-template.md` and write `.context/spec/backend/{name}.md`.
|
|
552
|
-
|
|
553
|
-
Codebase specs must:
|
|
554
|
-
- Link to the matching stack spec by `stack_key`.
|
|
555
|
-
- Separate `显式规则`, `代码推断`, and `待确认`.
|
|
556
|
-
- Use navigation facts and actual scanned conventions; do not invent rules or promote inconsistent legacy code to a hard rule.
|
|
557
|
-
- Include version metadata and regeneration triggers.
|
|
558
|
-
|
|
559
|
-
### 7.3 Generate spec indexes
|
|
560
|
-
|
|
561
|
-
Load `assets/context-spec-index-template.md` and write `.context/spec/index.md`.
|
|
562
|
-
|
|
563
|
-
Load `assets/context-domain-index-template.md` and write:
|
|
564
|
-
- `.context/spec/frontend/index.md`
|
|
565
|
-
- `.context/spec/backend/index.md`
|
|
566
|
-
- `.context/spec/design/index.md`
|
|
567
|
-
|
|
568
|
-
For `.context/spec/design/index.md`, project-context is the only writer. When `design_rule_pack.status` is `installed`, add a `## Shared Design Rule Package` section that links to `tokens/`, `recommendations/`, and `tools/ui-ux-pro-max/`, preserves the priority order (confirmed project facts before recommendations), and identifies the pack as recommendations rather than project facts. When it is `not_applicable`, retain the explicit no-frontend reason.
|
|
569
|
-
|
|
570
|
-
The root spec index must list:
|
|
571
|
-
- Every stack spec with its `stack_key`.
|
|
572
|
-
- Every codebase spec with codebase name, type, navigation file, and stack spec.
|
|
573
|
-
- Read order for downstream skills:
|
|
574
|
-
1. `.planning/rules/INDEX.md`
|
|
575
|
-
2. `.context/spec/index.md`
|
|
576
|
-
3. matching `.context/spec/stacks/{stack_key}.md`
|
|
577
|
-
4. matching `.context/spec/frontend|backend/{codebase}.md`
|
|
578
|
-
5. matching `.context/spec/{domain}/index.md` and applicable depth specs
|
|
579
|
-
6. `.planning/navigation/{codebase}.md`
|
|
580
|
-
7. `.planning/code-index/` machine symbols/relations when present and source-level relation facts are needed
|
|
581
|
-
8. actual source files
|
|
582
|
-
|
|
583
|
-
Each frontend/backend domain index must:
|
|
584
|
-
|
|
585
|
-
- List every codebase-level spec in that domain.
|
|
586
|
-
- Include a depth-spec registry row for every candidate topic and codebase.
|
|
587
|
-
- Emit one exact machine marker per registry row:
|
|
588
|
-
- Present: `<!-- depth_spec: codebase={name}; domain={domain}; topic={topic}; status=present; path={output_path} -->`
|
|
589
|
-
- Not applicable: `<!-- depth_spec: codebase={name}; domain={domain}; topic={topic}; status=not_applicable; path=none -->`
|
|
590
|
-
- Contain no marker from an earlier run that is absent from the current run manifest.
|
|
591
|
-
|
|
592
|
-
### 7.4 Generate depth spec files (REQUIRED)
|
|
593
|
-
|
|
594
|
-
本步骤**必须**执行。depth spec 是机器推导字段,刷新时必须与导航文件同步重新生成,禁止因为"已有旧文件"而跳过。
|
|
595
|
-
|
|
596
|
-
Depth specs are topic-specific expansions of the codebase spec. Determine the topic list dynamically from navigation scan data, then load and fill the matching template from `assets/spec-templates/{codebase-type}/`. Do not iterate a hardcoded file list.
|
|
597
|
-
|
|
598
|
-
**Backend topic discovery** (from backend-type codebase navigation):
|
|
599
|
-
|
|
600
|
-
| Topic | Match rule | Conditional |
|
|
601
|
-
|-------|-----------|-------------|
|
|
602
|
-
| `service` | directory matching `**/service*/` or `**/svc/` | always when present |
|
|
603
|
-
| `router` | directory matching `**/router*/`, `**/route*/`, `**/handler*/`, `**/controller*/`, `**/web/`, or route registration files | always when present |
|
|
604
|
-
| `schema` | directory matching `**/schema*/`, `**/dto*/`, `**/vo*/`, `**/request*/`, `**/response*/`, or request/response type files | always when present |
|
|
605
|
-
| `model` | directory matching `**/model*/`, `**/entity*/`, `**/domain/`, or ORM/entity files | always when present |
|
|
606
|
-
| `repository` | directory matching `**/repository*/`, `**/repo*/`, `**/dao/`, or persistence adapter files | always when present |
|
|
607
|
-
| `engine` | directory matching `**/engine*/`, `**/client*/`, `**/integration*/`, `**/external*/`, or outbound integration files | always when present |
|
|
608
|
-
| `scheduler` | files or directories matching `**/cron*`, `**/job*`, `**/task*`, `**/scheduler*`, or framework scheduler annotations/registrations | presence of cron/job files |
|
|
609
|
-
| `locator` | locator module detected | presence of locator-specific code |
|
|
610
|
-
| `testing` | directory matching `**/test*/`, `**/tests/`, or files matching `**/*_test.*`, `**/test_*`, `**/*.spec.*` | always when present |
|
|
611
|
-
| `directory-structure` | always | always |
|
|
612
|
-
| `errors` | always | always — derived from HTTP exception and error mapping patterns |
|
|
613
|
-
|
|
614
|
-
**Frontend topic discovery** (from frontend-type codebase navigation):
|
|
615
|
-
|
|
616
|
-
| Navigation signal | Depth spec topic | Conditional |
|
|
617
|
-
|---|---|---|
|
|
618
|
-
| Router config, `app/`, `pages/`, `src/app/`, `src/pages/`, or framework file-based routes detected | `routing` | always when present |
|
|
619
|
-
| API client dir/file exists (`**/api*/`, `**/client*/`, `**/request*`, `**/services*`) | `api-client` | always when present |
|
|
620
|
-
| State management (store/redux/zustand/pinia/vuex/context/composable state) detected | `state` | always when present |
|
|
621
|
-
| Components directory exists (`**/components/`, `**/ui/`, `**/widgets/`) | `components` | always when present |
|
|
622
|
-
| Form patterns detected | `forms` | always when present |
|
|
623
|
-
| Domain-specific editor detected | `case-editor` | presence of editor modules |
|
|
624
|
-
| Test dir/file exists (`**/test*/`, `**/*.test.*`, `**/*.spec.*`) | `testing` | always when present |
|
|
625
|
-
| always | `directory-structure` | always |
|
|
626
|
-
|
|
627
|
-
**Generation rules:**
|
|
628
|
-
|
|
629
|
-
Build `candidate_topics` and `expected_topics` independently for every local/scannable codebase:
|
|
630
|
-
|
|
631
|
-
1. Enumerate `candidate_topics` from the current filenames in `assets/spec-templates/{backend|frontend}/`; do not copy a fixed count or list into a completion gate.
|
|
632
|
-
2. Apply the discovery table to the navigation evidence. The matching subset becomes `expected_topics`.
|
|
633
|
-
3. Record both sets in `.planning/project-context-run.json.topic_inventory`.
|
|
634
|
-
|
|
635
|
-
The runtime inventory is the single source for generation and validation. A candidate topic must appear exactly once as either generated or `NOT_APPLICABLE`.
|
|
636
|
-
|
|
637
|
-
Choose output paths without collisions:
|
|
638
|
-
|
|
639
|
-
- When a domain has one codebase: `.context/spec/{domain}/{topic}.md`
|
|
640
|
-
- When a domain has multiple codebases: `.context/spec/{domain}/{codebase}/{topic}.md`
|
|
641
|
-
|
|
642
|
-
For each expected topic:
|
|
643
|
-
|
|
644
|
-
1. Record the codebase's absolute or project-relative root as `codebase_root`.
|
|
645
|
-
2. Collect every source file actually used to derive the topic as `source_paths` relative to that codebase root. Do not use directories or generated spec files as substitutes.
|
|
646
|
-
3. Compute `source_fingerprint` with the same algorithm as `scripts/validate_initialization.py`: sort unique paths, hash each file, then hash the sequence of `relative_path + NUL + file_sha256 + newline`.
|
|
647
|
-
4. Load `assets/spec-templates/{backend|frontend}/{topic}.md`, fill placeholders from navigation facts and stack template, and write the selected output path.
|
|
648
|
-
5. Add one matching entry to `.planning/project-context-run.json.depth_specs`.
|
|
649
|
-
6. Record every undiscovered candidate topic in `not_applicable_topics` and in the matching domain spec index.
|
|
650
|
-
7. Emit the exact matching `depth_spec` machine marker in the domain index.
|
|
651
|
-
|
|
652
|
-
Each depth spec uses the same structure: Generation Metadata, Scope, Source Summary (Type+Confidence), Stack-Specific Conventions, Observed Patterns, Rules (Strength+Source+Notes), Current Project Shape, Not Applicable, Pending Confirmation.
|
|
653
|
-
|
|
654
|
-
Placeholder filling rules:
|
|
655
|
-
- `{{run_id}}`: the current invocation's immutable run ID.
|
|
656
|
-
- `{{generated_at}}`: ISO-8601 UTC time when this file was regenerated.
|
|
657
|
-
- `{{source_fingerprint}}`: fingerprint computed from this manifest entry's `source_paths`.
|
|
658
|
-
- `{{scope_path}}`: derived from codebase root + navigation scan.
|
|
659
|
-
- `{{source_summary}}`: rows from navigation scan (`代码推断 | OBSERVED | high`), stack template (`SHOULD | medium`), and rule files (`MUST | high`).
|
|
660
|
-
- `{{stack_layer_rules}}`: extract the matching subsection from `.context/spec/stacks/{stack_key}.md` → `## Per-Layer Rules`. If the subsection is `NOT_APPLICABLE`, record that in this field and in `{{not_applicable}}`.
|
|
661
|
-
- `{{observed_rules}}`: rows or bullets from navigation facts, call-chain tracing, codebase conventions, explicit rule files, and lessons. Do not mix in generic stack rules here.
|
|
662
|
-
- `{{rules_table}}`: merged rows from stack layer rules, observed project conventions, explicit rule files, and lessons. Each row is `\| {{rule}} | {{strength}} | {{source}} | {{notes}} |`.
|
|
663
|
-
- `{{current_shape}}` / `{{directory_tree}}`: from navigation directory map and call chain map.
|
|
664
|
-
- `{{not_applicable}}`: layers and patterns observed to be absent.
|
|
665
|
-
- `{{pending}}`: items not yet confirmed.
|
|
666
|
-
|
|
667
|
-
Topics not discovered are skipped. Record them in the domain index and run manifest as `NOT_APPLICABLE`. A skipped topic must not be added to `depth_specs`.
|
|
668
|
-
|
|
669
|
-
If a topic is discovered but the matching template file is missing, do not silently skip it. Record a `PENDING_TEMPLATE` blocker in `.planning/STATE.md` front matter and in the matching domain spec index:
|
|
670
|
-
|
|
671
|
-
```yaml
|
|
672
|
-
blockers:
|
|
673
|
-
- type: PENDING_TEMPLATE
|
|
674
|
-
codebase: {{name}}
|
|
675
|
-
topic: {{topic}}
|
|
676
|
-
reason: found {{matched_path}} but no template in assets/spec-templates/{{backend_or_frontend}}/{{topic}}.md
|
|
677
|
-
impact: depth spec not generated for this layer
|
|
111
|
+
devflow_project_context(action="authority")
|
|
112
|
+
devflow_project_context(action="switch-authority", authority="database", expectedRevision=1)
|
|
678
113
|
```
|
|
679
114
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
Do not mark initialization fully complete while `PENDING_TEMPLATE` blockers exist.
|
|
683
|
-
|
|
684
|
-
**Completion gate:**
|
|
685
|
-
|
|
686
|
-
- Every frontend/backend codebase has its codebase-level spec.
|
|
687
|
-
- Every present domain has its domain index.
|
|
688
|
-
- Every domain index contains the current run ID and exactly the machine markers represented by the run manifest.
|
|
689
|
-
- Every `(codebase, domain, topic)` in `expected_topics` has exactly one run-manifest entry and one output file.
|
|
690
|
-
- Every undiscovered candidate topic is recorded as `NOT_APPLICABLE`, not generated to satisfy a fixed count.
|
|
691
|
-
- No two manifest entries share one output path.
|
|
692
|
-
- Every depth spec contains the current `run_id` and matching `source_fingerprint`.
|
|
693
|
-
|
|
694
|
-
Any mismatch means Step 7.4 is incomplete.
|
|
695
|
-
|
|
696
|
-
## Step 8 — Generate Rule Package Files
|
|
115
|
+
Authority changes use compare-and-swap revisions. Rollback from database to legacy requires a verified compatibility export. Backup includes the database, manifest, and referenced immutable content. Restore validates project identity, schema, foreign keys, database hash, and every referenced content hash before replacement.
|
|
697
116
|
|
|
698
|
-
|
|
117
|
+
## Completion gate
|
|
699
118
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
```bash
|
|
703
|
-
mkdir -p .planning/rules
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
### 8.2 Generate `.planning/execution-contract.md`
|
|
707
|
-
|
|
708
|
-
Load `assets/execution-contract-template.md` and fill from scan results:
|
|
709
|
-
|
|
710
|
-
- **Backend layer models**: from each backend-type codebase navigation file's "Layer Conventions" table. Map handler/service/repository/DAO directories and describe the dependency direction. One subsection per backend codebase.
|
|
711
|
-
- **Conversion rules**: from `.cursorrules` (if present) or codebase navigation Notes. Capture domain↔vo↔model conversion rules verbatim.
|
|
712
|
-
- **Interface rules**: from `.cursorrules` or code scan. E.g., "handler implements handler interface with RegisterRoutes method".
|
|
713
|
-
- **Frontend component hierarchies**: from each frontend-type codebase navigation file's "Component Conventions" table. Map pages→page components→common components→layout→hooks. One subsection per frontend codebase.
|
|
714
|
-
- **TDD Strategy**: already embedded in template default. Fill from codebase conventions when the project has explicit TDD rules. Keep the template default otherwise.
|
|
715
|
-
- **Code Generation**: `待确认` unless codegen commands (wire, protobuf, swagger, etc.) were found during scan. If found, list each command with its source and run condition.
|
|
716
|
-
- **Verification Gates**: already embedded in template default. Fill additional project-specific verification rules from codebase conventions when present. Keep the template default otherwise.
|
|
717
|
-
|
|
718
|
-
Rules:
|
|
719
|
-
- Only write what was observed during scan. Do not invent layer rules or component conventions.
|
|
720
|
-
- If `.cursorrules` or `AGENTS.md` / `CLAUDE.md` contain explicit conventions, quote or summarize them in the relevant section.
|
|
721
|
-
- Mark unobserved sections as `待确认`, not with guessed defaults.
|
|
722
|
-
|
|
723
|
-
### 8.3 Generate `.planning/toolchain.md`
|
|
724
|
-
|
|
725
|
-
Load `assets/toolchain-template.md` and fill from the "Commands" tables in all codebase navigation files:
|
|
726
|
-
|
|
727
|
-
- Consolidate commands from each codebase, grouped by codebase name.
|
|
728
|
-
- If database migration commands were found during scan, add them.
|
|
729
|
-
- If code generation commands (wire, protobuf, swagger, etc.) were found, add them.
|
|
730
|
-
- If a command is `待确认` in the navigation files, keep it as `待确认` here.
|
|
731
|
-
|
|
732
|
-
### 8.4 Generate `.planning/rules/INDEX.md`
|
|
733
|
-
|
|
734
|
-
Load `assets/rules-index-template.md` and fill status for every rule source:
|
|
735
|
-
|
|
736
|
-
- Files created in Step 8 (`execution-contract.md`, `toolchain.md`) → status `present`.
|
|
737
|
-
- Files created in Step 7 (`.context/spec/index.md`, stack specs, frontend/backend/design indexes, codebase specs) → status `present`.
|
|
738
|
-
- Files found during Step 3 scan (`.cursorrules`, `AGENTS.md`, existing `.context/spec/`, etc.) → status `present` with path.
|
|
739
|
-
- Files not found → status `missing`.
|
|
740
|
-
- Files that don't apply (e.g., frontend rules for backend-only projects) → status `不适用`.
|
|
741
|
-
|
|
742
|
-
This file is the first thing downstream skills read. It must accurately reflect what exists after initialization.
|
|
743
|
-
|
|
744
|
-
## Step 9 — Generate STATE.md
|
|
745
|
-
|
|
746
|
-
Load `assets/state-template.md` and create `.planning/STATE.md` with:
|
|
747
|
-
|
|
748
|
-
- Initialization date
|
|
749
|
-
- Current step
|
|
750
|
-
- Completed steps
|
|
751
|
-
- Pending steps
|
|
752
|
-
- Each codebase: name, type, path, scan status, navigation file path, stack_key, and generated spec path
|
|
753
|
-
- Whether `.planning/PROJECT.md` exists
|
|
754
|
-
- Whether `.planning/navigation/` exists
|
|
755
|
-
- Whether `.context/spec/` exists and each required spec file is complete
|
|
756
|
-
- Whether each codebase navigation is complete
|
|
757
|
-
- Whether `.planning/rules/INDEX.md`, `.planning/execution-contract.md`, and `.planning/toolchain.md` exist
|
|
758
|
-
- Current `run_id`, `run_started_at`, and `code_index_status`
|
|
759
|
-
- Design rule pack status and reason
|
|
760
|
-
- Last scan timestamp
|
|
761
|
-
- Blockers
|
|
762
|
-
- Known missing information
|
|
763
|
-
- Recommended next step, usually `workflow-requirement-baseline` after the user provides a requirement
|
|
764
|
-
|
|
765
|
-
## Step 9.5 — Finalize Run Manifest
|
|
766
|
-
|
|
767
|
-
Load `assets/run-manifest-template.json` and write `.planning/project-context-run.json`.
|
|
768
|
-
|
|
769
|
-
Requirements:
|
|
770
|
-
|
|
771
|
-
- `run_id` and `started_at` exactly match the values captured before Step 1.
|
|
772
|
-
- `mode` is `full` or `fast`.
|
|
773
|
-
- `code_index_status` is `complete` in full mode and `skipped` in fast mode.
|
|
774
|
-
- `code_index_skip_reason` is `none` in full mode or the explicit skip flag in fast mode.
|
|
775
|
-
- `design_rule_pack` has status `installed` with its verified assets for frontend projects, or `not_applicable` with a reason for projects without frontend codebases.
|
|
776
|
-
- Every local/scannable frontend/backend codebase has one `topic_inventory` entry. Its `candidate_topics` come from current template filenames and its `discovered_topics` come from the Step 7.4 evidence match.
|
|
777
|
-
- Every expected depth topic has one entry with its codebase root, actual output path, complete codebase-relative `source_paths`, and computed `source_fingerprint`.
|
|
778
|
-
- Every undiscovered candidate topic is listed under `not_applicable_topics`.
|
|
779
|
-
- JSON placeholders and example rows are fully removed.
|
|
780
|
-
|
|
781
|
-
## Step 10 — Review Gate
|
|
782
|
-
|
|
783
|
-
This is the final step. Before finishing, review generated files against `references/navigation-guide.md`, then run the deterministic completion validator.
|
|
784
|
-
|
|
785
|
-
Check:
|
|
786
|
-
|
|
787
|
-
- All codebase locations from Step 1 are recorded in INDEX.md Codebase Registry.
|
|
788
|
-
- Each codebase has a navigation file at `.planning/navigation/{name}.md`.
|
|
789
|
-
- Frameworks are recorded or marked `待确认` for each codebase.
|
|
790
|
-
- Entry points and key directories are recorded or marked `待确认` for each codebase.
|
|
791
|
-
- Each codebase has a Directory Map (3a gate: all top-level/second-level directories listed).
|
|
792
|
-
- Each codebase has a Call Chain Map (3b gate: all handlers/routes traced).
|
|
793
|
-
- Each codebase has Conventions (3c gate: at minimum layer order or component hierarchy recorded).
|
|
794
|
-
- Each local/scannable codebase has a Stack Profile (3d gate: stack_key, manifest path, and dependency fingerprint recorded).
|
|
795
|
-
- Every detected stack profile has `.context/spec/stacks/{stack_key}.md`.
|
|
796
|
-
- Every frontend-type codebase has `.context/spec/frontend/{name}.md`.
|
|
797
|
-
- Every backend/service-type codebase has `.context/spec/backend/{name}.md`.
|
|
798
|
-
- Every depth topic discovered in Step 7.4 has exactly one output and manifest entry.
|
|
799
|
-
- Every topic not discovered in Step 7.4 is recorded as `NOT_APPLICABLE`; no fixed topic count is imposed.
|
|
800
|
-
- Every frontend/backend domain index has exactly the current manifest's depth-spec registry markers and no stale markers.
|
|
801
|
-
- `.context/spec/index.md` lists every stack spec and codebase spec mapping.
|
|
802
|
-
- All generated context specs include generation metadata and regeneration triggers; depth specs include the current run ID and source fingerprint.
|
|
803
|
-
- Frontend-type codebases have Route-Component Map and Data Flow tables.
|
|
804
|
-
- Backend-type codebases have API Modules, Scheduled Jobs, and External Integrations tables.
|
|
805
|
-
- Commands are recorded or marked `待确认` for each codebase.
|
|
806
|
-
- `.planning/execution-contract.md` exists and contains layer order and component hierarchy from scan results, not invented defaults.
|
|
807
|
-
- `.planning/toolchain.md` exists and consolidates commands from all codebase navigation files.
|
|
808
|
-
- `.planning/rules/INDEX.md` exists and accurately reflects generated `.context/spec/` files as present.
|
|
809
|
-
- Project rule package locations are recorded when present, including `.context/spec/`, `.context/workflow/`, and lessons.
|
|
810
|
-
- History model locations are recorded, and outbound-call style `features/` history is labeled as optional legacy rather than the default source.
|
|
811
|
-
- `.planning/PROJECT.md` links to `.planning/navigation/INDEX.md`.
|
|
812
|
-
- `.planning/navigation/INDEX.md` Codebase Registry links to every codebase navigation file.
|
|
813
|
-
- `.planning/navigation/INDEX.md` includes downstream read contract.
|
|
814
|
-
- `.planning/navigation/INDEX.md` and `.context/spec/index.md` describe `.planning/code-index/` as the machine fact layer before source reads, unless fast mode skipped generation.
|
|
815
|
-
- Every frontend project has the design rule assets from Step 6.6, while `.context/spec/design/index.md` remains generated by project-context rather than overwritten by the installer.
|
|
816
|
-
- Future output locations include `.planning/features/{功能名}/功能点梳理.md`.
|
|
817
|
-
- No requirements or roadmap were generated without explicit user request.
|
|
818
|
-
- `STATE.md` includes completion statuses and next action for each codebase.
|
|
819
|
-
- Generated files include an initialization quality summary.
|
|
820
|
-
|
|
821
|
-
Run **only after every manifest-declared output has been written and all four
|
|
822
|
-
current-run status markers have been added**. This is a final gate, not a
|
|
823
|
-
planning or progress check. Do not call it while the preceding steps are still
|
|
824
|
-
describing or planning file updates.
|
|
825
|
-
|
|
826
|
-
Run:
|
|
119
|
+
Run the database validator with identifiers returned by the scan:
|
|
827
120
|
|
|
828
121
|
```text
|
|
829
|
-
devflow_skill_script(script="project-context-validate", args=["--
|
|
122
|
+
devflow_skill_script(script="project-context-db-validate", args=["--database", "<control.db>", "--project-id", "<project-id>", "--workspace-id", "<workspace-id>", "--run-id", "<run-id>"])
|
|
830
123
|
```
|
|
831
124
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
Fix every reported gap and rerun the validator. If the command does not pass, initialization is incomplete and the final response must report the blocker instead of claiming success.
|
|
835
|
-
|
|
836
|
-
Quality status rules:
|
|
837
|
-
|
|
838
|
-
- `complete`: required fields are known and commands are identified.
|
|
839
|
-
- `partial`: project is local and scannable, but some required fields are `待确认`.
|
|
840
|
-
- `pending`: project location is remote/unavailable or scan could not run.
|
|
841
|
-
- `not_applicable`: this codebase type does not support this field (e.g., component conventions for a backend service).
|
|
842
|
-
|
|
843
|
-
## Downstream Read Contract
|
|
844
|
-
|
|
845
|
-
This skill writes the contract and the initial rule package. Other skills consume them:
|
|
125
|
+
Completion requires a stable immutable input, matching context snapshot, accounted required categories, evidence for observed facts, a registered immutable index in full mode, revision-safe pointer publication, and separate document statuses. Workflow `STATE` and other non-initialization authorities must remain unchanged.
|
|
846
126
|
|
|
847
|
-
|
|
848
|
-
- Feature breakdown should read `.planning/PROJECT.md`, `.planning/navigation/INDEX.md`, and relevant codebase navigation files as needed.
|
|
849
|
-
- Test guide generation should read `.planning/PROJECT.md`, `.planning/navigation/INDEX.md`, and `.planning/rules/INDEX.md`.
|
|
850
|
-
- Frontend technical planning should read `.planning/rules/INDEX.md` → `.context/spec/index.md` → matching `.context/spec/stacks/{stack_key}.md` → matching `.context/spec/frontend/{codebase}.md` → `.context/spec/frontend/index.md` and applicable depth specs → `.planning/navigation/{codebase}.md` → `.planning/code-index/` when relation facts are needed → actual source files.
|
|
851
|
-
- Backend technical planning should read `.planning/rules/INDEX.md` → `.context/spec/index.md` → matching `.context/spec/stacks/{stack_key}.md` → matching `.context/spec/backend/{codebase}.md` → `.context/spec/backend/index.md` and applicable depth specs → `.planning/navigation/{codebase}.md` → `.planning/code-index/` when relation facts are needed → actual source files.
|
|
852
|
-
- Change-list generation should use `.planning/navigation/INDEX.md` for output locations and project conventions, and use discovered `.context/spec/` + `.planning/rules/` sources for task-level gates.
|
|
127
|
+
Report partial, unsupported, skipped, failed, and unknown coverage honestly. Initialization success does not mean tests passed, services ran, designs were approved, or requirements were delivered.
|