opentasks 0.0.3 → 0.0.4
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 +58 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +81 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/client.d.ts +20 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +46 -5
- package/dist/client/client.js.map +1 -1
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +11 -0
- package/dist/config/env.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.d.ts +76 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +60 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/init.d.ts +17 -0
- package/dist/core/init.d.ts.map +1 -0
- package/dist/core/init.js +54 -0
- package/dist/core/init.js.map +1 -0
- package/dist/daemon/entire-linker.d.ts +3 -0
- package/dist/daemon/entire-linker.d.ts.map +1 -1
- package/dist/daemon/entire-linker.js +29 -2
- package/dist/daemon/entire-linker.js.map +1 -1
- package/dist/daemon/factory.d.ts +3 -0
- package/dist/daemon/factory.d.ts.map +1 -1
- package/dist/daemon/factory.js +2 -1
- package/dist/daemon/factory.js.map +1 -1
- package/dist/daemon/lifecycle.d.ts.map +1 -1
- package/dist/daemon/lifecycle.js +34 -4
- package/dist/daemon/lifecycle.js.map +1 -1
- package/dist/daemon/location-state.d.ts +2 -1
- package/dist/daemon/location-state.d.ts.map +1 -1
- package/dist/daemon/location-state.js +19 -4
- package/dist/daemon/location-state.js.map +1 -1
- package/dist/daemon/methods/tools.d.ts +11 -1
- package/dist/daemon/methods/tools.d.ts.map +1 -1
- package/dist/daemon/methods/tools.js +40 -6
- package/dist/daemon/methods/tools.js.map +1 -1
- package/dist/entire/agent/agents/claude-code.d.ts +76 -0
- package/dist/entire/agent/agents/claude-code.d.ts.map +1 -0
- package/dist/entire/agent/agents/claude-code.js +759 -0
- package/dist/entire/agent/agents/claude-code.js.map +1 -0
- package/dist/entire/agent/agents/cursor.d.ts +35 -0
- package/dist/entire/agent/agents/cursor.d.ts.map +1 -0
- package/dist/entire/agent/agents/cursor.js +294 -0
- package/dist/entire/agent/agents/cursor.js.map +1 -0
- package/dist/entire/agent/agents/gemini-cli.d.ts +62 -0
- package/dist/entire/agent/agents/gemini-cli.d.ts.map +1 -0
- package/dist/entire/agent/agents/gemini-cli.js +462 -0
- package/dist/entire/agent/agents/gemini-cli.js.map +1 -0
- package/dist/entire/agent/agents/opencode.d.ts +100 -0
- package/dist/entire/agent/agents/opencode.d.ts.map +1 -0
- package/dist/entire/agent/agents/opencode.js +423 -0
- package/dist/entire/agent/agents/opencode.js.map +1 -0
- package/dist/entire/agent/registry.d.ts +54 -0
- package/dist/entire/agent/registry.d.ts.map +1 -0
- package/dist/entire/agent/registry.js +123 -0
- package/dist/entire/agent/registry.js.map +1 -0
- package/dist/entire/agent/session-types.d.ts +45 -0
- package/dist/entire/agent/session-types.d.ts.map +1 -0
- package/dist/entire/agent/session-types.js +50 -0
- package/dist/entire/agent/session-types.js.map +1 -0
- package/dist/entire/agent/types.d.ts +126 -0
- package/dist/entire/agent/types.d.ts.map +1 -0
- package/dist/entire/agent/types.js +39 -0
- package/dist/entire/agent/types.js.map +1 -0
- package/dist/entire/commands/clean.d.ts +30 -0
- package/dist/entire/commands/clean.d.ts.map +1 -0
- package/dist/entire/commands/clean.js +99 -0
- package/dist/entire/commands/clean.js.map +1 -0
- package/dist/entire/commands/disable.d.ts +23 -0
- package/dist/entire/commands/disable.d.ts.map +1 -0
- package/dist/entire/commands/disable.js +57 -0
- package/dist/entire/commands/disable.js.map +1 -0
- package/dist/entire/commands/doctor.d.ts +43 -0
- package/dist/entire/commands/doctor.d.ts.map +1 -0
- package/dist/entire/commands/doctor.js +97 -0
- package/dist/entire/commands/doctor.js.map +1 -0
- package/dist/entire/commands/enable.d.ts +29 -0
- package/dist/entire/commands/enable.d.ts.map +1 -0
- package/dist/entire/commands/enable.js +102 -0
- package/dist/entire/commands/enable.js.map +1 -0
- package/dist/entire/commands/explain.d.ts +68 -0
- package/dist/entire/commands/explain.d.ts.map +1 -0
- package/dist/entire/commands/explain.js +182 -0
- package/dist/entire/commands/explain.js.map +1 -0
- package/dist/entire/commands/reset.d.ts +23 -0
- package/dist/entire/commands/reset.d.ts.map +1 -0
- package/dist/entire/commands/reset.js +68 -0
- package/dist/entire/commands/reset.js.map +1 -0
- package/dist/entire/commands/resume.d.ts +42 -0
- package/dist/entire/commands/resume.d.ts.map +1 -0
- package/dist/entire/commands/resume.js +134 -0
- package/dist/entire/commands/resume.js.map +1 -0
- package/dist/entire/commands/rewind.d.ts +34 -0
- package/dist/entire/commands/rewind.d.ts.map +1 -0
- package/dist/entire/commands/rewind.js +155 -0
- package/dist/entire/commands/rewind.js.map +1 -0
- package/dist/entire/commands/status.d.ts +51 -0
- package/dist/entire/commands/status.d.ts.map +1 -0
- package/dist/entire/commands/status.js +94 -0
- package/dist/entire/commands/status.js.map +1 -0
- package/dist/entire/config.d.ts +40 -0
- package/dist/entire/config.d.ts.map +1 -0
- package/dist/entire/config.js +126 -0
- package/dist/entire/config.js.map +1 -0
- package/dist/entire/git-operations.d.ts +170 -0
- package/dist/entire/git-operations.d.ts.map +1 -0
- package/dist/entire/git-operations.js +395 -0
- package/dist/entire/git-operations.js.map +1 -0
- package/dist/entire/hooks/git-hooks.d.ts +22 -0
- package/dist/entire/hooks/git-hooks.d.ts.map +1 -0
- package/dist/entire/hooks/git-hooks.js +145 -0
- package/dist/entire/hooks/git-hooks.js.map +1 -0
- package/dist/entire/hooks/lifecycle.d.ts +21 -0
- package/dist/entire/hooks/lifecycle.d.ts.map +1 -0
- package/dist/entire/hooks/lifecycle.js +179 -0
- package/dist/entire/hooks/lifecycle.js.map +1 -0
- package/dist/entire/index.d.ts +68 -0
- package/dist/entire/index.d.ts.map +1 -0
- package/dist/entire/index.js +152 -0
- package/dist/entire/index.js.map +1 -0
- package/dist/entire/security/redaction.d.ts +35 -0
- package/dist/entire/security/redaction.d.ts.map +1 -0
- package/dist/entire/security/redaction.js +221 -0
- package/dist/entire/security/redaction.js.map +1 -0
- package/dist/entire/session/state-machine.d.ts +90 -0
- package/dist/entire/session/state-machine.d.ts.map +1 -0
- package/dist/entire/session/state-machine.js +347 -0
- package/dist/entire/session/state-machine.js.map +1 -0
- package/dist/entire/store/checkpoint-store.d.ts +47 -0
- package/dist/entire/store/checkpoint-store.d.ts.map +1 -0
- package/dist/entire/store/checkpoint-store.js +307 -0
- package/dist/entire/store/checkpoint-store.js.map +1 -0
- package/dist/entire/store/native-store.d.ts +14 -0
- package/dist/entire/store/native-store.d.ts.map +1 -0
- package/dist/entire/store/native-store.js +159 -0
- package/dist/entire/store/native-store.js.map +1 -0
- package/dist/entire/store/session-store.d.ts +28 -0
- package/dist/entire/store/session-store.d.ts.map +1 -0
- package/dist/entire/store/session-store.js +187 -0
- package/dist/entire/store/session-store.js.map +1 -0
- package/dist/entire/strategy/attribution.d.ts +39 -0
- package/dist/entire/strategy/attribution.d.ts.map +1 -0
- package/dist/entire/strategy/attribution.js +227 -0
- package/dist/entire/strategy/attribution.js.map +1 -0
- package/dist/entire/strategy/common.d.ts +57 -0
- package/dist/entire/strategy/common.d.ts.map +1 -0
- package/dist/entire/strategy/common.js +156 -0
- package/dist/entire/strategy/common.js.map +1 -0
- package/dist/entire/strategy/content-overlap.d.ts +33 -0
- package/dist/entire/strategy/content-overlap.d.ts.map +1 -0
- package/dist/entire/strategy/content-overlap.js +168 -0
- package/dist/entire/strategy/content-overlap.js.map +1 -0
- package/dist/entire/strategy/manual-commit.d.ts +31 -0
- package/dist/entire/strategy/manual-commit.d.ts.map +1 -0
- package/dist/entire/strategy/manual-commit.js +730 -0
- package/dist/entire/strategy/manual-commit.js.map +1 -0
- package/dist/entire/strategy/types.d.ts +163 -0
- package/dist/entire/strategy/types.d.ts.map +1 -0
- package/dist/entire/strategy/types.js +49 -0
- package/dist/entire/strategy/types.js.map +1 -0
- package/dist/entire/summarize/claude-generator.d.ts +25 -0
- package/dist/entire/summarize/claude-generator.d.ts.map +1 -0
- package/dist/entire/summarize/claude-generator.js +87 -0
- package/dist/entire/summarize/claude-generator.js.map +1 -0
- package/dist/entire/summarize/summarize.d.ts +52 -0
- package/dist/entire/summarize/summarize.d.ts.map +1 -0
- package/dist/entire/summarize/summarize.js +335 -0
- package/dist/entire/summarize/summarize.js.map +1 -0
- package/dist/entire/types.d.ts +288 -0
- package/dist/entire/types.d.ts.map +1 -0
- package/dist/entire/types.js +94 -0
- package/dist/entire/types.js.map +1 -0
- package/dist/entire/utils/chunk-files.d.ts +25 -0
- package/dist/entire/utils/chunk-files.d.ts.map +1 -0
- package/dist/entire/utils/chunk-files.js +47 -0
- package/dist/entire/utils/chunk-files.js.map +1 -0
- package/dist/entire/utils/commit-message.d.ts +11 -0
- package/dist/entire/utils/commit-message.d.ts.map +1 -0
- package/dist/entire/utils/commit-message.js +54 -0
- package/dist/entire/utils/commit-message.js.map +1 -0
- package/dist/entire/utils/detect-agent.d.ts +19 -0
- package/dist/entire/utils/detect-agent.d.ts.map +1 -0
- package/dist/entire/utils/detect-agent.js +34 -0
- package/dist/entire/utils/detect-agent.js.map +1 -0
- package/dist/entire/utils/hook-managers.d.ts +24 -0
- package/dist/entire/utils/hook-managers.d.ts.map +1 -0
- package/dist/entire/utils/hook-managers.js +87 -0
- package/dist/entire/utils/hook-managers.js.map +1 -0
- package/dist/entire/utils/ide-tags.d.ts +12 -0
- package/dist/entire/utils/ide-tags.d.ts.map +1 -0
- package/dist/entire/utils/ide-tags.js +30 -0
- package/dist/entire/utils/ide-tags.js.map +1 -0
- package/dist/entire/utils/paths.d.ts +32 -0
- package/dist/entire/utils/paths.d.ts.map +1 -0
- package/dist/entire/utils/paths.js +55 -0
- package/dist/entire/utils/paths.js.map +1 -0
- package/dist/entire/utils/preview-rewind.d.ts +23 -0
- package/dist/entire/utils/preview-rewind.d.ts.map +1 -0
- package/dist/entire/utils/preview-rewind.js +63 -0
- package/dist/entire/utils/preview-rewind.js.map +1 -0
- package/dist/entire/utils/rewind-conflict.d.ts +52 -0
- package/dist/entire/utils/rewind-conflict.d.ts.map +1 -0
- package/dist/entire/utils/rewind-conflict.js +79 -0
- package/dist/entire/utils/rewind-conflict.js.map +1 -0
- package/dist/entire/utils/shadow-branch.d.ts +44 -0
- package/dist/entire/utils/shadow-branch.d.ts.map +1 -0
- package/dist/entire/utils/shadow-branch.js +93 -0
- package/dist/entire/utils/shadow-branch.js.map +1 -0
- package/dist/entire/utils/string-utils.d.ts +24 -0
- package/dist/entire/utils/string-utils.d.ts.map +1 -0
- package/dist/entire/utils/string-utils.js +47 -0
- package/dist/entire/utils/string-utils.js.map +1 -0
- package/dist/entire/utils/todo-extract.d.ts +52 -0
- package/dist/entire/utils/todo-extract.d.ts.map +1 -0
- package/dist/entire/utils/todo-extract.js +167 -0
- package/dist/entire/utils/todo-extract.js.map +1 -0
- package/dist/entire/utils/trailers.d.ts +36 -0
- package/dist/entire/utils/trailers.d.ts.map +1 -0
- package/dist/entire/utils/trailers.js +149 -0
- package/dist/entire/utils/trailers.js.map +1 -0
- package/dist/entire/utils/transcript-parse.d.ts +57 -0
- package/dist/entire/utils/transcript-parse.d.ts.map +1 -0
- package/dist/entire/utils/transcript-parse.js +126 -0
- package/dist/entire/utils/transcript-parse.js.map +1 -0
- package/dist/entire/utils/transcript-timestamp.d.ts +22 -0
- package/dist/entire/utils/transcript-timestamp.d.ts.map +1 -0
- package/dist/entire/utils/transcript-timestamp.js +56 -0
- package/dist/entire/utils/transcript-timestamp.js.map +1 -0
- package/dist/entire/utils/tree-ops.d.ts +47 -0
- package/dist/entire/utils/tree-ops.d.ts.map +1 -0
- package/dist/entire/utils/tree-ops.js +145 -0
- package/dist/entire/utils/tree-ops.js.map +1 -0
- package/dist/entire/utils/tty.d.ts +25 -0
- package/dist/entire/utils/tty.d.ts.map +1 -0
- package/dist/entire/utils/tty.js +70 -0
- package/dist/entire/utils/tty.js.map +1 -0
- package/dist/entire/utils/validation.d.ts +31 -0
- package/dist/entire/utils/validation.d.ts.map +1 -0
- package/dist/entire/utils/validation.js +59 -0
- package/dist/entire/utils/validation.js.map +1 -0
- package/dist/entire/utils/worktree.d.ts +16 -0
- package/dist/entire/utils/worktree.d.ts.map +1 -0
- package/dist/entire/utils/worktree.js +50 -0
- package/dist/entire/utils/worktree.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/entire.d.ts +27 -2
- package/dist/providers/entire.d.ts.map +1 -1
- package/dist/providers/entire.js +13 -2
- package/dist/providers/entire.js.map +1 -1
- package/dist/providers/from-config.d.ts.map +1 -1
- package/dist/providers/from-config.js +23 -0
- package/dist/providers/from-config.js.map +1 -1
- package/dist/providers/global.d.ts +27 -0
- package/dist/providers/global.d.ts.map +1 -0
- package/dist/providers/global.js +242 -0
- package/dist/providers/global.js.map +1 -0
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +3 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/schema/edges.d.ts +5 -1
- package/dist/schema/edges.d.ts.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/tracking/claude-task-reconstructor.d.ts +41 -0
- package/dist/tracking/claude-task-reconstructor.d.ts.map +1 -0
- package/dist/tracking/claude-task-reconstructor.js +91 -0
- package/dist/tracking/claude-task-reconstructor.js.map +1 -0
- package/dist/tracking/claude-tool-categorizer.d.ts +30 -0
- package/dist/tracking/claude-tool-categorizer.d.ts.map +1 -0
- package/dist/tracking/claude-tool-categorizer.js +98 -0
- package/dist/tracking/claude-tool-categorizer.js.map +1 -0
- package/dist/tracking/index.d.ts +19 -0
- package/dist/tracking/index.d.ts.map +1 -0
- package/dist/tracking/index.js +14 -0
- package/dist/tracking/index.js.map +1 -0
- package/dist/tracking/plan-mode-tracker.d.ts +20 -0
- package/dist/tracking/plan-mode-tracker.d.ts.map +1 -0
- package/dist/tracking/plan-mode-tracker.js +35 -0
- package/dist/tracking/plan-mode-tracker.js.map +1 -0
- package/dist/tracking/skill-tracker.d.ts +133 -0
- package/dist/tracking/skill-tracker.d.ts.map +1 -0
- package/dist/tracking/skill-tracker.js +130 -0
- package/dist/tracking/skill-tracker.js.map +1 -0
- package/dist/tracking/transcript-extractor.d.ts +45 -0
- package/dist/tracking/transcript-extractor.d.ts.map +1 -0
- package/dist/tracking/transcript-extractor.js +174 -0
- package/dist/tracking/transcript-extractor.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Operations
|
|
3
|
+
*
|
|
4
|
+
* Low-level git operations that shell out to the git CLI.
|
|
5
|
+
* This approach avoids a dependency on a full git library while
|
|
6
|
+
* providing the operations needed for session and checkpoint management.
|
|
7
|
+
*/
|
|
8
|
+
export interface GitAuthor {
|
|
9
|
+
name: string;
|
|
10
|
+
email: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GitExecOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export declare class GitError extends Error {
|
|
18
|
+
readonly exitCode: number | null;
|
|
19
|
+
readonly stderr: string;
|
|
20
|
+
constructor(message: string, exitCode: number | null, stderr: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Execute a git command and return stdout
|
|
24
|
+
*/
|
|
25
|
+
export declare function git(args: string[], options?: GitExecOptions): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Execute a git command, returning null on error instead of throwing
|
|
28
|
+
*/
|
|
29
|
+
export declare function gitSafe(args: string[], options?: GitExecOptions): Promise<string | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the git directory for the working tree
|
|
32
|
+
*/
|
|
33
|
+
export declare function getGitDir(cwd?: string): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the git common directory (shared for worktrees)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getGitCommonDir(cwd?: string): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the worktree root directory
|
|
40
|
+
*/
|
|
41
|
+
export declare function getWorktreeRoot(cwd?: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if we're inside a git repository
|
|
44
|
+
*/
|
|
45
|
+
export declare function isGitRepository(cwd?: string): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the sessions directory path (.git/entire-sessions/)
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSessionsDir(cwd?: string): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current HEAD commit hash
|
|
52
|
+
*/
|
|
53
|
+
export declare function getHead(cwd?: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the short hash of a commit
|
|
56
|
+
*/
|
|
57
|
+
export declare function getShortHash(ref: string, cwd?: string): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Get current branch name, or null if detached HEAD
|
|
60
|
+
*/
|
|
61
|
+
export declare function getCurrentBranch(cwd?: string): Promise<string | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a ref exists
|
|
64
|
+
*/
|
|
65
|
+
export declare function refExists(ref: string, cwd?: string): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the tree hash for a commit
|
|
68
|
+
*/
|
|
69
|
+
export declare function getTreeHash(ref: string, cwd?: string): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* List branches matching a pattern
|
|
72
|
+
*/
|
|
73
|
+
export declare function listBranches(pattern?: string, cwd?: string): Promise<string[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Create a branch at a ref
|
|
76
|
+
*/
|
|
77
|
+
export declare function createBranch(name: string, ref: string, cwd?: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Delete a branch
|
|
80
|
+
*/
|
|
81
|
+
export declare function deleteBranch(name: string, force?: boolean, cwd?: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Update a branch ref to point to a new commit
|
|
84
|
+
*/
|
|
85
|
+
export declare function updateRef(ref: string, commitHash: string, cwd?: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Get the git author from config
|
|
88
|
+
*/
|
|
89
|
+
export declare function getGitAuthor(cwd?: string): Promise<GitAuthor>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a tree object from a list of entries
|
|
92
|
+
*/
|
|
93
|
+
export declare function mktree(entries: Array<{
|
|
94
|
+
mode: string;
|
|
95
|
+
type: string;
|
|
96
|
+
hash: string;
|
|
97
|
+
name: string;
|
|
98
|
+
}>, cwd?: string): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a blob from content
|
|
101
|
+
*/
|
|
102
|
+
export declare function hashObject(content: string | Buffer, cwd?: string): Promise<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Create a commit object
|
|
105
|
+
*/
|
|
106
|
+
export declare function commitTree(treeHash: string, parentHash: string | null, message: string, author: GitAuthor, cwd?: string): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* List entries in a tree
|
|
109
|
+
*/
|
|
110
|
+
export declare function lsTree(ref: string, treePath?: string, cwd?: string): Promise<Array<{
|
|
111
|
+
mode: string;
|
|
112
|
+
type: string;
|
|
113
|
+
hash: string;
|
|
114
|
+
name: string;
|
|
115
|
+
}>>;
|
|
116
|
+
/**
|
|
117
|
+
* Read a blob from the object store
|
|
118
|
+
*/
|
|
119
|
+
export declare function catFile(ref: string, cwd?: string): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Read a file from a specific tree/commit
|
|
122
|
+
*/
|
|
123
|
+
export declare function showFile(ref: string, filePath: string, cwd?: string): Promise<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Get log entries for a ref
|
|
126
|
+
*/
|
|
127
|
+
export declare function log(ref: string, options?: {
|
|
128
|
+
maxCount?: number;
|
|
129
|
+
format?: string;
|
|
130
|
+
}, cwd?: string): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Get list of files changed between two refs
|
|
133
|
+
*/
|
|
134
|
+
export declare function diffNameOnly(refA: string, refB: string, cwd?: string): Promise<{
|
|
135
|
+
added: string[];
|
|
136
|
+
modified: string[];
|
|
137
|
+
deleted: string[];
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Get stat of diff between two refs (line counts)
|
|
141
|
+
*/
|
|
142
|
+
export declare function diffStat(refA: string, refB: string, cwd?: string): Promise<{
|
|
143
|
+
additions: number;
|
|
144
|
+
deletions: number;
|
|
145
|
+
}>;
|
|
146
|
+
/**
|
|
147
|
+
* Check if the working tree has uncommitted changes
|
|
148
|
+
*/
|
|
149
|
+
export declare function hasUncommittedChanges(cwd?: string): Promise<boolean>;
|
|
150
|
+
/**
|
|
151
|
+
* Get list of untracked files
|
|
152
|
+
*/
|
|
153
|
+
export declare function getUntrackedFiles(cwd?: string): Promise<string[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Check if on the default branch (main/master)
|
|
156
|
+
*/
|
|
157
|
+
export declare function isOnDefaultBranch(cwd?: string): Promise<[boolean, string]>;
|
|
158
|
+
/**
|
|
159
|
+
* Push a branch to a remote
|
|
160
|
+
*/
|
|
161
|
+
export declare function pushBranch(remote: string, branch: string, force?: boolean, cwd?: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Resolve the git directory from a path, handling worktrees
|
|
164
|
+
*/
|
|
165
|
+
export declare function resolveGitDirSync(startPath: string): string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Atomically write a file (write to tmp, then rename)
|
|
168
|
+
*/
|
|
169
|
+
export declare function atomicWriteFile(filePath: string, content: string | Buffer): Promise<void>;
|
|
170
|
+
//# sourceMappingURL=git-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.d.ts","sourceRoot":"","sources":["../../src/entire/git-operations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkCH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,qBAAa,QAAS,SAAQ,KAAK;aAGf,QAAQ,EAAE,MAAM,GAAG,IAAI;aACvB,MAAM,EAAE,MAAM;gBAF9B,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM;CAKjC;AAMD;;GAEG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBvF;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMlG;AAMD;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,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OAAO,CAAC,IAAI,CAAC,CAIf;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqBlE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM/F"}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Operations
|
|
3
|
+
*
|
|
4
|
+
* Low-level git operations that shell out to the git CLI.
|
|
5
|
+
* This approach avoids a dependency on a full git library while
|
|
6
|
+
* providing the operations needed for session and checkpoint management.
|
|
7
|
+
*/
|
|
8
|
+
import { execFile } from 'node:child_process';
|
|
9
|
+
import { promisify } from 'node:util';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
const execFileAsync = promisify(execFile);
|
|
13
|
+
/**
|
|
14
|
+
* Execute a command with stdin input
|
|
15
|
+
*/
|
|
16
|
+
function execWithInput(cmd, args, input, options) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const child = execFile(cmd, args, options, (err, stdout, stderr) => {
|
|
19
|
+
if (err)
|
|
20
|
+
reject(err);
|
|
21
|
+
else
|
|
22
|
+
resolve({ stdout: String(stdout), stderr: String(stderr) });
|
|
23
|
+
});
|
|
24
|
+
if (child.stdin) {
|
|
25
|
+
child.stdin.write(input);
|
|
26
|
+
child.stdin.end();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export class GitError extends Error {
|
|
31
|
+
exitCode;
|
|
32
|
+
stderr;
|
|
33
|
+
constructor(message, exitCode, stderr) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.exitCode = exitCode;
|
|
36
|
+
this.stderr = stderr;
|
|
37
|
+
this.name = 'GitError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Core Git Execution
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Execute a git command and return stdout
|
|
45
|
+
*/
|
|
46
|
+
export async function git(args, options = {}) {
|
|
47
|
+
const cwd = options.cwd ?? process.cwd();
|
|
48
|
+
const timeout = options.timeout ?? 30000;
|
|
49
|
+
try {
|
|
50
|
+
const result = await execFileAsync('git', args, {
|
|
51
|
+
cwd,
|
|
52
|
+
timeout,
|
|
53
|
+
env: { ...process.env, ...options.env, GIT_TERMINAL_PROMPT: '0' },
|
|
54
|
+
maxBuffer: 50 * 1024 * 1024, // 50MB
|
|
55
|
+
});
|
|
56
|
+
return result.stdout.trimEnd();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const execError = error;
|
|
60
|
+
throw new GitError(`git ${args.join(' ')} failed: ${execError.stderr ?? execError.message ?? 'unknown error'}`, typeof execError.code === 'number' ? execError.code : null, String(execError.stderr ?? ''));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Execute a git command, returning null on error instead of throwing
|
|
65
|
+
*/
|
|
66
|
+
export async function gitSafe(args, options = {}) {
|
|
67
|
+
try {
|
|
68
|
+
return await git(args, options);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Repository Discovery
|
|
76
|
+
// ============================================================================
|
|
77
|
+
/**
|
|
78
|
+
* Get the git directory for the working tree
|
|
79
|
+
*/
|
|
80
|
+
export async function getGitDir(cwd) {
|
|
81
|
+
return git(['rev-parse', '--git-dir'], { cwd });
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get the git common directory (shared for worktrees)
|
|
85
|
+
*/
|
|
86
|
+
export async function getGitCommonDir(cwd) {
|
|
87
|
+
return git(['rev-parse', '--git-common-dir'], { cwd });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the worktree root directory
|
|
91
|
+
*/
|
|
92
|
+
export async function getWorktreeRoot(cwd) {
|
|
93
|
+
return git(['rev-parse', '--show-toplevel'], { cwd });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if we're inside a git repository
|
|
97
|
+
*/
|
|
98
|
+
export async function isGitRepository(cwd) {
|
|
99
|
+
const result = await gitSafe(['rev-parse', '--is-inside-work-tree'], { cwd });
|
|
100
|
+
return result === 'true';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the sessions directory path (.git/entire-sessions/)
|
|
104
|
+
*/
|
|
105
|
+
export async function getSessionsDir(cwd) {
|
|
106
|
+
const gitDir = await getGitDir(cwd);
|
|
107
|
+
return path.resolve(cwd ?? process.cwd(), gitDir, 'entire-sessions');
|
|
108
|
+
}
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// Ref Operations
|
|
111
|
+
// ============================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Get the current HEAD commit hash
|
|
114
|
+
*/
|
|
115
|
+
export async function getHead(cwd) {
|
|
116
|
+
return git(['rev-parse', 'HEAD'], { cwd });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the short hash of a commit
|
|
120
|
+
*/
|
|
121
|
+
export async function getShortHash(ref, cwd) {
|
|
122
|
+
return git(['rev-parse', '--short', ref], { cwd });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get current branch name, or null if detached HEAD
|
|
126
|
+
*/
|
|
127
|
+
export async function getCurrentBranch(cwd) {
|
|
128
|
+
const result = await gitSafe(['symbolic-ref', '--short', 'HEAD'], { cwd });
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if a ref exists
|
|
133
|
+
*/
|
|
134
|
+
export async function refExists(ref, cwd) {
|
|
135
|
+
const result = await gitSafe(['rev-parse', '--verify', ref], { cwd });
|
|
136
|
+
return result !== null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the tree hash for a commit
|
|
140
|
+
*/
|
|
141
|
+
export async function getTreeHash(ref, cwd) {
|
|
142
|
+
return git(['rev-parse', `${ref}^{tree}`], { cwd });
|
|
143
|
+
}
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// Branch Operations
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* List branches matching a pattern
|
|
149
|
+
*/
|
|
150
|
+
export async function listBranches(pattern, cwd) {
|
|
151
|
+
const args = ['branch', '--list', '--format=%(refname:short)'];
|
|
152
|
+
if (pattern)
|
|
153
|
+
args.push(pattern);
|
|
154
|
+
const result = await git(args, { cwd });
|
|
155
|
+
if (!result)
|
|
156
|
+
return [];
|
|
157
|
+
return result.split('\n').filter(Boolean);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a branch at a ref
|
|
161
|
+
*/
|
|
162
|
+
export async function createBranch(name, ref, cwd) {
|
|
163
|
+
await git(['branch', name, ref], { cwd });
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Delete a branch
|
|
167
|
+
*/
|
|
168
|
+
export async function deleteBranch(name, force = false, cwd) {
|
|
169
|
+
await git(['branch', force ? '-D' : '-d', name], { cwd });
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Update a branch ref to point to a new commit
|
|
173
|
+
*/
|
|
174
|
+
export async function updateRef(ref, commitHash, cwd) {
|
|
175
|
+
await git(['update-ref', `refs/heads/${ref}`, commitHash], { cwd });
|
|
176
|
+
}
|
|
177
|
+
// ============================================================================
|
|
178
|
+
// Commit & Tree Operations
|
|
179
|
+
// ============================================================================
|
|
180
|
+
/**
|
|
181
|
+
* Get the git author from config
|
|
182
|
+
*/
|
|
183
|
+
export async function getGitAuthor(cwd) {
|
|
184
|
+
const name = (await gitSafe(['config', 'user.name'], { cwd })) ?? 'Entire';
|
|
185
|
+
const email = (await gitSafe(['config', 'user.email'], { cwd })) ?? 'entire@localhost';
|
|
186
|
+
return { name, email };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Create a tree object from a list of entries
|
|
190
|
+
*/
|
|
191
|
+
export async function mktree(entries, cwd) {
|
|
192
|
+
const input = entries.map((e) => `${e.mode} ${e.type} ${e.hash}\t${e.name}`).join('\n') + '\n';
|
|
193
|
+
const result = await execWithInput('git', ['mktree'], input, {
|
|
194
|
+
cwd: cwd ?? process.cwd(),
|
|
195
|
+
timeout: 30000,
|
|
196
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
197
|
+
});
|
|
198
|
+
return result.stdout.trim();
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Create a blob from content
|
|
202
|
+
*/
|
|
203
|
+
export async function hashObject(content, cwd) {
|
|
204
|
+
const input = typeof content === 'string' ? content : content.toString('utf-8');
|
|
205
|
+
const result = await execWithInput('git', ['hash-object', '-w', '--stdin'], input, {
|
|
206
|
+
cwd: cwd ?? process.cwd(),
|
|
207
|
+
timeout: 30000,
|
|
208
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
209
|
+
});
|
|
210
|
+
return result.stdout.trim();
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Create a commit object
|
|
214
|
+
*/
|
|
215
|
+
export async function commitTree(treeHash, parentHash, message, author, cwd) {
|
|
216
|
+
const args = ['commit-tree', treeHash];
|
|
217
|
+
if (parentHash) {
|
|
218
|
+
args.push('-p', parentHash);
|
|
219
|
+
}
|
|
220
|
+
args.push('-m', message);
|
|
221
|
+
const env = {
|
|
222
|
+
GIT_AUTHOR_NAME: author.name,
|
|
223
|
+
GIT_AUTHOR_EMAIL: author.email,
|
|
224
|
+
GIT_COMMITTER_NAME: author.name,
|
|
225
|
+
GIT_COMMITTER_EMAIL: author.email,
|
|
226
|
+
};
|
|
227
|
+
return git(args, { cwd, env });
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* List entries in a tree
|
|
231
|
+
*/
|
|
232
|
+
export async function lsTree(ref, treePath, cwd) {
|
|
233
|
+
const args = ['ls-tree', ref];
|
|
234
|
+
if (treePath)
|
|
235
|
+
args.push(treePath);
|
|
236
|
+
const result = await gitSafe(args, { cwd });
|
|
237
|
+
if (!result)
|
|
238
|
+
return [];
|
|
239
|
+
return result
|
|
240
|
+
.split('\n')
|
|
241
|
+
.filter(Boolean)
|
|
242
|
+
.map((line) => {
|
|
243
|
+
const match = line.match(/^(\d+)\s+(\w+)\s+([0-9a-f]+)\t(.+)$/);
|
|
244
|
+
if (!match)
|
|
245
|
+
throw new Error(`Unexpected ls-tree output: ${line}`);
|
|
246
|
+
return { mode: match[1], type: match[2], hash: match[3], name: match[4] };
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Read a blob from the object store
|
|
251
|
+
*/
|
|
252
|
+
export async function catFile(ref, cwd) {
|
|
253
|
+
return git(['cat-file', '-p', ref], { cwd });
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Read a file from a specific tree/commit
|
|
257
|
+
*/
|
|
258
|
+
export async function showFile(ref, filePath, cwd) {
|
|
259
|
+
return git(['show', `${ref}:${filePath}`], { cwd });
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get log entries for a ref
|
|
263
|
+
*/
|
|
264
|
+
export async function log(ref, options = {}, cwd) {
|
|
265
|
+
const args = ['log', ref];
|
|
266
|
+
if (options.maxCount)
|
|
267
|
+
args.push(`-${options.maxCount}`);
|
|
268
|
+
if (options.format)
|
|
269
|
+
args.push(`--format=${options.format}`);
|
|
270
|
+
return git(args, { cwd });
|
|
271
|
+
}
|
|
272
|
+
// ============================================================================
|
|
273
|
+
// Diff Operations
|
|
274
|
+
// ============================================================================
|
|
275
|
+
/**
|
|
276
|
+
* Get list of files changed between two refs
|
|
277
|
+
*/
|
|
278
|
+
export async function diffNameOnly(refA, refB, cwd) {
|
|
279
|
+
const result = await git(['diff', '--name-status', refA, refB], { cwd });
|
|
280
|
+
const added = [];
|
|
281
|
+
const modified = [];
|
|
282
|
+
const deleted = [];
|
|
283
|
+
for (const line of result.split('\n').filter(Boolean)) {
|
|
284
|
+
const [status, ...rest] = line.split('\t');
|
|
285
|
+
const file = rest.join('\t');
|
|
286
|
+
switch (status[0]) {
|
|
287
|
+
case 'A':
|
|
288
|
+
added.push(file);
|
|
289
|
+
break;
|
|
290
|
+
case 'D':
|
|
291
|
+
deleted.push(file);
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
modified.push(file);
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return { added, modified, deleted };
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get stat of diff between two refs (line counts)
|
|
302
|
+
*/
|
|
303
|
+
export async function diffStat(refA, refB, cwd) {
|
|
304
|
+
const result = await git(['diff', '--shortstat', refA, refB], { cwd });
|
|
305
|
+
let additions = 0;
|
|
306
|
+
let deletions = 0;
|
|
307
|
+
const addMatch = result.match(/(\d+) insertion/);
|
|
308
|
+
const delMatch = result.match(/(\d+) deletion/);
|
|
309
|
+
if (addMatch)
|
|
310
|
+
additions = parseInt(addMatch[1], 10);
|
|
311
|
+
if (delMatch)
|
|
312
|
+
deletions = parseInt(delMatch[1], 10);
|
|
313
|
+
return { additions, deletions };
|
|
314
|
+
}
|
|
315
|
+
// ============================================================================
|
|
316
|
+
// Working Tree Operations
|
|
317
|
+
// ============================================================================
|
|
318
|
+
/**
|
|
319
|
+
* Check if the working tree has uncommitted changes
|
|
320
|
+
*/
|
|
321
|
+
export async function hasUncommittedChanges(cwd) {
|
|
322
|
+
const result = await git(['status', '--porcelain'], { cwd });
|
|
323
|
+
return result.length > 0;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get list of untracked files
|
|
327
|
+
*/
|
|
328
|
+
export async function getUntrackedFiles(cwd) {
|
|
329
|
+
const result = await git(['ls-files', '--others', '--exclude-standard'], { cwd });
|
|
330
|
+
if (!result)
|
|
331
|
+
return [];
|
|
332
|
+
return result.split('\n').filter(Boolean);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Check if on the default branch (main/master)
|
|
336
|
+
*/
|
|
337
|
+
export async function isOnDefaultBranch(cwd) {
|
|
338
|
+
const branch = await getCurrentBranch(cwd);
|
|
339
|
+
if (!branch)
|
|
340
|
+
return [false, ''];
|
|
341
|
+
const isDefault = branch === 'main' || branch === 'master';
|
|
342
|
+
return [isDefault, branch];
|
|
343
|
+
}
|
|
344
|
+
// ============================================================================
|
|
345
|
+
// Push Operations
|
|
346
|
+
// ============================================================================
|
|
347
|
+
/**
|
|
348
|
+
* Push a branch to a remote
|
|
349
|
+
*/
|
|
350
|
+
export async function pushBranch(remote, branch, force = false, cwd) {
|
|
351
|
+
const args = ['push', remote, branch];
|
|
352
|
+
if (force)
|
|
353
|
+
args.push('--force');
|
|
354
|
+
await git(args, { cwd, timeout: 60000 });
|
|
355
|
+
}
|
|
356
|
+
// ============================================================================
|
|
357
|
+
// Filesystem Helpers
|
|
358
|
+
// ============================================================================
|
|
359
|
+
/**
|
|
360
|
+
* Resolve the git directory from a path, handling worktrees
|
|
361
|
+
*/
|
|
362
|
+
export function resolveGitDirSync(startPath) {
|
|
363
|
+
let dir = startPath;
|
|
364
|
+
const root = path.parse(dir).root;
|
|
365
|
+
while (dir !== root) {
|
|
366
|
+
const gitPath = path.join(dir, '.git');
|
|
367
|
+
try {
|
|
368
|
+
const stat = fs.statSync(gitPath);
|
|
369
|
+
if (stat.isDirectory())
|
|
370
|
+
return gitPath;
|
|
371
|
+
if (stat.isFile()) {
|
|
372
|
+
const content = fs.readFileSync(gitPath, 'utf-8').trim();
|
|
373
|
+
const match = content.match(/^gitdir:\s*(.+)$/);
|
|
374
|
+
if (match)
|
|
375
|
+
return path.resolve(dir, match[1]);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
// Not found at this level
|
|
380
|
+
}
|
|
381
|
+
dir = path.dirname(dir);
|
|
382
|
+
}
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Atomically write a file (write to tmp, then rename)
|
|
387
|
+
*/
|
|
388
|
+
export async function atomicWriteFile(filePath, content) {
|
|
389
|
+
const dir = path.dirname(filePath);
|
|
390
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
391
|
+
const tmpPath = `${filePath}.tmp.${process.pid}`;
|
|
392
|
+
await fs.promises.writeFile(tmpPath, content, 'utf-8');
|
|
393
|
+
await fs.promises.rename(tmpPath, filePath);
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=git-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.js","sourceRoot":"","sources":["../../src/entire/git-operations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAwB,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C;;GAEG;AACH,SAAS,aAAa,CACpB,GAAW,EACX,IAAc,EACd,KAAa,EACb,OAAwB;IAExB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACjE,IAAI,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;;gBAChB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,C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|
|
5
|
+
* commit-msg, post-commit, pre-push) that integrate Entire into the git workflow.
|
|
6
|
+
*/
|
|
7
|
+
declare const HOOK_NAMES: readonly ["prepare-commit-msg", "commit-msg", "post-commit", "pre-push"];
|
|
8
|
+
export type GitHookName = (typeof HOOK_NAMES)[number];
|
|
9
|
+
/**
|
|
10
|
+
* Install git hooks for Entire into a repository
|
|
11
|
+
*/
|
|
12
|
+
export declare function installGitHooks(repoPath: string, entireExecutable?: string): Promise<number>;
|
|
13
|
+
/**
|
|
14
|
+
* Uninstall git hooks for Entire from a repository
|
|
15
|
+
*/
|
|
16
|
+
export declare function uninstallGitHooks(repoPath: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if git hooks are installed
|
|
19
|
+
*/
|
|
20
|
+
export declare function areGitHooksInstalled(repoPath: string): Promise<boolean>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=git-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../../src/entire/hooks/git-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,QAAA,MAAM,UAAU,0EAA2E,CAAC;AAE5F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAMtD;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,SAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCvE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAe7E"}
|