Class: AgentCode::Blueprint::ManifestManager
- Inherits:
-
Object
- Object
- AgentCode::Blueprint::ManifestManager
- Defined in:
- lib/agentcode/blueprint/manifest_manager.rb
Overview
Tracks file hashes and generated files for change detection. Port of agentcode-server ManifestManager.php / agentcode-adonis-server manifest_manager.ts.
Instance Method Summary collapse
-
#get_generated_files(filename) ⇒ Object
Get the list of generated files for a blueprint.
-
#get_tracked_files ⇒ Object
Get all tracked blueprint filenames.
-
#has_changed?(filename, current_hash) ⇒ Boolean
Check if a blueprint file has changed since last generation.
-
#initialize(blueprints_dir) ⇒ ManifestManager
constructor
A new instance of ManifestManager.
-
#load_manifest ⇒ Object
Load manifest from disk, returning empty structure if missing or corrupted.
-
#record_generation(filename, content_hash, generated_files) ⇒ Object
Record a successful generation.
-
#remove_tracking(filename) ⇒ Object
Remove tracking for a blueprint file.
-
#save ⇒ Object
Save manifest to disk.
Constructor Details
#initialize(blueprints_dir) ⇒ ManifestManager
Returns a new instance of ManifestManager.
10 11 12 13 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 10 def initialize(blueprints_dir) @manifest_path = File.join(blueprints_dir, ".blueprint-manifest.json") @manifest = load_manifest end |
Instance Method Details
#get_generated_files(filename) ⇒ Object
Get the list of generated files for a blueprint.
34 35 36 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 34 def get_generated_files(filename) @manifest.dig("files", filename, "generated_files") || [] end |
#get_tracked_files ⇒ Object
Get all tracked blueprint filenames.
39 40 41 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 39 def get_tracked_files @manifest["files"].keys end |
#has_changed?(filename, current_hash) ⇒ Boolean
Check if a blueprint file has changed since last generation.
16 17 18 19 20 21 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 16 def has_changed?(filename, current_hash) entry = @manifest.dig("files", filename) return true unless entry entry["content_hash"] != current_hash end |
#load_manifest ⇒ Object
Load manifest from disk, returning empty structure if missing or corrupted.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 54 def load_manifest return empty_manifest unless File.exist?(@manifest_path) begin parsed = JSON.parse(File.read(@manifest_path)) if parsed.is_a?(Hash) && parsed["version"] && parsed["files"] parsed else empty_manifest end rescue JSON::ParserError empty_manifest end end |
#record_generation(filename, content_hash, generated_files) ⇒ Object
Record a successful generation.
24 25 26 27 28 29 30 31 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 24 def record_generation(filename, content_hash, generated_files) @manifest["files"][filename] = { "content_hash" => content_hash, "generated_files" => generated_files, "generated_at" => Time.now.iso8601 } @manifest["generated_at"] = Time.now.iso8601 end |
#remove_tracking(filename) ⇒ Object
Remove tracking for a blueprint file.
44 45 46 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 44 def remove_tracking(filename) @manifest["files"].delete(filename) end |
#save ⇒ Object
Save manifest to disk.
49 50 51 |
# File 'lib/agentcode/blueprint/manifest_manager.rb', line 49 def save File.write(@manifest_path, JSON.pretty_generate(@manifest)) end |