@guanlin4924/devflow-pi 0.1.93 → 0.1.94

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.
Files changed (156) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/plugins/devflow-core/extensions/devflow-core.ts +87 -33
  4. package/plugins/devflow-core/runtime/hooks/context_sync_gate.py +3 -3
  5. package/plugins/devflow-core/runtime/hooks/hook_common.py +65 -11
  6. package/plugins/devflow-core/runtime/hooks/start.py +13 -13
  7. package/plugins/devflow-core/skills/wireframe-proposal/SKILL.md +2 -2
  8. package/plugins/devflow-core/skills/wireframe-validate/SKILL.md +4 -4
  9. package/plugins/devflow-core/skills/workflow-orchestrator/SKILL.md +19 -19
  10. package/plugins/devflow-core/skills/workflow-orchestrator/agents/openai.yaml +2 -2
  11. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/acceptance_test_runner.py +5 -5
  12. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/advance_state.rb +9 -9
  13. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/api_test_matrix.py +2 -2
  14. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/architecture_assessment.rb +1 -1
  15. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/architecture_brief.rb +1 -1
  16. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/architecture_feasibility.rb +1 -1
  17. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/business_invalidation.rb +5 -5
  18. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/business_model_commit.rb +4 -4
  19. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/business_model_validate.py +1 -1
  20. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/business_source_resolver.rb +4 -4
  21. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/checker_adapter.rb +7 -7
  22. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/control_io.rb +51 -7
  23. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/cross_track_consistency_check.rb +1 -1
  24. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/execution_contract.rb +6 -6
  25. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/gate_runtime.rb +3 -3
  26. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/init_state.rb +5 -5
  27. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/init_workflow.rb +5 -5
  28. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/inspect_state.rb +13 -13
  29. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/machine_evidence.rb +3 -3
  30. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/manage_lessons.rb +7 -7
  31. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/parallel_recover.rb +2 -2
  32. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/parallel_run.rb +3 -3
  33. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/phase_ownership.rb +6 -6
  34. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/repair_control_plane.rb +1 -1
  35. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/requirement_coverage.rb +1 -1
  36. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/requirement_graph.rb +3 -3
  37. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/review_preflight.py +3 -3
  38. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/review_run.py +18 -18
  39. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/runtime_context_collector.rb +3 -3
  40. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/session_rollover.rb +4 -4
  41. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/static_runtime_context_collector.rb +2 -2
  42. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/sync_artifacts.rb +5 -5
  43. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/tdd_evidence.py +3 -3
  44. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/test_command_policy.py +2 -2
  45. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/test_task_binding_check.py +3 -3
  46. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/update_triage_route.rb +3 -3
  47. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/validate_state.rb +6 -6
  48. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/wireframe_commit.rb +5 -5
  49. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/wireframe_validate.py +1 -1
  50. package/plugins/devflow-core/skills/workflow-orchestrator/templates/acceptance-remediation.yaml +12 -12
  51. package/plugins/devflow-core/skills/workflow-orchestrator/templates/feature-development.yaml +205 -205
  52. package/plugins/devflow-core/skills/workflow-pipeline/SKILL.md +3 -3
  53. package/plugins/devflow-core/skills/workflow-pipeline/references/pipeline-flow.md +10 -10
  54. package/plugins/devflow-core/skills/workflow-project-context/SKILL.md +14 -14
  55. package/plugins/devflow-core/skills/workflow-project-context/assets/agents-md-template.md +7 -7
  56. package/plugins/devflow-core/skills/workflow-project-context/assets/codebase-backend-spec-template.md +4 -4
  57. package/plugins/devflow-core/skills/workflow-project-context/assets/codebase-frontend-spec-template.md +4 -4
  58. package/plugins/devflow-core/skills/workflow-project-context/assets/codebase-navigation-template.md +1 -1
  59. package/plugins/devflow-core/skills/workflow-project-context/assets/context-domain-index-template.md +4 -4
  60. package/plugins/devflow-core/skills/workflow-project-context/assets/context-spec-index-template.md +10 -10
  61. package/plugins/devflow-core/skills/workflow-project-context/assets/execution-contract-template.md +2 -2
  62. package/plugins/devflow-core/skills/workflow-project-context/assets/navigation-index-template.md +18 -18
  63. package/plugins/devflow-core/skills/workflow-project-context/assets/project-initialization-template.md +32 -32
  64. package/plugins/devflow-core/skills/workflow-project-context/assets/rules-index-template.md +30 -30
  65. package/plugins/devflow-core/skills/workflow-project-context/assets/state-template.md +7 -7
  66. package/plugins/devflow-core/skills/workflow-project-context/references/navigation-guide.md +37 -37
  67. package/plugins/devflow-core/skills/workflow-project-context/scripts/validate_initialization.py +16 -16
  68. package/plugins/devflow-design/skills/workflow-api-call-guide/SKILL.md +4 -4
  69. package/plugins/devflow-design/skills/workflow-api-contract/SKILL.md +8 -8
  70. package/plugins/devflow-design/skills/workflow-api-supplement/SKILL.md +5 -5
  71. package/plugins/devflow-design/skills/workflow-architecture-feasibility/SKILL.md +1 -1
  72. package/plugins/devflow-design/skills/workflow-backend-tech-spec/SKILL.md +39 -39
  73. package/plugins/devflow-design/skills/workflow-backend-tech-spec/assets/backend-spec-template.md +10 -10
  74. package/plugins/devflow-design/skills/workflow-backend-tech-spec/references/affected-module-exploration.md +2 -2
  75. package/plugins/devflow-design/skills/workflow-backend-tech-spec/references/code-explore-guide.md +1 -1
  76. package/plugins/devflow-design/skills/workflow-backend-tech-spec/references/project-rule-contract.md +20 -20
  77. package/plugins/devflow-design/skills/workflow-design-rule-pack/SKILL.md +8 -8
  78. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/index.md +3 -3
  79. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/accessibility.md +2 -2
  80. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/component-library.md +2 -2
  81. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/design-systems.md +1 -1
  82. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/responsive-grid.md +2 -2
  83. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/stack-guidelines.md +6 -6
  84. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/recommendations/ux-patterns.md +2 -2
  85. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/tokens/project-tokens.md +1 -1
  86. package/plugins/devflow-design/skills/workflow-design-rule-pack/assets/design/tools/ui-ux-pro-max/SKILL.md +12 -12
  87. package/plugins/devflow-design/skills/workflow-design-rule-pack/scripts/install.py +2 -2
  88. package/plugins/devflow-design/skills/workflow-feature-breakdown/SKILL.md +30 -30
  89. package/plugins/devflow-design/skills/workflow-feature-breakdown/assets/output-template.md +2 -2
  90. package/plugins/devflow-design/skills/workflow-frontend-tech-spec/SKILL.md +41 -41
  91. package/plugins/devflow-design/skills/workflow-frontend-tech-spec/assets/frontend-spec-template.md +15 -15
  92. package/plugins/devflow-design/skills/workflow-frontend-tech-spec/references/affected-module-exploration.md +2 -2
  93. package/plugins/devflow-design/skills/workflow-frontend-tech-spec/references/project-rule-contract.md +25 -25
  94. package/plugins/devflow-design/skills/workflow-integration-verify/SKILL.md +13 -13
  95. package/plugins/devflow-design/skills/workflow-ui-spec/SKILL.md +23 -23
  96. package/plugins/devflow-design/skills/workflow-ui-spec/assets/ui-spec-template.md +3 -3
  97. package/plugins/devflow-implementation/agents/implementation-worker.md +2 -2
  98. package/plugins/devflow-implementation/skills/workflow-bug-fix/SKILL.md +9 -9
  99. package/plugins/devflow-implementation/skills/workflow-bug-fix/references/lesson-format.md +2 -2
  100. package/plugins/devflow-implementation/skills/workflow-bug-fix/references/root-cause-ladder.md +1 -1
  101. package/plugins/devflow-implementation/skills/workflow-change-plan/SKILL.md +17 -17
  102. package/plugins/devflow-implementation/skills/workflow-change-plan/references/code-conventions.md +1 -1
  103. package/plugins/devflow-implementation/skills/workflow-change-plan/references/output-template.md +3 -3
  104. package/plugins/devflow-implementation/skills/workflow-change-plan/references/project-rule-contract.md +16 -16
  105. package/plugins/devflow-implementation/skills/workflow-execute-phase/SKILL.md +38 -38
  106. package/plugins/devflow-implementation/skills/workflow-execute-phase/references/execute-phase.md +1 -1
  107. package/plugins/devflow-intel/agents/project-scout.md +1 -1
  108. package/plugins/devflow-intel/extensions/devflow-intel.ts +20 -19
  109. package/plugins/devflow-intel/skills/code-index-query/SKILL.md +6 -6
  110. package/plugins/devflow-intel/skills/workflow-code-index/SKILL.md +12 -12
  111. package/plugins/devflow-intel/skills/workflow-code-index/references/discovery.md +2 -2
  112. package/plugins/devflow-intel/skills/workflow-code-index/references/query-guide.md +1 -1
  113. package/plugins/devflow-intel/skills/workflow-code-index/scripts/code_index.py +8 -8
  114. package/plugins/devflow-intel/skills/workflow-code-index/scripts/core/discovery.py +2 -2
  115. package/plugins/devflow-intel/skills/workflow-code-index/scripts/core/scanner.py +4 -1
  116. package/plugins/devflow-intel/skills/workflow-code-index/scripts/validators/project_binding_check.py +4 -4
  117. package/plugins/devflow-intel/skills/workflow-context-sync/SKILL.md +14 -14
  118. package/plugins/devflow-intel/skills/workflow-context-sync/scripts/context_sync_cursor.py +2 -2
  119. package/plugins/devflow-intel/skills/workflow-update-navigation/SKILL.md +26 -26
  120. package/plugins/devflow-intel/skills/workflow-update-navigation/references/incremental-update-guide.md +2 -2
  121. package/plugins/devflow-quality/skills/code-review/SKILL.md +12 -12
  122. package/plugins/devflow-quality/skills/code-review/references/spec-checklist.md +1 -1
  123. package/plugins/devflow-quality/skills/workflow-acceptance-test-design/SKILL.md +8 -8
  124. package/plugins/devflow-quality/skills/workflow-gen-test-guide/SKILL.md +6 -6
  125. package/plugins/devflow-quality/skills/workflow-gen-test-guide/legacy/SKILL.md +14 -14
  126. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/SKILL.md +23 -23
  127. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/codebase-discovery.md +9 -9
  128. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/project-dsl-contract.md +1 -1
  129. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/compile_dsl.py +2 -2
  130. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/discover_codebases.py +2 -2
  131. package/plugins/devflow-quality/skills/workflow-release-closeout/SKILL.md +15 -15
  132. package/plugins/devflow-quality/skills/workflow-run-acceptance-tests/SKILL.md +5 -5
  133. package/plugins/devflow-requirements/skills/requirement-feasibility-review/SKILL.md +1 -1
  134. package/plugins/devflow-requirements/skills/workflow-demand-clarify/SKILL.md +10 -10
  135. package/plugins/devflow-requirements/skills/workflow-domain-modeling/SKILL.md +25 -25
  136. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/SKILL.md +49 -49
  137. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/assets/baseline-template.md +22 -22
  138. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/references/antipatterns.md +3 -3
  139. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/references/challenge-review-guide.md +3 -3
  140. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/references/project-context-guide.md +11 -11
  141. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/references/questioning.md +1 -1
  142. package/plugins/devflow-requirements/skills/workflow-requirement-baseline/references/requirement-review-checklist.md +4 -4
  143. package/plugins/devflow-requirements/skills/workflow-requirement-triage/SKILL.md +16 -16
  144. package/plugins/devflow-requirements/skills/workflow-wayfinder/SKILL.md +6 -6
  145. package/src/cli.ts +15 -0
  146. package/src/constants.ts +1 -1
  147. package/src/initialization-store.ts +3 -2
  148. package/src/project-context.ts +36 -14
  149. package/src/project-documents.ts +61 -61
  150. package/src/project-initializer.ts +9 -8
  151. package/src/project-layout.ts +217 -0
  152. package/src/runtime.ts +3 -3
  153. package/templates/commands/start.md +4 -4
  154. package/templates/omp/AGENTS.md +1 -1
  155. package/templates/omp/hook-config.json +7 -7
  156. package/templates/omp/index-policy.json +8 -8
@@ -0,0 +1,217 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { access, cp, lstat, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ export const DEVFLOW_DIRECTORY = ".devflow";
6
+ export const DEVFLOW_MANIFEST = ".devflow/project.json";
7
+ export const PLANNING_DIRECTORY = ".devflow/planning";
8
+ export const CONTEXT_DIRECTORY = ".devflow/context";
9
+ export const LEGACY_PLANNING_DIRECTORY = ".planning";
10
+ export const LEGACY_CONTEXT_DIRECTORY = ".context";
11
+ export const LAYOUT_MIGRATION_MARKER = ".devflow/layout-migration.json";
12
+ export const LEGACY_PLANNING_MARKERS = [
13
+ "STATE.md", "PROJECT.md", ".devflow.lock", "navigation/INDEX.md", "code-index/INDEX.md",
14
+ "workflows", "contracts", "evidence", "review-runs", "requirements", "features",
15
+ "handoffs", "artifacts", "phase-ownership.yaml",
16
+ ] as const;
17
+ export const LEGACY_CONTEXT_MARKERS = ["spec/index.md", "index.md", "project/index.md", "knowledge/index.md"] as const;
18
+ export const ACTIVE_LEGACY_CONTROL_PATHS = [
19
+ "STATE.md", "workflows", "contracts", "evidence", "review-runs", "requirements",
20
+ "features", "handoffs", "artifacts", "phase-ownership.yaml",
21
+ ] as const;
22
+
23
+ export const DEVFLOW_SCAN_EXCLUDES = [
24
+ ".git/**",
25
+ ".devflow/**",
26
+ ".planning/**",
27
+ ".context/**",
28
+ ] as const;
29
+
30
+ export type ProjectLayout = {
31
+ devflowRoot: string;
32
+ manifestPath: string;
33
+ planningRoot: string;
34
+ contextRoot: string;
35
+ };
36
+
37
+ export function projectLayout(root: string): ProjectLayout {
38
+ const projectRoot = path.resolve(root);
39
+ const devflowRoot = path.join(projectRoot, DEVFLOW_DIRECTORY);
40
+ return {
41
+ devflowRoot,
42
+ manifestPath: path.join(projectRoot, DEVFLOW_MANIFEST),
43
+ planningRoot: path.join(projectRoot, PLANNING_DIRECTORY),
44
+ contextRoot: path.join(projectRoot, CONTEXT_DIRECTORY),
45
+ };
46
+ }
47
+
48
+ async function exists(target: string): Promise<boolean> {
49
+ try {
50
+ await access(target);
51
+ return true;
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ async function containsLegacyMarker(root: string, kind: "planning" | "context"): Promise<boolean> {
58
+ const markers = kind === "planning" ? LEGACY_PLANNING_MARKERS : LEGACY_CONTEXT_MARKERS;
59
+ return (await Promise.all(markers.map(marker => exists(path.join(root, marker))))).some(Boolean);
60
+ }
61
+
62
+ async function containsActiveLegacyControl(root: string): Promise<string | null> {
63
+ for (const relative of ACTIVE_LEGACY_CONTROL_PATHS) {
64
+ if (await exists(path.join(root, relative))) return relative;
65
+ }
66
+ return null;
67
+ }
68
+
69
+ async function readValidProjectManifest(manifestPath: string): Promise<Record<string, unknown> | null> {
70
+ try {
71
+ const value = JSON.parse(await readFile(manifestPath, "utf8")) as Record<string, unknown>;
72
+ const valid = Object.getPrototypeOf(value) === Object.prototype
73
+ && value.schemaVersion === 1
74
+ && typeof value.name === "string" && value.name.trim().length > 0
75
+ && typeof value.createdAt === "string" && Number.isFinite(Date.parse(value.createdAt))
76
+ && typeof value.projectId === "string"
77
+ && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.projectId)
78
+ && (value.layoutVersion === undefined || value.layoutVersion === 1 || value.layoutVersion === 2);
79
+ return valid ? value : null;
80
+ } catch {
81
+ return null;
82
+ }
83
+ }
84
+
85
+ async function validMigrationMarker(root: string): Promise<boolean> {
86
+ try {
87
+ const value = JSON.parse(await readFile(path.join(root, LAYOUT_MIGRATION_MARKER), "utf8")) as Record<string, unknown>;
88
+ return value.schemaVersion === 1 && value.status === "complete" && Array.isArray(value.migrated);
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+
94
+ async function rewriteLegacyReferences(directory: string): Promise<void> {
95
+ const textExtensions = new Set([".md", ".json", ".jsonl", ".yaml", ".yml", ".txt"]);
96
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
97
+ const target = path.join(directory, entry.name);
98
+ if (entry.isSymbolicLink()) throw new Error(`DEVFLOW_LAYOUT_SYMLINK: ${target}`);
99
+ if (entry.isDirectory()) {
100
+ await rewriteLegacyReferences(target);
101
+ continue;
102
+ }
103
+ if (!entry.isFile() || !textExtensions.has(path.extname(entry.name).toLowerCase())) continue;
104
+ const original = await readFile(target, "utf8");
105
+ const rewritten = original
106
+ .replaceAll(".planning/", ".devflow/planning/")
107
+ .replaceAll(".context/", ".devflow/context/");
108
+ if (rewritten !== original) await writeFile(target, rewritten, "utf8");
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Copies an old Devflow layout into the namespaced layout. Legacy paths stay
114
+ * read-only and are never selected as new write targets. Migration is only
115
+ * permitted for a directory next to an existing project manifest and only
116
+ * when a Devflow-owned marker is present. A same-named business directory is
117
+ * therefore never treated as control state based on its name alone.
118
+ */
119
+ export type LayoutMigrationHooks = {
120
+ beforeCandidatePublish?: (kind: "planning" | "context") => void | Promise<void>;
121
+ beforeMarkerPublish?: () => void | Promise<void>;
122
+ allowActive?: boolean;
123
+ allowUnmanifested?: boolean;
124
+ };
125
+
126
+ export async function migrateLegacyProjectLayout(root: string, hooks: LayoutMigrationHooks = {}): Promise<string[]> {
127
+ const projectRoot = path.resolve(root);
128
+ const layout = projectLayout(projectRoot);
129
+ const candidates = [
130
+ { kind: "planning" as const, legacy: path.join(projectRoot, LEGACY_PLANNING_DIRECTORY), canonical: layout.planningRoot },
131
+ { kind: "context" as const, legacy: path.join(projectRoot, LEGACY_CONTEXT_DIRECTORY), canonical: layout.contextRoot },
132
+ ];
133
+ const markedCandidates: typeof candidates = [];
134
+ for (const candidate of candidates) {
135
+ const legacyStat = await lstat(candidate.legacy).catch(() => null);
136
+ if (!legacyStat?.isDirectory() || legacyStat.isSymbolicLink()) continue;
137
+ if (await containsLegacyMarker(candidate.legacy, candidate.kind)) markedCandidates.push(candidate);
138
+ }
139
+ if (!markedCandidates.length) return [];
140
+ let manifest = await readValidProjectManifest(layout.manifestPath);
141
+ if (!manifest && hooks.allowUnmanifested) {
142
+ manifest = {
143
+ schemaVersion: 1,
144
+ layoutVersion: 1,
145
+ projectId: randomUUID(),
146
+ name: path.basename(projectRoot),
147
+ createdAt: new Date().toISOString(),
148
+ };
149
+ await mkdir(layout.devflowRoot, { recursive: true });
150
+ await writeFile(layout.manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { encoding: "utf8", flag: "wx" });
151
+ }
152
+ if (!manifest) {
153
+ throw new Error("DEVFLOW_LEGACY_LAYOUT_CONFIRMATION_REQUIRED: legacy Devflow directories exist without a valid project manifest; initialize or confirm migration explicitly");
154
+ }
155
+ const markerValid = await validMigrationMarker(projectRoot);
156
+ const active = await containsActiveLegacyControl(path.join(projectRoot, LEGACY_PLANNING_DIRECTORY));
157
+ if (active && !hooks.allowActive && !markerValid) {
158
+ throw new Error(`DEVFLOW_ACTIVE_LEGACY_LAYOUT: .planning/${active} requires a dedicated control-plane migration before this project can run`);
159
+ }
160
+
161
+ await mkdir(layout.devflowRoot, { recursive: true });
162
+ const canonicalExists = await exists(layout.planningRoot) || await exists(layout.contextRoot);
163
+ // A completed v2 migration is immutable. Legacy directories are retained
164
+ // only as read-only history; never re-import them on a later startup.
165
+ if (manifest.layoutVersion === 2 && markerValid) {
166
+ for (const candidate of markedCandidates) {
167
+ if (!(await exists(candidate.canonical))) {
168
+ throw new Error(`DEVFLOW_LEGACY_REINTRODUCTION: v2 project will not backfill ${candidate.kind} from a legacy directory`);
169
+ }
170
+ }
171
+ return [];
172
+ }
173
+ if (manifest.layoutVersion === 2 && !markerValid) {
174
+ throw new Error("DEVFLOW_LEGACY_REINTRODUCTION: a v2 project cannot import newly introduced .planning/.context content");
175
+ }
176
+ if (canonicalExists && !markerValid) {
177
+ throw new Error("DEVFLOW_LAYOUT_CONFLICT: a partial canonical layout coexists with legacy Devflow content without a completed migration marker");
178
+ }
179
+ const migrated: string[] = [];
180
+ const committed: string[] = [];
181
+ for (const candidate of candidates) {
182
+ const legacyStat = await lstat(candidate.legacy).catch(() => null);
183
+ if (!legacyStat?.isDirectory() || legacyStat.isSymbolicLink()) continue;
184
+ if (!(await containsLegacyMarker(candidate.legacy, candidate.kind))) continue;
185
+ if (await exists(candidate.canonical)) {
186
+ if (markerValid) continue;
187
+ throw new Error(`DEVFLOW_LAYOUT_CONFLICT: both ${path.relative(projectRoot, candidate.legacy)} and ${path.relative(projectRoot, candidate.canonical)} exist without a completed migration marker`);
188
+ }
189
+ const staging = `${candidate.canonical}.migration-${randomUUID()}`;
190
+ try {
191
+ await cp(candidate.legacy, staging, { recursive: true, errorOnExist: true, force: false });
192
+ await rewriteLegacyReferences(staging);
193
+ await hooks.beforeCandidatePublish?.(candidate.kind);
194
+ await rename(staging, candidate.canonical);
195
+ committed.push(candidate.canonical);
196
+ } catch (error) {
197
+ await rm(staging, { recursive: true, force: true }).catch(() => {});
198
+ await Promise.all(committed.map(target => rm(target, { recursive: true, force: true }).catch(() => {})));
199
+ throw error;
200
+ }
201
+ migrated.push(path.relative(projectRoot, candidate.canonical).replaceAll("\\", "/"));
202
+ }
203
+ if (migrated.length) {
204
+ const marker = path.join(projectRoot, LAYOUT_MIGRATION_MARKER);
205
+ const temporary = `${marker}.${randomUUID()}.tmp`;
206
+ try {
207
+ await writeFile(temporary, `${JSON.stringify({ schemaVersion: 1, status: "complete", migrated, legacyReadOnly: true, migratedAt: new Date().toISOString() }, null, 2)}\n`, { encoding: "utf8", flag: "wx" });
208
+ await hooks.beforeMarkerPublish?.();
209
+ await rename(temporary, marker);
210
+ } catch (error) {
211
+ await rm(temporary, { force: true }).catch(() => {});
212
+ await Promise.all(committed.map(target => rm(target, { recursive: true, force: true }).catch(() => {})));
213
+ throw error;
214
+ }
215
+ }
216
+ return migrated;
217
+ }
package/src/runtime.ts CHANGED
@@ -21,7 +21,7 @@ export interface RuntimeOptions {
21
21
  const TOOL_CALL_SAFETY_PROMPT = `Devflow tool-call rules:
22
22
  - Read always requires a non-empty string path; never call Read with {} or omit path.
23
23
  - skill:// URLs identify one exact packaged resource. Never use Glob or Grep with a skill:// URL or wildcard; choose an exact resource and use Read.
24
- - A generated project path such as .context/spec/frontend/index.md is not automatically a packaged skill template path.
24
+ - A generated project path such as .devflow/context/spec/frontend/index.md is not automatically a packaged skill template path.
25
25
  - The project-context validator is a final gate. Do not run project-context-validate while files are still being planned or written.`;
26
26
 
27
27
  const MANAGED_SETTINGS: Record<string, unknown> = {
@@ -212,7 +212,7 @@ export async function runInteractiveRuntime(project: ProjectContext, options: Ru
212
212
  if (rolloverConsumptionInFlight || interactiveSubmissionInFlight || runtime.session.isStreaming) return;
213
213
  rolloverConsumptionInFlight = true;
214
214
  try {
215
- const requestPath = path.join(project.root, ".planning", "rollover-request.json");
215
+ const requestPath = path.join(project.root, ".devflow/planning", "rollover-request.json");
216
216
  let request: { schema_version?: number; rollover_id?: string; source_session_id?: string };
217
217
  let originalRequest: string;
218
218
  try {
@@ -279,7 +279,7 @@ export async function runInteractiveRuntime(project: ProjectContext, options: Ru
279
279
  }, delay);
280
280
  };
281
281
  const waitForControlledRollover = async (): Promise<void> => {
282
- const requestPath = path.join(project.root, ".planning", "rollover-request.json");
282
+ const requestPath = path.join(project.root, ".devflow/planning", "rollover-request.json");
283
283
  let requestObserved = false;
284
284
  // The input hook may finish its async state transition just after
285
285
  // submitInteractiveInput resolves. Wait briefly for that durable request
@@ -39,7 +39,7 @@
39
39
 
40
40
  **关键约定**:当用户要求进入下一个 workflow 步骤时(说"继续"、"下一步"、或直接调用 workflow skill),在执行新 skill 之前先做两件事:
41
41
 
42
- 1. 写入 `.planning/.next-intent`:
42
+ 1. 写入 `.devflow/planning/.next-intent`:
43
43
  - 继续下一步:`{"action": "continue"}`
44
44
  - 调用指定 skill:`{"action": "skill", "skill": "workflow-run-acceptance-tests", "args": "..."}`
45
45
  2. 执行 `/clear`
@@ -53,6 +53,6 @@
53
53
  - workflow skill 使用 `skill://<name>` 按需读取(如 `skill://workflow-run-acceptance-tests`)。
54
54
  - 上下文管理:你觉得需要时就 `/clear`,不要等 compaction。`/clear` 后 hook 会自动恢复 pipeline 状态和索引入口。
55
55
  - 优先读取最新的规则、规范和导航索引;索引缺失或过期时回退到 LSP、搜索和源码事实,并显式报告降级状态
56
- - 读 `.context/lessons/README.md`,避免已知陷阱
57
- - 每个步骤完成后更新 `.planning/STATE.md`
58
- - 遇到不确定的情况,在 `.context/lessons/` 中记录
56
+ - 读 `.devflow/context/lessons/README.md`,避免已知陷阱
57
+ - 每个步骤完成后更新 `.devflow/planning/STATE.md`
58
+ - 遇到不确定的情况,在 `.devflow/context/lessons/` 中记录
@@ -10,7 +10,7 @@ This repository uses an OMP-native, project-scoped software delivery runtime.
10
10
  - Mutate checkpoints and steps only with `devflow_transition`.
11
11
  - To abandon an active feature, use the runtime-confirmed `devflow_transition`
12
12
  `cancel-feature` operation or `/devflow abandon`; never edit control files.
13
- - Never directly edit `.planning/STATE.md`, `.planning/.next-intent`, `.planning/workflows/`, or `.planning/artifacts/index.yaml`.
13
+ - Never directly edit `.devflow/planning/STATE.md`, `.devflow/planning/.next-intent`, `.devflow/planning/workflows/`, or `.devflow/planning/artifacts/index.yaml`.
14
14
  - The parent session is the only workflow-state writer. Task agents return evidence or patches and never advance state.
15
15
 
16
16
  ## Evidence order
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "sources": {
3
- "state": ".planning/STATE.md",
4
- "workflow": ".context/workflow.md",
3
+ "state": ".devflow/planning/STATE.md",
4
+ "workflow": ".devflow/context/workflow.md",
5
5
  "indexes": [
6
- ".planning/rules/INDEX.md",
7
- ".context/spec/index.md",
8
- ".planning/navigation/INDEX.md",
9
- ".planning/code-index/INDEX.md"
6
+ ".devflow/planning/rules/INDEX.md",
7
+ ".devflow/context/spec/index.md",
8
+ ".devflow/planning/navigation/INDEX.md",
9
+ ".devflow/planning/code-index/INDEX.md"
10
10
  ],
11
- "lessons": ".context/lessons/README.md"
11
+ "lessons": ".devflow/context/lessons/README.md"
12
12
  },
13
13
  "gates": {
14
14
  "index_first": {
@@ -3,19 +3,19 @@
3
3
  "mode": "advisory",
4
4
  "protected_roots": [],
5
5
  "required_evidence": [
6
- ".planning/rules/INDEX.md",
7
- ".context/spec/index.md",
8
- ".planning/navigation/INDEX.md"
6
+ ".devflow/planning/rules/INDEX.md",
7
+ ".devflow/context/spec/index.md",
8
+ ".devflow/planning/navigation/INDEX.md"
9
9
  ],
10
10
  "optional_evidence": [
11
- ".planning/code-index/INDEX.md"
11
+ ".devflow/planning/code-index/INDEX.md"
12
12
  ],
13
13
  "allowed_before_gate": [
14
14
  "AGENTS.md",
15
15
  "README.md",
16
16
  ".omp/**",
17
- ".planning/**",
18
- ".context/**",
17
+ ".devflow/planning/**",
18
+ ".devflow/context/**",
19
19
  ".agent-gates/**",
20
20
  ".skills/**"
21
21
  ],
@@ -26,8 +26,8 @@
26
26
  "full_file_threshold": 30,
27
27
  "ignore": [
28
28
  ".omp/**",
29
- ".planning/**",
30
- ".context/**",
29
+ ".devflow/planning/**",
30
+ ".devflow/context/**",
31
31
  ".agent-gates/**",
32
32
  ".skills/**"
33
33
  ],