diff --git a/src/automation/condition_llm.jl b/archived/automation/condition_llm.jl similarity index 100% rename from src/automation/condition_llm.jl rename to archived/automation/condition_llm.jl diff --git a/src/automation/selector_llm.jl b/archived/automation/selector_llm.jl similarity index 100% rename from src/automation/selector_llm.jl rename to archived/automation/selector_llm.jl diff --git a/src/file_io/Conversation_JSON.jl b/archived/file_io/Conversation_JSON.jl similarity index 100% rename from src/file_io/Conversation_JSON.jl rename to archived/file_io/Conversation_JSON.jl diff --git a/archived/file_io/Persistable.jl b/archived/file_io/Persistable.jl new file mode 100644 index 0000000..ccac5e8 --- /dev/null +++ b/archived/file_io/Persistable.jl @@ -0,0 +1,44 @@ + +using JSON3 +using JLD2 + +@kwdef mutable struct PersistableState + path::String + PersistableState(path::String) = (mkpath(path); new(expanduser(abspath(expanduser((path)))))) +end + + + +# persist!(conv::ConversationCTX) = save_message(conv) +# save_message(conv::ConversationCTX) = save_conversation_to_file(conv) +get_conversation_filename(p::PersistableState,conv_id::String) = (files = filter(f -> endswith(f, "_$(conv_id).log"), readdir(p.path)); isempty(files) ? nothing : joinpath(p.path, first(files))) + +function generate_overview(conv::CONV, conv_id::String, p::PersistableState) + @assert false + sanitized_chars = strip(replace(replace(first(conv.messages[1].content, 32), r"[^\w\s-]" => "_"), r"\s+" => "_"), '_') + return joinpath(p.path, "$(date_format(conv.timestamp))_$(sanitized_chars)_$(conv_id).log") +end + +(p::PersistableState)(conv::Session) = begin + println(conversaion_path(p, conv)) + mkpath_if_missing(joinpath(p.path, conv.id)) + mkpath_if_missing(conversaion_path(p, conv)) + save_conversation(conversaion_file(p, conv), conv) + conv +end + + + +export VirtualWorkspace, init_virtual_workspace_path + +struct VirtualWorkspace + rel_path::String +end + +function init_virtual_workspace_path(p::PersistableState, conv_ctx::Session) + vpath = joinpath(conv_ctx.id, "workspace") + rel_path = mkdir(expanduser(joinpath(p.path, vpath))) + VirtualWorkspace(rel_path) +end + + diff --git a/src/file_io/custom_format.jl b/archived/file_io/custom_format.jl similarity index 100% rename from src/file_io/custom_format.jl rename to archived/file_io/custom_format.jl diff --git a/src/EasyContext.jl b/src/EasyContext.jl index 597aa50..e4020d2 100644 --- a/src/EasyContext.jl +++ b/src/EasyContext.jl @@ -18,14 +18,11 @@ include("tools/formats/format.jl") include("tools/tools.jl") include("prompts/guides.jl") include("ContextStructs.jl") -include("file_io/custom_format.jl") -include("file_io/Persistable.jl") include("protocol/AbstractTypes.jl") include("protocol/Message.jl") # include("protocol/CodeBlock.jl") include("protocol/Conversation.jl") include("protocol/Session.jl") -include("file_io/Conversation_JSON.jl") include("anthropic_extension.jl") include("Rephrase.v1.jl") include("chunkers/SourceChunks.jl") @@ -56,12 +53,6 @@ include("contexts/Contexts.jl") -# Automation -include("automation/selector_llm.jl") -include("automation/condition_llm.jl") - -include("model/persistence.jl") - include("precompile_scripts.jl") end # module EasyContext diff --git a/src/file_io/Persistable.jl b/src/file_io/Persistable.jl deleted file mode 100644 index 6054bbb..0000000 --- a/src/file_io/Persistable.jl +++ /dev/null @@ -1,13 +0,0 @@ - -using JSON3 -using JLD2 - -@kwdef mutable struct PersistableState - path::String - PersistableState(path::String) = (mkpath(path); new(expanduser(abspath(expanduser((path)))))) -end - - - -# persist!(conv::ConversationCTX) = save_message(conv) -# save_message(conv::ConversationCTX) = save_conversation_to_file(conv) diff --git a/src/loader/loaders.jl b/src/loader/loaders.jl index afa8c36..ffb2b6d 100644 --- a/src/loader/loaders.jl +++ b/src/loader/loaders.jl @@ -3,7 +3,6 @@ include("token_counter.jl") include("workspace_file_filters.jl") include("workspace_loader.jl") -include("virtual_workspace.jl") include("cached_loader.jl") include("julia_loader.jl") diff --git a/src/loader/virtual_workspace.jl b/src/loader/virtual_workspace.jl index 91d7375..e69de29 100644 --- a/src/loader/virtual_workspace.jl +++ b/src/loader/virtual_workspace.jl @@ -1,14 +0,0 @@ - -export VirtualWorkspace, init_virtual_workspace_path - -struct VirtualWorkspace - rel_path::String -end - -function init_virtual_workspace_path(p::PersistableState, conv_ctx::Session) - vpath = joinpath(conv_ctx.id, "workspace") - rel_path = mkdir(expanduser(joinpath(p.path, vpath))) - VirtualWorkspace(rel_path) -end - - diff --git a/src/model/persistence.jl b/src/model/persistence.jl deleted file mode 100644 index dae46f2..0000000 --- a/src/model/persistence.jl +++ /dev/null @@ -1,48 +0,0 @@ - -abstract type Workflow end - - -@kwdef mutable struct PersistableWorkFlowSettings - version::VersionNumber = v"1.0.0" - workflow - - timestamp::DateTime = now(UTC) - conv_ctx::Session - question_acc::QuestionCTX # TODO Question CTX to conv_ctx. so... with a function to get the question_acc actually.x - julia_ctx::JuliaCTX - workspace_ctx::WorkspaceCTX - version_control::Union{GitTracker,Nothing} - # workspace_paths::Vector{String} - # ignore... - git_paths::Vector{String} - - - logdir::String - config::Dict{String,Any} = Dict{String,Any}( - "detached_git_dev" => false, # Renamed here - # resume=args["resume"], - "silent" => false, - "loop" => false, - "show_tokens" => false, - "no_confirm" => false, - "compression" => true, - "checksum" => true - ) -end - - -(t::Workflow)(resume::PersistableWorkFlowSettings) = begin - typeof(t)(resume.conv_ctx; resume.persist, resume.question_acc, - resume.workspace_ctx, resume.julia_ctx, - resume.age_tracker, - resume.version_control, - no_confirm=resume.config["no_confirm"], ) -end - - - -# f <- c (load state + other clients interactions) -# f -> c (user interaction + ai interaction) -# f -> b (user_interaction) -# f <- b (ai_interaction) - diff --git a/src/precompile_scripts.jl b/src/precompile_scripts.jl index b784304..c1f2708 100644 --- a/src/precompile_scripts.jl +++ b/src/precompile_scripts.jl @@ -36,7 +36,6 @@ using DataStructures: OrderedDict # age_tracker = AgeTracker(max_history=14, cut_to=6) # question_acc = QuestionCTX() - # persister = PersistableState(logdir) # # Simulate usage of EasyContext functions # # print_project_tree(workspace_context.workspace, show_tokens=show_tokens) diff --git a/src/protocol/Conversation.jl b/src/protocol/Conversation.jl index cedf6fd..5da7b9d 100644 --- a/src/protocol/Conversation.jl +++ b/src/protocol/Conversation.jl @@ -75,7 +75,6 @@ update_last_user_message_meta(conv::CONV, itok::Int, otok::Int, cached::Int, cac last_msg(conv::CONV) = conv.messages[end].content get_message_separator(conv_id) = "===AISH_MSG_$(conv_id)===" -get_conversation_filename(p::PersistableState,conv_id::String) = (files = filter(f -> endswith(f, "_$(conv_id).log"), readdir(p.path)); isempty(files) ? nothing : joinpath(p.path, first(files))) function parse_conversation_filename(filename) m = match(CONVERSATION_FILE_REGEX, filename) @@ -87,12 +86,6 @@ function parse_conversation_filename(filename) end -function generate_overview(conv::CONV, conv_id::String, p::PersistableState) - @assert false - sanitized_chars = strip(replace(replace(first(conv.messages[1].content, 32), r"[^\w\s-]" => "_"), r"\s+" => "_"), '_') - return joinpath(p.path, "$(date_format(conv.timestamp))_$(sanitized_chars)_$(conv_id).log") -end - @kwdef mutable struct TODO <: CONV overview::String # max 20 token thing end diff --git a/src/protocol/Session.jl b/src/protocol/Session.jl index 3bc14ee..5974ef8 100644 --- a/src/protocol/Session.jl +++ b/src/protocol/Session.jl @@ -36,17 +36,10 @@ end conv end -abs_conversaion_path(p,conv::Session) = joinpath(abspath(expanduser(p.path)), conv.id, "conversations") -conversaion_path(p,conv::Session) = joinpath(p.path, conv.id, "conversations") -conversaion_file(p,conv::Session) = joinpath(conversaion_path(p, conv), "conversation.json") +abs_conversaion_path(p,conv::Session) = joinpath(abspath(expanduser(path)), conv.id, "conversations") +conversaion_path(path,conv::Session) = joinpath(path, conv.id, "conversations") +conversaion_file(path,conv::Session) = joinpath(conversaion_path(path, conv), "conversation.json") -(p::PersistableState)(conv::Session) = begin - println(conversaion_path(p, conv)) - mkpath_if_missing(joinpath(p.path, conv.id)) - mkpath_if_missing(conversaion_path(p, conv)) - save_conversation(conversaion_file(p, conv), conv) - conv -end function to_PT_messages(session::Session) return [ SystemMessage(session.system_message.content), diff --git a/src/stateful_transformation/GitTracker.jl b/src/stateful_transformation/GitTracker.jl index 52cc867..bef2147 100644 --- a/src/stateful_transformation/GitTracker.jl +++ b/src/stateful_transformation/GitTracker.jl @@ -21,7 +21,7 @@ end todo::String="" end -GitTracker!(ws, p::PersistableState, conv) = begin +GitTracker!(ws, path::String, conv) = begin # clean_unnamed() # TODO if there is branch name collision then regerenrate extending the list what we 'don't want' gits = WorkTree[] @@ -32,7 +32,7 @@ GitTracker!(ws, p::PersistableState, conv) = begin # proj_name = basename(normpath(project_path)) proj_name = get_project_name(expanded_project_path) - worktreepath = joinpath(p.path, conv.id, proj_name) # workpath cannot be ~ ... it MUST be expanded + worktreepath = joinpath(path, conv.id, proj_name) # workpath cannot be ~ ... it MUST be expanded ws.project_paths[i] = worktreepath create_worktree(expanded_project_path, worktreepath) @@ -40,7 +40,7 @@ GitTracker!(ws, p::PersistableState, conv) = begin push!(gits, WorkTree(LibGit2.GitRepo(worktreepath))) end ws.root_path, ws.rel_project_paths = resolve(ws.resolution_method, ws.project_paths) - conv_path = abs_conversaion_path(p, conv) + conv_path = abs_conversaion_path(path, conv) init_git(conv_path) conv_repo = LibGit2.GitRepo(conv_path)