context_spook 1.1.0 → 1.2.0

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: 41d55af33ce0adb0f4950f6a24b43fdc6d5c6d7401e6c6eb59bdce08d149043f
4
- data.tar.gz: fa121dce3b5c17f234a51133e93c947420609849bcc048676e4f0d5f9e718d42
3
+ metadata.gz: ce46a8a82422662465714da76e66762d8ce6ca9f44b2231c1064ca774e45696e
4
+ data.tar.gz: 3e6c9fbb246330a69232b4ddc4527aea2bc83385293b8a2d16829cd1f47dc3f4
5
5
  SHA512:
6
- metadata.gz: 812003a9986f5ca5bad980b57fececfc09085de3787dd671197453f977feaa249c67a1af858e93ba2be810ae941b1389dbc28e222fac853550b33b6e3d2076ac
7
- data.tar.gz: 6579a56156f1e6deaf64427d2038de99a2e68749e397fc57860fdf4b6c33359f467d72e7a2cc1a0effd691c7c8411666f23c8b414334d5ab0e55e6540ee39d98
6
+ metadata.gz: 22b6f481325481fbb323cc354c404a7c87a595a5546b9c70f0cfe99b3ef2e1871dd653864dfa460f45df23a10c3573a497cefb46e83b7b7e24fb2d69892279fe
7
+ data.tar.gz: 1f8228f7e8300d887865bf262b148433ab06ef680b3bf593b404a60732f5751b66384d668366b37168195fb463b168bbe9bd8211bbf6402c8d6cc4b95016daec
data/Rakefile CHANGED
@@ -38,6 +38,7 @@ GemHadar do
38
38
  dependency 'mime-types', '~> 3.0'
39
39
  dependency 'yaml', '~> 0.4'
40
40
  dependency 'pathname', '~> 0.4'
41
+ dependency 'ruby-json-toon', '~> 1.0'
41
42
  development_dependency 'all_images', '~> 0.6'
42
43
  development_dependency 'rspec', '~> 3.2'
43
44
  development_dependency 'debug'
data/bin/context_spook CHANGED
@@ -26,6 +26,7 @@ def usage
26
26
  -S suppress output (just show informational output)
27
27
  -i PATTERN Include files matching PATTERN (can be used multiple times)
28
28
  Supports glob patterns like **, *, ?, [abc], {a,b,c}
29
+ -F FORMAT Output context as format JSON (the default) or TOON
29
30
  -h Show this help message
30
31
 
31
32
  Examples:
@@ -54,7 +55,7 @@ def usage
54
55
  exit 0
55
56
  end
56
57
 
57
- opts = go 'o:i:pvSh', defaults: { ?v => true }
58
+ opts = go 'o:i:F:pvSh', defaults: { ?v => true }
58
59
  opts[?h] and usage
59
60
  context = nil
60
61
  output = nil
@@ -88,4 +89,14 @@ else
88
89
  output = STDOUT
89
90
  end
90
91
  end
91
- JSON.dump(context.as_json, output)
92
+ case opts[?F]
93
+ when /\ATOON\z/i
94
+ if opts[?v]
95
+ STDERR.puts "Built #{ContextSpook::Utils.format_size(context.toon_size)} of TOON context in total."
96
+ end
97
+ output.puts context.to_toon
98
+ when /\AJSON\z/i, nil
99
+ JSON.dump(context.as_json, output)
100
+ else
101
+ STDERR.puts "Invalid output format #{opts[?F].inspect}"
102
+ end
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: context_spook 1.1.0 ruby lib
2
+ # stub: context_spook 1.2.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "context_spook".freeze
6
- s.version = "1.1.0".freeze
6
+ s.version = "1.2.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.description = "context_spook is a library that collects and organizes project\ninformation to help AI assistants understand codebases better.\n".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["context_spook".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/version.rb".freeze]
16
- s.files = [".contexts/project.rb".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "hello_world.json".freeze, "hey_world.yaml".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/spec_helper.rb".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/toon.rb".freeze, "lib/context_spook/utils.rb".freeze, "lib/context_spook/version.rb".freeze]
16
+ s.files = [".contexts/project.rb".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "hello_world.json".freeze, "hey_world.yaml".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/toon.rb".freeze, "lib/context_spook/utils.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "https://github.com/flori/context_spook".freeze
18
18
  s.licenses = ["MIT".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "ContextSpook - context_spook collects project context for AI".freeze, "--main".freeze, "README.md".freeze]
@@ -36,4 +36,5 @@ Gem::Specification.new do |s|
36
36
  s.add_runtime_dependency(%q<mime-types>.freeze, ["~> 3.0".freeze])
37
37
  s.add_runtime_dependency(%q<yaml>.freeze, ["~> 0.4".freeze])
38
38
  s.add_runtime_dependency(%q<pathname>.freeze, ["~> 0.4".freeze])
39
+ s.add_runtime_dependency(%q<ruby-json-toon>.freeze, ["~> 1.0".freeze])
39
40
  end
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'mize'
5
5
  require 'mime-types'
6
6
  require 'yaml'
7
+ require 'context_spook/toon'
7
8
 
8
9
  # The ContextSpook module serves as a namespace container for collecting and
9
10
  # organizing project information for AI assistance.
@@ -111,11 +112,9 @@ module ContextSpook
111
112
  # JSON, formats it using binary units (KiB, MiB, etc.), and outputs the
112
113
  # result to standard error.
113
114
  def output_context_size
114
- context_size = @context&.size.to_i
115
- json_content_size = Tins::Unit.format(
116
- context_size, format: '%.2f %U', unit: ?b, prefix: 1024
117
- )
118
- verbose_puts "Built #{json_content_size} of JSON context in total."
115
+ context_size = @context&.size.to_i
116
+ json_context_size = ContextSpook::Utils.format_size(context_size)
117
+ verbose_puts "Built #{json_context_size} of JSON context in total."
119
118
  end
120
119
 
121
120
  # The Context class represents and manages project context data, providing
@@ -126,6 +125,7 @@ module ContextSpook
126
125
  include Tins::Scope
127
126
  include Tins::DSLAccessor
128
127
  include Term::ANSIColor
128
+ include ContextSpook::TOON
129
129
 
130
130
  # The initialize method sets up the object by evaluating the provided block
131
131
  # in the object's context.
@@ -0,0 +1,12 @@
1
+ require 'ruby_json_toon'
2
+
3
+ module ContextSpook::TOON
4
+ def to_toon
5
+ RubyJsonToon.encode(as_json)
6
+ end
7
+ memoize method: :to_toon
8
+
9
+ def toon_size
10
+ to_toon.size
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module ContextSpook::Utils
2
+ module_function
3
+
4
+ # The format_size method converts a byte size value into a human-readable
5
+ # string with binary units.
6
+ #
7
+ # This method takes a raw byte count and formats it using the Tins::Unit
8
+ # library to display the size with appropriate binary prefixes (KiB, MiB,
9
+ # etc.) and two decimal places.
10
+ #
11
+ # @param context_size [ Integer ] the size in bytes to be formatted
12
+ #
13
+ # @return [ String ] the formatted size string with binary units
14
+ def format_size(context_size)
15
+ Tins::Unit.format(context_size, format: '%.2f %U', unit: ?b, prefix: 1024)
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  module ContextSpook
2
2
  # ContextSpook version
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/lib/context_spook.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module ContextSpook
2
2
  end
3
3
  require 'context_spook/version'
4
+ require 'context_spook/utils'
4
5
  require 'context_spook/generator'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: context_spook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -177,6 +177,20 @@ dependencies:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0.4'
180
+ - !ruby/object:Gem::Dependency
181
+ name: ruby-json-toon
182
+ requirement: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '1.0'
187
+ type: :runtime
188
+ prerelease: false
189
+ version_requirements: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '1.0'
180
194
  description: |
181
195
  context_spook is a library that collects and organizes project
182
196
  information to help AI assistants understand codebases better.
@@ -188,6 +202,8 @@ extra_rdoc_files:
188
202
  - README.md
189
203
  - lib/context_spook.rb
190
204
  - lib/context_spook/generator.rb
205
+ - lib/context_spook/toon.rb
206
+ - lib/context_spook/utils.rb
191
207
  - lib/context_spook/version.rb
192
208
  files:
193
209
  - ".contexts/project.rb"
@@ -201,6 +217,8 @@ files:
201
217
  - hey_world.yaml
202
218
  - lib/context_spook.rb
203
219
  - lib/context_spook/generator.rb
220
+ - lib/context_spook/toon.rb
221
+ - lib/context_spook/utils.rb
204
222
  - lib/context_spook/version.rb
205
223
  - spec/context_spook/generator_spec.rb
206
224
  - spec/spec_helper.rb