@lumenflow/core 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @file wu-done-docs-generate.ts
3
+ * @description Documentation regeneration utilities for wu:done
4
+ *
5
+ * WU-1061: Integrate docs:generate into wu:done for @lumenflow/* changes
6
+ *
7
+ * Detects changes to files that affect generated documentation and triggers
8
+ * regeneration during wu:done (after gates pass, before metadata commit).
9
+ */
10
+ /**
11
+ * Pathspecs for files that affect generated documentation.
12
+ * When any of these files change, docs:generate should be run.
13
+ *
14
+ * Based on .husky/hooks/docs-sync.mjs patterns, expanded to match
15
+ * all files that can affect CLI/config documentation.
16
+ */
17
+ export declare const DOC_SOURCE_PATHSPECS: readonly ["tools/generate-cli-docs.ts", "packages/@lumenflow/core/src/arg-parser.ts", "packages/@lumenflow/core/src/lumenflow-config-schema.ts", "packages/@lumenflow/core/src/index.ts", "packages/@lumenflow/cli/package.json", "packages/@lumenflow/cli/src/"];
18
+ /**
19
+ * Output files generated by docs:generate.
20
+ * These files are staged before the metadata commit.
21
+ */
22
+ export declare const DOC_OUTPUT_FILES: readonly ["apps/docs/src/content/docs/reference/cli.mdx", "apps/docs/src/content/docs/reference/config.mdx"];
23
+ /**
24
+ * Check if any doc-source files changed compared to the base branch.
25
+ * Uses git diff with pathspecs for efficient detection.
26
+ *
27
+ * @param baseBranch - Base branch for comparison (e.g., 'main', 'origin/main')
28
+ * @returns Promise<boolean> - True if doc-source files changed
29
+ */
30
+ export declare function hasDocSourceChanges(baseBranch: string): Promise<boolean>;
31
+ /**
32
+ * Stage doc output files for the metadata commit.
33
+ *
34
+ * @returns Promise<void>
35
+ */
36
+ export declare function stageDocOutputs(): Promise<void>;
37
+ /**
38
+ * Run turbo docs:generate to regenerate documentation.
39
+ * Turbo handles build dependencies and caching.
40
+ *
41
+ * @param repoRoot - Repository root directory
42
+ * @returns void
43
+ */
44
+ export declare function runDocsGenerate(repoRoot: string): void;
45
+ /**
46
+ * Result of the docs regeneration check.
47
+ */
48
+ export interface DocsRegenerationResult {
49
+ /** Whether doc-source files changed */
50
+ docsChanged: boolean;
51
+ /** Whether docs were regenerated */
52
+ regenerated: boolean;
53
+ }
54
+ /**
55
+ * Options for maybeRegenerateAndStageDocs.
56
+ */
57
+ export interface MaybeRegenerateDocsOptions {
58
+ /** Base branch for comparison (e.g., 'main', calculated from defaultBranchFrom) */
59
+ baseBranch: string;
60
+ /** Repository root directory for running turbo */
61
+ repoRoot: string;
62
+ }
63
+ /**
64
+ * Detect doc-source changes and regenerate docs if needed.
65
+ * This is the main integration point for wu:done.
66
+ *
67
+ * Call this BEFORE stageAndFormatMetadata() to include doc outputs
68
+ * in the single atomic commit.
69
+ *
70
+ * @param options - Detection and regeneration options
71
+ * @returns Promise<DocsRegenerationResult> - Whether docs changed and were regenerated
72
+ */
73
+ export declare function maybeRegenerateAndStageDocs(options: MaybeRegenerateDocsOptions): Promise<DocsRegenerationResult>;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @file wu-done-docs-generate.ts
3
+ * @description Documentation regeneration utilities for wu:done
4
+ *
5
+ * WU-1061: Integrate docs:generate into wu:done for @lumenflow/* changes
6
+ *
7
+ * Detects changes to files that affect generated documentation and triggers
8
+ * regeneration during wu:done (after gates pass, before metadata commit).
9
+ */
10
+ import { execSync } from 'node:child_process';
11
+ import { getGitForCwd } from './git-adapter.js';
12
+ import { STDIO } from './wu-constants.js';
13
+ /**
14
+ * Pathspecs for files that affect generated documentation.
15
+ * When any of these files change, docs:generate should be run.
16
+ *
17
+ * Based on .husky/hooks/docs-sync.mjs patterns, expanded to match
18
+ * all files that can affect CLI/config documentation.
19
+ */
20
+ export const DOC_SOURCE_PATHSPECS = [
21
+ 'tools/generate-cli-docs.ts',
22
+ 'packages/@lumenflow/core/src/arg-parser.ts',
23
+ 'packages/@lumenflow/core/src/lumenflow-config-schema.ts',
24
+ 'packages/@lumenflow/core/src/index.ts',
25
+ 'packages/@lumenflow/cli/package.json',
26
+ 'packages/@lumenflow/cli/src/',
27
+ ];
28
+ /**
29
+ * Output files generated by docs:generate.
30
+ * These files are staged before the metadata commit.
31
+ */
32
+ export const DOC_OUTPUT_FILES = [
33
+ 'apps/docs/src/content/docs/reference/cli.mdx',
34
+ 'apps/docs/src/content/docs/reference/config.mdx',
35
+ ];
36
+ /**
37
+ * Check if any doc-source files changed compared to the base branch.
38
+ * Uses git diff with pathspecs for efficient detection.
39
+ *
40
+ * @param baseBranch - Base branch for comparison (e.g., 'main', 'origin/main')
41
+ * @returns Promise<boolean> - True if doc-source files changed
42
+ */
43
+ export async function hasDocSourceChanges(baseBranch) {
44
+ try {
45
+ const gitAdapter = getGitForCwd();
46
+ const diff = await gitAdapter.raw([
47
+ 'diff',
48
+ `${baseBranch}...HEAD`,
49
+ '--name-only',
50
+ '--',
51
+ ...DOC_SOURCE_PATHSPECS,
52
+ ]);
53
+ return diff.trim().length > 0;
54
+ }
55
+ catch {
56
+ // Fail-safe: don't regenerate on git errors
57
+ return false;
58
+ }
59
+ }
60
+ /**
61
+ * Stage doc output files for the metadata commit.
62
+ *
63
+ * @returns Promise<void>
64
+ */
65
+ export async function stageDocOutputs() {
66
+ const gitAdapter = getGitForCwd();
67
+ await gitAdapter.add([...DOC_OUTPUT_FILES]);
68
+ }
69
+ /**
70
+ * Run turbo docs:generate to regenerate documentation.
71
+ * Turbo handles build dependencies and caching.
72
+ *
73
+ * @param repoRoot - Repository root directory
74
+ * @returns void
75
+ */
76
+ export function runDocsGenerate(repoRoot) {
77
+ execSync('pnpm turbo docs:generate', {
78
+ cwd: repoRoot,
79
+ stdio: STDIO.INHERIT,
80
+ encoding: 'utf-8',
81
+ });
82
+ }
83
+ /**
84
+ * Detect doc-source changes and regenerate docs if needed.
85
+ * This is the main integration point for wu:done.
86
+ *
87
+ * Call this BEFORE stageAndFormatMetadata() to include doc outputs
88
+ * in the single atomic commit.
89
+ *
90
+ * @param options - Detection and regeneration options
91
+ * @returns Promise<DocsRegenerationResult> - Whether docs changed and were regenerated
92
+ */
93
+ export async function maybeRegenerateAndStageDocs(options) {
94
+ const { baseBranch, repoRoot } = options;
95
+ // Check if doc-source files changed
96
+ const docsChanged = await hasDocSourceChanges(baseBranch);
97
+ if (!docsChanged) {
98
+ console.log('[wu:done] No doc-source changes detected, skipping docs:generate');
99
+ return { docsChanged: false, regenerated: false };
100
+ }
101
+ console.log('[wu:done] Doc-source changes detected, running turbo docs:generate...');
102
+ // Run turbo docs:generate (Turbo handles caching and dependencies)
103
+ runDocsGenerate(repoRoot);
104
+ // Stage the doc output files
105
+ await stageDocOutputs();
106
+ console.log('[wu:done] Documentation regenerated and staged');
107
+ return { docsChanged: true, regenerated: true };
108
+ }
@@ -36,6 +36,8 @@ import { isPRModeEnabled, createPR, printPRCreatedMessage } from './wu-done-pr.j
36
36
  import { isBranchAlreadyMerged } from './wu-done-branch-utils.js';
37
37
  // WU-1371: Import rebase artifact cleanup functions
38
38
  import { detectRebasedArtifacts, cleanupRebasedArtifacts } from './rebase-artifact-cleanup.js';
39
+ // WU-1061: Import docs regeneration utilities
40
+ import { maybeRegenerateAndStageDocs } from './wu-done-docs-generate.js';
39
41
  import { WUTransaction, createTransactionSnapshot, restoreFromSnapshot } from './wu-transaction.js';
40
42
  // WU-1506: Import backlog invariant repair
41
43
  // WU-1574: Removed repairBacklogInvariants - no longer needed with state store architecture
@@ -261,6 +263,16 @@ export async function executeWorktreeCompletion(context) {
261
263
  // PHASE 4: GIT OPERATIONS (stage, format, commit)
262
264
  // Files are now written - proceed with git operations
263
265
  // ======================================================================
266
+ // ======================================================================
267
+ // WU-1061: Regenerate docs if doc-source files changed
268
+ // This runs BEFORE stageAndFormatMetadata to include doc outputs
269
+ // in the single atomic commit
270
+ // Uses main as base to detect changes introduced by this WU
271
+ // ======================================================================
272
+ await maybeRegenerateAndStageDocs({
273
+ baseBranch: BRANCHES.MAIN,
274
+ repoRoot: worktreePath,
275
+ });
264
276
  // Stage and format files
265
277
  await stageAndFormatMetadata({
266
278
  id,
package/dist/wu-schema.js CHANGED
@@ -826,10 +826,12 @@ export function validateWUCompleteness(wu) {
826
826
  warnings.push(`${wu.id}: Missing 'tests.manual' field. Add manual verification steps for acceptance criteria.`);
827
827
  }
828
828
  // Check for spec_refs (features should link to plans/specs)
829
+ // WU-1062: Accepts both repo-relative paths (docs/04-operations/plans/) and
830
+ // external paths (~/.lumenflow/plans/, $LUMENFLOW_HOME/plans/, lumenflow://plans/)
829
831
  if (type === 'feature') {
830
832
  const hasSpecRefs = wu.spec_refs && wu.spec_refs.length > 0;
831
833
  if (!hasSpecRefs) {
832
- warnings.push(`${wu.id}: Missing 'spec_refs' field. Link to plan file in docs/04-operations/plans/ for traceability.`);
834
+ warnings.push(`${wu.id}: Missing 'spec_refs' field. Link to plan file (docs/04-operations/plans/, lumenflow://plans/, or ~/.lumenflow/plans/) for traceability.`);
833
835
  }
834
836
  }
835
837
  return { warnings };
package/dist/wu-spawn.js CHANGED
@@ -89,6 +89,9 @@ function formatAcceptance(acceptance) {
89
89
  /**
90
90
  * Format spec_refs as markdown links
91
91
  *
92
+ * WU-1062: Handles external paths (lumenflow://, ~/.lumenflow/, $LUMENFLOW_HOME/)
93
+ * by expanding them to absolute paths and adding a note about reading them.
94
+ *
92
95
  * @param {string[]|undefined} specRefs - Spec references array
93
96
  * @returns {string} Formatted references or empty string if none
94
97
  */
@@ -96,7 +99,17 @@ function formatSpecRefs(specRefs) {
96
99
  if (!specRefs || specRefs.length === 0) {
97
100
  return '';
98
101
  }
99
- return specRefs.map((ref) => `- ${ref}`).join('\n');
102
+ const formattedRefs = specRefs.map((ref) => {
103
+ // WU-1062: Add note for external paths
104
+ if (ref.startsWith('lumenflow://') ||
105
+ ref.startsWith('~/') ||
106
+ ref.startsWith('$LUMENFLOW_HOME') ||
107
+ (ref.startsWith('/') && ref.includes('.lumenflow'))) {
108
+ return `- ${ref} (external - read with filesystem access)`;
109
+ }
110
+ return `- ${ref}`;
111
+ });
112
+ return formattedRefs.join('\n');
100
113
  }
101
114
  /**
102
115
  * Format risks as markdown list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumenflow/core",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Core WU lifecycle tools for LumenFlow workflow framework",
5
5
  "keywords": [
6
6
  "lumenflow",
@@ -76,6 +76,7 @@
76
76
  "gray-matter": "^4.0.3",
77
77
  "micromatch": "^4.0.8",
78
78
  "minimatch": "^10.1.1",
79
+ "ms": "^2.1.3",
79
80
  "picocolors": "^1.1.1",
80
81
  "pretty-ms": "^9.2.0",
81
82
  "ps-list": "^8.1.1",
@@ -90,8 +91,8 @@
90
91
  "vitest": "^4.0.17"
91
92
  },
92
93
  "peerDependencies": {
93
- "@lumenflow/memory": "1.3.0",
94
- "@lumenflow/initiatives": "1.3.0"
94
+ "@lumenflow/memory": "1.3.2",
95
+ "@lumenflow/initiatives": "1.3.2"
95
96
  },
96
97
  "peerDependenciesMeta": {
97
98
  "@lumenflow/memory": {