hiiro 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a553e1c19ac099d93b9232da28a1953a83b7c2a379c8ddb05475a43aa58e31fb
4
+ data.tar.gz: 33d06064609e82b1d1da5e7ec83ecfcd90d49cac93cc6a7b8cd3930ab4e48a57
5
+ SHA512:
6
+ metadata.gz: 4418cdbaa9056006099e9ec9e82eccc85c625ff380d4e92f93f1db6e4bc1b48a0b5617566c3c8d36c308b7db1c6f9caac4e9f596ac56663d5499be05bac1ce4b
7
+ data.tar.gz: bf153421fbf79ad299203ba871b9907521dd2674f554efb34619a90c84dfb4ab2b0c56c2d3b32cdab2820cd35efa94e5e5b0baa2d24dbf7619cd7181e98323bd
data/.config/.keep ADDED
File without changes
data/CLAUDE.md ADDED
@@ -0,0 +1,101 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Hiiro is a lightweight CLI framework for Ruby that enables building multi-command tools similar to `git` or `docker`. It provides subcommand dispatch, abbreviation matching (e.g., `h ex hel` matches `h example hello`), and a plugin system.
8
+
9
+ ## Development Commands
10
+
11
+ ```bash
12
+ # Edit the main h script
13
+ h edit
14
+
15
+ # List available subcommands
16
+ h
17
+
18
+ # Search plugin code
19
+ h plugin rg "pattern"
20
+
21
+ # Edit a specific plugin
22
+ h plugin edit pins
23
+
24
+ # Syntax check Ruby files
25
+ ruby -c bin/h
26
+ ruby -c plugins/*.rb
27
+ ```
28
+
29
+ There is no build step or test suite. This is a pure Ruby CLI tool.
30
+
31
+ ## Architecture
32
+
33
+ ### Core Components (bin/h)
34
+
35
+ The `Hiiro` class is the main entry point with these nested classes:
36
+
37
+ - **`Runners`** - Discovers executables matching `h-*` in PATH and manages inline subcommands. Implements exact and prefix-based matching.
38
+ - **`Runners::Bin`** - Represents external executables found in PATH
39
+ - **`Runners::Subcommand`** - Represents inline subcommands registered via blocks
40
+ - **`Args`** - Parses single-dash flags (`-abc` becomes flags `a`, `b`, `c`)
41
+ - **`Config`** - Manages `~/.config/hiiro/` directory structure
42
+
43
+ ### Subcommand Resolution Flow
44
+
45
+ 1. `Hiiro.init()` parses first arg as subcommand name
46
+ 2. `Runners` searches for exact match in subcommands and PATH executables
47
+ 3. If no exact match, tries prefix matching (abbreviations)
48
+ 4. Ambiguous matches show help with possible options
49
+
50
+ ### Plugin System
51
+
52
+ Plugins are Ruby modules with a `self.load(hiiro)` method:
53
+
54
+ ```ruby
55
+ module MyPlugin
56
+ def self.load(hiiro)
57
+ # Add methods to hiiro instance
58
+ hiiro.instance_eval do
59
+ def my_helper; end
60
+ end
61
+
62
+ # Register subcommands
63
+ hiiro.add_subcmd(:mycmd) { |*args| ... }
64
+ end
65
+ end
66
+ ```
67
+
68
+ Plugins auto-load from `~/.config/hiiro/plugins/`. Load order matters when plugins depend on each other (e.g., Task and Project depend on Tmux).
69
+
70
+ ### Global Values Pattern
71
+
72
+ Values passed to `Hiiro.init()` are available in subcommand handlers:
73
+
74
+ ```ruby
75
+ hiiro = Hiiro.init(*ARGV, cwd: Dir.pwd)
76
+ hiiro.add_subcmd(:pwd) do |*args, **values|
77
+ puts values[:cwd]
78
+ end
79
+ ```
80
+
81
+ ## Key Files
82
+
83
+ - `bin/h` - Core framework (~420 lines)
84
+ - `bin/h-*` - External subcommands (tmux wrappers, video operations)
85
+ - `plugins/*.rb` - Reusable plugin modules (Pins, Project, Task, Tmux, Notify)
86
+
87
+ ## External Dependencies
88
+
89
+ - Ruby with `pry` gem
90
+ - `tmux` for session/window/pane management
91
+ - `ffmpeg`/`ffprobe` for video operations (h-video)
92
+ - `terminal-notifier` for macOS notifications (notify plugin)
93
+
94
+ ## Configuration Locations
95
+
96
+ All config lives in `~/.config/hiiro/`:
97
+ - `plugins/` - Auto-loaded plugin files
98
+ - `pins/` - Per-command YAML key-value storage
99
+ - `tasks/` - Task metadata for worktree management
100
+ - `projects.yml` - Project directory aliases
101
+ - `apps.yml` - App directory mappings for task plugin
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # Hiiro
2
+
3
+ A lightweight, extensible CLI framework for Ruby. Build your own multi-command tools similar to `git` or `docker`.
4
+
5
+ ## Features
6
+
7
+ - **Subcommand dispatch** - Route commands to executables or Ruby blocks
8
+ - **Abbreviation matching** - Type `h ex hel` instead of `h example hello`
9
+ - **Plugin system** - Extend functionality with reusable modules
10
+ - **Per-command storage** - Each command gets its own pin/config namespace
11
+
12
+ See [docs/](docs/) for detailed documentation on all subcommands.
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ # Copy the main script
18
+ cp bin/h ~/bin/h
19
+ chmod +x ~/bin/h
20
+
21
+ # Copy subcommands (optional)
22
+ cp bin/h-* ~/bin/
23
+
24
+ # Copy plugins (optional)
25
+ mkdir -p ~/.config/hiiro/plugins
26
+ cp plugins/*.rb ~/.config/hiiro/plugins/
27
+ ```
28
+
29
+ Ensure `~/bin` is in your `$PATH`.
30
+
31
+ ### Dependencies
32
+
33
+ ```sh
34
+ gem install pry
35
+ # For notify plugin (macOS)
36
+ brew install terminal-notifier
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```sh
42
+ # List available subcommands
43
+ h
44
+
45
+ # Edit the main h script
46
+ h edit
47
+
48
+ # Get paths
49
+ h path # Print current directory
50
+ h ppath # Print project root (git repo root + relative dir)
51
+ h rpath # Print relative directory from git root
52
+
53
+ # Simple test
54
+ h ping
55
+ # => pong
56
+ ```
57
+
58
+ ## Adding Subcommands
59
+
60
+ ### Method 1: External Executables
61
+
62
+ Create an executable named `h-<subcommand>` anywhere in your `$PATH`:
63
+
64
+ ```sh
65
+ # ~/bin/h-greet
66
+ #!/bin/bash
67
+ echo "Hello, $1!"
68
+ ```
69
+
70
+ ```sh
71
+ h greet World
72
+ # => Hello, World!
73
+ ```
74
+
75
+ For nested subcommands, use hiiro in your script:
76
+
77
+ ```ruby
78
+ #!/usr/bin/env ruby
79
+ # ~/bin/h-example
80
+
81
+ load File.join(Dir.home, 'bin/h')
82
+
83
+ Hiiro.init(*ARGV) do |hiiro|
84
+ hiiro.add_subcommand(:hello) { puts "Hi!" }
85
+ hiiro.add_subcommand(:bye) { puts "Goodbye!" }
86
+ end.run
87
+ ```
88
+
89
+ ```sh
90
+ h example hello # => Hi!
91
+ h example bye # => Goodbye!
92
+ ```
93
+
94
+ ### Method 2: Inline Subcommands
95
+
96
+ Modify `bin/h` directly to add subcommands to the base `h` command:
97
+
98
+ ```ruby
99
+ hiiro = Hiiro.init(*ARGV, plugins: [Pins, Project, Task], cwd: Dir.pwd)
100
+
101
+ hiiro.add_subcommand(:hello) do |*args|
102
+ puts "Hello, #{args.first || 'World'}!"
103
+ end
104
+
105
+ hiiro.run
106
+ ```
107
+
108
+ Global values (like `cwd`) are passed to all subcommand handlers via keyword arguments:
109
+
110
+ ```ruby
111
+ hiiro.add_subcommand(:pwd) do |*args, **values|
112
+ puts values[:cwd] # Access the cwd passed during init
113
+ end
114
+ ```
115
+
116
+ ## Abbreviations
117
+
118
+ Any subcommand can be abbreviated as long as the prefix uniquely matches:
119
+
120
+ ```sh
121
+ h ex hel # matches h example hello
122
+ h te # matches h test (if unique)
123
+ h pp # matches h ppath
124
+ ```
125
+
126
+ If multiple commands match, the first match wins and a warning is logged (when logging is enabled).
127
+
128
+ ## Built-in Plugins
129
+
130
+ ### Pins
131
+
132
+ Key-value storage persisted per command:
133
+
134
+ ```sh
135
+ h pin # List all pins
136
+ h pin mykey # Get value
137
+ h pin mykey myvalue # Set value
138
+ h pin set mykey myvalue # Set value (explicit)
139
+ h pin rm mykey # Remove pin
140
+ ```
141
+
142
+ Pins are stored in `~/.config/hiiro/pins/<command>.yml`.
143
+
144
+ ### Tmux Subcommands
145
+
146
+ Hiiro includes several tmux wrapper commands for managing sessions, windows, panes, and buffers. See [docs/](docs/) for full documentation.
147
+
148
+ ```sh
149
+ h session ls # List tmux sessions
150
+ h window new # Create new window
151
+ h pane split # Split current pane
152
+ h buffer ls # List paste buffers
153
+ ```
154
+
155
+ ### Project
156
+
157
+ Quick project navigation with tmux integration:
158
+
159
+ ```sh
160
+ h project myproj # cd to ~/proj/myproj and start tmux session
161
+ ```
162
+
163
+ Projects can be configured in `~/.config/hiiro/projects.yml`:
164
+
165
+ ```yaml
166
+ myproject: /path/to/project
167
+ work: ~/work/main
168
+ ```
169
+
170
+ ### Task
171
+
172
+ Manage development tasks across git worktrees in `~/work/`:
173
+
174
+ ```sh
175
+ h task list # Show trees and their active tasks
176
+ h task start TICKET-123 # Start working on a task
177
+ h task status # Show current task info
178
+ h task app frontend # Open app directory in new tmux window
179
+ h task save # Save current tmux window state
180
+ h task stop # Release tree for other tasks
181
+ ```
182
+
183
+ Configure apps in `~/.config/hiiro/apps.yml`:
184
+
185
+ ```yaml
186
+ frontend: apps/frontend
187
+ api: services/api
188
+ admin: admin_portal/admin
189
+ ```
190
+
191
+ ### Notify (macOS)
192
+
193
+ Desktop notifications via `terminal-notifier`:
194
+
195
+ ```sh
196
+ h notify "Build complete"
197
+ h notify "Click me" "https://example.com"
198
+ ```
199
+
200
+ ### Video
201
+
202
+ FFmpeg wrapper for common video operations:
203
+
204
+ ```sh
205
+ h video info movie.mp4 # Human-readable video summary
206
+ h video resize720 movie.mp4 # Resize to 720p
207
+ h video clip movie.mp4 00:01:30 60 # Extract 60s clip starting at 1:30
208
+ h video gif movie.mp4 # Create animated GIF
209
+ h video help # Full command list
210
+ ```
211
+
212
+ See [docs/h-video.md](docs/h-video.md) for complete documentation.
213
+
214
+ ### Plugin
215
+
216
+ Manage hiiro plugins:
217
+
218
+ ```sh
219
+ h plugin ls # List installed plugins
220
+ h plugin edit pins # Edit a plugin file
221
+ h plugin rg "some_method" # Search plugin code
222
+ ```
223
+
224
+ ## Writing Plugins
225
+
226
+ Plugins are Ruby modules that extend Hiiro instances:
227
+
228
+ ```ruby
229
+ # ~/.config/hiiro/plugins/myplugin.rb
230
+
231
+ module MyPlugin
232
+ def self.load(hiiro)
233
+ attach_methods(hiiro)
234
+ add_subcommands(hiiro)
235
+ end
236
+
237
+ def self.add_subcommands(hiiro)
238
+ hiiro.add_subcmd(:mycmd) do |*args|
239
+ # command logic
240
+ end
241
+ end
242
+
243
+ def self.attach_methods(hiiro)
244
+ hiiro.instance_eval do
245
+ def my_helper
246
+ # helper method available to other plugins
247
+ end
248
+ end
249
+ end
250
+ end
251
+ ```
252
+
253
+ Load plugins in your command:
254
+
255
+ ```ruby
256
+ Hiiro.init(*ARGV, plugins: [MyPlugin]) do |hiiro|
257
+ # ...
258
+ end
259
+ ```
260
+
261
+ ## Configuration
262
+
263
+ All configuration lives in `~/.config/hiiro/`:
264
+
265
+ ```
266
+ ~/.config/hiiro/
267
+ plugins/ # Plugin files (auto-loaded)
268
+ pins/ # Pin storage (per command)
269
+ tasks/ # Task metadata
270
+ projects.yml # Project aliases
271
+ apps.yml # App directory mappings
272
+ ```
273
+
274
+ ## License
275
+
276
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build