Перейти к содержимому

Паттерн динамических файлов

Использование шаблонных переменных для путей к файлам, чтобы сделать workflow переиспользуемыми в разных проектах. Пути собираются во время выполнения и используются на протяжении всего процесса.

[collect-paths] → [use-paths-in-directives] → [output-to-path]
{
"type": "agent-directive",
"id": "collect-project-paths",
"directive": "Determine project structure:\n- Docs location?\n- Output location?\n- Test files location?",
"inputSchema": {
"type": "object",
"properties": {
"docs_path": {
"type": "string",
"description": "Path to project documentation"
},
"output_path": {
"type": "string",
"description": "Path for workflow outputs"
},
"test_path": { "type": "string", "description": "Path to test files" }
},
"required": ["docs_path", "output_path"]
},
"connections": { "success": "read-documentation" }
}
{
"type": "agent-directive",
"id": "read-documentation",
"directive": "Read project documentation from {{docs_path}}.\nAnalyze structure and content.",
"connections": { "success": "write-output" }
}
{
"type": "agent-directive",
"id": "write-output",
"directive": "Write results to {{output_path}}/analysis-results.md",
"connections": { "success": "next-step" }
}

Агент может определять пути следующими способами:

  1. Поиск в файловой системе: Искать типичные паттерны (docs/, README.md)
  2. Значения по умолчанию: Использовать стандартные расположения как запасной вариант
  3. Запрос у пользователя: Когда путь не удаётся определить
{
"directive": "Find project documentation:\n1. Search for docs/ directory\n2. Check for README.md\n3. Look in standard locations\n4. Ask user if not found"
}

Комбинирование с условными шаблонами:

{
"directive": "{{#if testing_guide_path}}Read testing guide from {{testing_guide_path}}{{else}}No testing guide found, proceed with default patterns{{/if}}"
}

Из development-flow.json:

{
"id": "get-initial-requirements",
"inputSchema": {
"properties": {
"checklist_path": {
"type": "string",
"description": "Path to project checklist or empty if none"
},
"agent_onboarding_path": {
"type": "string",
"description": "Path to agent onboarding document or empty if none"
},
"docs_standards_path": {
"type": "string",
"description": "Path to documentation standards or empty if none"
},
"testing_guide_path": {
"type": "string",
"description": "Path to testing guide or empty if none"
}
}
}
}

Используется далее:

{
"directive": "{{#if has_checklist}}Review project checklist: {{checklist_path}}{{/if}}"
}

Используйте pattern в inputSchema для базовой валидации:

{
"properties": {
"file_path": {
"type": "string",
"pattern": "^[a-zA-Z0-9/_.-]+$"
}
}
}