(cwd string, cfg config.Config)
| 366 | return content[:maxBytes], true, nil |
| 367 | } |
| 368 | |
| 369 | func LoadProjectInstructions(cwd string) (string, error) { |
| 370 | cfg := config.NewConfigForCWD(cwd) |
| 371 | return LoadProjectInstructionsWithConfig(cwd, cfg) |
| 372 | } |
| 373 | |
| 374 | func LoadProjectInstructionsWithConfig(cwd string, cfg config.Config) (string, error) { |
| 375 | result, err := DiscoverProjectDocs(cwd, cfg) |
| 376 | if err != nil { |
| 377 | return "", err |
| 378 | } |
| 379 | parts := make([]string, 0, len(result.Docs)) |
| 380 | for _, doc := range result.Docs { |
| 381 | parts = append(parts, doc.Content) |
| 382 | } |
| 383 | return strings.Join(parts, projectInstructionSeparator), nil |
| 384 | } |
| 385 | |
| 386 | func DiscoverProjectDocs(cwd string, cfg config.Config) (ProjectDocDiscoveryResult, error) { |
| 387 | workDir, err := projectInstructionDirectory(cwd) |
| 388 | if err != nil { |
| 389 | return ProjectDocDiscoveryResult{}, err |
| 390 | } |
| 391 | result := ProjectDocDiscoveryResult{CWD: workDir} |
| 392 | root := findProjectRootByMarkers(workDir, cfg.ProjectRootMarkersOrDefault()) |
| 393 | if root == "" { |
| 394 | root = workDir |
| 395 | } |
| 396 | result.Root = root |
| 397 | |
| 398 | var docs []ProjectDoc |
| 399 | for _, dir := range dirsFromRootToCWD(root, workDir) { |
| 400 | doc, readErr := readProjectInstructionFileWithOptions(dir, cfg.ProjectDocFilenamesOrDefault(), cfg.ProjectDocMaxBytesOrDefault()) |
| 401 | if readErr == nil { |
| 402 | docs = append(docs, doc) |
| 403 | } |
| 404 | } |
no test coverage detected