@posthog/agent 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +3 -3
- package/README.md +3 -3
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/src/adapters/claude/claude-adapter.d.ts +3 -3
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +1 -1
- package/dist/src/adapters/claude/claude-adapter.js +156 -111
- package/dist/src/adapters/claude/claude-adapter.js.map +1 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts +1 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts.map +1 -1
- package/dist/src/adapters/claude/tool-mapper.js.map +1 -1
- package/dist/src/adapters/types.d.ts +1 -1
- package/dist/src/adapters/types.d.ts.map +1 -1
- package/dist/src/agent.d.ts +7 -7
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +143 -85
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/file-manager.d.ts +4 -4
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +59 -58
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +1 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +93 -69
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +2 -3
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +22 -22
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +3 -3
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +123 -93
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/task-manager.d.ts +4 -4
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js +19 -18
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/task-progress-reporter.d.ts +3 -4
- package/dist/src/task-progress-reporter.d.ts.map +1 -1
- package/dist/src/task-progress-reporter.js +59 -54
- package/dist/src/task-progress-reporter.js.map +1 -1
- package/dist/src/template-manager.d.ts +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +30 -28
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +3 -3
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +29 -24
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.js +60 -60
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/types.d.ts +31 -31
- package/dist/src/types.d.ts +33 -33
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.d.ts +4 -4
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +8 -8
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/workflow/config.d.ts +1 -1
- package/dist/src/workflow/config.d.ts.map +1 -1
- package/dist/src/workflow/config.js +18 -18
- package/dist/src/workflow/config.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +46 -38
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +54 -48
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +58 -46
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +68 -56
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +12 -12
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/workflow/utils.d.ts +1 -1
- package/dist/src/workflow/utils.d.ts.map +1 -1
- package/dist/src/workflow/utils.js +7 -4
- package/dist/src/workflow/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/adapters/claude/claude-adapter.ts +220 -168
- package/src/adapters/claude/tool-mapper.ts +2 -2
- package/src/adapters/types.ts +1 -1
- package/src/agent.ts +579 -444
- package/src/agents/execution.ts +1 -1
- package/src/agents/planning.ts +1 -1
- package/src/agents/research.ts +0 -1
- package/src/file-manager.ts +64 -63
- package/src/git-manager.ts +152 -87
- package/src/posthog-api.ts +122 -82
- package/src/prompt-builder.ts +180 -135
- package/src/task-manager.ts +38 -30
- package/src/task-progress-reporter.ts +70 -59
- package/src/template-manager.ts +98 -45
- package/src/todo-manager.ts +35 -30
- package/src/tools/registry.ts +62 -62
- package/src/tools/types.ts +36 -36
- package/src/types.ts +93 -71
- package/src/utils/logger.ts +62 -56
- package/src/workflow/config.ts +48 -48
- package/src/workflow/steps/build.ts +122 -113
- package/src/workflow/steps/finalize.ts +214 -182
- package/src/workflow/steps/plan.ts +151 -131
- package/src/workflow/steps/research.ts +205 -186
- package/src/workflow/types.ts +38 -36
- package/src/workflow/utils.ts +37 -34
- package/LICENSE +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-manager.d.ts","sourceRoot":"","sources":["../../src/git-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,C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'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
3
|
import { Logger } from './utils/logger.js';
|
|
4
4
|
|
|
5
5
|
const execAsync = promisify(exec);
|
|
@@ -12,14 +12,15 @@ class GitManager {
|
|
|
12
12
|
this.repositoryPath = config.repositoryPath;
|
|
13
13
|
this.authorName = config.authorName;
|
|
14
14
|
this.authorEmail = config.authorEmail;
|
|
15
|
-
this.logger =
|
|
15
|
+
this.logger =
|
|
16
|
+
config.logger || new Logger({ debug: false, prefix: "[GitManager]" });
|
|
16
17
|
}
|
|
17
18
|
escapeShellArg(str) {
|
|
18
19
|
return str
|
|
19
|
-
.replace(/\\/g,
|
|
20
|
+
.replace(/\\/g, "\\\\")
|
|
20
21
|
.replace(/"/g, '\\"')
|
|
21
|
-
.replace(/`/g,
|
|
22
|
-
.replace(/\$/g,
|
|
22
|
+
.replace(/`/g, "\\`")
|
|
23
|
+
.replace(/\$/g, "\\$");
|
|
23
24
|
}
|
|
24
25
|
async runGitCommand(command) {
|
|
25
26
|
try {
|
|
@@ -41,7 +42,7 @@ class GitManager {
|
|
|
41
42
|
}
|
|
42
43
|
async isGitRepository() {
|
|
43
44
|
try {
|
|
44
|
-
await this.runGitCommand(
|
|
45
|
+
await this.runGitCommand("rev-parse --git-dir");
|
|
45
46
|
return true;
|
|
46
47
|
}
|
|
47
48
|
catch {
|
|
@@ -49,24 +50,24 @@ class GitManager {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
async getCurrentBranch() {
|
|
52
|
-
return await this.runGitCommand(
|
|
53
|
+
return await this.runGitCommand("branch --show-current");
|
|
53
54
|
}
|
|
54
55
|
async getDefaultBranch() {
|
|
55
56
|
try {
|
|
56
57
|
// Try to get the default branch from remote
|
|
57
|
-
const remoteBranch = await this.runGitCommand(
|
|
58
|
-
return remoteBranch.replace(
|
|
58
|
+
const remoteBranch = await this.runGitCommand("symbolic-ref refs/remotes/origin/HEAD");
|
|
59
|
+
return remoteBranch.replace("refs/remotes/origin/", "");
|
|
59
60
|
}
|
|
60
61
|
catch {
|
|
61
62
|
// Fallback: check if main exists, otherwise use master
|
|
62
|
-
if (await this.branchExists(
|
|
63
|
-
return
|
|
63
|
+
if (await this.branchExists("main")) {
|
|
64
|
+
return "main";
|
|
64
65
|
}
|
|
65
|
-
else if (await this.branchExists(
|
|
66
|
-
return
|
|
66
|
+
else if (await this.branchExists("master")) {
|
|
67
|
+
return "master";
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
throw new Error(
|
|
70
|
+
throw new Error("Cannot determine default branch. No main or master branch found.");
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -80,7 +81,7 @@ class GitManager {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
async createBranch(branchName, baseBranch) {
|
|
83
|
-
const base = baseBranch || await this.getCurrentBranch();
|
|
84
|
+
const base = baseBranch || (await this.getCurrentBranch());
|
|
84
85
|
await this.runGitCommand(`checkout -b ${branchName} ${base}`);
|
|
85
86
|
}
|
|
86
87
|
async switchToBranch(branchName) {
|
|
@@ -90,22 +91,25 @@ class GitManager {
|
|
|
90
91
|
const currentBranch = await this.getCurrentBranch();
|
|
91
92
|
const defaultBranch = await this.getDefaultBranch();
|
|
92
93
|
if (currentBranch === defaultBranch) {
|
|
93
|
-
this.logger.debug(
|
|
94
|
+
this.logger.debug("Already on default branch", { branch: defaultBranch });
|
|
94
95
|
return true;
|
|
95
96
|
}
|
|
96
97
|
if (await this.hasChanges()) {
|
|
97
|
-
this.logger.warn(
|
|
98
|
+
this.logger.warn("Skipping branch reset - uncommitted changes present", {
|
|
98
99
|
currentBranch,
|
|
99
|
-
defaultBranch
|
|
100
|
+
defaultBranch,
|
|
100
101
|
});
|
|
101
102
|
return false;
|
|
102
103
|
}
|
|
103
104
|
await this.switchToBranch(defaultBranch);
|
|
104
|
-
this.logger.info(
|
|
105
|
+
this.logger.info("Reset to default branch", {
|
|
106
|
+
from: currentBranch,
|
|
107
|
+
to: defaultBranch,
|
|
108
|
+
});
|
|
105
109
|
return true;
|
|
106
110
|
}
|
|
107
111
|
async createOrSwitchToBranch(branchName, baseBranch) {
|
|
108
|
-
await this.ensureCleanWorkingDirectory(
|
|
112
|
+
await this.ensureCleanWorkingDirectory("switching branches");
|
|
109
113
|
const exists = await this.branchExists(branchName);
|
|
110
114
|
if (exists) {
|
|
111
115
|
await this.switchToBranch(branchName);
|
|
@@ -115,17 +119,17 @@ class GitManager {
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
async addFiles(paths) {
|
|
118
|
-
const pathList = paths.map(p => `"${this.escapeShellArg(p)}"`).join(
|
|
122
|
+
const pathList = paths.map((p) => `"${this.escapeShellArg(p)}"`).join(" ");
|
|
119
123
|
await this.runGitCommand(`add ${pathList}`);
|
|
120
124
|
}
|
|
121
125
|
async addAllPostHogFiles() {
|
|
122
126
|
try {
|
|
123
127
|
// Use -A flag to add all changes (including new files) and ignore errors if directory is empty
|
|
124
|
-
await this.runGitCommand(
|
|
128
|
+
await this.runGitCommand("add -A .posthog/");
|
|
125
129
|
}
|
|
126
130
|
catch (error) {
|
|
127
131
|
// If the directory doesn't exist or has no files, that's fine - just log and continue
|
|
128
|
-
this.logger.debug(
|
|
132
|
+
this.logger.debug("No PostHog files to add", { error });
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
async commitChanges(message, options) {
|
|
@@ -134,8 +138,15 @@ class GitManager {
|
|
|
134
138
|
}
|
|
135
139
|
async hasChanges() {
|
|
136
140
|
try {
|
|
137
|
-
const status = await this.runGitCommand(
|
|
138
|
-
|
|
141
|
+
const status = await this.runGitCommand("status --porcelain");
|
|
142
|
+
if (!status || status.trim().length === 0) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
const lines = status.split("\n").filter((line) => {
|
|
146
|
+
const trimmed = line.trim();
|
|
147
|
+
return trimmed.length > 0 && !trimmed.includes(".posthog/");
|
|
148
|
+
});
|
|
149
|
+
return lines.length > 0;
|
|
139
150
|
}
|
|
140
151
|
catch {
|
|
141
152
|
return false;
|
|
@@ -143,7 +154,7 @@ class GitManager {
|
|
|
143
154
|
}
|
|
144
155
|
async hasStagedChanges() {
|
|
145
156
|
try {
|
|
146
|
-
const status = await this.runGitCommand(
|
|
157
|
+
const status = await this.runGitCommand("diff --cached --name-only");
|
|
147
158
|
return status.length > 0;
|
|
148
159
|
}
|
|
149
160
|
catch {
|
|
@@ -157,7 +168,7 @@ class GitManager {
|
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
170
|
async generateUniqueBranchName(baseName) {
|
|
160
|
-
if (!await this.branchExists(baseName)) {
|
|
171
|
+
if (!(await this.branchExists(baseName))) {
|
|
161
172
|
return baseName;
|
|
162
173
|
}
|
|
163
174
|
let counter = 1;
|
|
@@ -172,7 +183,7 @@ class GitManager {
|
|
|
172
183
|
const defaultBranch = await this.getDefaultBranch();
|
|
173
184
|
const currentBranch = await this.getCurrentBranch();
|
|
174
185
|
if (currentBranch !== defaultBranch) {
|
|
175
|
-
await this.ensureCleanWorkingDirectory(
|
|
186
|
+
await this.ensureCleanWorkingDirectory("switching to default branch");
|
|
176
187
|
await this.switchToBranch(defaultBranch);
|
|
177
188
|
}
|
|
178
189
|
return defaultBranch;
|
|
@@ -180,7 +191,7 @@ class GitManager {
|
|
|
180
191
|
buildCommitCommand(message, options) {
|
|
181
192
|
let command = `commit -m "${this.escapeShellArg(message)}"`;
|
|
182
193
|
if (options?.allowEmpty) {
|
|
183
|
-
command +=
|
|
194
|
+
command += " --allow-empty";
|
|
184
195
|
}
|
|
185
196
|
const authorName = options?.authorName || this.authorName;
|
|
186
197
|
const authorEmail = options?.authorEmail || this.authorEmail;
|
|
@@ -191,14 +202,14 @@ class GitManager {
|
|
|
191
202
|
}
|
|
192
203
|
async getRemoteUrl() {
|
|
193
204
|
try {
|
|
194
|
-
return await this.runGitCommand(
|
|
205
|
+
return await this.runGitCommand("remote get-url origin");
|
|
195
206
|
}
|
|
196
207
|
catch {
|
|
197
208
|
return null;
|
|
198
209
|
}
|
|
199
210
|
}
|
|
200
211
|
async pushBranch(branchName, force = false) {
|
|
201
|
-
const forceFlag = force ?
|
|
212
|
+
const forceFlag = force ? "--force" : "";
|
|
202
213
|
await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);
|
|
203
214
|
}
|
|
204
215
|
/**
|
|
@@ -211,10 +222,10 @@ class GitManager {
|
|
|
211
222
|
* const result = await tracker.finalize({ commitMessage: 'fallback message', push: true });
|
|
212
223
|
*/
|
|
213
224
|
async trackCommitsDuring() {
|
|
214
|
-
const initialSha = await this.getCommitSha(
|
|
225
|
+
const initialSha = await this.getCommitSha("HEAD");
|
|
215
226
|
return {
|
|
216
227
|
finalize: async (options) => {
|
|
217
|
-
const currentSha = await this.getCommitSha(
|
|
228
|
+
const currentSha = await this.getCommitSha("HEAD");
|
|
218
229
|
const externalCommitsCreated = initialSha !== currentSha;
|
|
219
230
|
const hasUncommittedChanges = await this.hasChanges();
|
|
220
231
|
// If no commits and no changes, nothing to do
|
|
@@ -224,7 +235,7 @@ class GitManager {
|
|
|
224
235
|
let commitCreated = externalCommitsCreated;
|
|
225
236
|
// Commit any remaining uncommitted changes
|
|
226
237
|
if (hasUncommittedChanges) {
|
|
227
|
-
await this.runGitCommand(
|
|
238
|
+
await this.runGitCommand("add .");
|
|
228
239
|
const hasStagedChanges = await this.hasStagedChanges();
|
|
229
240
|
if (hasStagedChanges) {
|
|
230
241
|
await this.commitChanges(options.commitMessage);
|
|
@@ -237,20 +248,22 @@ class GitManager {
|
|
|
237
248
|
const currentBranch = await this.getCurrentBranch();
|
|
238
249
|
await this.pushBranch(currentBranch);
|
|
239
250
|
pushedBranch = true;
|
|
240
|
-
this.logger.info(
|
|
251
|
+
this.logger.info("Pushed branch after operation", {
|
|
252
|
+
branch: currentBranch,
|
|
253
|
+
});
|
|
241
254
|
}
|
|
242
255
|
return { commitCreated, pushedBranch };
|
|
243
|
-
}
|
|
256
|
+
},
|
|
244
257
|
};
|
|
245
258
|
}
|
|
246
259
|
async createTaskBranch(taskSlug) {
|
|
247
260
|
const branchName = `posthog/task-${taskSlug}`;
|
|
248
261
|
// Ensure we're on default branch before creating task branch
|
|
249
262
|
const defaultBranch = await this.ensureOnDefaultBranch();
|
|
250
|
-
this.logger.info(
|
|
263
|
+
this.logger.info("Creating task branch from default branch", {
|
|
251
264
|
branchName,
|
|
252
265
|
taskSlug,
|
|
253
|
-
baseBranch: defaultBranch
|
|
266
|
+
baseBranch: defaultBranch,
|
|
254
267
|
});
|
|
255
268
|
await this.createOrSwitchToBranch(branchName, defaultBranch);
|
|
256
269
|
return branchName;
|
|
@@ -258,49 +271,55 @@ class GitManager {
|
|
|
258
271
|
async createTaskPlanningBranch(taskId, baseBranch) {
|
|
259
272
|
const baseName = `posthog/task-${taskId}-planning`;
|
|
260
273
|
const branchName = await this.generateUniqueBranchName(baseName);
|
|
261
|
-
this.logger.debug(
|
|
262
|
-
|
|
274
|
+
this.logger.debug("Creating unique planning branch", {
|
|
275
|
+
branchName,
|
|
276
|
+
taskId,
|
|
277
|
+
});
|
|
278
|
+
const base = baseBranch || (await this.ensureOnDefaultBranch());
|
|
263
279
|
await this.createBranch(branchName, base);
|
|
264
280
|
return branchName;
|
|
265
281
|
}
|
|
266
282
|
async createTaskImplementationBranch(taskId, planningBranchName) {
|
|
267
283
|
const baseName = `posthog/task-${taskId}-implementation`;
|
|
268
284
|
const branchName = await this.generateUniqueBranchName(baseName);
|
|
269
|
-
this.logger.debug(
|
|
285
|
+
this.logger.debug("Creating unique implementation branch", {
|
|
270
286
|
branchName,
|
|
271
287
|
taskId,
|
|
272
|
-
currentBranch: await this.getCurrentBranch()
|
|
288
|
+
currentBranch: await this.getCurrentBranch(),
|
|
273
289
|
});
|
|
274
290
|
// Determine base branch: explicit param > current planning branch > default
|
|
275
291
|
let baseBranch = planningBranchName;
|
|
276
292
|
if (!baseBranch) {
|
|
277
293
|
const currentBranch = await this.getCurrentBranch();
|
|
278
|
-
if (currentBranch.includes(
|
|
294
|
+
if (currentBranch.includes("-planning")) {
|
|
279
295
|
baseBranch = currentBranch;
|
|
280
|
-
this.logger.debug(
|
|
296
|
+
this.logger.debug("Using current planning branch", { baseBranch });
|
|
281
297
|
}
|
|
282
298
|
else {
|
|
283
299
|
baseBranch = await this.ensureOnDefaultBranch();
|
|
284
|
-
this.logger.debug(
|
|
300
|
+
this.logger.debug("Using default branch", { baseBranch });
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
|
-
this.logger.debug(
|
|
303
|
+
this.logger.debug("Creating implementation branch from base", {
|
|
304
|
+
baseBranch,
|
|
305
|
+
branchName,
|
|
306
|
+
});
|
|
288
307
|
await this.createBranch(branchName, baseBranch);
|
|
289
|
-
this.logger.info(
|
|
308
|
+
this.logger.info("Implementation branch created", {
|
|
290
309
|
branchName,
|
|
291
|
-
currentBranch: await this.getCurrentBranch()
|
|
310
|
+
currentBranch: await this.getCurrentBranch(),
|
|
292
311
|
});
|
|
293
312
|
return branchName;
|
|
294
313
|
}
|
|
295
314
|
async commitPlan(taskId, taskTitle) {
|
|
296
315
|
const currentBranch = await this.getCurrentBranch();
|
|
297
|
-
this.logger.debug(
|
|
316
|
+
this.logger.debug("Committing plan", { taskId, currentBranch });
|
|
298
317
|
await this.addAllPostHogFiles();
|
|
299
318
|
const hasChanges = await this.hasStagedChanges();
|
|
300
|
-
this.logger.debug(
|
|
319
|
+
this.logger.debug("Checking for staged changes", { hasChanges });
|
|
301
320
|
if (!hasChanges) {
|
|
302
|
-
this.logger.info(
|
|
303
|
-
return
|
|
321
|
+
this.logger.info("No plan changes to commit", { taskId });
|
|
322
|
+
return "No changes to commit";
|
|
304
323
|
}
|
|
305
324
|
const message = `📋 Add plan for task: ${taskTitle}
|
|
306
325
|
|
|
@@ -310,15 +329,15 @@ Generated by PostHog Agent
|
|
|
310
329
|
This commit contains the implementation plan and supporting documentation
|
|
311
330
|
for the task. Review the plan before proceeding with implementation.`;
|
|
312
331
|
const result = await this.commitChanges(message);
|
|
313
|
-
this.logger.info(
|
|
332
|
+
this.logger.info("Plan committed", { taskId, taskTitle });
|
|
314
333
|
return result;
|
|
315
334
|
}
|
|
316
335
|
async commitImplementation(taskId, taskTitle, planSummary) {
|
|
317
|
-
await this.runGitCommand(
|
|
336
|
+
await this.runGitCommand("add .");
|
|
318
337
|
const hasChanges = await this.hasStagedChanges();
|
|
319
338
|
if (!hasChanges) {
|
|
320
|
-
this.logger.warn(
|
|
321
|
-
return
|
|
339
|
+
this.logger.warn("No implementation changes to commit", { taskId });
|
|
340
|
+
return "No changes to commit";
|
|
322
341
|
}
|
|
323
342
|
let message = `✨ Implement task: ${taskTitle}
|
|
324
343
|
|
|
@@ -329,11 +348,11 @@ Generated by PostHog Agent`;
|
|
|
329
348
|
}
|
|
330
349
|
message += `\n\nThis commit implements the changes described in the task plan.`;
|
|
331
350
|
const result = await this.commitChanges(message);
|
|
332
|
-
this.logger.info(
|
|
351
|
+
this.logger.info("Implementation committed", { taskId, taskTitle });
|
|
333
352
|
return result;
|
|
334
353
|
}
|
|
335
354
|
async deleteBranch(branchName, force = false) {
|
|
336
|
-
const forceFlag = force ?
|
|
355
|
+
const forceFlag = force ? "-D" : "-d";
|
|
337
356
|
await this.runGitCommand(`branch ${forceFlag} ${branchName}`);
|
|
338
357
|
}
|
|
339
358
|
async deleteRemoteBranch(branchName) {
|
|
@@ -345,19 +364,19 @@ Generated by PostHog Agent`;
|
|
|
345
364
|
return {
|
|
346
365
|
name: branchName,
|
|
347
366
|
exists,
|
|
348
|
-
isCurrentBranch: branchName === currentBranch
|
|
367
|
+
isCurrentBranch: branchName === currentBranch,
|
|
349
368
|
};
|
|
350
369
|
}
|
|
351
|
-
async getCommitSha(ref =
|
|
370
|
+
async getCommitSha(ref = "HEAD") {
|
|
352
371
|
return await this.runGitCommand(`rev-parse ${ref}`);
|
|
353
372
|
}
|
|
354
|
-
async getCommitMessage(ref =
|
|
373
|
+
async getCommitMessage(ref = "HEAD") {
|
|
355
374
|
return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);
|
|
356
375
|
}
|
|
357
376
|
async createPullRequest(branchName, title, body, baseBranch) {
|
|
358
377
|
const currentBranch = await this.getCurrentBranch();
|
|
359
378
|
if (currentBranch !== branchName) {
|
|
360
|
-
await this.ensureCleanWorkingDirectory(
|
|
379
|
+
await this.ensureCleanWorkingDirectory("creating PR");
|
|
361
380
|
await this.switchToBranch(branchName);
|
|
362
381
|
}
|
|
363
382
|
await this.pushBranch(branchName);
|
|
@@ -376,12 +395,14 @@ Generated by PostHog Agent`;
|
|
|
376
395
|
async getTaskBranch(taskSlug) {
|
|
377
396
|
try {
|
|
378
397
|
// Get all branches matching the task slug pattern
|
|
379
|
-
const branches = await this.runGitCommand(
|
|
398
|
+
const branches = await this.runGitCommand("branch --list --all");
|
|
380
399
|
const branchPattern = `posthog/task-${taskSlug}`;
|
|
381
400
|
// Look for exact match or with counter suffix
|
|
382
|
-
const lines = branches
|
|
401
|
+
const lines = branches
|
|
402
|
+
.split("\n")
|
|
403
|
+
.map((l) => l.trim().replace(/^\*\s+/, ""));
|
|
383
404
|
for (const line of lines) {
|
|
384
|
-
const cleanBranch = line.replace(
|
|
405
|
+
const cleanBranch = line.replace("remotes/origin/", "");
|
|
385
406
|
if (cleanBranch.startsWith(branchPattern)) {
|
|
386
407
|
return cleanBranch;
|
|
387
408
|
}
|
|
@@ -389,14 +410,14 @@ Generated by PostHog Agent`;
|
|
|
389
410
|
return null;
|
|
390
411
|
}
|
|
391
412
|
catch (error) {
|
|
392
|
-
this.logger.debug(
|
|
413
|
+
this.logger.debug("Failed to get task branch", { taskSlug, error });
|
|
393
414
|
return null;
|
|
394
415
|
}
|
|
395
416
|
}
|
|
396
417
|
async commitAndPush(message, options) {
|
|
397
418
|
const hasChanges = await this.hasStagedChanges();
|
|
398
419
|
if (!hasChanges && !options?.allowEmpty) {
|
|
399
|
-
this.logger.debug(
|
|
420
|
+
this.logger.debug("No changes to commit, skipping");
|
|
400
421
|
return;
|
|
401
422
|
}
|
|
402
423
|
const command = this.buildCommitCommand(message, options);
|
|
@@ -404,7 +425,10 @@ Generated by PostHog Agent`;
|
|
|
404
425
|
// Push to origin
|
|
405
426
|
const currentBranch = await this.getCurrentBranch();
|
|
406
427
|
await this.pushBranch(currentBranch);
|
|
407
|
-
this.logger.info(
|
|
428
|
+
this.logger.info("Committed and pushed changes", {
|
|
429
|
+
branch: currentBranch,
|
|
430
|
+
message,
|
|
431
|
+
});
|
|
408
432
|
}
|
|
409
433
|
}
|
|
410
434
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private escapeShellArg(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/`/g, '\\\\`')\n .replace(/\\$/g, '\\\\$');\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async resetToDefaultBranchIfNeeded(): Promise<boolean> {\n const currentBranch = await this.getCurrentBranch();\n const defaultBranch = await this.getDefaultBranch();\n\n if (currentBranch === defaultBranch) {\n this.logger.debug('Already on default branch', { branch: defaultBranch });\n return true;\n }\n\n if (await this.hasChanges()) {\n this.logger.warn('Skipping branch reset - uncommitted changes present', {\n currentBranch,\n defaultBranch\n });\n return false;\n }\n\n await this.switchToBranch(defaultBranch);\n this.logger.info('Reset to default branch', { from: currentBranch, to: defaultBranch });\n return true;\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n await this.ensureCleanWorkingDirectory('switching branches');\n\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${this.escapeShellArg(p)}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n try {\n // Use -A flag to add all changes (including new files) and ignore errors if directory is empty\n await this.runGitCommand('add -A .posthog/');\n } catch (error) {\n // If the directory doesn't exist or has no files, that's fine - just log and continue\n this.logger.debug('No PostHog files to add', { error });\n }\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n const command = this.buildCommitCommand(message, options);\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n // Helper: Centralized safety check for uncommitted changes\n private async ensureCleanWorkingDirectory(operation: string): Promise<void> {\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before ${operation}.`);\n }\n }\n\n private async generateUniqueBranchName(baseName: string): Promise<string> {\n if (!await this.branchExists(baseName)) {\n return baseName;\n }\n\n let counter = 1;\n let uniqueName = `${baseName}-${counter}`;\n while (await this.branchExists(uniqueName)) {\n counter++;\n uniqueName = `${baseName}-${counter}`;\n }\n return uniqueName;\n }\n\n private async ensureOnDefaultBranch(): Promise<string> {\n const defaultBranch = await this.getDefaultBranch();\n const currentBranch = await this.getCurrentBranch();\n\n if (currentBranch !== defaultBranch) {\n await this.ensureCleanWorkingDirectory('switching to default branch');\n await this.switchToBranch(defaultBranch);\n }\n\n return defaultBranch;\n }\n\n private buildCommitCommand(message: string, options?: { allowEmpty?: boolean; authorName?: string; authorEmail?: string }): string {\n let command = `commit -m \"${this.escapeShellArg(message)}\"`;\n\n if (options?.allowEmpty) {\n command += ' --allow-empty';\n }\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return command;\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n /**\n * Tracks whether commits were made during an operation by comparing HEAD SHA\n * before and after. Returns an object with methods to finalize the operation.\n *\n * Usage:\n * const tracker = await gitManager.trackCommitsDuring();\n * // ... do work that might create commits ...\n * const result = await tracker.finalize({ commitMessage: 'fallback message', push: true });\n */\n async trackCommitsDuring(): Promise<{\n finalize: (options: {\n commitMessage: string;\n push?: boolean;\n }) => Promise<{ commitCreated: boolean; pushedBranch: boolean }>;\n }> {\n const initialSha = await this.getCommitSha('HEAD');\n\n return {\n finalize: async (options) => {\n const currentSha = await this.getCommitSha('HEAD');\n const externalCommitsCreated = initialSha !== currentSha;\n const hasUncommittedChanges = await this.hasChanges();\n\n // If no commits and no changes, nothing to do\n if (!externalCommitsCreated && !hasUncommittedChanges) {\n return { commitCreated: false, pushedBranch: false };\n }\n\n let commitCreated = externalCommitsCreated;\n\n // Commit any remaining uncommitted changes\n if (hasUncommittedChanges) {\n await this.runGitCommand('add .');\n const hasStagedChanges = await this.hasStagedChanges();\n\n if (hasStagedChanges) {\n await this.commitChanges(options.commitMessage);\n commitCreated = true;\n }\n }\n\n // Push if requested and commits were made\n let pushedBranch = false;\n if (options.push && commitCreated) {\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n pushedBranch = true;\n this.logger.info('Pushed branch after operation', { branch: currentBranch });\n }\n\n return { commitCreated, pushedBranch };\n }\n };\n }\n\n async createTaskBranch(taskSlug: string): Promise<string> {\n const branchName = `posthog/task-${taskSlug}`;\n\n // Ensure we're on default branch before creating task branch\n const defaultBranch = await this.ensureOnDefaultBranch();\n\n this.logger.info('Creating task branch from default branch', {\n branchName,\n taskSlug,\n baseBranch: defaultBranch\n });\n\n await this.createOrSwitchToBranch(branchName, defaultBranch);\n\n return branchName;\n }\n\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n const baseName = `posthog/task-${taskId}-planning`;\n const branchName = await this.generateUniqueBranchName(baseName);\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n const base = baseBranch || await this.ensureOnDefaultBranch();\n await this.createBranch(branchName, base);\n\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n const baseName = `posthog/task-${taskId}-implementation`;\n const branchName = await this.generateUniqueBranchName(baseName);\n\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: await this.getCurrentBranch()\n });\n\n // Determine base branch: explicit param > current planning branch > default\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch;\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n baseBranch = await this.ensureOnDefaultBranch();\n this.logger.debug('Using default branch', { baseBranch });\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch);\n\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: await this.getCurrentBranch()\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.ensureCleanWorkingDirectory('creating PR');\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${this.escapeShellArg(title)}\" --body \"${this.escapeShellArg(body)}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n\n async getTaskBranch(taskSlug: string): Promise<string | null> {\n try {\n // Get all branches matching the task slug pattern\n const branches = await this.runGitCommand('branch --list --all');\n const branchPattern = `posthog/task-${taskSlug}`;\n \n // Look for exact match or with counter suffix\n const lines = branches.split('\\n').map(l => l.trim().replace(/^\\*\\s+/, ''));\n for (const line of lines) {\n const cleanBranch = line.replace('remotes/origin/', '');\n if (cleanBranch.startsWith(branchPattern)) {\n return cleanBranch;\n }\n }\n \n return null;\n } catch (error) {\n this.logger.debug('Failed to get task branch', { taskSlug, error });\n return null;\n }\n }\n\n async commitAndPush(message: string, options?: { allowEmpty?: boolean }): Promise<void> {\n const hasChanges = await this.hasStagedChanges();\n\n if (!hasChanges && !options?.allowEmpty) {\n this.logger.debug('No changes to commit, skipping');\n return;\n }\n\n const command = this.buildCommitCommand(message, options);\n await this.runGitCommand(command);\n\n // Push to origin\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n\n this.logger.info('Committed and pushed changes', { branch: currentBranch, message });\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF;AAEQ,IAAA,cAAc,CAAC,GAAW,EAAA;AAChC,QAAA,OAAO;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ACF;AAEA,IAAA,MAAM,aAAa,CAAC,OAAe,EAAE,OAAkC,EAAA;AACrE,QAAA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;QAEhD,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;AACvC,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC;YACnD;QACF;QAEA,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC;AACzD,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;;AAGjC,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;AACnD,QAAA,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AAEpC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IACtF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Logger } from \"./utils/logger.js\";\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger =\n config.logger || new Logger({ debug: false, prefix: \"[GitManager]\" });\n }\n\n private escapeShellArg(str: string): string {\n return str\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/`/g, \"\\\\`\")\n .replace(/\\$/g, \"\\\\$\");\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(\n `cd \"${this.repositoryPath}\" && git ${command}`,\n );\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(\n `cd \"${this.repositoryPath}\" && ${command}`,\n );\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand(\"rev-parse --git-dir\");\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand(\"branch --show-current\");\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand(\n \"symbolic-ref refs/remotes/origin/HEAD\",\n );\n return remoteBranch.replace(\"refs/remotes/origin/\", \"\");\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists(\"main\")) {\n return \"main\";\n } else if (await this.branchExists(\"master\")) {\n return \"master\";\n } else {\n throw new Error(\n \"Cannot determine default branch. No main or master branch found.\",\n );\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || (await this.getCurrentBranch());\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async resetToDefaultBranchIfNeeded(): Promise<boolean> {\n const currentBranch = await this.getCurrentBranch();\n const defaultBranch = await this.getDefaultBranch();\n\n if (currentBranch === defaultBranch) {\n this.logger.debug(\"Already on default branch\", { branch: defaultBranch });\n return true;\n }\n\n if (await this.hasChanges()) {\n this.logger.warn(\"Skipping branch reset - uncommitted changes present\", {\n currentBranch,\n defaultBranch,\n });\n return false;\n }\n\n await this.switchToBranch(defaultBranch);\n this.logger.info(\"Reset to default branch\", {\n from: currentBranch,\n to: defaultBranch,\n });\n return true;\n }\n\n async createOrSwitchToBranch(\n branchName: string,\n baseBranch?: string,\n ): Promise<void> {\n await this.ensureCleanWorkingDirectory(\"switching branches\");\n\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map((p) => `\"${this.escapeShellArg(p)}\"`).join(\" \");\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n try {\n // Use -A flag to add all changes (including new files) and ignore errors if directory is empty\n await this.runGitCommand(\"add -A .posthog/\");\n } catch (error) {\n // If the directory doesn't exist or has no files, that's fine - just log and continue\n this.logger.debug(\"No PostHog files to add\", { error });\n }\n }\n\n async commitChanges(\n message: string,\n options?: {\n authorName?: string;\n authorEmail?: string;\n },\n ): Promise<string> {\n const command = this.buildCommitCommand(message, options);\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand(\"status --porcelain\");\n if (!status || status.trim().length === 0) {\n return false;\n }\n\n const lines = status.split(\"\\n\").filter((line) => {\n const trimmed = line.trim();\n return trimmed.length > 0 && !trimmed.includes(\".posthog/\");\n });\n\n return lines.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand(\"diff --cached --name-only\");\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n // Helper: Centralized safety check for uncommitted changes\n private async ensureCleanWorkingDirectory(operation: string): Promise<void> {\n if (await this.hasChanges()) {\n throw new Error(\n `Uncommitted changes detected. Please commit or stash changes before ${operation}.`,\n );\n }\n }\n\n private async generateUniqueBranchName(baseName: string): Promise<string> {\n if (!(await this.branchExists(baseName))) {\n return baseName;\n }\n\n let counter = 1;\n let uniqueName = `${baseName}-${counter}`;\n while (await this.branchExists(uniqueName)) {\n counter++;\n uniqueName = `${baseName}-${counter}`;\n }\n return uniqueName;\n }\n\n private async ensureOnDefaultBranch(): Promise<string> {\n const defaultBranch = await this.getDefaultBranch();\n const currentBranch = await this.getCurrentBranch();\n\n if (currentBranch !== defaultBranch) {\n await this.ensureCleanWorkingDirectory(\"switching to default branch\");\n await this.switchToBranch(defaultBranch);\n }\n\n return defaultBranch;\n }\n\n private buildCommitCommand(\n message: string,\n options?: {\n allowEmpty?: boolean;\n authorName?: string;\n authorEmail?: string;\n },\n ): string {\n let command = `commit -m \"${this.escapeShellArg(message)}\"`;\n\n if (options?.allowEmpty) {\n command += \" --allow-empty\";\n }\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return command;\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand(\"remote get-url origin\");\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? \"--force\" : \"\";\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n /**\n * Tracks whether commits were made during an operation by comparing HEAD SHA\n * before and after. Returns an object with methods to finalize the operation.\n *\n * Usage:\n * const tracker = await gitManager.trackCommitsDuring();\n * // ... do work that might create commits ...\n * const result = await tracker.finalize({ commitMessage: 'fallback message', push: true });\n */\n async trackCommitsDuring(): Promise<{\n finalize: (options: {\n commitMessage: string;\n push?: boolean;\n }) => Promise<{ commitCreated: boolean; pushedBranch: boolean }>;\n }> {\n const initialSha = await this.getCommitSha(\"HEAD\");\n\n return {\n finalize: async (options) => {\n const currentSha = await this.getCommitSha(\"HEAD\");\n const externalCommitsCreated = initialSha !== currentSha;\n const hasUncommittedChanges = await this.hasChanges();\n\n // If no commits and no changes, nothing to do\n if (!externalCommitsCreated && !hasUncommittedChanges) {\n return { commitCreated: false, pushedBranch: false };\n }\n\n let commitCreated = externalCommitsCreated;\n\n // Commit any remaining uncommitted changes\n if (hasUncommittedChanges) {\n await this.runGitCommand(\"add .\");\n const hasStagedChanges = await this.hasStagedChanges();\n\n if (hasStagedChanges) {\n await this.commitChanges(options.commitMessage);\n commitCreated = true;\n }\n }\n\n // Push if requested and commits were made\n let pushedBranch = false;\n if (options.push && commitCreated) {\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n pushedBranch = true;\n this.logger.info(\"Pushed branch after operation\", {\n branch: currentBranch,\n });\n }\n\n return { commitCreated, pushedBranch };\n },\n };\n }\n\n async createTaskBranch(taskSlug: string): Promise<string> {\n const branchName = `posthog/task-${taskSlug}`;\n\n // Ensure we're on default branch before creating task branch\n const defaultBranch = await this.ensureOnDefaultBranch();\n\n this.logger.info(\"Creating task branch from default branch\", {\n branchName,\n taskSlug,\n baseBranch: defaultBranch,\n });\n\n await this.createOrSwitchToBranch(branchName, defaultBranch);\n\n return branchName;\n }\n\n async createTaskPlanningBranch(\n taskId: string,\n baseBranch?: string,\n ): Promise<string> {\n const baseName = `posthog/task-${taskId}-planning`;\n const branchName = await this.generateUniqueBranchName(baseName);\n\n this.logger.debug(\"Creating unique planning branch\", {\n branchName,\n taskId,\n });\n\n const base = baseBranch || (await this.ensureOnDefaultBranch());\n await this.createBranch(branchName, base);\n\n return branchName;\n }\n\n async createTaskImplementationBranch(\n taskId: string,\n planningBranchName?: string,\n ): Promise<string> {\n const baseName = `posthog/task-${taskId}-implementation`;\n const branchName = await this.generateUniqueBranchName(baseName);\n\n this.logger.debug(\"Creating unique implementation branch\", {\n branchName,\n taskId,\n currentBranch: await this.getCurrentBranch(),\n });\n\n // Determine base branch: explicit param > current planning branch > default\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes(\"-planning\")) {\n baseBranch = currentBranch;\n this.logger.debug(\"Using current planning branch\", { baseBranch });\n } else {\n baseBranch = await this.ensureOnDefaultBranch();\n this.logger.debug(\"Using default branch\", { baseBranch });\n }\n }\n\n this.logger.debug(\"Creating implementation branch from base\", {\n baseBranch,\n branchName,\n });\n await this.createBranch(branchName, baseBranch);\n\n this.logger.info(\"Implementation branch created\", {\n branchName,\n currentBranch: await this.getCurrentBranch(),\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug(\"Committing plan\", { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug(\"Checking for staged changes\", { hasChanges });\n\n if (!hasChanges) {\n this.logger.info(\"No plan changes to commit\", { taskId });\n return \"No changes to commit\";\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info(\"Plan committed\", { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(\n taskId: string,\n taskTitle: string,\n planSummary?: string,\n ): Promise<string> {\n await this.runGitCommand(\"add .\");\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn(\"No implementation changes to commit\", { taskId });\n return \"No changes to commit\";\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info(\"Implementation committed\", { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(\n branchName: string,\n force: boolean = false,\n ): Promise<void> {\n const forceFlag = force ? \"-D\" : \"-d\";\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch,\n };\n }\n\n async getCommitSha(ref: string = \"HEAD\"): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = \"HEAD\"): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string,\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.ensureCleanWorkingDirectory(\"creating PR\");\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${this.escapeShellArg(title)}\" --body \"${this.escapeShellArg(body)}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n\n async getTaskBranch(taskSlug: string): Promise<string | null> {\n try {\n // Get all branches matching the task slug pattern\n const branches = await this.runGitCommand(\"branch --list --all\");\n const branchPattern = `posthog/task-${taskSlug}`;\n\n // Look for exact match or with counter suffix\n const lines = branches\n .split(\"\\n\")\n .map((l) => l.trim().replace(/^\\*\\s+/, \"\"));\n for (const line of lines) {\n const cleanBranch = line.replace(\"remotes/origin/\", \"\");\n if (cleanBranch.startsWith(branchPattern)) {\n return cleanBranch;\n }\n }\n\n return null;\n } catch (error) {\n this.logger.debug(\"Failed to get task branch\", { taskSlug, error });\n return null;\n }\n }\n\n async commitAndPush(\n message: string,\n options?: { allowEmpty?: boolean },\n ): Promise<void> {\n const hasChanges = await this.hasStagedChanges();\n\n if (!hasChanges && !options?.allowEmpty) {\n this.logger.debug(\"No changes to commit, skipping\");\n return;\n }\n\n const command = this.buildCommitCommand(message, options);\n await this.runGitCommand(command);\n\n // Push to origin\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n\n this.logger.info(\"Committed and pushed changes\", {\n branch: currentBranch,\n message,\n });\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;AACrC,QAAA,IAAI,CAAC,MAAM;AACT,YAAA,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACzE;AAEQ,IAAA,cAAc,CAAC,GAAW,EAAA;AAChC,QAAA,OAAO;AACJ,aAAA,OAAO,CAAC,KAAK,EAAE,MAAM;AACrB,aAAA,OAAO,CAAC,IAAI,EAAE,KAAK;AACnB,aAAA,OAAO,CAAC,IAAI,EAAE,KAAK;AACnB,aAAA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;IAC1B;IAEQ,MAAM,aAAa,CAAC,OAAe,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAChC,CAAA,IAAA,EAAO,IAAI,CAAC,cAAc,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAChD;AACD,YAAA,OAAO,MAAM,CAAC,IAAI,EAAE;QACtB;QAAE,OAAO,KAAK,EAAE;YACd,MAAM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AE,CAAC;AACnE,YAAA,OAAO,IAAI;QACb;IACF;AAEA,IAAA,MAAM,aAAa,CACjB,OAAe,EACf,OAAkC,EAAA;AAElC,QAAA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;QAEhD,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;AACvC,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC;YACnD;QACF;QAEA,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC;AACzD,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;;AAGjC,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;AACnD,QAAA,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AAEpC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE;AAC/C,YAAA,MAAM,EAAE,aAAa;YACrB,OAAO;AACR,SAAA,CAAC;IACJ;AACD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LogEntry, PostHogAPIConfig, PostHogResource, Task, TaskArtifactUploadPayload, TaskRun, TaskRunArtifact, UrlMention } from "./types.js";
|
|
2
2
|
export interface TaskRunUpdate {
|
|
3
3
|
status?: TaskRun["status"];
|
|
4
4
|
branch?: string | null;
|
|
@@ -9,7 +9,6 @@ export interface TaskRunUpdate {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class PostHogAPIClient {
|
|
11
11
|
private config;
|
|
12
|
-
private _teamId;
|
|
13
12
|
constructor(config: PostHogAPIConfig);
|
|
14
13
|
private get baseUrl();
|
|
15
14
|
private get headers();
|
|
@@ -27,7 +26,7 @@ export declare class PostHogAPIClient {
|
|
|
27
26
|
updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
|
|
28
27
|
listTaskRuns(taskId: string): Promise<TaskRun[]>;
|
|
29
28
|
getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
|
|
30
|
-
createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun,
|
|
29
|
+
createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun, "id" | "task" | "team" | "created_at" | "updated_at" | "completed_at">>): Promise<TaskRun>;
|
|
31
30
|
updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
|
|
32
31
|
setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun>;
|
|
33
32
|
appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,yBAAyB,EACzB,OAAO,EACP,eAAe,EACf,UAAU,EACX,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAmB;gBAErB,MAAM,EAAE,gBAAgB;IAIpC,O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