@lumenflow/core 1.3.6 → 1.5.0

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.
@@ -40,6 +40,18 @@ import { BRANCHES, REMOTES, GIT_REFS, PKG_MANAGER, SCRIPTS, PRETTIER_FLAGS, STDI
40
40
  * concurrently. Each retry fetches latest main and rebases.
41
41
  */
42
42
  export const MAX_MERGE_RETRIES = 3;
43
+ /**
44
+ * Environment variable name for LUMENFLOW_FORCE bypass
45
+ *
46
+ * WU-1081: Exported for use in micro-worktree push operations.
47
+ */
48
+ export const LUMENFLOW_FORCE_ENV = 'LUMENFLOW_FORCE';
49
+ /**
50
+ * Environment variable name for LUMENFLOW_FORCE_REASON audit trail
51
+ *
52
+ * WU-1081: Exported for use in micro-worktree push operations.
53
+ */
54
+ export const LUMENFLOW_FORCE_REASON_ENV = 'LUMENFLOW_FORCE_REASON';
43
55
  /**
44
56
  * Default log prefix for micro-worktree operations
45
57
  *
@@ -344,6 +356,51 @@ export async function mergeWithRetry(tempBranchName, microWorktreePath, logPrefi
344
356
  }
345
357
  }
346
358
  }
359
+ /**
360
+ * Push using refspec with LUMENFLOW_FORCE to bypass pre-push hooks
361
+ *
362
+ * WU-1081: Micro-worktree pushes to origin/main need to bypass pre-push hooks
363
+ * because they operate from temp branches in /tmp directories, which would
364
+ * otherwise be blocked by hook validation.
365
+ *
366
+ * Sets LUMENFLOW_FORCE=1 and LUMENFLOW_FORCE_REASON during the push,
367
+ * then restores original environment values (even on error).
368
+ *
369
+ * @param {GitAdapter} gitAdapter - GitAdapter instance to use for push
370
+ * @param {string} remote - Remote name (e.g., 'origin')
371
+ * @param {string} localRef - Local ref to push (e.g., 'tmp/wu-claim/wu-123')
372
+ * @param {string} remoteRef - Remote ref to update (e.g., 'main')
373
+ * @param {string} reason - Audit reason for the LUMENFLOW_FORCE bypass
374
+ * @returns {Promise<void>}
375
+ * @throws {Error} If push fails (env vars still restored)
376
+ */
377
+ export async function pushRefspecWithForce(gitAdapter, remote, localRef, remoteRef, reason) {
378
+ // Save original env values
379
+ const originalForce = process.env[LUMENFLOW_FORCE_ENV];
380
+ const originalReason = process.env[LUMENFLOW_FORCE_REASON_ENV];
381
+ try {
382
+ // Set LUMENFLOW_FORCE for the push
383
+ process.env[LUMENFLOW_FORCE_ENV] = '1';
384
+ process.env[LUMENFLOW_FORCE_REASON_ENV] = reason;
385
+ // Perform the push
386
+ await gitAdapter.pushRefspec(remote, localRef, remoteRef);
387
+ }
388
+ finally {
389
+ // Restore original env values
390
+ if (originalForce === undefined) {
391
+ delete process.env[LUMENFLOW_FORCE_ENV];
392
+ }
393
+ else {
394
+ process.env[LUMENFLOW_FORCE_ENV] = originalForce;
395
+ }
396
+ if (originalReason === undefined) {
397
+ delete process.env[LUMENFLOW_FORCE_REASON_ENV];
398
+ }
399
+ else {
400
+ process.env[LUMENFLOW_FORCE_REASON_ENV] = originalReason;
401
+ }
402
+ }
403
+ }
347
404
  /**
348
405
  * Execute an operation in a micro-worktree with full isolation
349
406
  *
@@ -401,8 +458,9 @@ export async function withMicroWorktree(options) {
401
458
  // Step 6: Push to origin (different paths for pushOnly vs standard)
402
459
  if (pushOnly) {
403
460
  // WU-1435: Push directly to origin/main without touching local main
461
+ // WU-1081: Use LUMENFLOW_FORCE to bypass pre-push hooks for micro-worktree pushes
404
462
  console.log(`${logPrefix} Pushing directly to ${REMOTES.ORIGIN}/${BRANCHES.MAIN} (push-only)...`);
405
- await gitWorktree.pushRefspec(REMOTES.ORIGIN, tempBranchName, BRANCHES.MAIN);
463
+ await pushRefspecWithForce(gitWorktree, REMOTES.ORIGIN, tempBranchName, BRANCHES.MAIN, `micro-worktree push for ${operation} (automated)`);
406
464
  console.log(`${logPrefix} ✅ Pushed to ${REMOTES.ORIGIN}/${BRANCHES.MAIN}`);
407
465
  // Fetch to update remote tracking ref (FETCH_HEAD)
408
466
  console.log(`${logPrefix} Fetching ${REMOTES.ORIGIN}/${BRANCHES.MAIN}...`);
@@ -2,6 +2,7 @@
2
2
  * Preflight validation helpers for wu:done.
3
3
  */
4
4
  import { execSync as execSyncImport } from 'node:child_process';
5
+ import { existsSync } from 'node:fs';
5
6
  import { validatePreflight } from './wu-preflight-validators.js';
6
7
  import { LOG_PREFIX, EMOJI, STDIO } from './wu-constants.js';
7
8
  /**
@@ -164,8 +165,14 @@ export function validateAllPreCommitHooks(id, worktreePath = null, options = {})
164
165
  if (worktreePath) {
165
166
  execOptions.cwd = worktreePath;
166
167
  }
168
+ // WU-1086: Check for .mjs extension first, fall back to .js for backwards compatibility
169
+ const basePath = worktreePath || '.';
170
+ const mjsPath = `${basePath}/tools/gates-pre-commit.mjs`;
171
+ const gateScript = existsSync(mjsPath)
172
+ ? 'tools/gates-pre-commit.mjs'
173
+ : 'tools/gates-pre-commit.js';
167
174
  // Run the gates-pre-commit script that contains all validation gates
168
- execSyncFn('node tools/gates-pre-commit.js', execOptions);
175
+ execSyncFn(`node ${gateScript}`, execOptions);
169
176
  console.log(`${LOG_PREFIX.DONE} ${EMOJI.SUCCESS} All pre-commit hooks passed`);
170
177
  return { valid: true, errors: [] };
171
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumenflow/core",
3
- "version": "1.3.6",
3
+ "version": "1.5.0",
4
4
  "description": "Core WU lifecycle tools for LumenFlow workflow framework",
5
5
  "keywords": [
6
6
  "lumenflow",
@@ -66,6 +66,7 @@
66
66
  "README.md"
67
67
  ],
68
68
  "dependencies": {
69
+ "chalk": "^5.6.2",
69
70
  "change-case": "^5.4.4",
70
71
  "cli-progress": "^3.12.0",
71
72
  "cli-table3": "^0.6.5",
@@ -91,15 +92,11 @@
91
92
  "vitest": "^4.0.17"
92
93
  },
93
94
  "peerDependencies": {
94
- "@lumenflow/memory": "1.3.6",
95
- "@lumenflow/initiatives": "1.3.6"
95
+ "@lumenflow/memory": "1.5.0"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@lumenflow/memory": {
99
99
  "optional": true
100
- },
101
- "@lumenflow/initiatives": {
102
- "optional": true
103
100
  }
104
101
  },
105
102
  "engines": {