@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.
Files changed (118) hide show
  1. package/CLAUDE.md +3 -3
  2. package/README.md +3 -3
  3. package/dist/index.d.ts +11 -11
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -3
  6. package/dist/src/adapters/claude/claude-adapter.d.ts +3 -3
  7. package/dist/src/adapters/claude/claude-adapter.d.ts.map +1 -1
  8. package/dist/src/adapters/claude/claude-adapter.js +156 -111
  9. package/dist/src/adapters/claude/claude-adapter.js.map +1 -1
  10. package/dist/src/adapters/claude/tool-mapper.d.ts +1 -1
  11. package/dist/src/adapters/claude/tool-mapper.d.ts.map +1 -1
  12. package/dist/src/adapters/claude/tool-mapper.js.map +1 -1
  13. package/dist/src/adapters/types.d.ts +1 -1
  14. package/dist/src/adapters/types.d.ts.map +1 -1
  15. package/dist/src/agent.d.ts +7 -7
  16. package/dist/src/agent.d.ts.map +1 -1
  17. package/dist/src/agent.js +143 -85
  18. package/dist/src/agent.js.map +1 -1
  19. package/dist/src/agents/execution.js.map +1 -1
  20. package/dist/src/agents/planning.js.map +1 -1
  21. package/dist/src/agents/research.js.map +1 -1
  22. package/dist/src/file-manager.d.ts +4 -4
  23. package/dist/src/file-manager.d.ts.map +1 -1
  24. package/dist/src/file-manager.js +59 -58
  25. package/dist/src/file-manager.js.map +1 -1
  26. package/dist/src/git-manager.d.ts +1 -1
  27. package/dist/src/git-manager.d.ts.map +1 -1
  28. package/dist/src/git-manager.js +93 -69
  29. package/dist/src/git-manager.js.map +1 -1
  30. package/dist/src/posthog-api.d.ts +2 -3
  31. package/dist/src/posthog-api.d.ts.map +1 -1
  32. package/dist/src/posthog-api.js +22 -22
  33. package/dist/src/posthog-api.js.map +1 -1
  34. package/dist/src/prompt-builder.d.ts +3 -3
  35. package/dist/src/prompt-builder.d.ts.map +1 -1
  36. package/dist/src/prompt-builder.js +123 -93
  37. package/dist/src/prompt-builder.js.map +1 -1
  38. package/dist/src/task-manager.d.ts +4 -4
  39. package/dist/src/task-manager.d.ts.map +1 -1
  40. package/dist/src/task-manager.js +19 -18
  41. package/dist/src/task-manager.js.map +1 -1
  42. package/dist/src/task-progress-reporter.d.ts +3 -4
  43. package/dist/src/task-progress-reporter.d.ts.map +1 -1
  44. package/dist/src/task-progress-reporter.js +59 -54
  45. package/dist/src/task-progress-reporter.js.map +1 -1
  46. package/dist/src/template-manager.d.ts +1 -1
  47. package/dist/src/template-manager.d.ts.map +1 -1
  48. package/dist/src/template-manager.js +30 -28
  49. package/dist/src/template-manager.js.map +1 -1
  50. package/dist/src/todo-manager.d.ts +3 -3
  51. package/dist/src/todo-manager.d.ts.map +1 -1
  52. package/dist/src/todo-manager.js +29 -24
  53. package/dist/src/todo-manager.js.map +1 -1
  54. package/dist/src/tools/registry.d.ts +1 -1
  55. package/dist/src/tools/registry.js +60 -60
  56. package/dist/src/tools/registry.js.map +1 -1
  57. package/dist/src/tools/types.d.ts +31 -31
  58. package/dist/src/types.d.ts +33 -33
  59. package/dist/src/types.d.ts.map +1 -1
  60. package/dist/src/types.js.map +1 -1
  61. package/dist/src/utils/logger.d.ts +4 -4
  62. package/dist/src/utils/logger.d.ts.map +1 -1
  63. package/dist/src/utils/logger.js +8 -8
  64. package/dist/src/utils/logger.js.map +1 -1
  65. package/dist/src/workflow/config.d.ts +1 -1
  66. package/dist/src/workflow/config.d.ts.map +1 -1
  67. package/dist/src/workflow/config.js +18 -18
  68. package/dist/src/workflow/config.js.map +1 -1
  69. package/dist/src/workflow/steps/build.d.ts +1 -1
  70. package/dist/src/workflow/steps/build.d.ts.map +1 -1
  71. package/dist/src/workflow/steps/build.js +46 -38
  72. package/dist/src/workflow/steps/build.js.map +1 -1
  73. package/dist/src/workflow/steps/finalize.d.ts +1 -1
  74. package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
  75. package/dist/src/workflow/steps/finalize.js +54 -48
  76. package/dist/src/workflow/steps/finalize.js.map +1 -1
  77. package/dist/src/workflow/steps/plan.d.ts +1 -1
  78. package/dist/src/workflow/steps/plan.d.ts.map +1 -1
  79. package/dist/src/workflow/steps/plan.js +58 -46
  80. package/dist/src/workflow/steps/plan.js.map +1 -1
  81. package/dist/src/workflow/steps/research.d.ts +1 -1
  82. package/dist/src/workflow/steps/research.d.ts.map +1 -1
  83. package/dist/src/workflow/steps/research.js +68 -56
  84. package/dist/src/workflow/steps/research.js.map +1 -1
  85. package/dist/src/workflow/types.d.ts +12 -12
  86. package/dist/src/workflow/types.d.ts.map +1 -1
  87. package/dist/src/workflow/utils.d.ts +1 -1
  88. package/dist/src/workflow/utils.d.ts.map +1 -1
  89. package/dist/src/workflow/utils.js +7 -4
  90. package/dist/src/workflow/utils.js.map +1 -1
  91. package/package.json +8 -8
  92. package/src/adapters/claude/claude-adapter.ts +220 -168
  93. package/src/adapters/claude/tool-mapper.ts +2 -2
  94. package/src/adapters/types.ts +1 -1
  95. package/src/agent.ts +579 -444
  96. package/src/agents/execution.ts +1 -1
  97. package/src/agents/planning.ts +1 -1
  98. package/src/agents/research.ts +0 -1
  99. package/src/file-manager.ts +64 -63
  100. package/src/git-manager.ts +152 -87
  101. package/src/posthog-api.ts +122 -82
  102. package/src/prompt-builder.ts +180 -135
  103. package/src/task-manager.ts +38 -30
  104. package/src/task-progress-reporter.ts +70 -59
  105. package/src/template-manager.ts +98 -45
  106. package/src/todo-manager.ts +35 -30
  107. package/src/tools/registry.ts +62 -62
  108. package/src/tools/types.ts +36 -36
  109. package/src/types.ts +93 -71
  110. package/src/utils/logger.ts +62 -56
  111. package/src/workflow/config.ts +48 -48
  112. package/src/workflow/steps/build.ts +122 -113
  113. package/src/workflow/steps/finalize.ts +214 -182
  114. package/src/workflow/steps/plan.ts +151 -131
  115. package/src/workflow/steps/research.ts +205 -186
  116. package/src/workflow/types.ts +38 -36
  117. package/src/workflow/utils.ts +37 -34
  118. package/LICENSE +0 -33
@@ -1 +1 @@
1
- {"version":3,"file":"template-manager.d.ts","sourceRoot":"","sources":["../../src/template-manager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAS;;YA+Cf,YAAY;IAS1B,OAAO,CAAC,mBAAmB;IAerB,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ3D,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQvF,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACrE,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,KAAK,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;KAAE,CAAC,CAAC;IA2CxG,qBAAqB,IAAI,MAAM;CAmChC"}
1
+ {"version":3,"file":"template-manager.d.ts","sourceRoot":"","sources":["../../src/template-manager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAS;;YA+Ef,YAAY;IAW1B,OAAO,CAAC,mBAAmB;IAkBrB,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ3D,kBAAkB,CACtB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC,MAAM,CAAC;IAQZ,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,KAAK,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC,CAAC;KACJ,GACA,OAAO,CACR,KAAK,CAAC;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;KACnD,CAAC,CACH;IA8CD,qBAAqB,IAAI,MAAM;CAmChC"}
@@ -1,6 +1,6 @@
1
- import { existsSync, promises } from 'fs';
2
- import { dirname, join } from 'path';
3
- import { fileURLToPath } from 'url';
1
+ import { existsSync, promises } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
4
 
5
5
  class TemplateManager {
6
6
  templatesDir;
@@ -10,38 +10,40 @@ class TemplateManager {
10
10
  // Exhaustive list of possible template locations
11
11
  const candidateDirs = [
12
12
  // Standard build output (dist/src/template-manager.js -> dist/templates)
13
- join(__dirname, '..', 'templates'),
13
+ join(__dirname, "..", "templates"),
14
14
  // If preserveModules creates nested structure (dist/src/template-manager.js -> dist/src/templates)
15
- join(__dirname, 'templates'),
15
+ join(__dirname, "templates"),
16
16
  // Development scenarios (src/template-manager.ts -> src/templates)
17
- join(__dirname, '..', '..', 'src', 'templates'),
17
+ join(__dirname, "..", "..", "src", "templates"),
18
18
  // Package root templates directory
19
- join(__dirname, '..', '..', 'templates'),
19
+ join(__dirname, "..", "..", "templates"),
20
20
  // When node_modules symlink or installed (node_modules/@posthog/agent/dist/src/... -> node_modules/@posthog/agent/dist/templates)
21
- join(__dirname, '..', '..', 'dist', 'templates'),
21
+ join(__dirname, "..", "..", "dist", "templates"),
22
22
  // When consumed from node_modules deep in tree
23
- join(__dirname, '..', '..', '..', 'templates'),
24
- join(__dirname, '..', '..', '..', 'dist', 'templates'),
25
- join(__dirname, '..', '..', '..', 'src', 'templates'),
23
+ join(__dirname, "..", "..", "..", "templates"),
24
+ join(__dirname, "..", "..", "..", "dist", "templates"),
25
+ join(__dirname, "..", "..", "..", "src", "templates"),
26
26
  // When bundled by Vite/Webpack (e.g., .vite/build/index.js -> node_modules/@posthog/agent/dist/templates)
27
27
  // Try to find node_modules from current location
28
- join(__dirname, '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
29
- join(__dirname, '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
30
- join(__dirname, '..', '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
28
+ join(__dirname, "..", "node_modules", "@posthog", "agent", "dist", "templates"),
29
+ join(__dirname, "..", "..", "node_modules", "@posthog", "agent", "dist", "templates"),
30
+ join(__dirname, "..", "..", "..", "node_modules", "@posthog", "agent", "dist", "templates"),
31
31
  ];
32
32
  const resolvedDir = candidateDirs.find((dir) => existsSync(dir));
33
33
  if (!resolvedDir) {
34
- console.error('[TemplateManager] Could not find templates directory.');
35
- console.error('[TemplateManager] Current file:', __filename);
36
- console.error('[TemplateManager] Current dir:', __dirname);
37
- console.error('[TemplateManager] Tried:', candidateDirs.map(d => `\n - ${d} (exists: ${existsSync(d)})`).join(''));
34
+ console.error("[TemplateManager] Could not find templates directory.");
35
+ console.error("[TemplateManager] Current file:", __filename);
36
+ console.error("[TemplateManager] Current dir:", __dirname);
37
+ console.error("[TemplateManager] Tried:", candidateDirs
38
+ .map((d) => `\n - ${d} (exists: ${existsSync(d)})`)
39
+ .join(""));
38
40
  }
39
41
  this.templatesDir = resolvedDir ?? candidateDirs[0];
40
42
  }
41
43
  async loadTemplate(templateName) {
42
44
  try {
43
45
  const templatePath = join(this.templatesDir, templateName);
44
- return await promises.readFile(templatePath, 'utf8');
46
+ return await promises.readFile(templatePath, "utf8");
45
47
  }
46
48
  catch (error) {
47
49
  throw new Error(`Failed to load template ${templateName} from ${this.templatesDir}: ${error}`);
@@ -51,25 +53,25 @@ class TemplateManager {
51
53
  let result = template;
52
54
  for (const [key, value] of Object.entries(variables)) {
53
55
  if (value !== undefined) {
54
- const placeholder = new RegExp(`{{${key}}}`, 'g');
56
+ const placeholder = new RegExp(`{{${key}}}`, "g");
55
57
  result = result.replace(placeholder, value);
56
58
  }
57
59
  }
58
- result = result.replace(/{{[^}]+}}/g, '[PLACEHOLDER]');
60
+ result = result.replace(/{{[^}]+}}/g, "[PLACEHOLDER]");
59
61
  return result;
60
62
  }
61
63
  async generatePlan(variables) {
62
- const template = await this.loadTemplate('plan-template.md');
64
+ const template = await this.loadTemplate("plan-template.md");
63
65
  return this.substituteVariables(template, {
64
66
  ...variables,
65
- date: variables.date || new Date().toISOString().split('T')[0]
67
+ date: variables.date || new Date().toISOString().split("T")[0],
66
68
  });
67
69
  }
68
70
  async generateCustomFile(templateName, variables) {
69
71
  const template = await this.loadTemplate(templateName);
70
72
  return this.substituteVariables(template, {
71
73
  ...variables,
72
- date: variables.date || new Date().toISOString().split('T')[0]
74
+ date: variables.date || new Date().toISOString().split("T")[0],
73
75
  });
74
76
  }
75
77
  async createTaskStructure(taskId, taskTitle, options) {
@@ -77,15 +79,15 @@ class TemplateManager {
77
79
  const variables = {
78
80
  task_id: taskId,
79
81
  task_title: taskTitle,
80
- date: new Date().toISOString().split('T')[0]
82
+ date: new Date().toISOString().split("T")[0],
81
83
  };
82
84
  // Generate plan file if requested
83
85
  if (options?.includePlan !== false) {
84
86
  const planContent = await this.generatePlan(variables);
85
87
  files.push({
86
- name: 'plan.md',
88
+ name: "plan.md",
87
89
  content: planContent,
88
- type: 'plan'
90
+ type: "plan",
89
91
  });
90
92
  }
91
93
  if (options?.additionalFiles) {
@@ -103,7 +105,7 @@ class TemplateManager {
103
105
  files.push({
104
106
  name: file.name,
105
107
  content,
106
- type: file.name.includes('context') ? 'context' : 'reference'
108
+ type: file.name.includes("context") ? "context" : "reference",
107
109
  });
108
110
  }
109
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"template-manager.js","sources":["../../src/template-manager.ts"],"sourcesContent":["import { promises as fs, existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\n\nexport interface TemplateVariables {\n task_id: string;\n task_title: string;\n task_description?: string;\n date: string;\n repository?: string;\n [key: string]: string | undefined;\n}\n\nexport class TemplateManager {\n private templatesDir: string;\n\n constructor() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n\n // Exhaustive list of possible template locations\n const candidateDirs = [\n // Standard build output (dist/src/template-manager.js -> dist/templates)\n join(__dirname, '..', 'templates'),\n\n // If preserveModules creates nested structure (dist/src/template-manager.js -> dist/src/templates)\n join(__dirname, 'templates'),\n\n // Development scenarios (src/template-manager.ts -> src/templates)\n join(__dirname, '..', '..', 'src', 'templates'),\n\n // Package root templates directory\n join(__dirname, '..', '..', 'templates'),\n\n // When node_modules symlink or installed (node_modules/@posthog/agent/dist/src/... -> node_modules/@posthog/agent/dist/templates)\n join(__dirname, '..', '..', 'dist', 'templates'),\n\n // When consumed from node_modules deep in tree\n join(__dirname, '..', '..', '..', 'templates'),\n join(__dirname, '..', '..', '..', 'dist', 'templates'),\n join(__dirname, '..', '..', '..', 'src', 'templates'),\n\n // When bundled by Vite/Webpack (e.g., .vite/build/index.js -> node_modules/@posthog/agent/dist/templates)\n // Try to find node_modules from current location\n join(__dirname, '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),\n join(__dirname, '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),\n join(__dirname, '..', '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),\n ];\n\n const resolvedDir = candidateDirs.find((dir) => existsSync(dir));\n\n if (!resolvedDir) {\n console.error('[TemplateManager] Could not find templates directory.');\n console.error('[TemplateManager] Current file:', __filename);\n console.error('[TemplateManager] Current dir:', __dirname);\n console.error('[TemplateManager] Tried:', candidateDirs.map(d => `\\n - ${d} (exists: ${existsSync(d)})`).join(''));\n }\n\n this.templatesDir = resolvedDir ?? candidateDirs[0];\n }\n\n private async loadTemplate(templateName: string): Promise<string> {\n try {\n const templatePath = join(this.templatesDir, templateName);\n return await fs.readFile(templatePath, 'utf8');\n } catch (error) {\n throw new Error(`Failed to load template ${templateName} from ${this.templatesDir}: ${error}`);\n }\n }\n\n private substituteVariables(template: string, variables: TemplateVariables): string {\n let result = template;\n \n for (const [key, value] of Object.entries(variables)) {\n if (value !== undefined) {\n const placeholder = new RegExp(`{{${key}}}`, 'g');\n result = result.replace(placeholder, value);\n }\n }\n \n result = result.replace(/{{[^}]+}}/g, '[PLACEHOLDER]');\n \n return result;\n }\n\n async generatePlan(variables: TemplateVariables): Promise<string> {\n const template = await this.loadTemplate('plan-template.md');\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split('T')[0]\n });\n }\n\n async generateCustomFile(templateName: string, variables: TemplateVariables): Promise<string> {\n const template = await this.loadTemplate(templateName);\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split('T')[0]\n });\n }\n\n async createTaskStructure(taskId: string, taskTitle: string, options?: {\n includePlan?: boolean;\n additionalFiles?: Array<{\n name: string;\n template?: string;\n content?: string;\n }>;\n }): Promise<Array<{ name: string; content: string; type: 'plan' | 'context' | 'reference' | 'output' }>> {\n const files: Array<{ name: string; content: string; type: 'plan' | 'context' | 'reference' | 'output' }> = [];\n \n const variables: TemplateVariables = {\n task_id: taskId,\n task_title: taskTitle,\n date: new Date().toISOString().split('T')[0]\n };\n\n // Generate plan file if requested\n if (options?.includePlan !== false) {\n const planContent = await this.generatePlan(variables);\n files.push({\n name: 'plan.md',\n content: planContent,\n type: 'plan'\n });\n }\n\n\n if (options?.additionalFiles) {\n for (const file of options.additionalFiles) {\n let content: string;\n \n if (file.template) {\n content = await this.generateCustomFile(file.template, variables);\n } else if (file.content) {\n content = this.substituteVariables(file.content, variables);\n } else {\n content = `# ${file.name}\\n\\nPlaceholder content for ${file.name}`;\n }\n\n files.push({\n name: file.name,\n content,\n type: file.name.includes('context') ? 'context' : 'reference'\n });\n }\n }\n\n return files;\n }\n\n generatePostHogReadme(): string {\n return `# PostHog Task Files\n\nThis directory contains task-related files generated by the PostHog Agent.\n\n## Structure\n\nEach task has its own subdirectory: \\`.posthog/{task-id}/\\`\n\n### Common Files\n\n- **plan.md** - Implementation plan generated during planning phase\n- **Supporting files** - Any additional files added for task context\n- **artifacts/** - Generated files, outputs, and temporary artifacts\n\n### Usage\n\nThese files are:\n- Version controlled alongside your code\n- Used by the PostHog Agent for context\n- Available for review in pull requests\n- Organized by task ID for easy reference\n\n### Gitignore\n\nCustomize \\`.posthog/.gitignore\\` to control which files are committed:\n- Include plans and documentation by default\n- Exclude temporary files and sensitive data\n- Customize based on your team's needs\n\n---\n\n*Generated by PostHog Agent*\n`;\n }\n}\n"],"names":["fs"],"mappings":";;;;MAaa,eAAe,CAAA;AAClB,IAAA,YAAY;AAEpB,IAAA,WAAA,GAAA;QACE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;A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,CAAC,IAAI,CAAC;AACT,gBAAA,IAAI,EAAE,SAAS;AACf,gBAAA,OAAO,EAAE,WAAW;AACpB,gBAAA,IAAI,EAAE;AACP,aAAA,CAAC;QACJ;AAGA,QAAA,IAAI,OAAO,EAAE,eAAe,EAAE;AAC5B,YAAA,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE;AAC1C,gBAAA,IAAI,OAAe;AAEnB,gBAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,oBAAA,OAAO,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;gBACnE;AAAO,qBAAA,IAAI,IAAI,CAAC,OAAO,EAAE;oBACvB,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;gBAC7D;qBAAO;oBACL,OAAO,GAAG,CAAA,EAAA,EAAK,IAAI,CAAC,IAAI,+BAA+B,IAAI,CAAC,IAAI,CAAA,CAAE;gBACpE;gBAEA,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO;AACP,oBAAA,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG;AACnD,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,KAAK;IACd;IAEA,qBAAqB,GAAA;QACnB,OAAO,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCV;IACC;AACD;;;;"}
1
+ {"version":3,"file":"template-manager.js","sources":["../../src/template-manager.ts"],"sourcesContent":["import { existsSync, promises as fs } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface TemplateVariables {\n task_id: string;\n task_title: string;\n task_description?: string;\n date: string;\n repository?: string;\n [key: string]: string | undefined;\n}\n\nexport class TemplateManager {\n private templatesDir: string;\n\n constructor() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n\n // Exhaustive list of possible template locations\n const candidateDirs = [\n // Standard build output (dist/src/template-manager.js -> dist/templates)\n join(__dirname, \"..\", \"templates\"),\n\n // If preserveModules creates nested structure (dist/src/template-manager.js -> dist/src/templates)\n join(__dirname, \"templates\"),\n\n // Development scenarios (src/template-manager.ts -> src/templates)\n join(__dirname, \"..\", \"..\", \"src\", \"templates\"),\n\n // Package root templates directory\n join(__dirname, \"..\", \"..\", \"templates\"),\n\n // When node_modules symlink or installed (node_modules/@posthog/agent/dist/src/... -> node_modules/@posthog/agent/dist/templates)\n join(__dirname, \"..\", \"..\", \"dist\", \"templates\"),\n\n // When consumed from node_modules deep in tree\n join(__dirname, \"..\", \"..\", \"..\", \"templates\"),\n join(__dirname, \"..\", \"..\", \"..\", \"dist\", \"templates\"),\n join(__dirname, \"..\", \"..\", \"..\", \"src\", \"templates\"),\n\n // When bundled by Vite/Webpack (e.g., .vite/build/index.js -> node_modules/@posthog/agent/dist/templates)\n // Try to find node_modules from current location\n join(\n __dirname,\n \"..\",\n \"node_modules\",\n \"@posthog\",\n \"agent\",\n \"dist\",\n \"templates\",\n ),\n join(\n __dirname,\n \"..\",\n \"..\",\n \"node_modules\",\n \"@posthog\",\n \"agent\",\n \"dist\",\n \"templates\",\n ),\n join(\n __dirname,\n \"..\",\n \"..\",\n \"..\",\n \"node_modules\",\n \"@posthog\",\n \"agent\",\n \"dist\",\n \"templates\",\n ),\n ];\n\n const resolvedDir = candidateDirs.find((dir) => existsSync(dir));\n\n if (!resolvedDir) {\n console.error(\"[TemplateManager] Could not find templates directory.\");\n console.error(\"[TemplateManager] Current file:\", __filename);\n console.error(\"[TemplateManager] Current dir:\", __dirname);\n console.error(\n \"[TemplateManager] Tried:\",\n candidateDirs\n .map((d) => `\\n - ${d} (exists: ${existsSync(d)})`)\n .join(\"\"),\n );\n }\n\n this.templatesDir = resolvedDir ?? candidateDirs[0];\n }\n\n private async loadTemplate(templateName: string): Promise<string> {\n try {\n const templatePath = join(this.templatesDir, templateName);\n return await fs.readFile(templatePath, \"utf8\");\n } catch (error) {\n throw new Error(\n `Failed to load template ${templateName} from ${this.templatesDir}: ${error}`,\n );\n }\n }\n\n private substituteVariables(\n template: string,\n variables: TemplateVariables,\n ): string {\n let result = template;\n\n for (const [key, value] of Object.entries(variables)) {\n if (value !== undefined) {\n const placeholder = new RegExp(`{{${key}}}`, \"g\");\n result = result.replace(placeholder, value);\n }\n }\n\n result = result.replace(/{{[^}]+}}/g, \"[PLACEHOLDER]\");\n\n return result;\n }\n\n async generatePlan(variables: TemplateVariables): Promise<string> {\n const template = await this.loadTemplate(\"plan-template.md\");\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split(\"T\")[0],\n });\n }\n\n async generateCustomFile(\n templateName: string,\n variables: TemplateVariables,\n ): Promise<string> {\n const template = await this.loadTemplate(templateName);\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split(\"T\")[0],\n });\n }\n\n async createTaskStructure(\n taskId: string,\n taskTitle: string,\n options?: {\n includePlan?: boolean;\n additionalFiles?: Array<{\n name: string;\n template?: string;\n content?: string;\n }>;\n },\n ): Promise<\n Array<{\n name: string;\n content: string;\n type: \"plan\" | \"context\" | \"reference\" | \"output\";\n }>\n > {\n const files: Array<{\n name: string;\n content: string;\n type: \"plan\" | \"context\" | \"reference\" | \"output\";\n }> = [];\n\n const variables: TemplateVariables = {\n task_id: taskId,\n task_title: taskTitle,\n date: new Date().toISOString().split(\"T\")[0],\n };\n\n // Generate plan file if requested\n if (options?.includePlan !== false) {\n const planContent = await this.generatePlan(variables);\n files.push({\n name: \"plan.md\",\n content: planContent,\n type: \"plan\",\n });\n }\n\n if (options?.additionalFiles) {\n for (const file of options.additionalFiles) {\n let content: string;\n\n if (file.template) {\n content = await this.generateCustomFile(file.template, variables);\n } else if (file.content) {\n content = this.substituteVariables(file.content, variables);\n } else {\n content = `# ${file.name}\\n\\nPlaceholder content for ${file.name}`;\n }\n\n files.push({\n name: file.name,\n content,\n type: file.name.includes(\"context\") ? \"context\" : \"reference\",\n });\n }\n }\n\n return files;\n }\n\n generatePostHogReadme(): string {\n return `# PostHog Task Files\n\nThis directory contains task-related files generated by the PostHog Agent.\n\n## Structure\n\nEach task has its own subdirectory: \\`.posthog/{task-id}/\\`\n\n### Common Files\n\n- **plan.md** - Implementation plan generated during planning phase\n- **Supporting files** - Any additional files added for task context\n- **artifacts/** - Generated files, outputs, and temporary artifacts\n\n### Usage\n\nThese files are:\n- Version controlled alongside your code\n- Used by the PostHog Agent for context\n- Available for review in pull requests\n- Organized by task ID for easy reference\n\n### Gitignore\n\nCustomize \\`.posthog/.gitignore\\` to control which files are committed:\n- Include plans and documentation by default\n- Exclude temporary files and sensitive data\n- Customize based on your team's needs\n\n---\n\n*Generated by PostHog Agent*\n`;\n }\n}\n"],"names":["fs"],"mappings":";;;;MAaa,eAAe,CAAA;AAClB,IAAA,YAAY;AAEpB,IAAA,WAAA,GAAA;QACE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;;AAGrC,QAAA,MAAM,aAAa,GAAG;;AAEpB,YAAA,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC;;AAGlC,YAAA,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;;YAG5B,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC;;YAG/C,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC;;YAGxC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC;;YAGhD,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC;AAC9C,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C;gBAC7D;qBAAO;oBACL,OAAO,GAAG,CAAA,EAAA,EAAK,IAAI,CAAC,IAAI,+BAA+B,IAAI,CAAC,IAAI,CAAA,CAAE;gBACpE;gBAEA,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO;AACP,oBAAA,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,WAAW;AAC9D,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,KAAK;IACd;IAEA,qBAAqB,GAAA;QACnB,OAAO,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCV;IACC;AACD;;;;"}
@@ -1,8 +1,8 @@
1
- import type { PostHogFileManager } from './file-manager.js';
2
- import { Logger } from './utils/logger.js';
1
+ import type { PostHogFileManager } from "./file-manager.js";
2
+ import { Logger } from "./utils/logger.js";
3
3
  export interface TodoItem {
4
4
  content: string;
5
- status: 'pending' | 'in_progress' | 'completed';
5
+ status: "pending" | "in_progress" | "completed";
6
6
  activeForm: string;
7
7
  }
8
8
  export interface TodoList {
@@ -1 +1 @@
1
- {"version":3,"file":"todo-manager.d.ts","sourceRoot":"","sources":["../../src/todo-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;Q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H;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,WAAW,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM;IAMtD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IA0BnD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBhE,mBAAmB,CAAC,SAAS,EAAE,GAAG,GAAG,QAAQ;IAkB7C,OAAO,CAAC,iBAAiB;IAenB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2B/C,0BAA0B,CAC9B,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAgC5B"}
@@ -5,16 +5,17 @@ class TodoManager {
5
5
  logger;
6
6
  constructor(fileManager, logger) {
7
7
  this.fileManager = fileManager;
8
- this.logger = logger || new Logger({ debug: false, prefix: '[TodoManager]' });
8
+ this.logger =
9
+ logger || new Logger({ debug: false, prefix: "[TodoManager]" });
9
10
  }
10
11
  async readTodos(taskId) {
11
12
  try {
12
- const content = await this.fileManager.readTaskFile(taskId, 'todos.json');
13
+ const content = await this.fileManager.readTaskFile(taskId, "todos.json");
13
14
  if (!content) {
14
15
  return null;
15
16
  }
16
17
  const parsed = JSON.parse(content);
17
- this.logger.debug('Loaded todos', {
18
+ this.logger.debug("Loaded todos", {
18
19
  taskId,
19
20
  total: parsed.metadata.total,
20
21
  pending: parsed.metadata.pending,
@@ -24,7 +25,7 @@ class TodoManager {
24
25
  return parsed;
25
26
  }
26
27
  catch (error) {
27
- this.logger.debug('Failed to read todos.json', {
28
+ this.logger.debug("Failed to read todos.json", {
28
29
  taskId,
29
30
  error: error instanceof Error ? error.message : String(error),
30
31
  });
@@ -32,7 +33,7 @@ class TodoManager {
32
33
  }
33
34
  }
34
35
  async writeTodos(taskId, todos) {
35
- this.logger.debug('Writing todos', {
36
+ this.logger.debug("Writing todos", {
36
37
  taskId,
37
38
  total: todos.metadata.total,
38
39
  pending: todos.metadata.pending,
@@ -40,11 +41,11 @@ class TodoManager {
40
41
  completed: todos.metadata.completed,
41
42
  });
42
43
  await this.fileManager.writeTaskFile(taskId, {
43
- name: 'todos.json',
44
+ name: "todos.json",
44
45
  content: JSON.stringify(todos, null, 2),
45
- type: 'artifact',
46
+ type: "artifact",
46
47
  });
47
- this.logger.info('Todos saved', {
48
+ this.logger.info("Todos saved", {
48
49
  taskId,
49
50
  total: todos.metadata.total,
50
51
  completed: todos.metadata.completed,
@@ -55,9 +56,9 @@ class TodoManager {
55
56
  if (toolInput.todos && Array.isArray(toolInput.todos)) {
56
57
  for (const todo of toolInput.todos) {
57
58
  items.push({
58
- content: todo.content || '',
59
- status: todo.status || 'pending',
60
- activeForm: todo.activeForm || todo.content || '',
59
+ content: todo.content || "",
60
+ status: todo.status || "pending",
61
+ activeForm: todo.activeForm || todo.content || "",
61
62
  });
62
63
  }
63
64
  }
@@ -66,9 +67,9 @@ class TodoManager {
66
67
  }
67
68
  calculateMetadata(items) {
68
69
  const total = items.length;
69
- const pending = items.filter((t) => t.status === 'pending').length;
70
- const in_progress = items.filter((t) => t.status === 'in_progress').length;
71
- const completed = items.filter((t) => t.status === 'completed').length;
70
+ const pending = items.filter((t) => t.status === "pending").length;
71
+ const in_progress = items.filter((t) => t.status === "in_progress").length;
72
+ const completed = items.filter((t) => t.status === "completed").length;
72
73
  return {
73
74
  total,
74
75
  pending,
@@ -80,29 +81,33 @@ class TodoManager {
80
81
  async getTodoContext(taskId) {
81
82
  const todos = await this.readTodos(taskId);
82
83
  if (!todos || todos.items.length === 0) {
83
- return '';
84
+ return "";
84
85
  }
85
- const lines = ['## Previous Todo List\n'];
86
- lines.push('You previously created the following todo list:\n');
86
+ const lines = ["## Previous Todo List\n"];
87
+ lines.push("You previously created the following todo list:\n");
87
88
  for (const item of todos.items) {
88
- const statusIcon = item.status === 'completed' ? '✓' : item.status === 'in_progress' ? '▶' : '○';
89
+ const statusIcon = item.status === "completed"
90
+ ? "✓"
91
+ : item.status === "in_progress"
92
+ ? "▶"
93
+ : "○";
89
94
  lines.push(`${statusIcon} [${item.status}] ${item.content}`);
90
95
  }
91
96
  lines.push(`\nProgress: ${todos.metadata.completed}/${todos.metadata.total} completed\n`);
92
- return lines.join('\n');
97
+ return lines.join("\n");
93
98
  }
94
99
  // check for TodoWrite tool call and persist if found
95
100
  async checkAndPersistFromMessage(message, taskId) {
96
- if (message.type !== 'assistant' || !message.message?.content) {
101
+ if (message.type !== "assistant" || !message.message?.content) {
97
102
  return null;
98
103
  }
99
104
  for (const block of message.message.content) {
100
- if (block.type === 'tool_use' && block.name === 'TodoWrite') {
105
+ if (block.type === "tool_use" && block.name === "TodoWrite") {
101
106
  try {
102
- this.logger.info('TodoWrite detected, persisting todos', { taskId });
107
+ this.logger.info("TodoWrite detected, persisting todos", { taskId });
103
108
  const todoList = this.parseTodoWriteInput(block.input);
104
109
  await this.writeTodos(taskId, todoList);
105
- this.logger.info('Persisted todos successfully', {
110
+ this.logger.info("Persisted todos successfully", {
106
111
  taskId,
107
112
  total: todoList.metadata.total,
108
113
  completed: todoList.metadata.completed,
@@ -110,7 +115,7 @@ class TodoManager {
110
115
  return todoList;
111
116
  }
112
117
  catch (error) {
113
- this.logger.error('Failed to persist todos', {
118
+ this.logger.error("Failed to persist todos", {
114
119
  taskId,
115
120
  error: error instanceof Error ? error.message : String(error),
116
121
  });
@@ -1 +1 @@
1
- {"version":3,"file":"todo-manager.js","sources":["../../src/todo-manager.ts"],"sourcesContent":["import type { PostHogFileManager } from './file-manager.js';\nimport { Logger } from './utils/logger.js';\n\nexport interface TodoItem {\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n activeForm: string;\n}\n\nexport interface TodoList {\n items: TodoItem[];\n metadata: {\n total: number;\n pending: number;\n in_progress: number;\n completed: number;\n last_updated: string;\n };\n}\n\nexport class TodoManager {\n private fileManager: PostHogFileManager;\n private logger: Logger;\n\n constructor(fileManager: PostHogFileManager, logger?: Logger) {\n this.fileManager = fileManager;\n this.logger = logger || new Logger({ debug: false, prefix: '[TodoManager]' });\n }\n\n async readTodos(taskId: string): Promise<TodoList | null> {\n try {\n const content = await this.fileManager.readTaskFile(taskId, 'todos.json');\n if (!content) {\n return null;\n }\n\n const parsed = JSON.parse(content) as TodoList;\n this.logger.debug('Loaded todos', {\n taskId,\n total: parsed.metadata.total,\n pending: parsed.metadata.pending,\n in_progress: parsed.metadata.in_progress,\n completed: parsed.metadata.completed,\n });\n\n return parsed;\n } catch (error) {\n this.logger.debug('Failed to read todos.json', {\n taskId,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n }\n\n async writeTodos(taskId: string, todos: TodoList): Promise<void> {\n this.logger.debug('Writing todos', {\n taskId,\n total: todos.metadata.total,\n pending: todos.metadata.pending,\n in_progress: todos.metadata.in_progress,\n completed: todos.metadata.completed,\n });\n\n await this.fileManager.writeTaskFile(taskId, {\n name: 'todos.json',\n content: JSON.stringify(todos, null, 2),\n type: 'artifact',\n });\n\n this.logger.info('Todos saved', {\n taskId,\n total: todos.metadata.total,\n completed: todos.metadata.completed,\n });\n }\n\n parseTodoWriteInput(toolInput: any): TodoList {\n const items: TodoItem[] = [];\n\n if (toolInput.todos && Array.isArray(toolInput.todos)) {\n for (const todo of toolInput.todos) {\n items.push({\n content: todo.content || '',\n status: todo.status || 'pending',\n activeForm: todo.activeForm || todo.content || '',\n });\n }\n }\n\n const metadata = this.calculateMetadata(items);\n\n return { items, metadata };\n }\n\n private calculateMetadata(items: TodoItem[]): TodoList['metadata'] {\n const total = items.length;\n const pending = items.filter((t) => t.status === 'pending').length;\n const in_progress = items.filter((t) => t.status === 'in_progress').length;\n const completed = items.filter((t) => t.status === 'completed').length;\n\n return {\n total,\n pending,\n in_progress,\n completed,\n last_updated: new Date().toISOString(),\n };\n }\n\n async getTodoContext(taskId: string): Promise<string> {\n const todos = await this.readTodos(taskId);\n if (!todos || todos.items.length === 0) {\n return '';\n }\n\n const lines: string[] = ['## Previous Todo List\\n'];\n lines.push('You previously created the following todo list:\\n');\n\n for (const item of todos.items) {\n const statusIcon =\n item.status === 'completed' ? '✓' : item.status === 'in_progress' ? '▶' : '○';\n lines.push(`${statusIcon} [${item.status}] ${item.content}`);\n }\n\n lines.push(\n `\\nProgress: ${todos.metadata.completed}/${todos.metadata.total} completed\\n`\n );\n\n return lines.join('\\n');\n }\n\n // check for TodoWrite tool call and persist if found\n async checkAndPersistFromMessage(\n message: any,\n taskId: string\n ): Promise<TodoList | null> {\n if (message.type !== 'assistant' || !message.message?.content) {\n return null;\n }\n\n for (const block of message.message.content) {\n if (block.type === 'tool_use' && block.name === 'TodoWrite') {\n try {\n this.logger.info('TodoWrite detected, persisting todos', { taskId });\n\n const todoList = this.parseTodoWriteInput(block.input);\n await this.writeTodos(taskId, todoList);\n\n this.logger.info('Persisted todos successfully', {\n taskId,\n total: todoList.metadata.total,\n completed: todoList.metadata.completed,\n });\n\n return todoList;\n } catch (error) {\n this.logger.error('Failed to persist todos', {\n taskId,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n }\n }\n\n return null;\n }\n}\n"],"names":[],"mappings":";;MAoBa,WAAW,CAAA;AACd,IAAA,WAAW;AACX,IAAA,MAAM;IAEd,WAAA,CAAY,WAA+B,EAAE,MAAe,EAAA;AAC1D,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAC/E;IAEA,MAAM,SAAS,CAAC,MAAc,EAAA;AAC5B,QAAA,IAAI;AACF,YAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,C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AO,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7D,YAAA,OAAO,IAAI;QACb;QAEA,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;AAC3C,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;AAC3D,gBAAA,IAAI;oBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,MAAM,EAAE,CAAC;oBAEpE,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC;oBACtD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;AAEvC,oBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE;wBAC/C,MAAM;AACN,wBAAA,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK;AAC9B,wBAAA,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS;AACvC,qBAAA,CAAC;AAEF,oBAAA,OAAO,QAAQ;gBACjB;gBAAE,OAAO,KAAK,EAAE;AACd,oBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;wBAC3C,MAAM;AACN,wBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,qBAAA,CAAC;AACF,oBAAA,OAAO,IAAI;gBACb;YACF;QACF;AAEA,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
1
+ {"version":3,"file":"todo-manager.js","sources":["../../src/todo-manager.ts"],"sourcesContent":["import type { PostHogFileManager } from \"./file-manager.js\";\nimport { Logger } from \"./utils/logger.js\";\n\nexport interface TodoItem {\n content: string;\n status: \"pending\" | \"in_progress\" | \"completed\";\n activeForm: string;\n}\n\nexport interface TodoList {\n items: TodoItem[];\n metadata: {\n total: number;\n pending: number;\n in_progress: number;\n completed: number;\n last_updated: string;\n };\n}\n\nexport class TodoManager {\n private fileManager: PostHogFileManager;\n private logger: Logger;\n\n constructor(fileManager: PostHogFileManager, logger?: Logger) {\n this.fileManager = fileManager;\n this.logger =\n logger || new Logger({ debug: false, prefix: \"[TodoManager]\" });\n }\n\n async readTodos(taskId: string): Promise<TodoList | null> {\n try {\n const content = await this.fileManager.readTaskFile(taskId, \"todos.json\");\n if (!content) {\n return null;\n }\n\n const parsed = JSON.parse(content) as TodoList;\n this.logger.debug(\"Loaded todos\", {\n taskId,\n total: parsed.metadata.total,\n pending: parsed.metadata.pending,\n in_progress: parsed.metadata.in_progress,\n completed: parsed.metadata.completed,\n });\n\n return parsed;\n } catch (error) {\n this.logger.debug(\"Failed to read todos.json\", {\n taskId,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n }\n\n async writeTodos(taskId: string, todos: TodoList): Promise<void> {\n this.logger.debug(\"Writing todos\", {\n taskId,\n total: todos.metadata.total,\n pending: todos.metadata.pending,\n in_progress: todos.metadata.in_progress,\n completed: todos.metadata.completed,\n });\n\n await this.fileManager.writeTaskFile(taskId, {\n name: \"todos.json\",\n content: JSON.stringify(todos, null, 2),\n type: \"artifact\",\n });\n\n this.logger.info(\"Todos saved\", {\n taskId,\n total: todos.metadata.total,\n completed: todos.metadata.completed,\n });\n }\n\n parseTodoWriteInput(toolInput: any): TodoList {\n const items: TodoItem[] = [];\n\n if (toolInput.todos && Array.isArray(toolInput.todos)) {\n for (const todo of toolInput.todos) {\n items.push({\n content: todo.content || \"\",\n status: todo.status || \"pending\",\n activeForm: todo.activeForm || todo.content || \"\",\n });\n }\n }\n\n const metadata = this.calculateMetadata(items);\n\n return { items, metadata };\n }\n\n private calculateMetadata(items: TodoItem[]): TodoList[\"metadata\"] {\n const total = items.length;\n const pending = items.filter((t) => t.status === \"pending\").length;\n const in_progress = items.filter((t) => t.status === \"in_progress\").length;\n const completed = items.filter((t) => t.status === \"completed\").length;\n\n return {\n total,\n pending,\n in_progress,\n completed,\n last_updated: new Date().toISOString(),\n };\n }\n\n async getTodoContext(taskId: string): Promise<string> {\n const todos = await this.readTodos(taskId);\n if (!todos || todos.items.length === 0) {\n return \"\";\n }\n\n const lines: string[] = [\"## Previous Todo List\\n\"];\n lines.push(\"You previously created the following todo list:\\n\");\n\n for (const item of todos.items) {\n const statusIcon =\n item.status === \"completed\"\n ? \"✓\"\n : item.status === \"in_progress\"\n ? \"▶\"\n : \"○\";\n lines.push(`${statusIcon} [${item.status}] ${item.content}`);\n }\n\n lines.push(\n `\\nProgress: ${todos.metadata.completed}/${todos.metadata.total} completed\\n`,\n );\n\n return lines.join(\"\\n\");\n }\n\n // check for TodoWrite tool call and persist if found\n async checkAndPersistFromMessage(\n message: any,\n taskId: string,\n ): Promise<TodoList | null> {\n if (message.type !== \"assistant\" || !message.message?.content) {\n return null;\n }\n\n for (const block of message.message.content) {\n if (block.type === \"tool_use\" && block.name === \"TodoWrite\") {\n try {\n this.logger.info(\"TodoWrite detected, persisting todos\", { taskId });\n\n const todoList = this.parseTodoWriteInput(block.input);\n await this.writeTodos(taskId, todoList);\n\n this.logger.info(\"Persisted todos successfully\", {\n taskId,\n total: todoList.metadata.total,\n completed: todoList.metadata.completed,\n });\n\n return todoList;\n } catch (error) {\n this.logger.error(\"Failed to persist todos\", {\n taskId,\n error: error instanceof Error ? error.message : String(error),\n });\n return null;\n }\n }\n }\n\n return null;\n }\n}\n"],"names":[],"mappings":";;MAoBa,WAAW,CAAA;AACd,IAAA,WAAW;AACX,IAAA,MAAM;IAEd,WAAA,CAAY,WAA+B,EAAE,MAAe,EAAA;AAC1D,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,MAAM;AACT,YAAA,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACnE;IAEA,MAAM,SAAS,CAAC,M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,CAC9B,OAAY,EACZ,MAAc,EAAA;AAEd,QAAA,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7D,YAAA,OAAO,IAAI;QACb;QAEA,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;AAC3C,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;AAC3D,gBAAA,IAAI;oBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,MAAM,EAAE,CAAC;oBAEpE,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC;oBACtD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;AAEvC,oBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE;wBAC/C,MAAM;AACN,wBAAA,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK;AAC9B,wBAAA,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS;AACvC,qBAAA,CAAC;AAEF,oBAAA,OAAO,QAAQ;gBACjB;gBAAE,OAAO,KAAK,EAAE;AACd,oBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;wBAC3C,MAAM;AACN,wBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,qBAAA,CAAC;AACF,oBAAA,OAAO,IAAI;gBACb;YACF;QACF;AAEA,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
@@ -1,4 +1,4 @@
1
- import type { Tool } from './types.js';
1
+ import type { Tool } from "./types.js";
2
2
  /**
3
3
  * Tool registry for looking up tool definitions by name.
4
4
  * Provides metadata about tools for UI consumption.
@@ -4,84 +4,84 @@
4
4
  */
5
5
  const TOOL_DEFINITIONS = {
6
6
  // Filesystem tools
7
- 'Read': {
8
- name: 'Read',
9
- category: 'filesystem',
10
- description: 'Read file contents from the filesystem',
7
+ Read: {
8
+ name: "Read",
9
+ category: "filesystem",
10
+ description: "Read file contents from the filesystem",
11
11
  },
12
- 'Write': {
13
- name: 'Write',
14
- category: 'filesystem',
15
- description: 'Write content to a file',
12
+ Write: {
13
+ name: "Write",
14
+ category: "filesystem",
15
+ description: "Write content to a file",
16
16
  },
17
- 'Edit': {
18
- name: 'Edit',
19
- category: 'filesystem',
20
- description: 'Edit file with find and replace operations',
17
+ Edit: {
18
+ name: "Edit",
19
+ category: "filesystem",
20
+ description: "Edit file with find and replace operations",
21
21
  },
22
- 'Glob': {
23
- name: 'Glob',
24
- category: 'filesystem',
25
- description: 'Find files matching a pattern',
22
+ Glob: {
23
+ name: "Glob",
24
+ category: "filesystem",
25
+ description: "Find files matching a pattern",
26
26
  },
27
- 'NotebookEdit': {
28
- name: 'NotebookEdit',
29
- category: 'filesystem',
30
- description: 'Edit Jupyter notebook cells',
27
+ NotebookEdit: {
28
+ name: "NotebookEdit",
29
+ category: "filesystem",
30
+ description: "Edit Jupyter notebook cells",
31
31
  },
32
32
  // Shell tools
33
- 'Bash': {
34
- name: 'Bash',
35
- category: 'shell',
36
- description: 'Execute bash commands',
33
+ Bash: {
34
+ name: "Bash",
35
+ category: "shell",
36
+ description: "Execute bash commands",
37
37
  },
38
- 'BashOutput': {
39
- name: 'BashOutput',
40
- category: 'shell',
41
- description: 'Read output from a background bash process',
38
+ BashOutput: {
39
+ name: "BashOutput",
40
+ category: "shell",
41
+ description: "Read output from a background bash process",
42
42
  },
43
- 'KillShell': {
44
- name: 'KillShell',
45
- category: 'shell',
46
- description: 'Terminate a background bash process',
43
+ KillShell: {
44
+ name: "KillShell",
45
+ category: "shell",
46
+ description: "Terminate a background bash process",
47
47
  },
48
48
  // Web tools
49
- 'WebFetch': {
50
- name: 'WebFetch',
51
- category: 'web',
52
- description: 'Fetch content from a URL',
49
+ WebFetch: {
50
+ name: "WebFetch",
51
+ category: "web",
52
+ description: "Fetch content from a URL",
53
53
  },
54
- 'WebSearch': {
55
- name: 'WebSearch',
56
- category: 'web',
57
- description: 'Search the web',
54
+ WebSearch: {
55
+ name: "WebSearch",
56
+ category: "web",
57
+ description: "Search the web",
58
58
  },
59
59
  // Search tools
60
- 'Grep': {
61
- name: 'Grep',
62
- category: 'search',
63
- description: 'Search file contents using patterns',
60
+ Grep: {
61
+ name: "Grep",
62
+ category: "search",
63
+ description: "Search file contents using patterns",
64
64
  },
65
65
  // Assistant tools
66
- 'Task': {
67
- name: 'Task',
68
- category: 'assistant',
69
- description: 'Launch a specialized agent for a sub-task',
66
+ Task: {
67
+ name: "Task",
68
+ category: "assistant",
69
+ description: "Launch a specialized agent for a sub-task",
70
70
  },
71
- 'TodoWrite': {
72
- name: 'TodoWrite',
73
- category: 'assistant',
74
- description: 'Manage task list and track progress',
71
+ TodoWrite: {
72
+ name: "TodoWrite",
73
+ category: "assistant",
74
+ description: "Manage task list and track progress",
75
75
  },
76
- 'ExitPlanMode': {
77
- name: 'ExitPlanMode',
78
- category: 'assistant',
79
- description: 'Exit plan mode and present plan to user',
76
+ ExitPlanMode: {
77
+ name: "ExitPlanMode",
78
+ category: "assistant",
79
+ description: "Exit plan mode and present plan to user",
80
80
  },
81
- 'SlashCommand': {
82
- name: 'SlashCommand',
83
- category: 'assistant',
84
- description: 'Execute a slash command',
81
+ SlashCommand: {
82
+ name: "SlashCommand",
83
+ category: "assistant",
84
+ description: "Execute a slash command",
85
85
  },
86
86
  };
87
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sources":["../../../src/tools/registry.ts"],"sourcesContent":["import type { Tool } from './types.js';\n\n/**\n * Registry of all known tools with their metadata.\n * Maps tool names to their definitions.\n */\nconst TOOL_DEFINITIONS: Record<string, Tool> = {\n // Filesystem tools\n 'Read': {\n name: 'Read',\n category: 'filesystem',\n description: 'Read file contents from the filesystem',\n },\n 'Write': {\n name: 'Write',\n category: 'filesystem',\n description: 'Write content to a file',\n },\n 'Edit': {\n name: 'Edit',\n category: 'filesystem',\n description: 'Edit file with find and replace operations',\n },\n 'Glob': {\n name: 'Glob',\n category: 'filesystem',\n description: 'Find files matching a pattern',\n },\n 'NotebookEdit': {\n name: 'NotebookEdit',\n category: 'filesystem',\n description: 'Edit Jupyter notebook cells',\n },\n\n // Shell tools\n 'Bash': {\n name: 'Bash',\n category: 'shell',\n description: 'Execute bash commands',\n },\n 'BashOutput': {\n name: 'BashOutput',\n category: 'shell',\n description: 'Read output from a background bash process',\n },\n 'KillShell': {\n name: 'KillShell',\n category: 'shell',\n description: 'Terminate a background bash process',\n },\n\n // Web tools\n 'WebFetch': {\n name: 'WebFetch',\n category: 'web',\n description: 'Fetch content from a URL',\n },\n 'WebSearch': {\n name: 'WebSearch',\n category: 'web',\n description: 'Search the web',\n },\n\n // Search tools\n 'Grep': {\n name: 'Grep',\n category: 'search',\n description: 'Search file contents using patterns',\n },\n\n // Assistant tools\n 'Task': {\n name: 'Task',\n category: 'assistant',\n description: 'Launch a specialized agent for a sub-task',\n },\n 'TodoWrite': {\n name: 'TodoWrite',\n category: 'assistant',\n description: 'Manage task list and track progress',\n },\n 'ExitPlanMode': {\n name: 'ExitPlanMode',\n category: 'assistant',\n description: 'Exit plan mode and present plan to user',\n },\n 'SlashCommand': {\n name: 'SlashCommand',\n category: 'assistant',\n description: 'Execute a slash command',\n },\n};\n\n/**\n * Tool registry for looking up tool definitions by name.\n * Provides metadata about tools for UI consumption.\n */\nexport class ToolRegistry {\n /**\n * Get tool definition by name.\n * Returns undefined if tool is not recognized.\n */\n get(name: string): Tool | undefined {\n return TOOL_DEFINITIONS[name];\n }\n\n /**\n * Get all registered tools.\n */\n getAll(): Tool[] {\n return Object.values(TOOL_DEFINITIONS);\n }\n\n /**\n * Check if a tool name is registered.\n */\n has(name: string): boolean {\n return name in TOOL_DEFINITIONS;\n }\n\n /**\n * Get all tools in a specific category.\n */\n getByCategory(category: string): Tool[] {\n return Object.values(TOOL_DEFINITIONS).filter(\n (tool) => tool.category === category\n );\n }\n}\n"],"names":[],"mappings":"AAEA;;;AAGG;AACH,MAAM,gBAAgB,GAAyB;;AAE7C,IAAA,MAAM,EAAE;AACN,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,wCAAwC;AACtD,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,yBAAyB;AACvC,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,4CAA4C;AAC1D,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,+BAA+B;AAC7C,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,6BAA6B;AAC3C,KAAA;;AAGD,IAAA,MAAM,EAAE;AACN,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,uBAAuB;AACrC,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,4CAA4C;AAC1D,KAAA;AACD,IAAA,WAAW,EAAE;AACX,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,qCAAqC;AACnD,KAAA;;AAGD,IAAA,UAAU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AAgB,EAAA;QAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAC3C,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,KAAK,QAAQ,CACrC;IACH;AACD;;;;"}
1
+ {"version":3,"file":"registry.js","sources":["../../../src/tools/registry.ts"],"sourcesContent":["import type { Tool } from \"./types.js\";\n\n/**\n * Registry of all known tools with their metadata.\n * Maps tool names to their definitions.\n */\nconst TOOL_DEFINITIONS: Record<string, Tool> = {\n // Filesystem tools\n Read: {\n name: \"Read\",\n category: \"filesystem\",\n description: \"Read file contents from the filesystem\",\n },\n Write: {\n name: \"Write\",\n category: \"filesystem\",\n description: \"Write content to a file\",\n },\n Edit: {\n name: \"Edit\",\n category: \"filesystem\",\n description: \"Edit file with find and replace operations\",\n },\n Glob: {\n name: \"Glob\",\n category: \"filesystem\",\n description: \"Find files matching a pattern\",\n },\n NotebookEdit: {\n name: \"NotebookEdit\",\n category: \"filesystem\",\n description: \"Edit Jupyter notebook cells\",\n },\n\n // Shell tools\n Bash: {\n name: \"Bash\",\n category: \"shell\",\n description: \"Execute bash commands\",\n },\n BashOutput: {\n name: \"BashOutput\",\n category: \"shell\",\n description: \"Read output from a background bash process\",\n },\n KillShell: {\n name: \"KillShell\",\n category: \"shell\",\n description: \"Terminate a background bash process\",\n },\n\n // Web tools\n WebFetch: {\n name: \"WebFetch\",\n category: \"web\",\n description: \"Fetch content from a URL\",\n },\n WebSearch: {\n name: \"WebSearch\",\n category: \"web\",\n description: \"Search the web\",\n },\n\n // Search tools\n Grep: {\n name: \"Grep\",\n category: \"search\",\n description: \"Search file contents using patterns\",\n },\n\n // Assistant tools\n Task: {\n name: \"Task\",\n category: \"assistant\",\n description: \"Launch a specialized agent for a sub-task\",\n },\n TodoWrite: {\n name: \"TodoWrite\",\n category: \"assistant\",\n description: \"Manage task list and track progress\",\n },\n ExitPlanMode: {\n name: \"ExitPlanMode\",\n category: \"assistant\",\n description: \"Exit plan mode and present plan to user\",\n },\n SlashCommand: {\n name: \"SlashCommand\",\n category: \"assistant\",\n description: \"Execute a slash command\",\n },\n};\n\n/**\n * Tool registry for looking up tool definitions by name.\n * Provides metadata about tools for UI consumption.\n */\nexport class ToolRegistry {\n /**\n * Get tool definition by name.\n * Returns undefined if tool is not recognized.\n */\n get(name: string): Tool | undefined {\n return TOOL_DEFINITIONS[name];\n }\n\n /**\n * Get all registered tools.\n */\n getAll(): Tool[] {\n return Object.values(TOOL_DEFINITIONS);\n }\n\n /**\n * Check if a tool name is registered.\n */\n has(name: string): boolean {\n return name in TOOL_DEFINITIONS;\n }\n\n /**\n * Get all tools in a specific category.\n */\n getByCategory(category: string): Tool[] {\n return Object.values(TOOL_DEFINITIONS).filter(\n (tool) => tool.category === category,\n );\n }\n}\n"],"names":[],"mappings":"AAEA;;;AAGG;AACH,MAAM,gBAAgB,GAAyB;;AAE7C,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,wCAAwC;AACtD,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,yBAAyB;AACvC,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,4CAA4C;AAC1D,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,+BAA+B;AAC7C,KAAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,WAAW,EAAE,6BAA6B;AAC3C,KAAA;;AAGD,IAAA,IAAI,EAAE;AACJ,QAAA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