hiiro 0.1.90 → 0.1.92

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: cb9904dbebc9b97674f2e5ee778a75522ebbc48f76232fe926166e6432087b82
4
- data.tar.gz: 2814bb1bd3947b87c7e9520fdf2ea6a6cde9f400de96876614872ed392f32703
3
+ metadata.gz: a225754bf06275debc8ce5bad696541103d1a062a2d4a5565f2b3ce34d628983
4
+ data.tar.gz: 4c7d7f4c88694b90a05254908558eabe0cd54f944b7fe0ba8c76ff0baba64a15
5
5
  SHA512:
6
- metadata.gz: a66db43a473bcd7f2da40e1def830928dd69a431163af352105e3019673ff249147be3e9e2153a015747fb2f4d128ff492eba42fd6e15935283a5a0d8dfdec49
7
- data.tar.gz: d4c8cfc36412db2a5be0689cf589d931ac28232b8b057a958da4234ead72a9e49b692321cf567208fb46639a20167e22a2cd5a5da2b1e9b26d1ca07cc7ee9876
6
+ metadata.gz: 381d57d3d69d3da9a47dedf7ed379b0b81706902523e2bb8158593e5240dddc69f00f460b41f4a8ec3d3294a5d91c117ecd689df845e7576122934466e2a12a7
7
+ data.tar.gz: e1ee7670dd9b3d3f580eeb76c5f6032e9e9dd48afe0ebaa6e8510488c3bba81a99457e5ad1d2d1ea39488ca1630ffc33d46dbbf9fb84d1c14ccd24ff8a988dba
data/CLAUDE.md CHANGED
@@ -161,23 +161,35 @@ Instance methods available in subcommand blocks:
161
161
  - `attach_method(name, &block)` - Add methods to hiiro instance dynamically
162
162
  - `make_child(subcmd, *args)` - Create nested Hiiro for sub-subcommands
163
163
 
164
- ### Hiiro::PrefixMatcher (lib/hiiro/prefix_matcher.rb)
164
+ ### Hiiro::Matcher (lib/hiiro/matcher.rb)
165
165
 
166
- Handles abbreviation matching for commands and items:
166
+ Handles pattern matching for commands and items with prefix and substring matching:
167
167
 
168
168
  ```ruby
169
- matcher = Hiiro::PrefixMatcher.new(items, :name)
170
- result = matcher.find("pre") # Find items where name starts with "pre"
169
+ matcher = Hiiro::Matcher.new(items, :name)
170
+
171
+ # Prefix matching - find items where name starts with pattern
172
+ result = matcher.by_prefix("pre")
171
173
  result.match? # Any matches?
172
174
  result.one? # Exactly one match?
173
175
  result.ambiguous? # Multiple matches?
174
176
  result.first&.item # Get first matching item
175
177
  result.resolved&.item # Get exact or single match
176
178
 
179
+ # Substring matching - find items where name contains pattern anywhere
180
+ result = matcher.by_substring("abc")
181
+ result.matches.map(&:item) # All matching items
182
+
177
183
  # Path-based matching for hierarchical names (e.g., "task/subtask")
178
184
  result = matcher.resolve_path("t/s")
185
+
186
+ # Class methods for one-off matching
187
+ Hiiro::Matcher.by_prefix(items, "pre", key: :name)
188
+ Hiiro::Matcher.by_substring(items, "abc", key: :name)
179
189
  ```
180
190
 
191
+ Note: `Hiiro::PrefixMatcher` is aliased to `Hiiro::Matcher` for backward compatibility.
192
+
181
193
  ### Hiiro::Git (lib/hiiro/git.rb)
182
194
 
183
195
  Git operations wrapper with submodules for branches, worktrees, remotes, and PRs:
@@ -235,7 +247,7 @@ History.by_session("work") # Filter by tmux session
235
247
  - `bin/h-*` - External subcommands (tmux wrappers, video operations)
236
248
  - `plugins/*.rb` - Reusable plugin modules (Pins, Project, Task, Tmux, Notify)
237
249
  - `lib/hiiro.rb` - Main Hiiro class and Runners
238
- - `lib/hiiro/*.rb` - Supporting classes (Git, PrefixMatcher, Fuzzyfind, Todo, History)
250
+ - `lib/hiiro/*.rb` - Supporting classes (Git, Matcher, Fuzzyfind, Todo, History)
239
251
 
240
252
  ## External Dependencies
241
253
 
data/bin/h-claude CHANGED
@@ -2,12 +2,46 @@
2
2
 
3
3
  require 'hiiro'
4
4
 
5
+ opts = Hiiro::Options.setup {
6
+ flag(:horizontal, short: :h, default: false)
7
+ flag(:percent, short: :p, default: false)
8
+ option(:size, short: :s, default: nil)
9
+ }
10
+
5
11
  Hiiro.run(*ARGV, plugins: [Pins]) {
12
+ add_subcmd(:split) { |*args|
13
+ opts = opts.parse(args)
14
+ direction = opts.horizontal ? '-v' : '-h'
15
+
16
+ size = opts.size || '40'
17
+ size += '%' if opts.percent
18
+
19
+ system('tmux', 'split-window', direction, '-l', size, *opts.args)
20
+ }
21
+
6
22
  add_subcmd(:vsplit) { |*args|
7
- system('tmux', 'split-window', '-h', '-l', '40%', *args)
23
+ size = '40%'
24
+
25
+ opts = opts.parse(args)
26
+
27
+ if opts.size
28
+ size = opts.size
29
+ size += '%' if opts.percent
30
+ end
31
+
32
+ system('tmux', 'split-window', '-h', '-l', size, *opts.args)
8
33
  }
9
34
 
10
35
  add_subcmd(:hsplit) { |*args|
11
- system('tmux', 'split-window', '-v', '-l', '40%', *args)
36
+ size = '40%'
37
+
38
+ opts = opts.parse(args)
39
+
40
+ if opts.size
41
+ size = opts.size
42
+ size += '%' if opts.percent
43
+ end
44
+
45
+ system('tmux', 'split-window', '-v', '-l', size, *opts.args)
12
46
  }
13
47
  }
data/bin/h-plugin CHANGED
@@ -23,8 +23,8 @@ o.add_subcmd(:edit) { |*args|
23
23
  if args.none?
24
24
  system(ENV['EDITOR'] || 'safe_nvim', __FILE__)
25
25
  else
26
- pm = Hiiro::PrefixMatcher.new(plugin_files) { |f| File.basename(f) }
27
- plugins = args.flat_map { |arg| pm.find_all(arg).matches.map(&:item) }.uniq
26
+ pm = Hiiro::Matcher.new(plugin_files) { |f| File.basename(f) }
27
+ plugins = args.flat_map { |arg| pm.by_prefix(arg).matches.map(&:item) }.uniq
28
28
 
29
29
  if plugins.none?
30
30
  puts "No matching plugins found for: #{args.map(&:inspect).join(' ')}"
@@ -1,16 +1,17 @@
1
1
  class Hiiro
2
- class PrefixMatcher
2
+ class Matcher
3
3
  class << self
4
+ # Prefix matching class methods
4
5
  def find(items, prefix, key: nil, &block)
5
- new(items, key, &block).find(prefix)
6
+ new(items, key, &block).by_prefix(prefix)
6
7
  end
7
8
 
8
9
  def find_all(items, prefix, key: nil, &block)
9
- new(items, key, &block).find_all(prefix)
10
+ new(items, key, &block).by_prefix(prefix)
10
11
  end
11
12
 
12
13
  def resolve(items, prefix, key: nil, &block)
13
- new(items, key, &block).resolve(prefix)
14
+ new(items, key, &block).by_prefix(prefix)
14
15
  end
15
16
 
16
17
  def find_path(items, prefix, key: nil, &block)
@@ -24,6 +25,16 @@ class Hiiro
24
25
  def resolve_path(items, prefix, key: nil, &block)
25
26
  new(items, key, &block).resolve_path(prefix)
26
27
  end
28
+
29
+ # Substring matching class methods
30
+ def by_substring(items, substring, key: nil, &block)
31
+ new(items, key, &block).by_substring(substring)
32
+ end
33
+
34
+ # Prefix matching class methods (explicit)
35
+ def by_prefix(items, prefix, key: nil, &block)
36
+ new(items, key, &block).by_prefix(prefix)
37
+ end
27
38
  end
28
39
 
29
40
  attr_reader :original_items, :key, :block
@@ -51,28 +62,48 @@ class Hiiro
51
62
  }
52
63
  end
53
64
 
54
- def search(prefix, key = nil, &block)
65
+ # Primary prefix matching method
66
+ def by_prefix(prefix, key = nil, &block)
55
67
  Result.new(
56
68
  matcher: self,
57
69
  all_items: all_items(key, &block),
58
- prefix: prefix,
70
+ pattern: prefix,
71
+ match_type: :prefix,
59
72
  key: key || @key,
60
73
  block: block || @block
61
74
  )
62
75
  end
63
76
 
77
+ # Primary substring matching method
78
+ def by_substring(substring, key = nil, &block)
79
+ Result.new(
80
+ matcher: self,
81
+ all_items: all_items(key, &block),
82
+ pattern: substring,
83
+ match_type: :substring,
84
+ key: key || @key,
85
+ block: block || @block
86
+ )
87
+ end
88
+
89
+ # Legacy method aliases for backward compatibility
90
+ def search(prefix, key = nil, &block)
91
+ by_prefix(prefix, key, &block)
92
+ end
93
+
64
94
  def find(prefix, key = nil, &block)
65
- search(prefix, key, &block)
95
+ by_prefix(prefix, key, &block)
66
96
  end
67
97
 
68
98
  def find_all(prefix, key = nil, &block)
69
- search(prefix, key, &block)
99
+ by_prefix(prefix, key, &block)
70
100
  end
71
101
 
72
102
  def resolve(prefix, key = nil, &block)
73
- search(prefix, key, &block)
103
+ by_prefix(prefix, key, &block)
74
104
  end
75
105
 
106
+ # Path-based matching
76
107
  def find_path(prefix, key = nil, &block)
77
108
  search_path(prefix, key, &block)
78
109
  end
@@ -119,18 +150,33 @@ class Hiiro
119
150
  end
120
151
 
121
152
  class Result
122
- attr_reader :matcher, :all_items, :key, :block, :prefix
153
+ attr_reader :matcher, :all_items, :key, :block, :pattern, :match_type
123
154
 
124
- def initialize(matcher:, all_items:, prefix:, key: nil, block: nil)
155
+ def initialize(matcher:, all_items:, pattern:, match_type: :prefix, key: nil, block: nil)
125
156
  @matcher = matcher
126
157
  @all_items = all_items
127
- @prefix = prefix
158
+ @pattern = pattern
159
+ @match_type = match_type
128
160
  @key = key
129
161
  @block = block
130
162
  end
131
163
 
164
+ # Alias for backward compatibility
165
+ def prefix
166
+ pattern
167
+ end
168
+
132
169
  def matches
133
- @matches ||= all_items.select { |item| item.extracted_item.to_s.start_with?(prefix.to_s) }
170
+ @matches ||= all_items.select { |item|
171
+ case match_type
172
+ when :prefix
173
+ item.extracted_item.to_s.start_with?(pattern.to_s)
174
+ when :substring
175
+ item.extracted_item.to_s.include?(pattern.to_s)
176
+ else
177
+ item.extracted_item.to_s.start_with?(pattern.to_s)
178
+ end
179
+ }
134
180
  end
135
181
 
136
182
  def count
@@ -142,7 +188,7 @@ class Hiiro
142
188
  end
143
189
 
144
190
  def exact_match
145
- all_items.find { |item| item.extracted_item == prefix }
191
+ all_items.find { |item| item.extracted_item == pattern }
146
192
  end
147
193
 
148
194
  def match
@@ -238,4 +284,7 @@ class Hiiro
238
284
  end
239
285
  end
240
286
  end
287
+
288
+ # Backward compatibility alias
289
+ PrefixMatcher = Matcher
241
290
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.90"
2
+ VERSION = "0.1.92"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -4,7 +4,7 @@ require "shellwords"
4
4
  require "pry"
5
5
 
6
6
  require_relative "hiiro/version"
7
- require_relative "hiiro/prefix_matcher"
7
+ require_relative "hiiro/matcher"
8
8
  require_relative "hiiro/git"
9
9
  require_relative "hiiro/options"
10
10
  require_relative "hiiro/notification"
data/plugins/pins.rb CHANGED
@@ -54,7 +54,7 @@ module Pins
54
54
  end
55
55
 
56
56
  def search(partial)
57
- Hiiro::PrefixMatcher.find(pins.keys.map(&:to_s), partial)
57
+ Hiiro::Matcher.by_prefix(pins.keys.map(&:to_s), partial)
58
58
  end
59
59
 
60
60
  def find(partial)
data/plugins/tasks.rb CHANGED
@@ -178,19 +178,19 @@ class Environment
178
178
  end
179
179
 
180
180
  def tree_matcher
181
- @tree_matcher ||= Hiiro::PrefixMatcher.new(all_trees, :name)
181
+ @tree_matcher ||= Hiiro::Matcher.new(all_trees, :name)
182
182
  end
183
183
 
184
184
  def session_matcher
185
- @session_matcher ||= Hiiro::PrefixMatcher.new(all_sessions, :name)
185
+ @session_matcher ||= Hiiro::Matcher.new(all_sessions, :name)
186
186
  end
187
187
 
188
188
  def app_matcher
189
- @app_matcher ||= Hiiro::PrefixMatcher.new(all_apps, :name)
189
+ @app_matcher ||= Hiiro::Matcher.new(all_apps, :name)
190
190
  end
191
191
 
192
192
  def task_matcher
193
- @task_matcher ||= Hiiro::PrefixMatcher.new(all_tasks, :name)
193
+ @task_matcher ||= Hiiro::Matcher.new(all_tasks, :name)
194
194
  end
195
195
 
196
196
  def task
@@ -286,7 +286,7 @@ class TaskManager
286
286
  return slash_lookup(name) if name.include?('/')
287
287
 
288
288
  key = (scope == :subtask) ? :short_name : :name
289
- Hiiro::PrefixMatcher.new(tasks, key).find(name).first&.item
289
+ Hiiro::Matcher.new(tasks, key).by_prefix(name).first&.item
290
290
  end
291
291
 
292
292
  def task_by_tree(tree_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.90
4
+ version: 0.1.92
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -103,9 +103,9 @@ files:
103
103
  - lib/hiiro/git/remote.rb
104
104
  - lib/hiiro/git/worktree.rb
105
105
  - lib/hiiro/git/worktrees.rb
106
+ - lib/hiiro/matcher.rb
106
107
  - lib/hiiro/notification.rb
107
108
  - lib/hiiro/options.rb
108
- - lib/hiiro/prefix_matcher.rb
109
109
  - lib/hiiro/shell.rb
110
110
  - lib/hiiro/todo.rb
111
111
  - lib/hiiro/version.rb