@posthog/agent 1.24.0 → 1.24.2

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 (116) hide show
  1. package/LICENSE +33 -0
  2. package/dist/index.d.ts +11 -11
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -3
  5. package/dist/src/adapters/claude/claude-adapter.d.ts +3 -3
  6. package/dist/src/adapters/claude/claude-adapter.d.ts.map +1 -1
  7. package/dist/src/adapters/claude/claude-adapter.js +111 -156
  8. package/dist/src/adapters/claude/claude-adapter.js.map +1 -1
  9. package/dist/src/adapters/claude/tool-mapper.d.ts +1 -1
  10. package/dist/src/adapters/claude/tool-mapper.d.ts.map +1 -1
  11. package/dist/src/adapters/claude/tool-mapper.js.map +1 -1
  12. package/dist/src/adapters/types.d.ts +1 -1
  13. package/dist/src/adapters/types.d.ts.map +1 -1
  14. package/dist/src/agent.d.ts +7 -7
  15. package/dist/src/agent.d.ts.map +1 -1
  16. package/dist/src/agent.js +85 -143
  17. package/dist/src/agent.js.map +1 -1
  18. package/dist/src/agents/execution.js.map +1 -1
  19. package/dist/src/agents/planning.js.map +1 -1
  20. package/dist/src/agents/research.js.map +1 -1
  21. package/dist/src/file-manager.d.ts +4 -4
  22. package/dist/src/file-manager.d.ts.map +1 -1
  23. package/dist/src/file-manager.js +58 -59
  24. package/dist/src/file-manager.js.map +1 -1
  25. package/dist/src/git-manager.d.ts +1 -1
  26. package/dist/src/git-manager.d.ts.map +1 -1
  27. package/dist/src/git-manager.js +70 -87
  28. package/dist/src/git-manager.js.map +1 -1
  29. package/dist/src/posthog-api.d.ts +3 -2
  30. package/dist/src/posthog-api.d.ts.map +1 -1
  31. package/dist/src/posthog-api.js +22 -22
  32. package/dist/src/posthog-api.js.map +1 -1
  33. package/dist/src/prompt-builder.d.ts +3 -3
  34. package/dist/src/prompt-builder.d.ts.map +1 -1
  35. package/dist/src/prompt-builder.js +93 -123
  36. package/dist/src/prompt-builder.js.map +1 -1
  37. package/dist/src/task-manager.d.ts +4 -4
  38. package/dist/src/task-manager.d.ts.map +1 -1
  39. package/dist/src/task-manager.js +18 -19
  40. package/dist/src/task-manager.js.map +1 -1
  41. package/dist/src/task-progress-reporter.d.ts +4 -3
  42. package/dist/src/task-progress-reporter.d.ts.map +1 -1
  43. package/dist/src/task-progress-reporter.js +54 -59
  44. package/dist/src/task-progress-reporter.js.map +1 -1
  45. package/dist/src/template-manager.d.ts +1 -1
  46. package/dist/src/template-manager.d.ts.map +1 -1
  47. package/dist/src/template-manager.js +28 -30
  48. package/dist/src/template-manager.js.map +1 -1
  49. package/dist/src/todo-manager.d.ts +3 -3
  50. package/dist/src/todo-manager.d.ts.map +1 -1
  51. package/dist/src/todo-manager.js +24 -29
  52. package/dist/src/todo-manager.js.map +1 -1
  53. package/dist/src/tools/registry.d.ts +1 -1
  54. package/dist/src/tools/registry.js +60 -60
  55. package/dist/src/tools/registry.js.map +1 -1
  56. package/dist/src/tools/types.d.ts +31 -31
  57. package/dist/src/types.d.ts +33 -33
  58. package/dist/src/types.d.ts.map +1 -1
  59. package/dist/src/types.js.map +1 -1
  60. package/dist/src/utils/logger.d.ts +4 -4
  61. package/dist/src/utils/logger.d.ts.map +1 -1
  62. package/dist/src/utils/logger.js +8 -8
  63. package/dist/src/utils/logger.js.map +1 -1
  64. package/dist/src/workflow/config.d.ts +1 -1
  65. package/dist/src/workflow/config.d.ts.map +1 -1
  66. package/dist/src/workflow/config.js +18 -18
  67. package/dist/src/workflow/config.js.map +1 -1
  68. package/dist/src/workflow/steps/build.d.ts +1 -1
  69. package/dist/src/workflow/steps/build.d.ts.map +1 -1
  70. package/dist/src/workflow/steps/build.js +38 -46
  71. package/dist/src/workflow/steps/build.js.map +1 -1
  72. package/dist/src/workflow/steps/finalize.d.ts +1 -1
  73. package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
  74. package/dist/src/workflow/steps/finalize.js +48 -54
  75. package/dist/src/workflow/steps/finalize.js.map +1 -1
  76. package/dist/src/workflow/steps/plan.d.ts +1 -1
  77. package/dist/src/workflow/steps/plan.d.ts.map +1 -1
  78. package/dist/src/workflow/steps/plan.js +46 -58
  79. package/dist/src/workflow/steps/plan.js.map +1 -1
  80. package/dist/src/workflow/steps/research.d.ts +1 -1
  81. package/dist/src/workflow/steps/research.d.ts.map +1 -1
  82. package/dist/src/workflow/steps/research.js +56 -68
  83. package/dist/src/workflow/steps/research.js.map +1 -1
  84. package/dist/src/workflow/types.d.ts +12 -12
  85. package/dist/src/workflow/types.d.ts.map +1 -1
  86. package/dist/src/workflow/utils.d.ts +1 -1
  87. package/dist/src/workflow/utils.d.ts.map +1 -1
  88. package/dist/src/workflow/utils.js +4 -7
  89. package/dist/src/workflow/utils.js.map +1 -1
  90. package/package.json +6 -6
  91. package/src/adapters/claude/claude-adapter.ts +168 -220
  92. package/src/adapters/claude/tool-mapper.ts +2 -2
  93. package/src/adapters/types.ts +1 -1
  94. package/src/agent.ts +444 -579
  95. package/src/agents/execution.ts +1 -1
  96. package/src/agents/planning.ts +1 -1
  97. package/src/agents/research.ts +1 -0
  98. package/src/file-manager.ts +63 -64
  99. package/src/git-manager.ts +88 -144
  100. package/src/posthog-api.ts +82 -122
  101. package/src/prompt-builder.ts +135 -180
  102. package/src/task-manager.ts +30 -38
  103. package/src/task-progress-reporter.ts +59 -70
  104. package/src/template-manager.ts +45 -98
  105. package/src/todo-manager.ts +30 -35
  106. package/src/tools/registry.ts +62 -62
  107. package/src/tools/types.ts +36 -36
  108. package/src/types.ts +71 -93
  109. package/src/utils/logger.ts +56 -62
  110. package/src/workflow/config.ts +48 -48
  111. package/src/workflow/steps/build.ts +113 -122
  112. package/src/workflow/steps/finalize.ts +182 -214
  113. package/src/workflow/steps/plan.ts +131 -151
  114. package/src/workflow/steps/research.ts +186 -205
  115. package/src/workflow/types.ts +36 -38
  116. package/src/workflow/utils.ts +34 -37
@@ -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+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
+ {"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,6 +1,6 @@
1
- import { existsSync, promises } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
1
+ import { existsSync, promises } from 'fs';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
4
 
5
5
  class TemplateManager {
6
6
  templatesDir;
@@ -10,40 +10,38 @@ 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
38
- .map((d) => `\n - ${d} (exists: ${existsSync(d)})`)
39
- .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.map(d => `\n - ${d} (exists: ${existsSync(d)})`).join(''));
40
38
  }
41
39
  this.templatesDir = resolvedDir ?? candidateDirs[0];
42
40
  }
43
41
  async loadTemplate(templateName) {
44
42
  try {
45
43
  const templatePath = join(this.templatesDir, templateName);
46
- return await promises.readFile(templatePath, "utf8");
44
+ return await promises.readFile(templatePath, 'utf8');
47
45
  }
48
46
  catch (error) {
49
47
  throw new Error(`Failed to load template ${templateName} from ${this.templatesDir}: ${error}`);
@@ -53,25 +51,25 @@ class TemplateManager {
53
51
  let result = template;
54
52
  for (const [key, value] of Object.entries(variables)) {
55
53
  if (value !== undefined) {
56
- const placeholder = new RegExp(`{{${key}}}`, "g");
54
+ const placeholder = new RegExp(`{{${key}}}`, 'g');
57
55
  result = result.replace(placeholder, value);
58
56
  }
59
57
  }
60
- result = result.replace(/{{[^}]+}}/g, "[PLACEHOLDER]");
58
+ result = result.replace(/{{[^}]+}}/g, '[PLACEHOLDER]');
61
59
  return result;
62
60
  }
63
61
  async generatePlan(variables) {
64
- const template = await this.loadTemplate("plan-template.md");
62
+ const template = await this.loadTemplate('plan-template.md');
65
63
  return this.substituteVariables(template, {
66
64
  ...variables,
67
- date: variables.date || new Date().toISOString().split("T")[0],
65
+ date: variables.date || new Date().toISOString().split('T')[0]
68
66
  });
69
67
  }
70
68
  async generateCustomFile(templateName, variables) {
71
69
  const template = await this.loadTemplate(templateName);
72
70
  return this.substituteVariables(template, {
73
71
  ...variables,
74
- date: variables.date || new Date().toISOString().split("T")[0],
72
+ date: variables.date || new Date().toISOString().split('T')[0]
75
73
  });
76
74
  }
77
75
  async createTaskStructure(taskId, taskTitle, options) {
@@ -79,15 +77,15 @@ class TemplateManager {
79
77
  const variables = {
80
78
  task_id: taskId,
81
79
  task_title: taskTitle,
82
- date: new Date().toISOString().split("T")[0],
80
+ date: new Date().toISOString().split('T')[0]
83
81
  };
84
82
  // Generate plan file if requested
85
83
  if (options?.includePlan !== false) {
86
84
  const planContent = await this.generatePlan(variables);
87
85
  files.push({
88
- name: "plan.md",
86
+ name: 'plan.md',
89
87
  content: planContent,
90
- type: "plan",
88
+ type: 'plan'
91
89
  });
92
90
  }
93
91
  if (options?.additionalFiles) {
@@ -105,7 +103,7 @@ class TemplateManager {
105
103
  files.push({
106
104
  name: file.name,
107
105
  content,
108
- type: file.name.includes("context") ? "context" : "reference",
106
+ type: file.name.includes('context') ? 'context' : 'reference'
109
107
  });
110
108
  }
111
109
  }
@@ -1 +1 @@
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,YAAA,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC;AACtD,YAAA,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC;;;AAIrD,YAAA,IAAI,CACF,SAAS,EACT,IAAI,EACJ,cAAc,EACd,UAAU,EACV,OAAO,EACP,MAAM,EACN,WAAW,CACZ;AACD,YAAA,IAAI,CACF,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,UAAU,EACV,OAAO,EACP,MAAM,EACN,WAAW,CACZ;AACD,YAAA,IAAI,CACF,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,IAA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":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;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,YAAA,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI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,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,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;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,E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W,CAAqB;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,WAAW,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM;IAKtD,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;IAuB/C,0BAA0B,CAC9B,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAgC5B"}
@@ -5,17 +5,16 @@ class TodoManager {
5
5
  logger;
6
6
  constructor(fileManager, logger) {
7
7
  this.fileManager = fileManager;
8
- this.logger =
9
- logger || new Logger({ debug: false, prefix: "[TodoManager]" });
8
+ this.logger = logger || new Logger({ debug: false, prefix: '[TodoManager]' });
10
9
  }
11
10
  async readTodos(taskId) {
12
11
  try {
13
- const content = await this.fileManager.readTaskFile(taskId, "todos.json");
12
+ const content = await this.fileManager.readTaskFile(taskId, 'todos.json');
14
13
  if (!content) {
15
14
  return null;
16
15
  }
17
16
  const parsed = JSON.parse(content);
18
- this.logger.debug("Loaded todos", {
17
+ this.logger.debug('Loaded todos', {
19
18
  taskId,
20
19
  total: parsed.metadata.total,
21
20
  pending: parsed.metadata.pending,
@@ -25,7 +24,7 @@ class TodoManager {
25
24
  return parsed;
26
25
  }
27
26
  catch (error) {
28
- this.logger.debug("Failed to read todos.json", {
27
+ this.logger.debug('Failed to read todos.json', {
29
28
  taskId,
30
29
  error: error instanceof Error ? error.message : String(error),
31
30
  });
@@ -33,7 +32,7 @@ class TodoManager {
33
32
  }
34
33
  }
35
34
  async writeTodos(taskId, todos) {
36
- this.logger.debug("Writing todos", {
35
+ this.logger.debug('Writing todos', {
37
36
  taskId,
38
37
  total: todos.metadata.total,
39
38
  pending: todos.metadata.pending,
@@ -41,11 +40,11 @@ class TodoManager {
41
40
  completed: todos.metadata.completed,
42
41
  });
43
42
  await this.fileManager.writeTaskFile(taskId, {
44
- name: "todos.json",
43
+ name: 'todos.json',
45
44
  content: JSON.stringify(todos, null, 2),
46
- type: "artifact",
45
+ type: 'artifact',
47
46
  });
48
- this.logger.info("Todos saved", {
47
+ this.logger.info('Todos saved', {
49
48
  taskId,
50
49
  total: todos.metadata.total,
51
50
  completed: todos.metadata.completed,
@@ -56,9 +55,9 @@ class TodoManager {
56
55
  if (toolInput.todos && Array.isArray(toolInput.todos)) {
57
56
  for (const todo of toolInput.todos) {
58
57
  items.push({
59
- content: todo.content || "",
60
- status: todo.status || "pending",
61
- activeForm: todo.activeForm || todo.content || "",
58
+ content: todo.content || '',
59
+ status: todo.status || 'pending',
60
+ activeForm: todo.activeForm || todo.content || '',
62
61
  });
63
62
  }
64
63
  }
@@ -67,9 +66,9 @@ class TodoManager {
67
66
  }
68
67
  calculateMetadata(items) {
69
68
  const total = items.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;
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;
73
72
  return {
74
73
  total,
75
74
  pending,
@@ -81,33 +80,29 @@ class TodoManager {
81
80
  async getTodoContext(taskId) {
82
81
  const todos = await this.readTodos(taskId);
83
82
  if (!todos || todos.items.length === 0) {
84
- return "";
83
+ return '';
85
84
  }
86
- const lines = ["## Previous Todo List\n"];
87
- lines.push("You previously created the following todo list:\n");
85
+ const lines = ['## Previous Todo List\n'];
86
+ lines.push('You previously created the following todo list:\n');
88
87
  for (const item of todos.items) {
89
- const statusIcon = item.status === "completed"
90
- ? "✓"
91
- : item.status === "in_progress"
92
- ? "▶"
93
- : "○";
88
+ const statusIcon = item.status === 'completed' ? '✓' : item.status === 'in_progress' ? '▶' : '○';
94
89
  lines.push(`${statusIcon} [${item.status}] ${item.content}`);
95
90
  }
96
91
  lines.push(`\nProgress: ${todos.metadata.completed}/${todos.metadata.total} completed\n`);
97
- return lines.join("\n");
92
+ return lines.join('\n');
98
93
  }
99
94
  // check for TodoWrite tool call and persist if found
100
95
  async checkAndPersistFromMessage(message, taskId) {
101
- if (message.type !== "assistant" || !message.message?.content) {
96
+ if (message.type !== 'assistant' || !message.message?.content) {
102
97
  return null;
103
98
  }
104
99
  for (const block of message.message.content) {
105
- if (block.type === "tool_use" && block.name === "TodoWrite") {
100
+ if (block.type === 'tool_use' && block.name === 'TodoWrite') {
106
101
  try {
107
- this.logger.info("TodoWrite detected, persisting todos", { taskId });
102
+ this.logger.info('TodoWrite detected, persisting todos', { taskId });
108
103
  const todoList = this.parseTodoWriteInput(block.input);
109
104
  await this.writeTodos(taskId, todoList);
110
- this.logger.info("Persisted todos successfully", {
105
+ this.logger.info('Persisted todos successfully', {
111
106
  taskId,
112
107
  total: todoList.metadata.total,
113
108
  completed: todoList.metadata.completed,
@@ -115,7 +110,7 @@ class TodoManager {
115
110
  return todoList;
116
111
  }
117
112
  catch (error) {
118
- this.logger.error("Failed to persist todos", {
113
+ this.logger.error('Failed to persist todos', {
119
114
  taskId,
120
115
  error: error instanceof Error ? error.message : String(error),
121
116
  });
@@ -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 =\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,MAAc,EAAA;AAC5B,QAAA,IAAI;AACF,YAAA,MAAM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AAI,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
+ {"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,OA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I,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,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,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,uBAAuB;AACrC,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,4CAA4C;AAC1D,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,QAAQ,EAAE,OAAO;AACjB,QAAA,WAAW,EAAE,qCAAqC;AACnD,KAAA;;AAGD,IAAA,QAAQ,EAAE;AACR,QAAA,I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C5B,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,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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