@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
package/src/agents/execution.ts
CHANGED
package/src/agents/planning.ts
CHANGED
|
@@ -57,4 +57,4 @@ If research findings, context files, or reference materials are provided:
|
|
|
57
57
|
- Follow patterns and approaches identified in research
|
|
58
58
|
- Build upon or refine any existing planning work
|
|
59
59
|
- Reference specific files and components mentioned in context
|
|
60
|
-
</context_integration>`;
|
|
60
|
+
</context_integration>`;
|
package/src/agents/research.ts
CHANGED
|
@@ -158,4 +158,3 @@ Reason: Options request user input instead of being actionable choices. Should b
|
|
|
158
158
|
Reason: "Let me specify" requires user input. Should be "Primary blue (#0066FF, existing theme)" or "Secondary gray (#6B7280, existing theme)"
|
|
159
159
|
</bad_example>
|
|
160
160
|
</question_examples>`;
|
|
161
|
-
|
package/src/file-manager.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { promises as fs } from
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import { Logger } from
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import { extname, join } from "node:path";
|
|
3
|
+
import type { ResearchEvaluation, SupportingFile } from "./types.js";
|
|
4
|
+
import { Logger } from "./utils/logger.js";
|
|
5
5
|
|
|
6
6
|
export interface TaskFile {
|
|
7
7
|
name: string;
|
|
8
8
|
content: string;
|
|
9
|
-
type:
|
|
9
|
+
type: "plan" | "context" | "reference" | "output" | "artifact";
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface LocalArtifact {
|
|
13
13
|
name: string;
|
|
14
14
|
content: string;
|
|
15
|
-
type: TaskFile[
|
|
15
|
+
type: TaskFile["type"];
|
|
16
16
|
contentType: string;
|
|
17
17
|
size: number;
|
|
18
18
|
}
|
|
@@ -23,11 +23,12 @@ export class PostHogFileManager {
|
|
|
23
23
|
|
|
24
24
|
constructor(repositoryPath: string, logger?: Logger) {
|
|
25
25
|
this.repositoryPath = repositoryPath;
|
|
26
|
-
this.logger =
|
|
26
|
+
this.logger =
|
|
27
|
+
logger || new Logger({ debug: false, prefix: "[FileManager]" });
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
private getTaskDirectory(taskId: string): string {
|
|
30
|
-
return join(this.repositoryPath,
|
|
31
|
+
return join(this.repositoryPath, ".posthog", taskId);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
private getTaskFilePath(taskId: string, fileName: string): string {
|
|
@@ -47,23 +48,23 @@ export class PostHogFileManager {
|
|
|
47
48
|
await this.ensureTaskDirectory(taskId);
|
|
48
49
|
const filePath = this.getTaskFilePath(taskId, file.name);
|
|
49
50
|
|
|
50
|
-
this.logger.debug(
|
|
51
|
+
this.logger.debug("Writing task file", {
|
|
51
52
|
filePath,
|
|
52
53
|
contentLength: file.content.length,
|
|
53
|
-
contentType: typeof file.content
|
|
54
|
+
contentType: typeof file.content,
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
await fs.writeFile(filePath, file.content,
|
|
57
|
+
await fs.writeFile(filePath, file.content, "utf8");
|
|
57
58
|
|
|
58
|
-
this.logger.debug(
|
|
59
|
+
this.logger.debug("File written successfully", { filePath });
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
async readTaskFile(taskId: string, fileName: string): Promise<string | null> {
|
|
62
63
|
try {
|
|
63
64
|
const filePath = this.getTaskFilePath(taskId, fileName);
|
|
64
|
-
return await fs.readFile(filePath,
|
|
65
|
+
return await fs.readFile(filePath, "utf8");
|
|
65
66
|
} catch (error) {
|
|
66
|
-
if ((error as NodeJS.ErrnoException).code ===
|
|
67
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
69
70
|
throw error;
|
|
@@ -74,9 +75,9 @@ export class PostHogFileManager {
|
|
|
74
75
|
try {
|
|
75
76
|
const taskDir = this.getTaskDirectory(taskId);
|
|
76
77
|
const files = await fs.readdir(taskDir);
|
|
77
|
-
return files.filter(file => !file.startsWith(
|
|
78
|
+
return files.filter((file) => !file.startsWith("."));
|
|
78
79
|
} catch (error) {
|
|
79
|
-
if ((error as NodeJS.ErrnoException).code ===
|
|
80
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
80
81
|
return [];
|
|
81
82
|
}
|
|
82
83
|
throw error;
|
|
@@ -88,7 +89,7 @@ export class PostHogFileManager {
|
|
|
88
89
|
const filePath = this.getTaskFilePath(taskId, fileName);
|
|
89
90
|
await fs.unlink(filePath);
|
|
90
91
|
} catch (error) {
|
|
91
|
-
if ((error as NodeJS.ErrnoException).code !==
|
|
92
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
92
93
|
throw error;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
@@ -109,7 +110,7 @@ export class PostHogFileManager {
|
|
|
109
110
|
const taskDir = this.getTaskDirectory(taskId);
|
|
110
111
|
await fs.rm(taskDir, { recursive: true, force: true });
|
|
111
112
|
} catch (error) {
|
|
112
|
-
if ((error as NodeJS.ErrnoException).code !==
|
|
113
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
113
114
|
throw error;
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -117,51 +118,51 @@ export class PostHogFileManager {
|
|
|
117
118
|
|
|
118
119
|
// Convenience methods for common file types
|
|
119
120
|
async writePlan(taskId: string, plan: string): Promise<void> {
|
|
120
|
-
this.logger.debug(
|
|
121
|
+
this.logger.debug("Writing plan", {
|
|
121
122
|
taskId,
|
|
122
123
|
planLength: plan.length,
|
|
123
|
-
contentPreview: plan.substring(0, 200)
|
|
124
|
+
contentPreview: plan.substring(0, 200),
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
await this.writeTaskFile(taskId, {
|
|
127
|
-
name:
|
|
128
|
+
name: "plan.md",
|
|
128
129
|
content: plan,
|
|
129
|
-
type:
|
|
130
|
+
type: "plan",
|
|
130
131
|
});
|
|
131
132
|
|
|
132
|
-
this.logger.info(
|
|
133
|
+
this.logger.info("Plan file written", { taskId });
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
async readPlan(taskId: string): Promise<string | null> {
|
|
136
|
-
return await this.readTaskFile(taskId,
|
|
137
|
+
return await this.readTaskFile(taskId, "plan.md");
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
async writeContext(taskId: string, context: string): Promise<void> {
|
|
140
141
|
await this.writeTaskFile(taskId, {
|
|
141
|
-
name:
|
|
142
|
+
name: "context.md",
|
|
142
143
|
content: context,
|
|
143
|
-
type:
|
|
144
|
+
type: "context",
|
|
144
145
|
});
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
async readContext(taskId: string): Promise<string | null> {
|
|
148
|
-
return await this.readTaskFile(taskId,
|
|
149
|
+
return await this.readTaskFile(taskId, "context.md");
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
async writeRequirements(taskId: string, requirements: string): Promise<void> {
|
|
152
153
|
await this.writeTaskFile(taskId, {
|
|
153
|
-
name:
|
|
154
|
+
name: "requirements.md",
|
|
154
155
|
content: requirements,
|
|
155
|
-
type:
|
|
156
|
+
type: "reference",
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
async readRequirements(taskId: string): Promise<string | null> {
|
|
160
|
-
return await this.readTaskFile(taskId,
|
|
161
|
+
return await this.readTaskFile(taskId, "requirements.md");
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
async writeResearch(taskId: string, data: ResearchEvaluation): Promise<void> {
|
|
164
|
-
this.logger.debug(
|
|
165
|
+
this.logger.debug("Writing research", {
|
|
165
166
|
taskId,
|
|
166
167
|
score: data.actionabilityScore,
|
|
167
168
|
hasQuestions: !!data.questions,
|
|
@@ -170,13 +171,13 @@ export class PostHogFileManager {
|
|
|
170
171
|
});
|
|
171
172
|
|
|
172
173
|
await this.writeTaskFile(taskId, {
|
|
173
|
-
name:
|
|
174
|
+
name: "research.json",
|
|
174
175
|
content: JSON.stringify(data, null, 2),
|
|
175
|
-
type:
|
|
176
|
+
type: "artifact",
|
|
176
177
|
});
|
|
177
178
|
|
|
178
|
-
this.logger.info(
|
|
179
|
-
taskId,
|
|
179
|
+
this.logger.info("Research file written", {
|
|
180
|
+
taskId,
|
|
180
181
|
score: data.actionabilityScore,
|
|
181
182
|
hasQuestions: !!data.questions,
|
|
182
183
|
answered: data.answered ?? false,
|
|
@@ -185,28 +186,28 @@ export class PostHogFileManager {
|
|
|
185
186
|
|
|
186
187
|
async readResearch(taskId: string): Promise<ResearchEvaluation | null> {
|
|
187
188
|
try {
|
|
188
|
-
const content = await this.readTaskFile(taskId,
|
|
189
|
-
return content ? JSON.parse(content) as ResearchEvaluation : null;
|
|
189
|
+
const content = await this.readTaskFile(taskId, "research.json");
|
|
190
|
+
return content ? (JSON.parse(content) as ResearchEvaluation) : null;
|
|
190
191
|
} catch (error) {
|
|
191
|
-
this.logger.debug(
|
|
192
|
+
this.logger.debug("Failed to parse research.json", { error });
|
|
192
193
|
return null;
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
async writeTodos(taskId: string, data: any): Promise<void> {
|
|
197
|
-
this.logger.debug(
|
|
198
|
+
this.logger.debug("Writing todos", {
|
|
198
199
|
taskId,
|
|
199
200
|
total: data.metadata?.total ?? 0,
|
|
200
201
|
completed: data.metadata?.completed ?? 0,
|
|
201
202
|
});
|
|
202
203
|
|
|
203
204
|
await this.writeTaskFile(taskId, {
|
|
204
|
-
name:
|
|
205
|
+
name: "todos.json",
|
|
205
206
|
content: JSON.stringify(data, null, 2),
|
|
206
|
-
type:
|
|
207
|
+
type: "artifact",
|
|
207
208
|
});
|
|
208
209
|
|
|
209
|
-
this.logger.info(
|
|
210
|
+
this.logger.info("Todos file written", {
|
|
210
211
|
taskId,
|
|
211
212
|
total: data.metadata?.total ?? 0,
|
|
212
213
|
completed: data.metadata?.completed ?? 0,
|
|
@@ -215,10 +216,10 @@ export class PostHogFileManager {
|
|
|
215
216
|
|
|
216
217
|
async readTodos(taskId: string): Promise<any | null> {
|
|
217
218
|
try {
|
|
218
|
-
const content = await this.readTaskFile(taskId,
|
|
219
|
+
const content = await this.readTaskFile(taskId, "todos.json");
|
|
219
220
|
return content ? JSON.parse(content) : null;
|
|
220
221
|
} catch (error) {
|
|
221
|
-
this.logger.debug(
|
|
222
|
+
this.logger.debug("Failed to parse todos.json", { error });
|
|
222
223
|
return null;
|
|
223
224
|
}
|
|
224
225
|
}
|
|
@@ -226,22 +227,22 @@ export class PostHogFileManager {
|
|
|
226
227
|
async getTaskFiles(taskId: string): Promise<SupportingFile[]> {
|
|
227
228
|
const fileNames = await this.listTaskFiles(taskId);
|
|
228
229
|
const files: SupportingFile[] = [];
|
|
229
|
-
|
|
230
|
+
|
|
230
231
|
for (const fileName of fileNames) {
|
|
231
232
|
const content = await this.readTaskFile(taskId, fileName);
|
|
232
233
|
if (content !== null) {
|
|
233
234
|
// Determine type based on file name
|
|
234
235
|
const type = this.resolveFileType(fileName);
|
|
235
|
-
|
|
236
|
+
|
|
236
237
|
files.push({
|
|
237
238
|
name: fileName,
|
|
238
239
|
content,
|
|
239
240
|
type,
|
|
240
|
-
created_at: new Date().toISOString() // Could be enhanced with file stats
|
|
241
|
+
created_at: new Date().toISOString(), // Could be enhanced with file stats
|
|
241
242
|
});
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
+
|
|
245
246
|
return files;
|
|
246
247
|
}
|
|
247
248
|
|
|
@@ -257,7 +258,7 @@ export class PostHogFileManager {
|
|
|
257
258
|
|
|
258
259
|
const type = this.resolveFileType(fileName);
|
|
259
260
|
const contentType = this.inferContentType(fileName);
|
|
260
|
-
const size = Buffer.byteLength(content,
|
|
261
|
+
const size = Buffer.byteLength(content, "utf8");
|
|
261
262
|
|
|
262
263
|
artifacts.push({
|
|
263
264
|
name: fileName,
|
|
@@ -271,26 +272,26 @@ export class PostHogFileManager {
|
|
|
271
272
|
return artifacts;
|
|
272
273
|
}
|
|
273
274
|
|
|
274
|
-
private resolveFileType(fileName: string): TaskFile[
|
|
275
|
-
if (fileName ===
|
|
276
|
-
if (fileName ===
|
|
277
|
-
if (fileName ===
|
|
278
|
-
if (fileName.startsWith(
|
|
279
|
-
if (fileName.endsWith(
|
|
280
|
-
return
|
|
275
|
+
private resolveFileType(fileName: string): TaskFile["type"] {
|
|
276
|
+
if (fileName === "plan.md") return "plan";
|
|
277
|
+
if (fileName === "context.md") return "context";
|
|
278
|
+
if (fileName === "requirements.md") return "reference";
|
|
279
|
+
if (fileName.startsWith("output_")) return "output";
|
|
280
|
+
if (fileName.endsWith(".md")) return "reference";
|
|
281
|
+
return "artifact";
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
private inferContentType(fileName: string): string {
|
|
284
285
|
const extension = extname(fileName).toLowerCase();
|
|
285
286
|
switch (extension) {
|
|
286
|
-
case
|
|
287
|
-
return
|
|
288
|
-
case
|
|
289
|
-
return
|
|
290
|
-
case
|
|
291
|
-
return
|
|
287
|
+
case ".md":
|
|
288
|
+
return "text/markdown";
|
|
289
|
+
case ".json":
|
|
290
|
+
return "application/json";
|
|
291
|
+
case ".txt":
|
|
292
|
+
return "text/plain";
|
|
292
293
|
default:
|
|
293
|
-
return
|
|
294
|
+
return "text/plain";
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
}
|