Class: ClaudeMemory::Publish
- Inherits:
-
Object
- Object
- ClaudeMemory::Publish
- Defined in:
- lib/claude_memory/publish.rb
Overview
Generates Markdown snapshots from active facts for use as project memory. Publishes to .claude/rules/ (shared), a local file, or the home directory.
Constant Summary collapse
- RULES_DIR =
".claude/rules"- GENERATED_FILE =
"claude_memory.generated.md"
Instance Method Summary collapse
-
#generate_snapshot(since: nil) ⇒ String
Generate a complete Markdown snapshot with header and body.
-
#initialize(store, file_system: Infrastructure::FileSystem.new) ⇒ Publish
constructor
A new instance of Publish.
-
#publish!(mode: :shared, granularity: :repo, since: nil, rules_dir: nil) ⇒ Hash
Write snapshot to disk if content has changed.
Constructor Details
#initialize(store, file_system: Infrastructure::FileSystem.new) ⇒ Publish
Returns a new instance of Publish.
15 16 17 18 |
# File 'lib/claude_memory/publish.rb', line 15 def initialize(store, file_system: Infrastructure::FileSystem.new) @store = store @fs = file_system end |
Instance Method Details
#generate_snapshot(since: nil) ⇒ String
Generate a complete Markdown snapshot with header and body
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/claude_memory/publish.rb', line 23 def generate_snapshot(since: nil) header = <<~HEADER <!-- This file is auto-generated by claude-memory. Do not edit manually - changes will be overwritten. Generated: #{Time.now.utc.iso8601} --> # Project Memory HEADER header + generate_body(since: since) end |
#publish!(mode: :shared, granularity: :repo, since: nil, rules_dir: nil) ⇒ Hash
Write snapshot to disk if content has changed
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/claude_memory/publish.rb', line 44 def publish!(mode: :shared, granularity: :repo, since: nil, rules_dir: nil) path = output_path(mode, rules_dir: rules_dir) body = generate_body(since: since) if should_write?(path, body) content = generate_snapshot(since: since) @fs.write(path, content) ensure_import_exists(mode, path, rules_dir: rules_dir) {status: :updated, path: path} else {status: :unchanged, path: path} end end |