llmemory 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc37d3f00fe0f347b1cf37d17665a84b92fa8a0effdf6f238178651f44f58a9
4
- data.tar.gz: 35dc741e76e12814e6abae4ede8cace697802359892cbb9c419a5e224c5b16f9
3
+ metadata.gz: 1758a40a096cf694812a669cb4c92ee6010954b68f733acf8d31083cd8ccaf21
4
+ data.tar.gz: 9f7c8a4d63c2f71325ef6dc5134fa5895655e1d2fadfe93b64ebbcc2e68224f6
5
5
  SHA512:
6
- metadata.gz: 7161647ed2bd7ac8b48a4695cd915fb26e80aee867238f8b40a70d8d2b014af72f3206c0b738738d2429a17760927b486e101ce3e82dae09efa59469bb8b54c8
7
- data.tar.gz: 310bc288d0e6570280dfd78cfe8f002bb2e071275baf47521649ab2ba56d40ce182cdce2b93cc0bc21ba3c2ccebce7122c4e99c4e481a004790fb030634f1a43
6
+ metadata.gz: f8ef12d0d2294ebc7eca0d1ad4760f92c288fb54c02c41ce88b88c16d8fd459d77364ab3f29388801daaaf4cf1c42d4e972dacfbda69c8433c13dc7ff4f4e5c0
7
+ data.tar.gz: 7b6bbe90b6b251f11cbc2692eb4f63d3dc57699dbadda16001d171b836a28fd4ac871e1e94742e81bd2b80efff890c13142934c7a210dee790331bad78ef1c37
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Llmemory
4
+ class Railtie < ::Rails::Railtie
5
+ rake_tasks do
6
+ load File.expand_path("../tasks/llmemory.rake", __dir__)
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "base"
4
- require_relative "../../active_record_helpers"
4
+ require_relative "../active_record_helpers"
5
5
 
6
6
  module Llmemory
7
7
  module VectorStore
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Llmemory
4
- VERSION = "0.2.7"
4
+ VERSION = "0.2.9"
5
5
  end
data/lib/llmemory.rb CHANGED
@@ -28,3 +28,4 @@ module Llmemory
28
28
  end
29
29
 
30
30
  require_relative "llmemory/crypto/cipher"
31
+ require_relative "llmemory/railtie" if defined?(Rails::Railtie)
@@ -3,7 +3,9 @@
3
3
  namespace :llmemory do
4
4
  desc "Backfill search_tokens blind index (and name_det on skills) for encrypted keyword search. " \
5
5
  "Env: FORCE=1 (re-backfill all rows), DRY_RUN=1 (count only), STORE=active_record|postgres"
6
- task :backfill_search_tokens, [:user_id] do |_t, args|
6
+ task_deps = Rake::Task.task_defined?(:environment) ? [:environment] : []
7
+
8
+ task :backfill_search_tokens, [:user_id] => task_deps do |_t, args|
7
9
  require "llmemory"
8
10
  require_relative "../llmemory/maintenance/search_tokens_backfill"
9
11
 
@@ -1,22 +1,86 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module Release
4
+ RELEASE_FILES = %w[lib/llmemory/version.rb Gemfile.lock CHANGELOG.txt].freeze
5
+ DEFAULT_NOTES_PATH = File.expand_path("../../tmp/release_notes.txt", __dir__)
6
+
7
+ module_function
8
+
9
+ def resolve_notes_path(arg)
10
+ path = arg.to_s.strip
11
+ path = DEFAULT_NOTES_PATH if path.empty?
12
+ File.expand_path(path)
13
+ end
14
+
15
+ def build_changelog_entry(version, date, notes_body)
16
+ body = notes_body.strip
17
+ body = body.sub(/\A#+\s*[^\n]*\n+/, "") # drop optional leading markdown title
18
+
19
+ <<~ENTRY
20
+
21
+ ## [#{version}] - #{date}
22
+
23
+ #{body}
24
+ ENTRY
25
+ end
26
+
27
+ def allowed_dirty_path?(path, notes_path)
28
+ RELEASE_FILES.include?(path) || File.expand_path(path) == File.expand_path(notes_path)
29
+ end
30
+ end
31
+
3
32
  namespace :release do
4
- desc "Bump version (patch|minor|major). Checks: branch=main, no uncommitted changes, tests pass. Then: Gemfile.lock, CHANGELOG, commit, push, tag"
5
- task :bump, [:bump_type] => [] do |_t, args|
33
+ desc "Show commits and diff stat since the last tag (helper before writing release notes)"
34
+ task :since_tag do
35
+ last_tag = `git describe --tags --abbrev=0 2>/dev/null`.strip
36
+ range = last_tag.empty? ? "HEAD" : "#{last_tag}..HEAD"
37
+ puts "Last tag: #{last_tag.empty? ? '(none)' : last_tag}"
38
+ puts "Range: #{range}\n\n"
39
+ puts "Commits:"
40
+ puts(`git log #{range} --oneline`.strip)
41
+ puts "\nDiff stat:"
42
+ puts(`git diff #{range} --stat`.strip)
43
+ end
44
+
45
+ desc "Bump version (patch|minor|major). Requires tmp/release_notes.txt or notes path. Checks: branch=main, clean tree, tests pass. Then: version, CHANGELOG, commit, push, tag"
46
+ task :bump, [:bump_type, :notes_file] => [] do |_t, args|
6
47
  require_relative "../llmemory/version"
7
48
 
8
- # Pre-flight checks
9
49
  current_branch = `git rev-parse --abbrev-ref HEAD`.strip
10
50
  abort "Current branch must be main (got: #{current_branch})" unless current_branch == "main"
11
51
 
12
- # Allow only release-related files to be modified (we'll commit them)
13
- release_files = %w[lib/llmemory/version.rb Gemfile.lock CHANGELOG.txt]
14
- status_lines = `git status --porcelain`.strip.lines
52
+ notes_path = Release.resolve_notes_path(args[:notes_file])
53
+
54
+ status_lines = `git status --porcelain --untracked-files=normal`.strip.lines
15
55
  other_changes = status_lines.reject do |line|
16
- path = line.sub(/\A..\s+/, "").strip
17
- release_files.include?(path)
56
+ path = line.sub(/\A..\s+/, "").strip.split(" -> ").last
57
+ Release.allowed_dirty_path?(path, notes_path)
58
+ end
59
+ unless other_changes.empty?
60
+ abort "Working tree has uncommitted changes outside release files. Commit or stash them first.\n#{other_changes.join}"
61
+ end
62
+
63
+ unless File.exist?(notes_path)
64
+ abort <<~MSG
65
+ Release notes file not found: #{notes_path}
66
+
67
+ 1. Inspect changes since the last tag:
68
+ bundle exec rake release:since_tag
69
+
70
+ 2. Write a changelog entry (user-visible changes, not raw commits) to:
71
+ tmp/release_notes.txt
72
+
73
+ Use sections such as Added / Changed / Fixed / Removed / Notes.
74
+ Follow the style of recent entries in CHANGELOG.txt (e.g. v0.2.7).
75
+
76
+ 3. Re-run:
77
+ bundle exec rake release:bump[#{args[:bump_type] || 'patch'}]
78
+ bundle exec rake release:bump[#{args[:bump_type] || 'patch'},path/to/notes.txt]
79
+ MSG
18
80
  end
19
- abort "Working tree has uncommitted changes outside release files. Commit or stash them first." unless other_changes.empty?
81
+
82
+ notes_body = File.read(notes_path).strip
83
+ abort "Release notes file is empty: #{notes_path}" if notes_body.empty?
20
84
 
21
85
  puts "Running tests..."
22
86
  sh "bundle exec rspec"
@@ -36,41 +100,21 @@ namespace :release do
36
100
  new_version_s = new_version.to_s
37
101
 
38
102
  puts "Bumping #{Llmemory::VERSION} -> #{new_version_s} (#{bump_type})"
103
+ puts " Release notes: #{notes_path}"
39
104
 
40
- # 1. Update version.rb
41
105
  version_file = File.expand_path("../llmemory/version.rb", __dir__)
42
106
  content = File.read(version_file)
43
107
  content = content.sub(/VERSION = "[^"]+"/, %(VERSION = "#{new_version_s}"))
44
108
  File.write(version_file, content)
45
109
  puts " Updated lib/llmemory/version.rb"
46
110
 
47
- # 2. bundle install
48
111
  sh "bundle install"
49
112
  puts " Updated Gemfile.lock"
50
113
 
51
- # 3. Update CHANGELOG.txt
52
114
  changelog_path = File.expand_path("../../CHANGELOG.txt", __dir__)
53
- changelog_content = if File.exist?(changelog_path)
54
- File.read(changelog_path)
55
- else
56
- ""
57
- end
58
-
115
+ changelog_content = File.exist?(changelog_path) ? File.read(changelog_path) : ""
59
116
  today = Time.now.strftime("%Y-%m-%d")
60
- last_tag = `git describe --tags --abbrev=0 2>/dev/null`.strip
61
- commits = if last_tag.empty?
62
- `git log --oneline`.strip
63
- else
64
- `git log #{last_tag}..HEAD --oneline`.strip
65
- end
66
-
67
- new_entry = <<~CHANGELOG
68
-
69
- ## [#{new_version_s}] - #{today}
70
-
71
- ### Changes
72
- #{commits.lines.map { |l| "- #{l.strip}" }.join("\n")}
73
- CHANGELOG
117
+ new_entry = Release.build_changelog_entry(new_version_s, today, notes_body)
74
118
 
75
119
  header = "# Changelog\n\n"
76
120
  if changelog_content.empty?
@@ -82,19 +126,14 @@ namespace :release do
82
126
  File.write(changelog_path, changelog_content)
83
127
  puts " Updated CHANGELOG.txt"
84
128
 
85
- # 4. Commit
86
129
  sh "git add lib/llmemory/version.rb Gemfile.lock CHANGELOG.txt"
87
130
  sh "git commit -m 'Release v#{new_version_s}'"
88
-
89
- # 5. Push
90
131
  sh "git push"
91
-
92
- # 6. Tag
93
132
  sh "git tag v#{new_version_s}"
94
-
95
- # 7. Push tag
96
133
  sh "git push origin v#{new_version_s}"
97
134
 
135
+ default_notes = Release::DEFAULT_NOTES_PATH
136
+ File.delete(notes_path) if File.expand_path(notes_path) == File.expand_path(default_notes) && File.exist?(notes_path)
98
137
  puts "\nDone. Released v#{new_version_s}"
99
138
  end
100
139
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llmemory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - llmemory
@@ -246,6 +246,7 @@ files:
246
246
  - lib/llmemory/memory_module.rb
247
247
  - lib/llmemory/noise_filter.rb
248
248
  - lib/llmemory/provenance.rb
249
+ - lib/llmemory/railtie.rb
249
250
  - lib/llmemory/reflection.rb
250
251
  - lib/llmemory/reflection/reflector.rb
251
252
  - lib/llmemory/retrieval.rb