hiiro 0.1.132 → 0.1.133
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 +4 -4
- data/bin/h-claude +97 -0
- data/lib/hiiro/version.rb +1 -1
- data/lib/hiiro.rb +18 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1fad92bb1b8ae6893d1b27fe0c9f077c938fbdafb440cedeabb8dedf50f09f31
|
|
4
|
+
data.tar.gz: 6c702fe77535f178498b5bf561edcde9f247dca6b816b2d1ee68bb9985fb0a25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 599336e66a32564d50eda3c945b7a01be369aa751a0e738f8083e793c35e9a427a976ce508028ca9ef6ff0b75d2bcc888d19d10668bd93b65355358ad2bac6c8
|
|
7
|
+
data.tar.gz: da2877f35766f04272a6cb8b4a0c62a4d8d5a2b427fb8366dcba7246ec295cf6060915afb94ca335eb055785c543bf0b656a22d99bf7d37dc3f62568325181b5
|
data/bin/h-claude
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'hiiro'
|
|
4
4
|
require 'shellwords'
|
|
5
|
+
require 'tempfile'
|
|
5
6
|
|
|
6
7
|
opts = Hiiro::Options.setup {
|
|
7
8
|
flag(:danger, short: :d, default: false)
|
|
@@ -55,4 +56,100 @@ Hiiro.run(*ARGV, plugins: [Pins]) {
|
|
|
55
56
|
|
|
56
57
|
system('tmux', 'split-window', '-v', '-l', size, start_command(opts))
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
add_subcmd(:env) { |*args|
|
|
61
|
+
ap ENV
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
add_subcmd(:inline) { |*args|
|
|
65
|
+
if args.empty? && !$stdin.tty?
|
|
66
|
+
prompt = $stdin.read.strip
|
|
67
|
+
elsif args.any?
|
|
68
|
+
prompt = args.join(' ')
|
|
69
|
+
else
|
|
70
|
+
tmpfile = Tempfile.new(['claude-inline-', '.md'])
|
|
71
|
+
tmpfile.close
|
|
72
|
+
editor = ENV['EDITOR'] || 'vim'
|
|
73
|
+
system(editor, tmpfile.path)
|
|
74
|
+
prompt = File.read(tmpfile.path).strip
|
|
75
|
+
tmpfile.unlink
|
|
76
|
+
if prompt.empty?
|
|
77
|
+
puts "Aborted (empty file)"
|
|
78
|
+
next
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
IO.popen(['claude', '-p'], 'w') { |io| io.write(prompt) }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
add_subcmd(:loop) { |*args|
|
|
86
|
+
editor = ENV['EDITOR'] || 'vim'
|
|
87
|
+
separator = "-" * 72
|
|
88
|
+
history = []
|
|
89
|
+
|
|
90
|
+
loop do
|
|
91
|
+
tmpfile = Tempfile.new(['claude-loop-', '.md'])
|
|
92
|
+
|
|
93
|
+
if history.any?
|
|
94
|
+
lines = []
|
|
95
|
+
history.each_with_index do |(prev_prompt, response), i|
|
|
96
|
+
lines << "# Prompt #{i + 1} (old - do not edit)"
|
|
97
|
+
prev_prompt.lines.each { |l| lines << "> #{l.chomp}" }
|
|
98
|
+
lines << ""
|
|
99
|
+
lines << "## Response #{i + 1}"
|
|
100
|
+
lines << response
|
|
101
|
+
lines << ""
|
|
102
|
+
end
|
|
103
|
+
lines << separator
|
|
104
|
+
lines << "# Put your new prompt below this line"
|
|
105
|
+
lines << ""
|
|
106
|
+
tmpfile.write(lines.join("\n"))
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
tmpfile.close
|
|
110
|
+
system(editor, tmpfile.path)
|
|
111
|
+
content = File.read(tmpfile.path).strip
|
|
112
|
+
tmpfile.unlink
|
|
113
|
+
|
|
114
|
+
if content.empty?
|
|
115
|
+
puts "Done."
|
|
116
|
+
break
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Extract only the new prompt (below the separator)
|
|
120
|
+
if content.include?(separator)
|
|
121
|
+
new_prompt = content.split(separator, 2).last.strip
|
|
122
|
+
# Strip the instruction line if present
|
|
123
|
+
new_prompt = new_prompt.sub(/\A# Put your new prompt below this line\n*/, '').strip
|
|
124
|
+
else
|
|
125
|
+
new_prompt = content.strip
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if new_prompt.empty?
|
|
129
|
+
puts "Done."
|
|
130
|
+
break
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Build the full prompt with context for claude
|
|
134
|
+
full_prompt = ""
|
|
135
|
+
if history.any?
|
|
136
|
+
history.each_with_index do |(prev_prompt, response), i|
|
|
137
|
+
full_prompt << "--- Previous prompt #{i + 1} ---\n#{prev_prompt}\n\n"
|
|
138
|
+
full_prompt << "--- Response #{i + 1} ---\n#{response}\n\n"
|
|
139
|
+
end
|
|
140
|
+
full_prompt << "--- New prompt ---\n"
|
|
141
|
+
end
|
|
142
|
+
full_prompt << new_prompt
|
|
143
|
+
|
|
144
|
+
puts "\nSending to claude...\n\n"
|
|
145
|
+
response = IO.popen(['claude', '-p'], 'r+') { |io|
|
|
146
|
+
io.write(full_prompt)
|
|
147
|
+
io.close_write
|
|
148
|
+
io.read
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
puts response
|
|
152
|
+
history << [new_prompt, response]
|
|
153
|
+
end
|
|
154
|
+
}
|
|
58
155
|
}
|
data/lib/hiiro/version.rb
CHANGED
data/lib/hiiro.rb
CHANGED
|
@@ -79,6 +79,10 @@ class Hiiro
|
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
def self.options(&block)
|
|
83
|
+
Options.setup(&block)
|
|
84
|
+
end
|
|
85
|
+
|
|
82
86
|
def self.run(*args, plugins: [], logging: false, tasks: false, task_scope: nil, **values, &block)
|
|
83
87
|
hiiro = init(*args, plugins:, logging:, tasks:, task_scope:, **values, &block)
|
|
84
88
|
|
|
@@ -99,6 +103,7 @@ class Hiiro
|
|
|
99
103
|
attr_reader :logging
|
|
100
104
|
attr_reader :global_values
|
|
101
105
|
attr_reader :task_scope
|
|
106
|
+
attr_reader :opts
|
|
102
107
|
|
|
103
108
|
def initialize(bin, *all_args, logging: false, tasks: false, task_scope: nil, **values)
|
|
104
109
|
@bin = bin
|
|
@@ -208,9 +213,9 @@ class Hiiro
|
|
|
208
213
|
runners.add_default(handler, **global_values, **values)
|
|
209
214
|
end
|
|
210
215
|
|
|
211
|
-
def add_subcommand(*names, **values, &handler)
|
|
216
|
+
def add_subcommand(*names, opts: nil, **values, &handler)
|
|
212
217
|
names.each do |name|
|
|
213
|
-
runners.add_subcommand(name, handler, **global_values, **values)
|
|
218
|
+
runners.add_subcommand(name, handler, opts: opts, **global_values, **values)
|
|
214
219
|
end
|
|
215
220
|
end
|
|
216
221
|
alias add_subcmd add_subcommand
|
|
@@ -403,8 +408,8 @@ class Hiiro
|
|
|
403
408
|
Dir.glob(pattern).map { |path| Bin.new(bin_name, path) }
|
|
404
409
|
end
|
|
405
410
|
|
|
406
|
-
def add_subcommand(name, handler, **values)
|
|
407
|
-
@subcommands[name] = Subcommand.new(bin_name, name, handler, values)
|
|
411
|
+
def add_subcommand(name, handler, opts: nil, **values)
|
|
412
|
+
@subcommands[name] = Subcommand.new(bin_name, name, handler, values, opts: opts)
|
|
408
413
|
end
|
|
409
414
|
|
|
410
415
|
def run_subcommand(name, *args)
|
|
@@ -493,18 +498,24 @@ class Hiiro
|
|
|
493
498
|
end
|
|
494
499
|
|
|
495
500
|
class Subcommand
|
|
496
|
-
attr_reader :bin_name, :name, :handler, :values
|
|
501
|
+
attr_reader :bin_name, :name, :handler, :values, :opts
|
|
497
502
|
alias subcommand_name name
|
|
498
503
|
|
|
499
|
-
def initialize(bin_name, name, handler, values={})
|
|
504
|
+
def initialize(bin_name, name, handler, values={}, opts: nil)
|
|
500
505
|
@bin_name = bin_name
|
|
501
506
|
@name = name.to_s
|
|
502
507
|
@handler = handler
|
|
503
508
|
@values = values || {}
|
|
509
|
+
@opts = opts
|
|
504
510
|
end
|
|
505
511
|
|
|
506
512
|
def run(*args)
|
|
507
|
-
|
|
513
|
+
if opts
|
|
514
|
+
parsed = opts.parse(args)
|
|
515
|
+
handler.call(parsed)
|
|
516
|
+
else
|
|
517
|
+
handler.call(*args)
|
|
518
|
+
end
|
|
508
519
|
end
|
|
509
520
|
|
|
510
521
|
def exact_match?(subcmd)
|