Compare commits
No commits in common. "develop" and "feature/issue/9-add-support-for-jinja-template" have entirely different histories.
develop
...
feature/is
23 changed files with 71 additions and 133 deletions
|
@ -17,5 +17,5 @@ output_path: null
|
|||
prompt:
|
||||
header_path: null
|
||||
footer_path: null
|
||||
template_path: null
|
||||
template_path: misc/templates/default.j2
|
||||
#
|
||||
|
|
|
@ -158,12 +158,9 @@ ignore_list:
|
|||
- bin
|
||||
- prompts
|
||||
|
||||
prompt:
|
||||
header_path: prompts/context.txt
|
||||
footer_path: prompts/request-readme.txt
|
||||
template_path: null
|
||||
|
||||
output_file_path: null
|
||||
header_prompt_file_path: prompts/context.txt
|
||||
footer_prompt_file_path: prompts/request-readme.txt
|
||||
```
|
||||
|
||||
Then you can type a shorter command like:
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
Please focus on «@@ FILE ...» and analyze the content of «@@ FILE "{{FIXME: name of the file you want ot analyze}}"».
|
||||
|
||||
Provide your analysis as an appreciative feedback, stating:
|
||||
- what you appreciate in current version
|
||||
- what you would amplify / augment
|
||||
- what you would adjust / change / remplace
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Focus on the existing «@@ FILE "README.md"». and concentrate on your analysis and appreciative feedback too.
|
||||
|
||||
Please take in account each change you propose and write a fixed/improved version of the «@@ FILE "README.md"»
|
|
@ -1,10 +0,0 @@
|
|||
I would like to replace the hardcoded structure of the output "@@ ... " with a jinja template that would be handler with the crinja.cr shard.
|
||||
|
||||
My strategy is to preload the content during process_file and store it in a hash.
|
||||
Then the hash will be used in the end to render a final template (from crinja).
|
||||
|
||||
Can you please tell me :
|
||||
* where the changes should occur (which file? which class? which method?)
|
||||
* what kind of changes must be made there?
|
||||
|
||||
Please do not write code yet, simply explain.
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
We want to improve the README.md file as for an open-source project following the best practices.
|
||||
|
||||
Please focus on the code provided in the « @@ File ... » sections and analyze the existing « @@ File "README.md" », then take in account the content of class Config which analyzes the command line.
|
||||
|
||||
In this analysis of the existing « @@ File "README.md" », please provide me with a list of things that you appreciate, a list of things to amplify, a list of things to adjust.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
We want to improve the README.md file as for an open-source project following the best practices.
|
||||
|
||||
Please focus on the code provided in the « @@ File ... » sections and analyze the existing « @@ File "README.md" », then take in account the content of class Config which analyzes the command line.
|
||||
|
||||
Please concentrate on the detail of your analysis in your previous message and write a new improved/fixed version of « @@ File "README.md"
|
||||
|
16
prompts/footer-improve-readme.txt
Normal file
16
prompts/footer-improve-readme.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
@@ REQUEST (ANALYZE)
|
||||
|
||||
We want to improve the README.md file as for an open-source project following the best practices.
|
||||
|
||||
Please focus on the code provided in the « @@ File ... » sections and analyze the existing « @@ File "README.md" », then take in account the content of class Config which analyzes the command line.
|
||||
|
||||
In this analysis of the existing « @@ File "README.md" », please provide me with a list of things that you appreciate, a list of things to amplify, a list of things to adjust.
|
||||
|
||||
@@ REQUEST (WRITE)
|
||||
|
||||
We want to improve the README.md file as for an open-source project following the best practices.
|
||||
|
||||
Please focus on the code provided in the « @@ File ... » sections and analyze the existing « @@ File "README.md" », then take in account the content of class Config which analyzes the command line.
|
||||
|
||||
Please concentrate on the detail of your analysis in your previous message and write a new improved/fixed version of « @@ File "README.md"
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
@@REQUEST
|
||||
|
||||
I would like to change CLI parameters structure add add two subcommands:
|
||||
* init : which will create an example .code_preloader.yml file (with comments)
|
||||
* pack : which will create the packed version of the current directory for LLM prompting
|
|
@ -1,9 +1,5 @@
|
|||
version: 2.0
|
||||
shards:
|
||||
baked_file_system:
|
||||
git: https://github.com/schovi/baked_file_system.git
|
||||
version: 0.10.0
|
||||
|
||||
crinja:
|
||||
git: https://github.com/straight-shoota/crinja.git
|
||||
version: 0.8.1
|
||||
|
|
|
@ -18,9 +18,6 @@ dependencies:
|
|||
github: alexherbo2/walk.cr
|
||||
version_from_shard:
|
||||
github: hugopl/version_from_shard
|
||||
baked_file_system:
|
||||
github: schovi/baked_file_system
|
||||
version: 0.10.0
|
||||
# completion:
|
||||
# github: f/completion
|
||||
|
||||
|
|
|
@ -12,11 +12,10 @@ ignore_list:
|
|||
- complex/ignore2
|
||||
|
||||
# Path to the output file (if null, output to STDOUT)
|
||||
output_path: complex_output.txt
|
||||
output_file_path: complex_output.txt
|
||||
|
||||
prompt:
|
||||
# Optional: Path to a file containing the header prompt
|
||||
header_path: null
|
||||
# Optional: Path to a file containing the header prompt
|
||||
header_prompt_file_path: null
|
||||
|
||||
# Optional: Path to a file containing the footer prompt
|
||||
footer_path: null
|
||||
# Optional: Path to a file containing the footer prompt
|
||||
footer_prompt_file_path: null
|
||||
|
|
|
@ -11,11 +11,10 @@ ignore_list:
|
|||
- simple/ignore
|
||||
|
||||
# Path to the output file (if null, output to STDOUT)
|
||||
output_path: simple_output.txt
|
||||
output_file_path: simple_output.txt
|
||||
|
||||
prompt:
|
||||
# Optional: Path to a file containing the header prompt
|
||||
header_path: null
|
||||
# Optional: Path to a file containing the header prompt
|
||||
header_prompt_file_path: null
|
||||
|
||||
# Optional: Path to a file containing the footer prompt
|
||||
footer_path: null
|
||||
# Optional: Path to a file containing the footer prompt
|
||||
footer_prompt_file_path: null
|
||||
|
|
|
@ -50,7 +50,7 @@ describe CodePreloader::Config do
|
|||
config.subcommand.should eq(Config::Subcommand::Pack)
|
||||
config.pack_options.should be_truthy
|
||||
config.pack_options.try do |opts|
|
||||
opts.source_list.should eq ["path/to/repo1", "path/to/repo2"]
|
||||
opts.repository_path_list.should eq ["path/to/repo1", "path/to/repo2"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,7 +72,7 @@ describe CodePreloader::Config do
|
|||
config.subcommand.should eq(Config::Subcommand::Pack)
|
||||
config.pack_options.should be_truthy
|
||||
config.pack_options.try do |opts|
|
||||
opts.output_path.should eq "output.txt"
|
||||
opts.output_file_path.should eq "output.txt"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,9 +88,9 @@ describe CodePreloader::Config do
|
|||
# Assuming the simple_config.yml has specific settings
|
||||
config.pack_options.should be_truthy
|
||||
config.pack_options.try do |opts|
|
||||
opts.source_list.should eq ["path/to/repo"]
|
||||
opts.repository_path_list.should eq ["path/to/repo"]
|
||||
opts.ignore_list.should eq ["simple/ignore"]
|
||||
opts.output_path.should eq "simple_output.txt"
|
||||
opts.output_file_path.should eq "simple_output.txt"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,9 +103,9 @@ describe CodePreloader::Config do
|
|||
# Assuming the complex_config.yml has specific settings
|
||||
config.pack_options.should be_truthy
|
||||
config.pack_options.try do |opts|
|
||||
opts.source_list.should eq [repo_path]
|
||||
opts.repository_path_list.should eq [repo_path]
|
||||
opts.ignore_list.should eq ["complex/ignore1", "complex/ignore2"]
|
||||
opts.output_path.should eq "complex_output.txt"
|
||||
opts.output_file_path.should eq "complex_output.txt"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
require "spec"
|
||||
|
||||
ENV["CODE_PRELOADER_DETECT"] = "no"
|
||||
|
||||
# require "../src/"
|
||||
|
|
40
src/cli.cr
40
src/cli.cr
|
@ -6,7 +6,6 @@ require "crinja"
|
|||
|
||||
require "./config"
|
||||
require "./filelist"
|
||||
require "./file_storage"
|
||||
|
||||
# The CodePreloader module organizes classes and methods related to preloading code files.
|
||||
module CodePreloader
|
||||
|
@ -41,14 +40,35 @@ module CodePreloader
|
|||
abort("Unexpected nil value for init_options!") if init_options.nil?
|
||||
|
||||
# Default path for the .code_preloader.yml file
|
||||
default_config_path = ".code_preloader.yml"
|
||||
default_config_path = "example.code_preloader.yml"
|
||||
|
||||
# Use the specified path if provided, otherwise use the default
|
||||
config_path = init_options.config_path || default_config_path
|
||||
abort("ERROR: configuration file already exist: #{config_path}") if File.exists? config_path
|
||||
|
||||
# Content of the default .code_preloader.yml file
|
||||
config_content = FileStorage.get("default_config.yml").gets_to_end
|
||||
# Content of the .code_preloader.yml file
|
||||
config_content = [
|
||||
"---",
|
||||
"# Example configuration for Code-Preloader",
|
||||
"",
|
||||
"# List of repository paths to preload",
|
||||
"# source_list:",
|
||||
"# - \"path/to/repo1\"",
|
||||
"# - \"path/to/repo2\"",
|
||||
"",
|
||||
"# List of patterns to ignore during preloading",
|
||||
"ignore_list:",
|
||||
" - ^\\.git/.*",
|
||||
"",
|
||||
"# Path to the output file (if null, output to STDOUT)",
|
||||
"output_path: null",
|
||||
"",
|
||||
"# Optional: Path to a file containing the header prompt",
|
||||
"header_path: null",
|
||||
"",
|
||||
"# Optional: Path to a file containing the footer prompt",
|
||||
"footer_path: null",
|
||||
""
|
||||
].join("\n")
|
||||
|
||||
# Writing the configuration content to the file
|
||||
File.write(config_path, config_content)
|
||||
|
@ -96,12 +116,8 @@ module CodePreloader
|
|||
filelist.reject { |path| !!(path =~ Regex.new(ignore_pattern)) }
|
||||
end
|
||||
|
||||
STDERR.puts "Loading template file from: #{prompt_template_path ? prompt_template_path : "<internal>" }".colorize(:yellow)
|
||||
if prompt_template_path
|
||||
prompt_template_content = File.read(prompt_template_path)
|
||||
else
|
||||
prompt_template_content = FileStorage.get("default_template.j2").gets_to_end
|
||||
end
|
||||
abort("No prompt file defined!") if prompt_template_path.nil?
|
||||
prompt_template_content = File.read(prompt_template_path)
|
||||
|
||||
|
||||
if !prompt_header_path.nil?
|
||||
|
@ -127,7 +143,7 @@ module CodePreloader
|
|||
|
||||
STDERR.puts "Processing source directories: #{source_list}".colorize(:yellow)
|
||||
processed_files = [] of ProcessedFile
|
||||
filelist.to_a.sort.each do |file_path|
|
||||
filelist.each do |file_path|
|
||||
STDERR.puts "Processing file: #{file_path}".colorize(:yellow)
|
||||
file_result = process_file(file_path, output_file)
|
||||
processed_files << file_result
|
||||
|
|
|
@ -86,10 +86,8 @@ module CodePreloader
|
|||
def parse_pack_options(parser)
|
||||
@pack_options = PackOptions.new
|
||||
|
||||
unless ENV["CODE_PRELOADER_DETECT"]? =~ /(no|false|0)/i
|
||||
config_file = detect_config_file
|
||||
config_file.try { |path| load_pack_config(path) }
|
||||
end
|
||||
config_file = detect_config_file
|
||||
config_file.try { |path| load_pack_config(path) }
|
||||
|
||||
parser.banner = [
|
||||
"Usage: code-preloader pack [options] DIR ...\n",
|
||||
|
@ -101,7 +99,7 @@ module CodePreloader
|
|||
parser.on(
|
||||
"-c FILE",
|
||||
"--config=FILE",
|
||||
"Load parameters from FILE\n(default: autodetect)"
|
||||
"Load parameters from FILE\n(default: \".code_preload.yml\", if present)"
|
||||
) do |config_file|
|
||||
@pack_options.try { |opt| load_pack_config(config_file) }
|
||||
end
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
require "baked_file_system"
|
||||
|
||||
class FileStorage
|
||||
extend BakedFileSystem
|
||||
|
||||
bake_folder "../static"
|
||||
end
|
|
@ -46,7 +46,7 @@ module CodePreloader
|
|||
seen = Set(String).new
|
||||
|
||||
# walk each source
|
||||
@sources.sort.each do |dir|
|
||||
@sources.each do |dir|
|
||||
walker = Walk::Down.new(dir)
|
||||
|
||||
walker = walker.filter do |path|
|
||||
|
@ -88,7 +88,7 @@ module CodePreloader
|
|||
self.each do |path|
|
||||
files << path.to_s
|
||||
end
|
||||
files.sort
|
||||
files
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
# Example configuration for Code-Preloader
|
||||
|
||||
# List of repository paths to preload
|
||||
# source_list:
|
||||
# - "path/to/repo1"
|
||||
# - "path/to/repo2"
|
||||
|
||||
# List of patterns to ignore during preloading
|
||||
ignore_list:
|
||||
- ^\.git/.*
|
||||
|
||||
# Path to the output file (if null, output to STDOUT)
|
||||
output_path: null
|
||||
|
||||
prompt:
|
||||
# Optional: Path to a file containing the prompt header
|
||||
header_path: null
|
||||
|
||||
# Optional: Path to a file containing the prompt footer
|
||||
footer_path: null
|
||||
|
||||
# Optional: Path to a file container a jinja template to structure the prompt
|
||||
template_path: null
|
|
@ -1,16 +0,0 @@
|
|||
{%- if prompt_header -%}
|
||||
@@ CONTEXT
|
||||
|
||||
{{ prompt_header }}
|
||||
{%- endif -%}
|
||||
{%- for file in prompt_files -%}
|
||||
@@ FILE "{{ file.path }}" WITH MIME-TYPE "{{ file.mime_type }}"
|
||||
|
||||
{{- file.content -}}
|
||||
|
||||
{%- endfor -%}
|
||||
{%- if prompt_footer -%}
|
||||
@@ REQUEST
|
||||
|
||||
{{ prompt_footer }}
|
||||
{%- endif -%}
|
Loading…
Reference in a new issue