@lumenflow/shims 3.1.3 → 3.2.1
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/dist/git-shim.d.ts +90 -0
- package/dist/git-shim.d.ts.map +1 -0
- package/dist/git-shim.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/pnpm-shim.d.ts +48 -0
- package/dist/pnpm-shim.d.ts.map +1 -0
- package/dist/pnpm-shim.js.map +1 -0
- package/dist/types.d.ts +77 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +66 -0
- package/dist/types.js.map +1 -0
- package/dist/worktree.d.ts +42 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +87 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @lumenflow/shims - Git Command Shim (WU-2546)
|
|
4
|
+
*
|
|
5
|
+
* Intercepts git commands and blocks destructive operations on main branch/worktree.
|
|
6
|
+
*
|
|
7
|
+
* Usage: Add shims directory to PATH before /usr/bin
|
|
8
|
+
* export PATH="$(pwd)/node_modules/.bin:$PATH"
|
|
9
|
+
*
|
|
10
|
+
* Blocked commands on main:
|
|
11
|
+
* - git reset --hard
|
|
12
|
+
* - git stash (any form)
|
|
13
|
+
* - git clean -fd
|
|
14
|
+
* - git checkout -f
|
|
15
|
+
* - git push --force / -f
|
|
16
|
+
* - hook bypass flags
|
|
17
|
+
*
|
|
18
|
+
* These commands are ALLOWED on lane branches in worktrees (safe context).
|
|
19
|
+
*
|
|
20
|
+
* @module @lumenflow/shims/git
|
|
21
|
+
*/
|
|
22
|
+
import type { GitShimConfig, BannedPatternResult, ProtectedContextResult, WorktreeRemoveCheckResult } from './types.js';
|
|
23
|
+
/**
|
|
24
|
+
* Detect user type based on environment variables.
|
|
25
|
+
*
|
|
26
|
+
* @param config - Git shim configuration
|
|
27
|
+
* @returns User type: 'agent', 'human', or 'unknown'
|
|
28
|
+
*/
|
|
29
|
+
export declare function detectUserType(config?: GitShimConfig): string;
|
|
30
|
+
/**
|
|
31
|
+
* Check if arguments contain a banned command pattern.
|
|
32
|
+
*
|
|
33
|
+
* @param args - Git command arguments
|
|
34
|
+
* @param config - Git shim configuration
|
|
35
|
+
* @returns Object with banned status and reason
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkBannedPattern(args: string[], config?: GitShimConfig): BannedPatternResult;
|
|
38
|
+
/**
|
|
39
|
+
* Check if we're in a protected context (main branch or main worktree).
|
|
40
|
+
*
|
|
41
|
+
* Updated in WU-1026 to support:
|
|
42
|
+
* - Agent branches (bypass protection)
|
|
43
|
+
* - Guarded headless mode (LUMENFLOW_HEADLESS + admin/CI)
|
|
44
|
+
* - Detached HEAD (fail-closed)
|
|
45
|
+
* - Core config for protected branches (single source of truth)
|
|
46
|
+
*
|
|
47
|
+
* @param config - Git shim configuration
|
|
48
|
+
* @returns Object with protected status and context description
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkProtectedContext(config?: GitShimConfig): ProtectedContextResult;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a worktree remove command should be blocked for agents (WU-1027).
|
|
53
|
+
*
|
|
54
|
+
* Agents must not delete worktrees that belong to other sessions.
|
|
55
|
+
* Only proper workflow (wu:done, wu:prune) should remove worktrees.
|
|
56
|
+
*
|
|
57
|
+
* @param args - Git command arguments
|
|
58
|
+
* @param config - Git shim configuration
|
|
59
|
+
* @returns Object with blocked status and reason
|
|
60
|
+
*/
|
|
61
|
+
export declare function checkWorktreeRemoveForAgent(args: string[], config?: GitShimConfig): WorktreeRemoveCheckResult;
|
|
62
|
+
/**
|
|
63
|
+
* Format error message for blocked command.
|
|
64
|
+
*
|
|
65
|
+
* @param command - The blocked command
|
|
66
|
+
* @param reason - Why it was blocked
|
|
67
|
+
* @param context - Where it was blocked
|
|
68
|
+
* @returns Formatted error message
|
|
69
|
+
*/
|
|
70
|
+
export declare function formatBlockedError(command: string, reason: string, context: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Find real git executable.
|
|
73
|
+
*
|
|
74
|
+
* @param preferredPath - Preferred git path from config
|
|
75
|
+
* @returns Path to real git
|
|
76
|
+
*/
|
|
77
|
+
export declare function findRealGit(preferredPath?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Run the git shim with given configuration.
|
|
80
|
+
*
|
|
81
|
+
* @param args - Git command arguments
|
|
82
|
+
* @param config - Git shim configuration
|
|
83
|
+
* @returns Exit code
|
|
84
|
+
*/
|
|
85
|
+
export declare function runGitShim(args: string[], config?: GitShimConfig): number;
|
|
86
|
+
/**
|
|
87
|
+
* Main entry point for CLI execution.
|
|
88
|
+
*/
|
|
89
|
+
export declare function main(): void;
|
|
90
|
+
//# sourceMappingURL=git-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-shim.d.ts","sourceRoot":"","sources":["../src/git-shim.ts"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAkDpB;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,aAA8B,GAAG,MAAM,CAO7E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,GAAE,aAA8B,GACrC,mBAAmB,CAqCrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,aAA8B,GACrC,sBAAsB,CA+CxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,GAAE,aAA8B,GACrC,yBAAyB,CA8B3B;AAED;;;;;;;GAOG;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AChB,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI;IAClB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACnC,MAAM,UAAU,GAAG,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;IAC9B,IAAI,EAAE,CAAC;AACT,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lumenflow/shims - Git and pnpm Safety Shims (WU-2546)
|
|
3
|
+
*
|
|
4
|
+
* Provides worktree-aware safety wrappers for git and pnpm commands.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export declare const VERSION = "0.0.0";
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './worktree.js';
|
|
11
|
+
export { detectUserType, checkBannedPattern, checkProtectedContext, formatBlockedError, findRealGit, runGitShim, } from './git-shim.js';
|
|
12
|
+
export { findRealPnpm, isDependencyCommand, runPnpmShim } from './pnpm-shim.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,cAAc,YAAY,CAAC;AAG3B,cAAc,eAAe,CAAC;AAG9B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAE3B,+BAA+B;AAC/B,cAAc,eAAe,CAAC;AAE9B,+BAA+B;AAC/B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @lumenflow/shims - pnpm Command Shim (WU-2546)
|
|
4
|
+
*
|
|
5
|
+
* Fixes ERR_PNPM_UNEXPECTED_VIRTUAL_STORE error in git worktrees.
|
|
6
|
+
*
|
|
7
|
+
* Problem: pnpm computes virtual-store-dir relative to the project root before
|
|
8
|
+
* following symlinks. In worktrees with symlinked node_modules, this results in
|
|
9
|
+
* a path mismatch because main and worktree compute different absolute paths.
|
|
10
|
+
*
|
|
11
|
+
* Solution: This shim dynamically computes the main checkout's virtual store
|
|
12
|
+
* path using `git rev-parse --git-common-dir` and passes it to pnpm via
|
|
13
|
+
* --config.virtual-store-dir.
|
|
14
|
+
*
|
|
15
|
+
* Usage: Add shims directory to PATH before npm/pnpm bin locations
|
|
16
|
+
* export PATH="$(pwd)/node_modules/.bin:$PATH"
|
|
17
|
+
*
|
|
18
|
+
* @module @lumenflow/shims/pnpm
|
|
19
|
+
*/
|
|
20
|
+
import type { PnpmShimConfig } from './types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Find real pnpm executable (after removing shims from PATH).
|
|
23
|
+
*
|
|
24
|
+
* @param config - Pnpm shim configuration
|
|
25
|
+
* @returns Path to real pnpm
|
|
26
|
+
*/
|
|
27
|
+
export declare function findRealPnpm(config?: PnpmShimConfig): string;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the command modifies dependencies.
|
|
30
|
+
*
|
|
31
|
+
* @param args - pnpm command arguments
|
|
32
|
+
* @param config - Pnpm shim configuration
|
|
33
|
+
* @returns True if command modifies dependencies
|
|
34
|
+
*/
|
|
35
|
+
export declare function isDependencyCommand(args: string[], config?: PnpmShimConfig): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Run the pnpm shim with given configuration.
|
|
38
|
+
*
|
|
39
|
+
* @param args - pnpm command arguments
|
|
40
|
+
* @param config - Pnpm shim configuration
|
|
41
|
+
* @returns Exit code
|
|
42
|
+
*/
|
|
43
|
+
export declare function runPnpmShim(args: string[], config?: PnpmShimConfig): number;
|
|
44
|
+
/**
|
|
45
|
+
* Main entry point for CLI execution.
|
|
46
|
+
*/
|
|
47
|
+
export declare function main(): void;
|
|
48
|
+
//# sourceMappingURL=pnpm-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm-shim.d.ts","sourceRoot":"","sources":["../src/pnpm-shim.ts"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AASjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,cAA+B,GAAG,MAAM,CAsC5E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,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QAC5B,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE;QACvC,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI;IAClB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC;AAED,2BAA2B;AAC3B,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,IAAI,EAAE,CAAC;AACT,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const GitShimConfigSchema: z.ZodObject<{
|
|
3
|
+
protectedBranch: z.ZodDefault<z.ZodString>;
|
|
4
|
+
bannedPatterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
5
|
+
command: z.ZodString;
|
|
6
|
+
flags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
}, z.core.$strip>>>;
|
|
8
|
+
bannedFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
9
|
+
realGitPath: z.ZodDefault<z.ZodString>;
|
|
10
|
+
enableLogging: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
logPath: z.ZodOptional<z.ZodString>;
|
|
12
|
+
recursionEnvVar: z.ZodDefault<z.ZodString>;
|
|
13
|
+
agentEnvVars: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type GitShimConfig = z.infer<typeof GitShimConfigSchema>;
|
|
16
|
+
export declare const PnpmShimConfigSchema: z.ZodObject<{
|
|
17
|
+
dependencyCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
systemPnpmPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
recursionEnvVar: z.ZodDefault<z.ZodString>;
|
|
20
|
+
enableDebug: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type PnpmShimConfig = z.infer<typeof PnpmShimConfigSchema>;
|
|
23
|
+
export declare const ShimConfigSchema: z.ZodObject<{
|
|
24
|
+
git: z.ZodDefault<z.ZodObject<{
|
|
25
|
+
protectedBranch: z.ZodDefault<z.ZodString>;
|
|
26
|
+
bannedPatterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
27
|
+
command: z.ZodString;
|
|
28
|
+
flags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>>>;
|
|
30
|
+
bannedFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
31
|
+
realGitPath: z.ZodDefault<z.ZodString>;
|
|
32
|
+
enableLogging: z.ZodDefault<z.ZodBoolean>;
|
|
33
|
+
logPath: z.ZodOptional<z.ZodString>;
|
|
34
|
+
recursionEnvVar: z.ZodDefault<z.ZodString>;
|
|
35
|
+
agentEnvVars: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
pnpm: z.ZodDefault<z.ZodObject<{
|
|
38
|
+
dependencyCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
39
|
+
systemPnpmPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
40
|
+
recursionEnvVar: z.ZodDefault<z.ZodString>;
|
|
41
|
+
enableDebug: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type ShimConfig = z.infer<typeof ShimConfigSchema>;
|
|
45
|
+
export declare const UserType: {
|
|
46
|
+
readonly AGENT: "agent";
|
|
47
|
+
readonly HUMAN: "human";
|
|
48
|
+
readonly UNKNOWN: "unknown";
|
|
49
|
+
};
|
|
50
|
+
export type UserType = (typeof UserType)[keyof typeof UserType];
|
|
51
|
+
export declare const CommandOutcome: {
|
|
52
|
+
readonly ALLOWED: "allowed";
|
|
53
|
+
readonly BLOCKED: "blocked";
|
|
54
|
+
readonly UNKNOWN: "unknown";
|
|
55
|
+
};
|
|
56
|
+
export type CommandOutcome = (typeof CommandOutcome)[keyof typeof CommandOutcome];
|
|
57
|
+
export interface BannedPatternResult {
|
|
58
|
+
banned: boolean;
|
|
59
|
+
reason: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface ProtectedContextResult {
|
|
62
|
+
protected: boolean;
|
|
63
|
+
context: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Result of worktree remove check for agents (WU-1027).
|
|
67
|
+
*/
|
|
68
|
+
export interface WorktreeRemoveCheckResult {
|
|
69
|
+
blocked: boolean;
|
|
70
|
+
reason: string | null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Environment variable to bypass worktree remove blocking.
|
|
74
|
+
* Set by wu:done and wu:prune before removing worktrees.
|
|
75
|
+
*/
|
|
76
|
+
export declare const WORKTREE_REMOVE_BYPASS_ENV_VAR = "LUMENFLOW_WORKTREE_REMOVE_ALLOWED";
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBA8B9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,oBAAoB;;;;;iBAS/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;iBAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAEhE,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAElF,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,sCAAsC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
// @lumenflow/shims - Type definitions (WU-2546)
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
// Strings stored separately to avoid hook false positives
|
|
6
|
+
const NO_VERIFY_FLAG = '--no-' + 'verify';
|
|
7
|
+
const NO_GPG_SIGN_FLAG = '--no-' + 'gpg-sign';
|
|
8
|
+
export const GitShimConfigSchema = z.object({
|
|
9
|
+
protectedBranch: z.string().default('main'),
|
|
10
|
+
bannedPatterns: z
|
|
11
|
+
.array(z.object({
|
|
12
|
+
command: z.string(),
|
|
13
|
+
flags: z.array(z.string()).optional(),
|
|
14
|
+
}))
|
|
15
|
+
.default([
|
|
16
|
+
{ command: 'reset', flags: ['--hard'] },
|
|
17
|
+
{ command: 'stash' },
|
|
18
|
+
{ command: 'clean', flags: ['-fd', '-df'] },
|
|
19
|
+
{ command: 'checkout', flags: ['-f', '--force'] },
|
|
20
|
+
{ command: 'push', flags: ['--force', '-f'] },
|
|
21
|
+
]),
|
|
22
|
+
bannedFlags: z.array(z.string()).default([NO_VERIFY_FLAG, NO_GPG_SIGN_FLAG]),
|
|
23
|
+
realGitPath: z.string().default('/usr/bin/git'),
|
|
24
|
+
enableLogging: z.boolean().default(false),
|
|
25
|
+
logPath: z.string().optional(),
|
|
26
|
+
recursionEnvVar: z.string().default('LUMENFLOW_GIT_SHIM_ACTIVE'),
|
|
27
|
+
agentEnvVars: z
|
|
28
|
+
.array(z.string())
|
|
29
|
+
.default([
|
|
30
|
+
'CLAUDE_SESSION_ID',
|
|
31
|
+
'LUMENFLOW_AGENT_SESSION',
|
|
32
|
+
'CI',
|
|
33
|
+
'GITHUB_ACTIONS',
|
|
34
|
+
'ANTHROPIC_API_KEY',
|
|
35
|
+
]),
|
|
36
|
+
});
|
|
37
|
+
export const PnpmShimConfigSchema = z.object({
|
|
38
|
+
dependencyCommands: z
|
|
39
|
+
.array(z.string())
|
|
40
|
+
.default(['add', 'remove', 'install', 'update', 'i', 'rm', 'up']),
|
|
41
|
+
systemPnpmPaths: z
|
|
42
|
+
.array(z.string())
|
|
43
|
+
.default(['/usr/local/bin/pnpm', '/usr/bin/pnpm', '/opt/homebrew/bin/pnpm']),
|
|
44
|
+
recursionEnvVar: z.string().default('LUMENFLOW_PNPM_SHIM_ACTIVE'),
|
|
45
|
+
enableDebug: z.boolean().default(false),
|
|
46
|
+
});
|
|
47
|
+
export const ShimConfigSchema = z.object({
|
|
48
|
+
git: GitShimConfigSchema.default(() => GitShimConfigSchema.parse({})),
|
|
49
|
+
pnpm: PnpmShimConfigSchema.default(() => PnpmShimConfigSchema.parse({})),
|
|
50
|
+
});
|
|
51
|
+
export const UserType = {
|
|
52
|
+
AGENT: 'agent',
|
|
53
|
+
HUMAN: 'human',
|
|
54
|
+
UNKNOWN: 'unknown',
|
|
55
|
+
};
|
|
56
|
+
export const CommandOutcome = {
|
|
57
|
+
ALLOWED: 'allowed',
|
|
58
|
+
BLOCKED: 'blocked',
|
|
59
|
+
UNKNOWN: 'unknown',
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Environment variable to bypass worktree remove blocking.
|
|
63
|
+
* Set by wu:done and wu:prune before removing worktrees.
|
|
64
|
+
*/
|
|
65
|
+
export const WORKTREE_REMOVE_BYPASS_ENV_VAR = 'LUMENFLOW_WORKTREE_REMOVE_ALLOWED';
|
|
66
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC,gDAAgD;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0DAA0D;AAC1D,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC1C,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3C,cAAc,EAAE,CAAC;SACd,KAAK,CACJ,CAAC,CAAC,MAA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E,CAAC;SAClB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACnE,eAAe,EAAE,CAAC;SACf,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,OAAO,CAAC,CAAC,qBAAqB,EAAE,eAAe,EAAE,wBAAwB,CAAC,CAAC;IAC9E,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC;IACjE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACxC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,GAAG,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrE,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACzE,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACV,CAAC;AAsBX;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute a shell command and return the output.
|
|
3
|
+
*
|
|
4
|
+
* @param cmd - Command to execute
|
|
5
|
+
* @returns Command output or empty string on error
|
|
6
|
+
*/
|
|
7
|
+
export declare function run(cmd: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Get the current git branch name.
|
|
10
|
+
*
|
|
11
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
12
|
+
* @returns Branch name or null if not in a git repo
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCurrentBranch(gitPath?: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Check if we're in the main worktree (not a lane worktree).
|
|
17
|
+
*
|
|
18
|
+
* In the main checkout, git-dir returns ".git".
|
|
19
|
+
* In a worktree, git-dir returns ".git/worktrees/<name>".
|
|
20
|
+
*
|
|
21
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
22
|
+
* @returns True if in main worktree
|
|
23
|
+
*/
|
|
24
|
+
export declare function isMainWorktree(gitPath?: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if we're in any worktree (not the main checkout).
|
|
27
|
+
*
|
|
28
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
29
|
+
* @returns True if in a worktree
|
|
30
|
+
*/
|
|
31
|
+
export declare function isInWorktree(gitPath?: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get the main checkout's path using git.
|
|
34
|
+
*
|
|
35
|
+
* Works in both main checkout and worktrees.
|
|
36
|
+
* Uses git rev-parse --git-common-dir which returns the main .git directory
|
|
37
|
+
* even when run from a worktree.
|
|
38
|
+
*
|
|
39
|
+
* @returns Path to main checkout, or null if not in a git repo
|
|
40
|
+
*/
|
|
41
|
+
export declare function getMainCheckoutPath(): string | null;
|
|
42
|
+
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAkBA;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMvC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,GAAG,IAAI,CAElF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAyB,GAAG,OAAO,CAK1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,MAAyB,GAAG,OAAO,CAIxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAWnD"}
|
package/dist/worktree.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
/**
|
|
4
|
+
* @lumenflow/shims - Worktree Detection Utilities (WU-2546)
|
|
5
|
+
*
|
|
6
|
+
* Shared utilities for detecting git worktree context.
|
|
7
|
+
*
|
|
8
|
+
* @module @lumenflow/shims/worktree
|
|
9
|
+
*/
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
const STDIO_PIPE = ['pipe', 'pipe', 'pipe'];
|
|
13
|
+
const ENCODING = 'utf8';
|
|
14
|
+
const DEFAULT_GIT_PATH = '/usr/bin/git';
|
|
15
|
+
/**
|
|
16
|
+
* Execute a shell command and return the output.
|
|
17
|
+
*
|
|
18
|
+
* @param cmd - Command to execute
|
|
19
|
+
* @returns Command output or empty string on error
|
|
20
|
+
*/
|
|
21
|
+
export function run(cmd) {
|
|
22
|
+
try {
|
|
23
|
+
return execSync(cmd, { stdio: STDIO_PIPE, encoding: ENCODING }).trim();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the current git branch name.
|
|
31
|
+
*
|
|
32
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
33
|
+
* @returns Branch name or null if not in a git repo
|
|
34
|
+
*/
|
|
35
|
+
export function getCurrentBranch(gitPath = DEFAULT_GIT_PATH) {
|
|
36
|
+
return run(`${gitPath} rev-parse --abbrev-ref HEAD`) || null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if we're in the main worktree (not a lane worktree).
|
|
40
|
+
*
|
|
41
|
+
* In the main checkout, git-dir returns ".git".
|
|
42
|
+
* In a worktree, git-dir returns ".git/worktrees/<name>".
|
|
43
|
+
*
|
|
44
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
45
|
+
* @returns True if in main worktree
|
|
46
|
+
*/
|
|
47
|
+
export function isMainWorktree(gitPath = DEFAULT_GIT_PATH) {
|
|
48
|
+
const gitDir = run(`${gitPath} rev-parse --git-dir`);
|
|
49
|
+
if (!gitDir)
|
|
50
|
+
return true;
|
|
51
|
+
const normalized = gitDir.replace(/\\/g, '/');
|
|
52
|
+
return !normalized.includes('/worktrees/');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if we're in any worktree (not the main checkout).
|
|
56
|
+
*
|
|
57
|
+
* @param gitPath - Path to git executable (default: '/usr/bin/git')
|
|
58
|
+
* @returns True if in a worktree
|
|
59
|
+
*/
|
|
60
|
+
export function isInWorktree(gitPath = DEFAULT_GIT_PATH) {
|
|
61
|
+
const gitDir = run(`${gitPath} rev-parse --git-dir`);
|
|
62
|
+
if (!gitDir)
|
|
63
|
+
return false;
|
|
64
|
+
return gitDir.includes('/worktrees/');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the main checkout's path using git.
|
|
68
|
+
*
|
|
69
|
+
* Works in both main checkout and worktrees.
|
|
70
|
+
* Uses git rev-parse --git-common-dir which returns the main .git directory
|
|
71
|
+
* even when run from a worktree.
|
|
72
|
+
*
|
|
73
|
+
* @returns Path to main checkout, or null if not in a git repo
|
|
74
|
+
*/
|
|
75
|
+
export function getMainCheckoutPath() {
|
|
76
|
+
try {
|
|
77
|
+
const gitCommonDir = execSync('git rev-parse --git-common-dir', {
|
|
78
|
+
encoding: ENCODING,
|
|
79
|
+
stdio: STDIO_PIPE,
|
|
80
|
+
}).trim();
|
|
81
|
+
return path.dirname(path.resolve(gitCommonDir));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=worktree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAqB,MAAM,oBAAoB,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,GAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1D,MAAM,QAAQ,GAAG,MAAe,CAAC;AACjC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB,gBAAgB;IACjE,OAAO,GAAG,CAAC,GAAG,OAAO,8BAA8B,CAAC,IAAI,IAAI,CAAC;AAC/D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB,gBAAgB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,OAAO,sBAAsB,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,gBAAgB;IAC7D,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,OAAO,sBAAsB,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,QAAQ,CAAC,gCAAgC,EAAE;YAC9D,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumenflow/shims",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Git and pnpm safety shims for LumenFlow worktree discipline",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumenflow",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"zod": "^4.3.6",
|
|
52
|
-
"@lumenflow/core": "3.1
|
|
52
|
+
"@lumenflow/core": "3.2.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@vitest/coverage-v8": "^4.0.18",
|