appydave-tools 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +9 -0
- data/bin/gpt_context.rb +77 -0
- data/lib/appydave/tools/gpt_context/file_collector.rb +82 -0
- data/lib/appydave/tools/version.rb +1 -1
- data/lib/appydave/tools.rb +2 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ee42ce5c9044d5a983fc3498d31ec92ccff797f79085f81ca041c83e5372f48
|
4
|
+
data.tar.gz: '014092b8684629253bcc8241e618272ccec12bc664d158c954a736da72534637'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3343f90930a9c5a6dfcc38abaf6ed909ae2b4470ed676c423d6d790a3f6e1fd38c9d131a3e540788becc8b915a730ebe44cef871ebb5f00001024b9da06d12
|
7
|
+
data.tar.gz: 47cd64a4281c46cd07c63c785862e98cb04911f8805788667b3860c7d50f9f415cf8fb626c3b59318e0c3b9e729d30ed66de6e71349f340716d7a4dd1e3e7632
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.0.2](https://github.com/klueless-io/appydave-tools/compare/v0.0.1...v0.0.2) (2024-05-07)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* update semantic dependency ([e76705e](https://github.com/klueless-io/appydave-tools/commit/e76705eb925f0be271884acc5af5119e3fa57325))
|
7
|
+
* update semantic dependency ([45623c4](https://github.com/klueless-io/appydave-tools/commit/45623c4575689ef1e813eb89bc9c55f3bf4d374f))
|
8
|
+
* update semantic dependency ([2ebb9bc](https://github.com/klueless-io/appydave-tools/commit/2ebb9bcb582b67b6bf4d8ccb6db9eff0e3b095e5))
|
9
|
+
|
1
10
|
## [Unreleased]
|
2
11
|
|
3
12
|
## [0.1.0] - 2024-05-07
|
data/bin/gpt_context.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Usage:
|
5
|
+
# ./bin/gpt_context.rb -d -i 'lib/openai_101/tools/**/*.rb'
|
6
|
+
# ./bin/gpt_context.rb -d -i 'lib/openai_101/tools/**/*' -e 'node_modules/**/*' -e 'package-lock.json' -e 'lib/openai_101/tools/prompts/*.txt'
|
7
|
+
#
|
8
|
+
# Get GPT Context Gatherer code
|
9
|
+
# ./bin/gpt_context.rb -i 'bin/**/*gather*.rb' -i 'lib/openai_101/tools/**/*gather*.rb'
|
10
|
+
require 'optparse'
|
11
|
+
require 'clipboard'
|
12
|
+
require_relative '../lib/appydave/tools/gpt_context/file_collector'
|
13
|
+
|
14
|
+
options = {
|
15
|
+
include_patterns: [],
|
16
|
+
exclude_patterns: [],
|
17
|
+
format: nil,
|
18
|
+
debug: false
|
19
|
+
}
|
20
|
+
|
21
|
+
OptionParser.new do |opts|
|
22
|
+
opts.banner = 'Usage: gather_content.rb [options]'
|
23
|
+
|
24
|
+
opts.on('-i', '--include PATTERN', 'Pattern or file to include (can be used multiple times)') do |pattern|
|
25
|
+
options[:include_patterns] << pattern
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on('-e', '--exclude PATTERN', 'Pattern or file to exclude (can be used multiple times)') do |pattern|
|
29
|
+
options[:exclude_patterns] << pattern
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on('-f', '--format FORMAT', 'Output format: default or tree') do |format|
|
33
|
+
options[:format] = format
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on('-d', '--debug', 'Enable debug mode') do
|
37
|
+
options[:debug] = true
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
41
|
+
puts opts
|
42
|
+
puts "\nExamples:"
|
43
|
+
puts " #{File.basename($PROGRAM_NAME)} -i 'lib/**/*.rb' -e 'lib/excluded/**/*.rb' -d"
|
44
|
+
puts " #{File.basename($PROGRAM_NAME)} --include 'src/**/*.js' --exclude 'src/vendor/**/*.js'"
|
45
|
+
|
46
|
+
puts ''
|
47
|
+
puts ' # Get GPT Context Gatherer code that is found in any folder (bin, lib & spec)'
|
48
|
+
puts " #{File.basename($PROGRAM_NAME)} -i '**/*gather*.rb'"
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end.parse!
|
52
|
+
|
53
|
+
if options[:include_patterns].empty? && options[:exclude_patterns].empty? && options[:format].nil?
|
54
|
+
script_name = File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME))
|
55
|
+
|
56
|
+
puts 'No options provided to GPT Context. Please specify patterns to include or exclude.'
|
57
|
+
puts "For help, run: #{script_name} --help"
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
|
61
|
+
pp options if options[:debug]
|
62
|
+
|
63
|
+
gatherer = Appydave::Tools::GptContext::FileCollector.new(
|
64
|
+
include_patterns: options[:include_patterns],
|
65
|
+
exclude_patterns: options[:exclude_patterns],
|
66
|
+
format: options[:format]
|
67
|
+
)
|
68
|
+
|
69
|
+
content = gatherer.build
|
70
|
+
|
71
|
+
if options[:debug]
|
72
|
+
puts '-' * 80
|
73
|
+
puts content
|
74
|
+
puts '-' * 80
|
75
|
+
end
|
76
|
+
|
77
|
+
Clipboard.copy(content)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
# Build GPT context from various sources
|
6
|
+
module GptContext
|
7
|
+
# Gathers file names and content based on include and exclude patterns
|
8
|
+
class FileCollector
|
9
|
+
attr_reader :include_patterns, :exclude_patterns, :format
|
10
|
+
|
11
|
+
def initialize(include_patterns: [], exclude_patterns: [], format: nil)
|
12
|
+
@include_patterns = include_patterns
|
13
|
+
@exclude_patterns = exclude_patterns
|
14
|
+
@format = format
|
15
|
+
end
|
16
|
+
|
17
|
+
def build
|
18
|
+
case format
|
19
|
+
when 'tree'
|
20
|
+
build_tree
|
21
|
+
else
|
22
|
+
build_content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build_content
|
29
|
+
concatenated_content = []
|
30
|
+
|
31
|
+
include_patterns.each do |pattern|
|
32
|
+
Dir.glob(pattern).each do |file_path|
|
33
|
+
next if excluded?(file_path) || File.directory?(file_path)
|
34
|
+
|
35
|
+
content = "# file: #{file_path}\n\n#{File.read(file_path)}"
|
36
|
+
concatenated_content << content
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
concatenated_content.join("\n\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_tree
|
44
|
+
tree_view = {}
|
45
|
+
|
46
|
+
include_patterns.each do |pattern|
|
47
|
+
Dir.glob(pattern).each do |file_path|
|
48
|
+
next if excluded?(file_path)
|
49
|
+
|
50
|
+
path_parts = file_path.split('/')
|
51
|
+
insert_into_tree(tree_view, path_parts)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
build_tree_pretty(tree_view).rstrip
|
56
|
+
end
|
57
|
+
|
58
|
+
def insert_into_tree(tree, path_parts)
|
59
|
+
node = tree
|
60
|
+
path_parts.each do |part|
|
61
|
+
node[part] ||= {}
|
62
|
+
node = node[part]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_tree_pretty(node, prefix: '', is_last: true, output: ''.dup)
|
67
|
+
node.each_with_index do |(part, child), index|
|
68
|
+
connector = is_last && index == node.size - 1 ? '└' : '├'
|
69
|
+
output << "#{prefix}#{connector}─ #{part}\n"
|
70
|
+
next_prefix = is_last && index == node.size - 1 ? ' ' : '│ '
|
71
|
+
build_tree_pretty(child, prefix: "#{prefix}#{next_prefix}", is_last: child.empty? || index == node.size - 1, output: output)
|
72
|
+
end
|
73
|
+
output
|
74
|
+
end
|
75
|
+
|
76
|
+
def excluded?(file_path)
|
77
|
+
exclude_patterns.any? { |pattern| File.fnmatch(pattern, file_path) }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/appydave/tools.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "appydave-tools",
|
3
|
-
"version": "0.0
|
3
|
+
"version": "0.1.0",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "appydave-tools",
|
9
|
-
"version": "0.0
|
9
|
+
"version": "0.1.0",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.3",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appydave-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: clipboard
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1'
|
27
27
|
description: " AppyDave YouTube Automation Tools\n"
|
28
28
|
email:
|
29
29
|
- david@ideasmen.com.au
|
@@ -45,8 +45,10 @@ files:
|
|
45
45
|
- README.md
|
46
46
|
- Rakefile
|
47
47
|
- bin/console
|
48
|
+
- bin/gpt_context.rb
|
48
49
|
- bin/setup
|
49
50
|
- lib/appydave/tools.rb
|
51
|
+
- lib/appydave/tools/gpt_context/file_collector.rb
|
50
52
|
- lib/appydave/tools/version.rb
|
51
53
|
- package-lock.json
|
52
54
|
- package.json
|