maistro 1.0.390
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/LICENSE +15 -0
- package/README.md +107 -0
- package/dist/app.d.ts +247 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +4971 -0
- package/dist/app.js.map +1 -0
- package/dist/buildInfo.d.ts +5 -0
- package/dist/buildInfo.d.ts.map +1 -0
- package/dist/buildInfo.js +2 -0
- package/dist/buildInfo.js.map +1 -0
- package/dist/caffeinate.d.ts +72 -0
- package/dist/caffeinate.d.ts.map +1 -0
- package/dist/caffeinate.js +258 -0
- package/dist/caffeinate.js.map +1 -0
- package/dist/claudePath.d.ts +10 -0
- package/dist/claudePath.d.ts.map +1 -0
- package/dist/claudePath.js +34 -0
- package/dist/claudePath.js.map +1 -0
- package/dist/clipboard.d.ts +44 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +442 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/config.d.ts +211 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +933 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +50 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +81 -0
- package/dist/constants.js.map +1 -0
- package/dist/contextBuilder.d.ts +38 -0
- package/dist/contextBuilder.d.ts.map +1 -0
- package/dist/contextBuilder.js +113 -0
- package/dist/contextBuilder.js.map +1 -0
- package/dist/dependencyDetector.d.ts +57 -0
- package/dist/dependencyDetector.d.ts.map +1 -0
- package/dist/dependencyDetector.js +505 -0
- package/dist/dependencyDetector.js.map +1 -0
- package/dist/executor.d.ts +83 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +583 -0
- package/dist/executor.js.map +1 -0
- package/dist/git.d.ts +85 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +283 -0
- package/dist/git.js.map +1 -0
- package/dist/imageManager.d.ts +161 -0
- package/dist/imageManager.d.ts.map +1 -0
- package/dist/imageManager.js +674 -0
- package/dist/imageManager.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +437 -0
- package/dist/index.js.map +1 -0
- package/dist/input-visual-test.d.ts +9 -0
- package/dist/input-visual-test.d.ts.map +1 -0
- package/dist/input-visual-test.js +108 -0
- package/dist/input-visual-test.js.map +1 -0
- package/dist/inputBox.d.ts +228 -0
- package/dist/inputBox.d.ts.map +1 -0
- package/dist/inputBox.js +966 -0
- package/dist/inputBox.js.map +1 -0
- package/dist/logger.d.ts +136 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +347 -0
- package/dist/logger.js.map +1 -0
- package/dist/orchestrator.d.ts +149 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +821 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/planner.d.ts +86 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +830 -0
- package/dist/planner.js.map +1 -0
- package/dist/pty-test-runner.d.ts +87 -0
- package/dist/pty-test-runner.d.ts.map +1 -0
- package/dist/pty-test-runner.js +721 -0
- package/dist/pty-test-runner.js.map +1 -0
- package/dist/screen.d.ts +44 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +152 -0
- package/dist/screen.js.map +1 -0
- package/dist/taskQueue.d.ts +70 -0
- package/dist/taskQueue.d.ts.map +1 -0
- package/dist/taskQueue.js +282 -0
- package/dist/taskQueue.js.map +1 -0
- package/dist/tui-test-harness.d.ts +216 -0
- package/dist/tui-test-harness.d.ts.map +1 -0
- package/dist/tui-test-harness.js +527 -0
- package/dist/tui-test-harness.js.map +1 -0
- package/dist/types.d.ts +257 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +46 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-visual-test.d.ts +15 -0
- package/dist/ui-visual-test.d.ts.map +1 -0
- package/dist/ui-visual-test.js +141 -0
- package/dist/ui-visual-test.js.map +1 -0
- package/dist/ui.d.ts +272 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +1531 -0
- package/dist/ui.js.map +1 -0
- package/dist/validator.d.ts +53 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +491 -0
- package/dist/validator.js.map +1 -0
- package/dist/versionCheck.d.ts +63 -0
- package/dist/versionCheck.d.ts.map +1 -0
- package/dist/versionCheck.js +261 -0
- package/dist/versionCheck.js.map +1 -0
- package/package.json +62 -0
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface GitResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
output: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Check if a directory is a git repository
|
|
8
|
+
*/
|
|
9
|
+
export declare function isGitRepo(cwd: string): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize a new git repository
|
|
12
|
+
*/
|
|
13
|
+
export declare function initRepo(cwd: string): Promise<GitResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the current branch name
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCurrentBranch(cwd: string): Promise<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Get git status (short format)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getStatus(cwd: string): Promise<GitResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if there are uncommitted changes
|
|
24
|
+
*/
|
|
25
|
+
export declare function hasChanges(cwd: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Stage all changes
|
|
28
|
+
*/
|
|
29
|
+
export declare function stageAll(cwd: string): Promise<GitResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Stage specific files
|
|
32
|
+
*/
|
|
33
|
+
export declare function stageFiles(cwd: string, files: string[]): Promise<GitResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Unstage all staged changes (keeps files, removes from staging area)
|
|
36
|
+
*/
|
|
37
|
+
export declare function unstageAll(cwd: string): Promise<GitResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Create a commit with the given message
|
|
40
|
+
*/
|
|
41
|
+
export declare function commit(cwd: string, message: string): Promise<GitResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Stage all changes and commit
|
|
44
|
+
*/
|
|
45
|
+
export declare function commitAll(cwd: string, message: string): Promise<GitResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the diff of uncommitted changes
|
|
48
|
+
*/
|
|
49
|
+
export declare function getDiff(cwd: string, staged?: boolean): Promise<GitResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Get recent commit logs
|
|
52
|
+
*/
|
|
53
|
+
export declare function getLog(cwd: string, count?: number): Promise<GitResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the latest commit hash
|
|
56
|
+
*/
|
|
57
|
+
export declare function getLatestCommitHash(cwd: string): Promise<string | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Reset to a specific commit (soft reset - keeps changes staged)
|
|
60
|
+
*/
|
|
61
|
+
export declare function resetSoft(cwd: string, commitRef: string): Promise<GitResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Discard all uncommitted changes
|
|
64
|
+
*/
|
|
65
|
+
export declare function discardChanges(cwd: string): Promise<GitResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Get list of changed files
|
|
68
|
+
*/
|
|
69
|
+
export declare function getChangedFiles(cwd: string): Promise<string[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Get list of staged files (files that will be in the next commit)
|
|
72
|
+
*/
|
|
73
|
+
export declare function getStagedFiles(cwd: string): Promise<string[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the size of the staged diff in bytes
|
|
76
|
+
*/
|
|
77
|
+
export declare function getStagedDiffSize(cwd: string): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Ensure .maistro is in .gitignore
|
|
80
|
+
* - If .gitignore doesn't exist, creates it with .maistro/
|
|
81
|
+
* - If .gitignore exists but doesn't contain .maistro, appends it
|
|
82
|
+
* - If already present, does nothing
|
|
83
|
+
*/
|
|
84
|
+
export declare function ensureMaistroInGitignore(cwd: string): Promise<GitResult>;
|
|
85
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoBD;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7D;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAO9D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO1E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAO/D;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG9D;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAO9D;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAOjF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAOhE;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAY7E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAOhF;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAQtF;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAW/E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO7E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAOlF;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAQpE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAapE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAanE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA6B9E"}
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { readFile, writeFile, access } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* Extract error message from an unknown error
|
|
6
|
+
*/
|
|
7
|
+
function getErrorMessage(error) {
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
// Check for execa error properties
|
|
10
|
+
const execaError = error;
|
|
11
|
+
if (typeof execaError.stderr === 'string' && execaError.stderr) {
|
|
12
|
+
return execaError.stderr;
|
|
13
|
+
}
|
|
14
|
+
if (typeof execaError.stdout === 'string' && execaError.stdout) {
|
|
15
|
+
return execaError.stdout;
|
|
16
|
+
}
|
|
17
|
+
return error.message;
|
|
18
|
+
}
|
|
19
|
+
return String(error);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a directory is a git repository
|
|
23
|
+
*/
|
|
24
|
+
export async function isGitRepo(cwd) {
|
|
25
|
+
try {
|
|
26
|
+
await execa('git', ['rev-parse', '--git-dir'], { cwd });
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize a new git repository
|
|
35
|
+
*/
|
|
36
|
+
export async function initRepo(cwd) {
|
|
37
|
+
try {
|
|
38
|
+
const result = await execa('git', ['init'], { cwd });
|
|
39
|
+
return { success: true, output: result.stdout };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the current branch name
|
|
47
|
+
*/
|
|
48
|
+
export async function getCurrentBranch(cwd) {
|
|
49
|
+
try {
|
|
50
|
+
const result = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd });
|
|
51
|
+
return result.stdout.trim();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get git status (short format)
|
|
59
|
+
*/
|
|
60
|
+
export async function getStatus(cwd) {
|
|
61
|
+
try {
|
|
62
|
+
const result = await execa('git', ['status', '--short'], { cwd });
|
|
63
|
+
return { success: true, output: result.stdout };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if there are uncommitted changes
|
|
71
|
+
*/
|
|
72
|
+
export async function hasChanges(cwd) {
|
|
73
|
+
const status = await getStatus(cwd);
|
|
74
|
+
return status.success && status.output.trim().length > 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Stage all changes
|
|
78
|
+
*/
|
|
79
|
+
export async function stageAll(cwd) {
|
|
80
|
+
try {
|
|
81
|
+
const result = await execa('git', ['add', '-A'], { cwd });
|
|
82
|
+
return { success: true, output: result.stdout };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Stage specific files
|
|
90
|
+
*/
|
|
91
|
+
export async function stageFiles(cwd, files) {
|
|
92
|
+
try {
|
|
93
|
+
const result = await execa('git', ['add', ...files], { cwd });
|
|
94
|
+
return { success: true, output: result.stdout };
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Unstage all staged changes (keeps files, removes from staging area)
|
|
102
|
+
*/
|
|
103
|
+
export async function unstageAll(cwd) {
|
|
104
|
+
try {
|
|
105
|
+
await execa('git', ['reset', 'HEAD'], { cwd });
|
|
106
|
+
return { success: true, output: 'Changes unstaged' };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a commit with the given message
|
|
114
|
+
*/
|
|
115
|
+
export async function commit(cwd, message) {
|
|
116
|
+
try {
|
|
117
|
+
const result = await execa('git', ['commit', '-m', message], { cwd });
|
|
118
|
+
return { success: true, output: result.stdout };
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const errorMsg = getErrorMessage(error);
|
|
122
|
+
// Check if it's just "nothing to commit"
|
|
123
|
+
if (errorMsg.includes('nothing to commit')) {
|
|
124
|
+
return { success: true, output: 'Nothing to commit' };
|
|
125
|
+
}
|
|
126
|
+
return { success: false, output: '', error: errorMsg };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Stage all changes and commit
|
|
131
|
+
*/
|
|
132
|
+
export async function commitAll(cwd, message) {
|
|
133
|
+
const stageResult = await stageAll(cwd);
|
|
134
|
+
if (!stageResult.success) {
|
|
135
|
+
return stageResult;
|
|
136
|
+
}
|
|
137
|
+
return commit(cwd, message);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get the diff of uncommitted changes
|
|
141
|
+
*/
|
|
142
|
+
export async function getDiff(cwd, staged = false) {
|
|
143
|
+
try {
|
|
144
|
+
const args = staged ? ['diff', '--staged'] : ['diff'];
|
|
145
|
+
const result = await execa('git', args, { cwd });
|
|
146
|
+
return { success: true, output: result.stdout };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get recent commit logs
|
|
154
|
+
*/
|
|
155
|
+
export async function getLog(cwd, count = 5) {
|
|
156
|
+
try {
|
|
157
|
+
const result = await execa('git', ['log', `--oneline`, `-n`, count.toString()], { cwd });
|
|
158
|
+
return { success: true, output: result.stdout };
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get the latest commit hash
|
|
166
|
+
*/
|
|
167
|
+
export async function getLatestCommitHash(cwd) {
|
|
168
|
+
try {
|
|
169
|
+
const result = await execa('git', ['rev-parse', 'HEAD'], { cwd });
|
|
170
|
+
return result.stdout.trim();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Reset to a specific commit (soft reset - keeps changes staged)
|
|
178
|
+
*/
|
|
179
|
+
export async function resetSoft(cwd, commitRef) {
|
|
180
|
+
try {
|
|
181
|
+
const result = await execa('git', ['reset', '--soft', commitRef], { cwd });
|
|
182
|
+
return { success: true, output: result.stdout };
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Discard all uncommitted changes
|
|
190
|
+
*/
|
|
191
|
+
export async function discardChanges(cwd) {
|
|
192
|
+
try {
|
|
193
|
+
await execa('git', ['checkout', '.'], { cwd });
|
|
194
|
+
await execa('git', ['clean', '-fd'], { cwd });
|
|
195
|
+
return { success: true, output: 'Changes discarded' };
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get list of changed files
|
|
203
|
+
*/
|
|
204
|
+
export async function getChangedFiles(cwd) {
|
|
205
|
+
try {
|
|
206
|
+
const result = await execa('git', ['status', '--porcelain'], { cwd });
|
|
207
|
+
if (!result.stdout.trim()) {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
return result.stdout
|
|
211
|
+
.trim()
|
|
212
|
+
.split('\n')
|
|
213
|
+
.map(line => line.slice(3).trim());
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get list of staged files (files that will be in the next commit)
|
|
221
|
+
*/
|
|
222
|
+
export async function getStagedFiles(cwd) {
|
|
223
|
+
try {
|
|
224
|
+
const result = await execa('git', ['diff', '--staged', '--name-only'], { cwd });
|
|
225
|
+
if (!result.stdout.trim()) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
return result.stdout
|
|
229
|
+
.trim()
|
|
230
|
+
.split('\n')
|
|
231
|
+
.filter(Boolean);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get the size of the staged diff in bytes
|
|
239
|
+
*/
|
|
240
|
+
export async function getStagedDiffSize(cwd) {
|
|
241
|
+
try {
|
|
242
|
+
const result = await execa('git', ['diff', '--staged'], { cwd });
|
|
243
|
+
return result.stdout.length;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Ensure .maistro is in .gitignore
|
|
251
|
+
* - If .gitignore doesn't exist, creates it with .maistro/
|
|
252
|
+
* - If .gitignore exists but doesn't contain .maistro, appends it
|
|
253
|
+
* - If already present, does nothing
|
|
254
|
+
*/
|
|
255
|
+
export async function ensureMaistroInGitignore(cwd) {
|
|
256
|
+
const gitignorePath = join(cwd, '.gitignore');
|
|
257
|
+
try {
|
|
258
|
+
// Check if .gitignore exists
|
|
259
|
+
let content = '';
|
|
260
|
+
try {
|
|
261
|
+
await access(gitignorePath);
|
|
262
|
+
content = await readFile(gitignorePath, 'utf-8');
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// File doesn't exist, will create it
|
|
266
|
+
}
|
|
267
|
+
// Check if .maistro is already in .gitignore (with or without trailing slash)
|
|
268
|
+
const maistroPattern = /^\.maistro\/?$/m;
|
|
269
|
+
if (maistroPattern.test(content)) {
|
|
270
|
+
return { success: true, output: '.maistro already in .gitignore' };
|
|
271
|
+
}
|
|
272
|
+
// Append .maistro/ to .gitignore
|
|
273
|
+
const newContent = content.length > 0 && !content.endsWith('\n')
|
|
274
|
+
? `${content}\n.maistro/\n`
|
|
275
|
+
: `${content}.maistro/\n`;
|
|
276
|
+
await writeFile(gitignorePath, newContent, 'utf-8');
|
|
277
|
+
return { success: true, output: 'Added .maistro/ to .gitignore' };
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
return { success: false, output: '', error: getErrorMessage(error) };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC;;GAEG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,mCAAmC;QACnC,MAAM,UAAU,GAAG,KAAuD,CAAC;QAC3E,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YAC/D,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B,CAAC;QACD,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YAC/D,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAA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,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC9D,CAAC,CAAC,GAAG,OAAO,eAAe;YAC3B,CAAC,CAAC,GAAG,OAAO,aAAa,CAAC;QAE5B,MAAM,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,+BAA+B,EAAE,CAAC;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;IACvE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ImageMetadata } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the images directory path for a project
|
|
4
|
+
*/
|
|
5
|
+
export declare function getImagesDir(projectPath: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize an image ID for use as a filename
|
|
8
|
+
* - Lowercase
|
|
9
|
+
* - Replace spaces and special chars with hyphens
|
|
10
|
+
* - Remove consecutive hyphens
|
|
11
|
+
*/
|
|
12
|
+
export declare function sanitizeImageId(id: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a string looks like an image file path
|
|
15
|
+
*/
|
|
16
|
+
export declare function looksLikeImagePath(input: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a string looks like an image URL
|
|
19
|
+
* Accepts any HTTP/HTTPS URL that:
|
|
20
|
+
* - Has an image extension in the path (before query params)
|
|
21
|
+
* - Includes common image-related path segments
|
|
22
|
+
* - Is from known image hosting services
|
|
23
|
+
* - Has an image extension anywhere in the URL (including query params)
|
|
24
|
+
*/
|
|
25
|
+
export declare function looksLikeImageUrl(input: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Extract image placeholders from text
|
|
28
|
+
* Supports:
|
|
29
|
+
* - [image:name], [img:name] - generic image references
|
|
30
|
+
* - [task-X-image-Y] - task-specific image references (e.g., [task-1-image-1])
|
|
31
|
+
*/
|
|
32
|
+
export declare function extractImagePlaceholders(text: string): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Extract image URLs from text
|
|
35
|
+
* Returns an array of unique image URLs found in the text
|
|
36
|
+
*/
|
|
37
|
+
export declare function extractImageUrls(text: string): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Process a task description to download image URLs and replace them with placeholders
|
|
40
|
+
* Returns the updated description and any image metadata that was created
|
|
41
|
+
*/
|
|
42
|
+
export declare function processDescriptionImageUrls(projectPath: string, description: string, taskId: string): Promise<{
|
|
43
|
+
updatedDescription: string;
|
|
44
|
+
downloadedImages: ImageMetadata[];
|
|
45
|
+
errors: string[];
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the storage path for an image
|
|
49
|
+
*/
|
|
50
|
+
export declare function getImageStoragePath(imageId: string, extension: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the absolute path to an image file
|
|
53
|
+
*/
|
|
54
|
+
export declare function getImageAbsolutePath(projectPath: string, storagePath: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Add an image from a local file path
|
|
57
|
+
*/
|
|
58
|
+
export declare function addImageFromFile(projectPath: string, filePath: string, imageId: string, description?: string): Promise<{
|
|
59
|
+
success: boolean;
|
|
60
|
+
metadata?: ImageMetadata;
|
|
61
|
+
error?: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Add an image from a URL (download)
|
|
65
|
+
*/
|
|
66
|
+
export declare function addImageFromUrl(projectPath: string, url: string, imageId: string, description?: string): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
metadata?: ImageMetadata;
|
|
69
|
+
error?: string;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Get all images for a project
|
|
73
|
+
*/
|
|
74
|
+
export declare function getImages(projectPath: string): Promise<Record<string, ImageMetadata>>;
|
|
75
|
+
/**
|
|
76
|
+
* Get a single image by ID
|
|
77
|
+
*/
|
|
78
|
+
export declare function getImage(projectPath: string, imageId: string): Promise<ImageMetadata | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Delete an image
|
|
81
|
+
*/
|
|
82
|
+
export declare function deleteImage(projectPath: string, imageId: string): Promise<{
|
|
83
|
+
success: boolean;
|
|
84
|
+
error?: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Format image size for display
|
|
88
|
+
*/
|
|
89
|
+
export declare function formatImageSize(bytes: number): string;
|
|
90
|
+
/**
|
|
91
|
+
* Generate a task-specific image ID
|
|
92
|
+
* Format: task-{taskId}-image-{index}
|
|
93
|
+
*/
|
|
94
|
+
export declare function getTaskImageId(taskId: string, imageIndex: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Generate a placeholder string for a task image
|
|
97
|
+
* Format: [task-{taskId}-image-{index}]
|
|
98
|
+
*/
|
|
99
|
+
export declare function getImagePlaceholder(taskId: string, imageIndex: number): string;
|
|
100
|
+
/**
|
|
101
|
+
* Save an image for a specific task
|
|
102
|
+
* Convenience wrapper that uses task-specific naming convention
|
|
103
|
+
*/
|
|
104
|
+
export declare function saveTaskImage(projectPath: string, sourcePath: string, taskId: string, imageIndex: number, description?: string): Promise<{
|
|
105
|
+
success: boolean;
|
|
106
|
+
metadata?: ImageMetadata;
|
|
107
|
+
error?: string;
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Get the next available image index for a task
|
|
112
|
+
*/
|
|
113
|
+
export declare function getNextTaskImageIndex(projectPath: string, taskId: string): Promise<number>;
|
|
114
|
+
/**
|
|
115
|
+
* Result of image paste detection
|
|
116
|
+
*/
|
|
117
|
+
export interface PastedImageResult {
|
|
118
|
+
detected: boolean;
|
|
119
|
+
buffer?: Buffer;
|
|
120
|
+
format?: string;
|
|
121
|
+
extension?: string;
|
|
122
|
+
mimeType?: string;
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Detect if a string contains base64-encoded image data
|
|
127
|
+
*
|
|
128
|
+
* Supports:
|
|
129
|
+
* - Raw base64 data (detects by magic bytes after decoding)
|
|
130
|
+
* - Data URLs (data:image/png;base64,...)
|
|
131
|
+
* - iTerm2 inline image sequences (ESC]1337;File=...)
|
|
132
|
+
*
|
|
133
|
+
* @param input The string to check for image data
|
|
134
|
+
* @returns Detection result with buffer and format info if found
|
|
135
|
+
*/
|
|
136
|
+
export declare function detectPastedImage(input: string): PastedImageResult;
|
|
137
|
+
/**
|
|
138
|
+
* Add an image from pasted base64 data
|
|
139
|
+
*
|
|
140
|
+
* @param projectPath Project directory path
|
|
141
|
+
* @param pastedData The pasted string (base64, data URL, or escape sequence)
|
|
142
|
+
* @param imageId Identifier for the image
|
|
143
|
+
* @param description Optional description
|
|
144
|
+
* @returns Result with success status and metadata
|
|
145
|
+
*/
|
|
146
|
+
export declare function addImageFromPaste(projectPath: string, pastedData: string, imageId: string, description?: string): Promise<{
|
|
147
|
+
success: boolean;
|
|
148
|
+
metadata?: ImageMetadata;
|
|
149
|
+
error?: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Check if input looks like it might contain pasted image data
|
|
153
|
+
* This is a quick check before doing full detection
|
|
154
|
+
*/
|
|
155
|
+
export declare function mightBePastedImage(input: string): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Generate a unique image ID for pasted images
|
|
158
|
+
* Format: paste-{timestamp}-{random}
|
|
159
|
+
*/
|
|
160
|
+
export declare function generatePasteImageId(): string;
|
|
161
|
+
//# sourceMappingURL=imageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageManager.d.ts","sourceRoot":"","sources":["../src/imageManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AAuBzD;;GAEG;AAC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