11import { promises as fs } from "node:fs" ;
22import { join } from "node:path" ;
33import type { TemplateVariables } from "./template-manager.js" ;
4- import type { PostHogResource , Task , UrlMention } from "./types.js" ;
4+ import type {
5+ PostHogResource ,
6+ ResourceType ,
7+ SupportingFile ,
8+ Task ,
9+ UrlMention ,
10+ } from "./types.js" ;
511import { Logger } from "./utils/logger.js" ;
612
713export interface PromptBuilderDeps {
8- getTaskFiles : ( taskId : string ) => Promise < any [ ] > ;
14+ getTaskFiles : ( taskId : string ) => Promise < SupportingFile [ ] > ;
915 generatePlanTemplate : ( vars : TemplateVariables ) => Promise < string > ;
1016 posthogClient ?: {
1117 fetchResourceByUrl : ( mention : UrlMention ) => Promise < PostHogResource > ;
@@ -81,9 +87,9 @@ export class PromptBuilder {
8187 const [ , type , id ] = match ;
8288 mentions . push ( {
8389 url : "" , // Will be reconstructed if needed
84- type : type as any ,
90+ type : type as ResourceType ,
8591 id,
86- label : this . generateUrlLabel ( "" , type as any ) ,
92+ label : this . generateUrlLabel ( "" , type as ResourceType ) ,
8793 } ) ;
8894 match = resourceRegex . exec ( description ) ;
8995 }
@@ -249,8 +255,8 @@ export class PromptBuilder {
249255 prompt += `<title>${ task . title } </title>\n` ;
250256 prompt += `<description>${ processedDescription } </description>\n` ;
251257
252- if ( ( task as any ) . primary_repository ) {
253- prompt += `<repository>${ ( task as any ) . primary_repository } </repository>\n` ;
258+ if ( task . primary_repository ) {
259+ prompt += `<repository>${ task . primary_repository } </repository>\n` ;
254260 }
255261 prompt += "</task>\n" ;
256262
@@ -278,7 +284,7 @@ export class PromptBuilder {
278284 try {
279285 const taskFiles = await this . getTaskFiles ( task . id ) ;
280286 const contextFiles = taskFiles . filter (
281- ( f : any ) => f . type === "context" || f . type === "reference" ,
287+ ( f : SupportingFile ) => f . type === "context" || f . type === "reference" ,
282288 ) ;
283289 if ( contextFiles . length > 0 ) {
284290 prompt += "\n<supporting_files>\n" ;
@@ -312,8 +318,8 @@ export class PromptBuilder {
312318 prompt += `<title>${ task . title } </title>\n` ;
313319 prompt += `<description>${ processedDescription } </description>\n` ;
314320
315- if ( ( task as any ) . primary_repository ) {
316- prompt += `<repository>${ ( task as any ) . primary_repository } </repository>\n` ;
321+ if ( task . primary_repository ) {
322+ prompt += `<repository>${ task . primary_repository } </repository>\n` ;
317323 }
318324 prompt += "</task>\n" ;
319325
@@ -341,7 +347,7 @@ export class PromptBuilder {
341347 try {
342348 const taskFiles = await this . getTaskFiles ( task . id ) ;
343349 const contextFiles = taskFiles . filter (
344- ( f : any ) => f . type === "context" || f . type === "reference" ,
350+ ( f : SupportingFile ) => f . type === "context" || f . type === "reference" ,
345351 ) ;
346352 if ( contextFiles . length > 0 ) {
347353 prompt += "\n<supporting_files>\n" ;
@@ -361,7 +367,7 @@ export class PromptBuilder {
361367 task_title : task . title ,
362368 task_description : processedDescription ,
363369 date : new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] ,
364- repository : ( ( task as any ) . primary_repository || "" ) as string ,
370+ repository : task . primary_repository || "" ,
365371 } ;
366372
367373 const planTemplate = await this . generatePlanTemplate ( templateVariables ) ;
@@ -393,8 +399,8 @@ export class PromptBuilder {
393399 prompt += `<title>${ task . title } </title>\n` ;
394400 prompt += `<description>${ processedDescription } </description>\n` ;
395401
396- if ( ( task as any ) . primary_repository ) {
397- prompt += `<repository>${ ( task as any ) . primary_repository } </repository>\n` ;
402+ if ( task . primary_repository ) {
403+ prompt += `<repository>${ task . primary_repository } </repository>\n` ;
398404 }
399405 prompt += "</task>\n" ;
400406
@@ -421,8 +427,10 @@ export class PromptBuilder {
421427
422428 try {
423429 const taskFiles = await this . getTaskFiles ( task . id ) ;
424- const hasPlan = taskFiles . some ( ( f : any ) => f . type === "plan" ) ;
425- const todosFile = taskFiles . find ( ( f : any ) => f . name === "todos.json" ) ;
430+ const hasPlan = taskFiles . some ( ( f : SupportingFile ) => f . type === "plan" ) ;
431+ const todosFile = taskFiles . find (
432+ ( f : SupportingFile ) => f . name === "todos.json" ,
433+ ) ;
426434
427435 if ( taskFiles . length > 0 ) {
428436 prompt += "\n<context>\n" ;
0 commit comments