Module: Legion::Extensions::Planner::Helpers::ContextGatherer
- Extended by:
- ContextGatherer
- Included in:
- ContextGatherer
- Defined in:
- lib/legion/extensions/planner/helpers/context_gatherer.rb
Overview
rubocop:disable Legion/HelperMigration/DirectJson, Legion/HelperMigration/DirectCache
Constant Summary collapse
- DOC_FILE_NAMES =
%w[CLAUDE.md README.md AGENTS.md CONTRIBUTING.md CHANGELOG.md].freeze
- CACHE_PREFIX =
'fleet:context:'- DEFAULT_TTL =
24 hours
86_400
Instance Method Summary collapse
- #doc_file_names ⇒ Object
- #gather(repo:, config:, work_item_id:, keywords: []) ⇒ Object
- #load_context(context_ref:) ⇒ Object
- #store_context!(work_item_id:, context:) ⇒ Object
Instance Method Details
#doc_file_names ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/planner/helpers/context_gatherer.rb', line 44 def doc_file_names DOC_FILE_NAMES end |
#gather(repo:, config:, work_item_id:, keywords: []) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/planner/helpers/context_gatherer.rb', line 15 def gather(repo:, config:, work_item_id:, keywords: [], **) context = { file_tree: config[:load_file_tree] ? fetch_file_tree(repo: repo) : [], docs: config[:load_repo_docs] ? fetch_docs(repo: repo) : {}, relevant_files: fetch_relevant_files( repo: repo, keywords: keywords, max_files: config[:max_context_files] || 50 ) } cache_key = store_context!(work_item_id: work_item_id, context: context) context.merge(context_ref: cache_key) end |
#load_context(context_ref:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/legion/extensions/planner/helpers/context_gatherer.rb', line 37 def load_context(context_ref:) raw = cache_get(context_ref) return nil if raw.nil? json_load(raw) end |
#store_context!(work_item_id:, context:) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/legion/extensions/planner/helpers/context_gatherer.rb', line 30 def store_context!(work_item_id:, context:) key = "#{CACHE_PREFIX}#{work_item_id}" serialized = json_dump(context) cache_set(key, serialized, ttl: DEFAULT_TTL) key end |