Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/tri/tri_utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,16 @@ pub const CLIState = struct {
const corpus = try allocator.create(tvc.TVCCorpus);
corpus.initInPlace();
// Try loading existing corpus from disk (load into heap-allocated struct)
corpus.loadInto(TVC_CORPUS_PATH) catch {};
corpus.loadInto(TVC_CORPUS_PATH) catch |err| {
std.log.debug("corpus load: {s}", .{@errorName(err)});
};

// Codebase Context Manager (Cycle 92)
const ctx_mgr = try allocator.create(tri_context.ContextManager);
ctx_mgr.* = tri_context.ContextManager.init(allocator);
ctx_mgr.loadIndex() catch {};
ctx_mgr.loadIndex() catch |err| {
std.log.debug("context index load: {s}", .{@errorName(err)});
};

// Read API keys from environment
const groq_key = std.process.getEnvVarOwned(allocator, "GROQ_API_KEY") catch null;
Expand Down Expand Up @@ -362,15 +366,19 @@ pub const CLIState = struct {
// Save context index before exit (Cycle 92)
if (self.context_mgr) |mgr| {
if (mgr.is_dirty) {
mgr.saveIndex() catch {};
mgr.saveIndex() catch |err| {
std.log.debug("context index save: {s}", .{@errorName(err)});
};
}
mgr.deinit();
self.allocator.destroy(mgr);
self.context_mgr = null;
}
// Save TVC corpus to disk before exit
if (self.tvc_corpus) |corpus| {
corpus.save(TVC_CORPUS_PATH) catch {};
corpus.save(TVC_CORPUS_PATH) catch |err| {
std.log.debug("corpus save: {s}", .{@errorName(err)});
};
self.allocator.destroy(corpus);
self.tvc_corpus = null;
}
Expand Down
Loading