processIncludedFile processes a single included file, optionally extracting a section processIncludedFileWithVisited processes a single included file with cycle detection for nested includes
(filePath, sectionName string, extractTools bool, visited map[string]struct {
})
| 171 | // processIncludedFile processes a single included file, optionally extracting a section |
| 172 | // processIncludedFileWithVisited processes a single included file with cycle detection for nested includes |
| 173 | func processIncludedFileWithVisited(filePath, sectionName string, extractTools bool, visited map[string]struct { |
| 174 | }) (string, error) { |
| 175 | includeLog.Printf("Reading included file: %s (extractTools=%t, section=%s)", filePath, extractTools, sectionName) |
| 176 | content, err := readFileFunc(filePath) |
| 177 | if err != nil { |
| 178 | return "", fmt.Errorf("failed to read included file %s: %w", filePath, err) |
| 179 | } |
| 180 | includeLog.Printf("Read %d bytes from included file: %s", len(content), filePath) |
| 181 | |
| 182 | result, validationErr, isWorkflowFile, isAgentFile, err := parseAndValidateIncludedFrontmatter(filePath, content) |
| 183 | if err != nil { |
| 184 | return "", err |
| 185 | } |
| 186 | |
| 187 | if extractTools { |
| 188 | return extractToolsFromIncludedResult(result, validationErr, isWorkflowFile, isAgentFile) |
| 189 | } |
| 190 | |
| 191 | // Extract markdown content |
| 192 | return extractIncludedMarkdownContent(filePath, sectionName, content, visited, extractTools) |
| 193 | } |
| 194 | |
| 195 | func parseAndValidateIncludedFrontmatter(filePath string, content []byte) (*FrontmatterResult, error, bool, bool, error) { |
| 196 | result, err := extractIncludedFrontmatter(filePath, content) |