elelem-tools 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 +7 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +4 -0
- data/lib/elelem/tools/compact.rb +10 -0
- data/lib/elelem/tools/edit.rb +15 -0
- data/lib/elelem/tools/eval.rb +20 -0
- data/lib/elelem/tools/git.rb +15 -0
- data/lib/elelem/tools/glob.rb +13 -0
- data/lib/elelem/tools/grep.rb +22 -0
- data/lib/elelem/tools/init.rb +29 -0
- data/lib/elelem/tools/interview.rb +14 -0
- data/lib/elelem/tools/list.rb +14 -0
- data/lib/elelem/tools/shell.rb +23 -0
- data/lib/elelem/tools/task.rb +13 -0
- data/lib/elelem/tools/verify.rb +19 -0
- data/lib/elelem/tools/version.rb +7 -0
- data/lib/elelem/tools.rb +19 -0
- metadata +101 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 10d95e567040251074141f329ea4f0e1400a866715c8ca6b3c5c58f61136576a
|
|
4
|
+
data.tar.gz: 135c83d3d9945b31555a28012a5b0e9d91260d4d8e2e984de42f71461e8f76dc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c7026b46f8b420cb9be98b16282dda7a0048b909057b7c945e76df481a5b7139846ffe3f12239868c3829d43e45bc5da2a0f2e8155caa5b90f73001841ae6741
|
|
7
|
+
data.tar.gz: fb44a774890cafa5d26cf14eb8d5d7b117a73cd56bd8190c49cef711e7611aa7c431faf95b0b8b4ed0be399a65fb61a818bf7a76e66a73877bd36bdc4b4e410e
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mo khan
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:compact) do |agent|
|
|
4
|
+
agent.commands.register("compact", description: "Compress context") do
|
|
5
|
+
response = agent.turn("Summarize: accomplishments, state, next steps. Brief.")
|
|
6
|
+
agent.conversation.clear!
|
|
7
|
+
agent.conversation.add(role: "user", content: "Context: #{response}")
|
|
8
|
+
agent.terminal.say " → compacted"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:edit) do |agent|
|
|
4
|
+
agent.toolbox.add("edit",
|
|
5
|
+
description: "Replace first occurrence of text in file",
|
|
6
|
+
params: { path: { type: "string" }, old: { type: "string" }, new: { type: "string" } },
|
|
7
|
+
required: ["path", "old", "new"]
|
|
8
|
+
) do |args|
|
|
9
|
+
path = Pathname.new(args["path"]).expand_path
|
|
10
|
+
content = path.read
|
|
11
|
+
agent.toolbox
|
|
12
|
+
.run("write", { "path" => args["path"], "content" => content.sub(args["old"], args["new"]) })
|
|
13
|
+
.merge(replaced: args["old"], with: args["new"])
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:eval) do |agent|
|
|
4
|
+
description = <<~'DESC'
|
|
5
|
+
Evaluate Ruby code. Available API:
|
|
6
|
+
|
|
7
|
+
name = "search"
|
|
8
|
+
agent.toolbox.add(name, description: "Search using rg", params: { query: { type: "string" } }, required: ["query"], aliases: []) do |args|
|
|
9
|
+
agent.toolbox.run("execute", { "command" => "rg --json -nI -F #{args["query"]}" })
|
|
10
|
+
end
|
|
11
|
+
DESC
|
|
12
|
+
|
|
13
|
+
agent.toolbox.add("eval",
|
|
14
|
+
description: description,
|
|
15
|
+
params: { ruby: { type: "string" } },
|
|
16
|
+
required: ["ruby"]
|
|
17
|
+
) do |args|
|
|
18
|
+
{ result: binding.eval(args["ruby"]) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:git) do |agent|
|
|
4
|
+
agent.toolbox.add("git",
|
|
5
|
+
description: "Run git command",
|
|
6
|
+
params: { command: { type: "string" }, args: { type: "array", items: { type: "string" } } },
|
|
7
|
+
required: ["command"]
|
|
8
|
+
) do |args|
|
|
9
|
+
agent.toolbox.exec("git", args["command"], *(args["args"] || []))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
agent.toolbox.after("git") do |_, result|
|
|
13
|
+
agent.terminal.say " ! #{result[:error]}" if result[:error]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:glob) do |agent|
|
|
4
|
+
agent.toolbox.add("glob",
|
|
5
|
+
description: "Find files matching pattern",
|
|
6
|
+
params: { pattern: { type: "string" }, path: { type: "string" } },
|
|
7
|
+
required: ["pattern"]
|
|
8
|
+
) do |args|
|
|
9
|
+
path = args["path"].to_s.empty? ? "." : args["path"]
|
|
10
|
+
result = agent.toolbox.exec("fd", "--glob", args["pattern"], path)
|
|
11
|
+
result[:ok] ? result : agent.toolbox.exec("find", path, "-name", args["pattern"])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:grep) do |agent|
|
|
4
|
+
agent.toolbox.add("grep",
|
|
5
|
+
description: "Search file contents",
|
|
6
|
+
params: { pattern: { type: "string" }, path: { type: "string" }, glob: { type: "string" } },
|
|
7
|
+
required: ["pattern"]
|
|
8
|
+
) do |args|
|
|
9
|
+
path = args["path"].to_s.empty? ? "." : args["path"]
|
|
10
|
+
glob = args["glob"]
|
|
11
|
+
|
|
12
|
+
rg_args = ["rg", "-n", args["pattern"], path]
|
|
13
|
+
rg_args += ["-g", glob] if glob
|
|
14
|
+
result = agent.toolbox.exec(*rg_args)
|
|
15
|
+
next result if result[:ok]
|
|
16
|
+
|
|
17
|
+
grep_args = ["grep", "-rn"]
|
|
18
|
+
grep_args += ["--include", glob] if glob
|
|
19
|
+
grep_args += [args["pattern"], path]
|
|
20
|
+
agent.toolbox.exec(*grep_args)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:init) do |agent|
|
|
4
|
+
agent.commands.register("init", description: "Generate AGENTS.md") do
|
|
5
|
+
system_prompt = <<~PROMPT
|
|
6
|
+
AGENTS.md generator. Analyze codebase and write AGENTS.md to project root.
|
|
7
|
+
|
|
8
|
+
# AGENTS.md Spec (https://agents.md/)
|
|
9
|
+
A file providing context and instructions for AI coding agents.
|
|
10
|
+
|
|
11
|
+
## Recommended Sections
|
|
12
|
+
- Commands: build, test, lint commands
|
|
13
|
+
- Code Style: conventions, patterns
|
|
14
|
+
- Architecture: key components and flow
|
|
15
|
+
- Testing: how to run tests
|
|
16
|
+
|
|
17
|
+
## Process
|
|
18
|
+
1. Read README.md if present
|
|
19
|
+
2. Identify language (Gemfile, package.json, go.mod)
|
|
20
|
+
3. Find test scripts (bin/test, npm test)
|
|
21
|
+
4. Check linter configs
|
|
22
|
+
5. Write concise AGENTS.md
|
|
23
|
+
|
|
24
|
+
Keep it minimal. No fluff.
|
|
25
|
+
PROMPT
|
|
26
|
+
|
|
27
|
+
agent.fork(system_prompt: system_prompt).turn("Generate AGENTS.md for this project")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:interview) do |agent|
|
|
4
|
+
agent.toolbox.add("interview",
|
|
5
|
+
description: "Ask the user a question and wait for their response",
|
|
6
|
+
params: {
|
|
7
|
+
question: { type: "string", description: "The question to ask the user" },
|
|
8
|
+
},
|
|
9
|
+
required: ["question"]
|
|
10
|
+
) do |args|
|
|
11
|
+
agent.terminal.say(agent.terminal.markdown(args["question"]))
|
|
12
|
+
{ answer: agent.terminal.ask("> ") }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:list) do |agent|
|
|
4
|
+
agent.toolbox.add("list",
|
|
5
|
+
description: "List directory contents",
|
|
6
|
+
params: { path: { type: "string" }, recursive: { type: "boolean" } },
|
|
7
|
+
required: [],
|
|
8
|
+
aliases: ["ls"]
|
|
9
|
+
) do |args|
|
|
10
|
+
path = args["path"] && !args["path"].empty? ? args["path"] : "."
|
|
11
|
+
flags = args["recursive"] ? "-laR" : "-la"
|
|
12
|
+
agent.toolbox.exec("ls", flags, path)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:shell) do |agent|
|
|
4
|
+
strip_ansi = ->(text) do
|
|
5
|
+
text
|
|
6
|
+
.gsub(/^Script started.*?\n/, "")
|
|
7
|
+
.gsub(/\nScript done.*$/, "")
|
|
8
|
+
.gsub(/\e\].*?(?:\a|\e\\)/, "")
|
|
9
|
+
.gsub(/\e\[[0-9;?]*[A-Za-z]/, "")
|
|
10
|
+
.gsub(/\e[PX^_].*?\e\\/, "")
|
|
11
|
+
.gsub(/\e./, "")
|
|
12
|
+
.gsub(/[\b]/, "")
|
|
13
|
+
.gsub(/\r/, "")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
agent.commands.register("shell", description: "Start interactive shell") do
|
|
17
|
+
transcript = Tempfile.create do |file|
|
|
18
|
+
system("script", "-q", file.path, chdir: Dir.pwd)
|
|
19
|
+
strip_ansi.call(File.read(file.path))
|
|
20
|
+
end
|
|
21
|
+
agent.conversation.add(role: "user", content: transcript) unless transcript.strip.empty?
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:task) do |agent|
|
|
4
|
+
agent.toolbox.add("task",
|
|
5
|
+
description: "Delegate subtask to focused agent (complex searches, multi-file analysis)",
|
|
6
|
+
params: { prompt: { type: "string" } },
|
|
7
|
+
required: ["prompt"]
|
|
8
|
+
) do |args|
|
|
9
|
+
sub = agent.fork(system_prompt: "Research agent. Search, analyze, report. Be concise.")
|
|
10
|
+
sub.turn(args["prompt"])
|
|
11
|
+
{ result: sub.conversation.last[:content] }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Elelem::Plugins.register(:verify) do |agent|
|
|
4
|
+
agent.toolbox.add("verify",
|
|
5
|
+
description: "Verify file syntax and run tests",
|
|
6
|
+
params: { path: { type: "string" } },
|
|
7
|
+
required: ["path"]
|
|
8
|
+
) do |args|
|
|
9
|
+
path = args["path"]
|
|
10
|
+
Elelem::Plugins::Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
|
|
11
|
+
agent.terminal.say agent.toolbox.header("execute", { "command" => cmd })
|
|
12
|
+
v = agent.toolbox.run("execute", { "command" => cmd })
|
|
13
|
+
break v.merge(path: path, command: cmd) if v[:exit_status] != 0
|
|
14
|
+
|
|
15
|
+
memo[:verified] << cmd
|
|
16
|
+
memo
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/elelem/tools.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "elelem"
|
|
4
|
+
require "pathname"
|
|
5
|
+
require "tempfile"
|
|
6
|
+
|
|
7
|
+
require_relative "tools/version"
|
|
8
|
+
require_relative "tools/compact"
|
|
9
|
+
require_relative "tools/edit"
|
|
10
|
+
require_relative "tools/eval"
|
|
11
|
+
require_relative "tools/git"
|
|
12
|
+
require_relative "tools/glob"
|
|
13
|
+
require_relative "tools/grep"
|
|
14
|
+
require_relative "tools/init"
|
|
15
|
+
require_relative "tools/interview"
|
|
16
|
+
require_relative "tools/list"
|
|
17
|
+
require_relative "tools/shell"
|
|
18
|
+
require_relative "tools/task"
|
|
19
|
+
require_relative "tools/verify"
|
metadata
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: elelem-tools
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- mo khan
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: elelem
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.10'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.10'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: pathname
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0.5'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.5'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: tempfile
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.3'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0.3'
|
|
54
|
+
description: Adds tools to elelem.
|
|
55
|
+
email:
|
|
56
|
+
- mo@mokhan.ca
|
|
57
|
+
executables: []
|
|
58
|
+
extensions: []
|
|
59
|
+
extra_rdoc_files: []
|
|
60
|
+
files:
|
|
61
|
+
- LICENSE.txt
|
|
62
|
+
- Rakefile
|
|
63
|
+
- lib/elelem/tools.rb
|
|
64
|
+
- lib/elelem/tools/compact.rb
|
|
65
|
+
- lib/elelem/tools/edit.rb
|
|
66
|
+
- lib/elelem/tools/eval.rb
|
|
67
|
+
- lib/elelem/tools/git.rb
|
|
68
|
+
- lib/elelem/tools/glob.rb
|
|
69
|
+
- lib/elelem/tools/grep.rb
|
|
70
|
+
- lib/elelem/tools/init.rb
|
|
71
|
+
- lib/elelem/tools/interview.rb
|
|
72
|
+
- lib/elelem/tools/list.rb
|
|
73
|
+
- lib/elelem/tools/shell.rb
|
|
74
|
+
- lib/elelem/tools/task.rb
|
|
75
|
+
- lib/elelem/tools/verify.rb
|
|
76
|
+
- lib/elelem/tools/version.rb
|
|
77
|
+
homepage: https://src.mokhan.ca/elelem/tools
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
metadata:
|
|
81
|
+
allowed_push_host: https://rubygems.org
|
|
82
|
+
homepage_uri: https://src.mokhan.ca/elelem/tools
|
|
83
|
+
source_code_uri: https://src.mokhan.ca/elelem/tools
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: 4.0.0
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubygems_version: 4.0.20
|
|
99
|
+
specification_version: 4
|
|
100
|
+
summary: Optional tools for elelem.
|
|
101
|
+
test_files: []
|