context_spook 0.6.0 → 0.7.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: e70334ee77b21283268eaabfc74ea73593a375119003d74be68442188f4dbf5b
4
- data.tar.gz: cc7ca13e3a403a97f16c897a797d0b2a4a92bba1b8e3da99adb199f807169b1c
3
+ metadata.gz: c6fb6162c0afe83a80278392b433a3d02736b27a22e8fd565729665f3ba6db97
4
+ data.tar.gz: 98302a7facca6c08627d3572caf4aa0678ce21cc8b6c65a8ad96c3d583064440
5
5
  SHA512:
6
- metadata.gz: db73acce9ba9aa696619be04671adde77a115d63b2e2c48d559848cc3d02c608579982a29da2bba7bd70bda7a5fae5654828c6ad1f763e2b04094e47820c98e0
7
- data.tar.gz: f95575da363d9c70d5f9303ce66bc13d8c2bb2e4c70c7c6074fe3c61f1bf35554dbfc68f286bf2eac2d4080fe39291ad4b1f2ce9ca0910560e2a4b86f5eb6154
6
+ metadata.gz: b856851ee22f9df0c56e17c9d287589101c9752859443a31c8d30bc9c0917d7f02424e2a0f785359830c508f221e791f3b4a0aa6976a5e20f30de4d0eb5b8701
7
+ data.tar.gz: c63473ad56525d7ba0d8ffcde23570b1d09ad25044406f299a65a03c416c10864030e83cf4e59920b8c1f0c069146983a8b316ea17ea1cb4afb0cb4c134c2b39
data/README.md CHANGED
@@ -154,6 +154,17 @@ The CLI tool also supports file redirection:
154
154
  ./bin/context_spook .contexts/project.rb -o context.json
155
155
  ```
156
156
 
157
+ You can also use directory globbing to automatically collect files without
158
+ manually specifying each one:
159
+
160
+ ```bash
161
+ # Collect all Ruby files from lib/ and spec/ directories
162
+ ./bin/context_spook -d lib -d spec -s rb
163
+
164
+ # Collect Markdown and YAML files from current directory
165
+ ./bin/context_spook -s md -s yaml
166
+ ```
167
+
157
168
  This is how you can show the usage message:
158
169
 
159
170
  ```
data/Rakefile CHANGED
@@ -37,6 +37,7 @@ GemHadar do
37
37
  dependency 'mize', '~> 0.6'
38
38
  dependency 'mime-types', '~> 3.0'
39
39
  dependency 'yaml', '~> 0.4'
40
+ dependency 'pathname', '~> 0.4'
40
41
  development_dependency 'all_images', '~> 0.6'
41
42
  development_dependency 'rspec', '~> 3.2'
42
43
  development_dependency 'debug'
data/bin/context_spook CHANGED
@@ -4,6 +4,7 @@ require 'context_spook'
4
4
  require 'tins/go'
5
5
  include Tins::GO
6
6
  require 'json'
7
+ require 'pathname'
7
8
 
8
9
  # The usage method displays the command-line interface help text and example
9
10
  # usage patterns for the ContextSpook tool.
@@ -23,29 +24,55 @@ def usage
23
24
  -o FILE Write output to FILE instead of stdout
24
25
  -v Verbose output
25
26
  -h Show this help message
27
+ -d DIR Directory to search for files (defaults to current dir, can be
28
+ used multiple times)
29
+ -s SUFFIX File suffix to include (can be used multiple times)
26
30
 
27
31
  Examples:
28
32
  # Generate context and output to stdout
29
33
  #{File.basename($0)} .contexts/project.rb
30
34
 
31
- # Generate context and save to file
32
- #{File.basename($0)} .contexts/project.rb -o context.json
35
+ # Generate context from directory globs
36
+ #{File.basename($0)} -d lib -d spec -s rb
33
37
 
34
38
  # Generate context with verbose output
35
39
  #{File.basename($0)} .contexts/project.rb -v
36
40
 
37
- # Generate context and pipe to another tool
38
- #{File.basename($0)} .contexts/project.rb | ollama_chat_send
41
+ # Generate context from directory globs with verbose output
42
+ #{File.basename($0)} -d lib -d spec -s rb -v
43
+
44
+ # Generate context and save to file
45
+ #{File.basename($0)} .contexts/project.rb -o context.json
46
+
47
+ # Generate context from directory globs and save to file
48
+ #{File.basename($0)} -d lib -d spec -s rb -o context.json
39
49
 
40
50
  EOT
41
51
  exit 0
42
52
  end
43
53
 
44
- opts = go 'o:pvh'
54
+ opts = go 'd:s:o:pvh', defaults: { ?d => ?. }
45
55
  opts[?h] and usage
56
+ context = nil
57
+ output = nil
58
+ if opts[?s]
59
+ context = ContextSpook.generate_context(verbose: opts[?v]) do
60
+ context do
61
+ Array(opts[?d]).each do |d|
62
+ dir = Pathname.new(d).expand_path
63
+ Array(opts[?s]).each do |suffix|
64
+ dir_glob = dir + "**/*.#{suffix}"
65
+ Dir[dir_glob].each do |filename|
66
+ file filename
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ else
46
73
  filename = ARGV.shift or fail 'require context definition file as an argument'
47
- output = nil
48
- context = ContextSpook.generate_context(filename, verbose: opts[?v])
74
+ context = ContextSpook.generate_context(filename, verbose: opts[?v])
75
+ end
49
76
  if output_filename = opts[?o]
50
77
  if File.exist?(output_filename)
51
78
  fail "Filename #{output_filename.inspect} already exists!"
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: context_spook 0.6.0 ruby lib
2
+ # stub: context_spook 0.7.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "context_spook".freeze
6
- s.version = "0.6.0".freeze
6
+ s.version = "0.7.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]
@@ -35,4 +35,5 @@ Gem::Specification.new do |s|
35
35
  s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.6".freeze])
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
+ s.add_runtime_dependency(%q<pathname>.freeze, ["~> 0.4".freeze])
38
39
  end
@@ -29,7 +29,7 @@ module ContextSpook
29
29
  #
30
30
  # @return [ nil ] always returns nil after attempting to output
31
31
  def verbose_puts(*a)
32
- @verbose and return
32
+ @verbose or return
33
33
  STDERR.puts(a)
34
34
  end
35
35
  end
@@ -57,10 +57,11 @@ module ContextSpook
57
57
  # @raise [ ArgumentError ] if neither a filename nor a block is provided
58
58
  # @raise [ ArgumentError ] if both a filename and a block are provided
59
59
  def self.generate_context(filename = nil, verbose: false, &block)
60
+ verbose = !!verbose
60
61
  filename.present? ^ block or
61
62
  raise ArgumentError, 'need either a filename or a &block argument'
62
63
  generator = if filename
63
- Generator.send(:new, verbose:).send(:parse, File.read(filename))
64
+ Generator.send(:new, verbose:).send(:parse, File.read(filename))
64
65
  else
65
66
  Generator.send(:new, verbose:, &block)
66
67
  end
@@ -1,6 +1,6 @@
1
1
  module ContextSpook
2
2
  # ContextSpook version
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.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:
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: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -163,6 +163,20 @@ dependencies:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0.4'
166
+ - !ruby/object:Gem::Dependency
167
+ name: pathname
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '0.4'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.4'
166
180
  description: |
167
181
  context_spook is a library that collects and organizes project
168
182
  information to help AI assistants understand codebases better.