|
8 | 8 | "path/filepath" |
9 | 9 | "strings" |
10 | 10 |
|
11 | | - "github.com/1broseidon/promptext/internal/format" |
12 | 11 | "github.com/1broseidon/promptext/internal/initializer" |
13 | 12 | "github.com/1broseidon/promptext/internal/processor" |
14 | 13 | "github.com/1broseidon/promptext/internal/update" |
@@ -398,127 +397,6 @@ func formatTokenCount(tokens int) string { |
398 | 397 | return result.String() |
399 | 398 | } |
400 | 399 |
|
401 | | -// Helper functions to convert between library and internal types |
402 | | -func parseExtensions(extension string) []string { |
403 | | - if extension == "" { |
404 | | - return nil |
405 | | - } |
406 | | - return strings.Split(extension, ",") |
407 | | -} |
408 | | - |
409 | | -func parseExcludes(exclude string) []string { |
410 | | - if exclude == "" { |
411 | | - return nil |
412 | | - } |
413 | | - return strings.Split(exclude, ",") |
414 | | -} |
415 | | - |
416 | | -func toInternalProjectOutput(output *promptext.ProjectOutput) *format.ProjectOutput { |
417 | | - if output == nil { |
418 | | - return nil |
419 | | - } |
420 | | - |
421 | | - internal := &format.ProjectOutput{} |
422 | | - |
423 | | - // Convert DirectoryTree |
424 | | - if output.DirectoryTree != nil { |
425 | | - internal.DirectoryTree = toInternalDirectoryNode(output.DirectoryTree) |
426 | | - } |
427 | | - |
428 | | - // Convert GitInfo |
429 | | - if output.GitInfo != nil { |
430 | | - internal.GitInfo = &format.GitInfo{ |
431 | | - Branch: output.GitInfo.Branch, |
432 | | - CommitHash: output.GitInfo.CommitHash, |
433 | | - CommitMessage: output.GitInfo.CommitMessage, |
434 | | - } |
435 | | - } |
436 | | - |
437 | | - // Convert Metadata |
438 | | - if output.Metadata != nil { |
439 | | - internal.Metadata = &format.Metadata{ |
440 | | - Language: output.Metadata.Language, |
441 | | - Version: output.Metadata.Version, |
442 | | - Dependencies: output.Metadata.Dependencies, |
443 | | - } |
444 | | - } |
445 | | - |
446 | | - // Convert Files |
447 | | - internal.Files = make([]format.FileInfo, len(output.Files)) |
448 | | - for i, file := range output.Files { |
449 | | - internal.Files[i] = format.FileInfo{ |
450 | | - Path: file.Path, |
451 | | - Content: file.Content, |
452 | | - Tokens: file.Tokens, |
453 | | - } |
454 | | - if file.Truncation != nil { |
455 | | - internal.Files[i].Truncation = &format.TruncationInfo{ |
456 | | - Mode: file.Truncation.Mode, |
457 | | - OriginalTokens: file.Truncation.OriginalTokens, |
458 | | - } |
459 | | - } |
460 | | - } |
461 | | - |
462 | | - // Convert FileStats |
463 | | - if output.FileStats != nil { |
464 | | - internal.FileStats = &format.FileStatistics{ |
465 | | - TotalFiles: output.FileStats.TotalFiles, |
466 | | - TotalLines: output.FileStats.TotalLines, |
467 | | - PackageCount: output.FileStats.PackageCount, |
468 | | - } |
469 | | - } |
470 | | - |
471 | | - // Convert Budget |
472 | | - if output.Budget != nil { |
473 | | - internal.Budget = &format.BudgetInfo{ |
474 | | - MaxTokens: output.Budget.MaxTokens, |
475 | | - EstimatedTokens: output.Budget.EstimatedTokens, |
476 | | - FileTruncations: output.Budget.FileTruncations, |
477 | | - } |
478 | | - } |
479 | | - |
480 | | - // Convert FilterConfig |
481 | | - if output.FilterConfig != nil { |
482 | | - internal.FilterConfig = &format.FilterConfig{ |
483 | | - Includes: output.FilterConfig.Includes, |
484 | | - Excludes: output.FilterConfig.Excludes, |
485 | | - } |
486 | | - } |
487 | | - |
488 | | - return internal |
489 | | -} |
490 | | - |
491 | | -func toInternalDirectoryNode(node *promptext.DirectoryNode) *format.DirectoryNode { |
492 | | - if node == nil { |
493 | | - return nil |
494 | | - } |
495 | | - |
496 | | - internal := &format.DirectoryNode{ |
497 | | - Name: node.Name, |
498 | | - Type: node.Type, |
499 | | - } |
500 | | - |
501 | | - if len(node.Children) > 0 { |
502 | | - internal.Children = make([]*format.DirectoryNode, len(node.Children)) |
503 | | - for i, child := range node.Children { |
504 | | - internal.Children[i] = toInternalDirectoryNode(child) |
505 | | - } |
506 | | - } |
507 | | - |
508 | | - return internal |
509 | | -} |
510 | | - |
511 | | -func toInternalExcludedList(list []promptext.ExcludedFileInfo) []processor.ExcludedFileInfo { |
512 | | - result := make([]processor.ExcludedFileInfo, len(list)) |
513 | | - for i, item := range list { |
514 | | - result[i] = processor.ExcludedFileInfo{ |
515 | | - Path: item.Path, |
516 | | - Tokens: item.Tokens, |
517 | | - } |
518 | | - } |
519 | | - return result |
520 | | -} |
521 | | - |
522 | 400 | type cliDeps struct { |
523 | 401 | stdout io.Writer |
524 | 402 | stderr io.Writer |
|
0 commit comments