Skip to content

Commit 1c31bb6

Browse files
committed
feat(fs): add ideas_dir to Paths struct
Add ideas_dir field to track .opencoder/ideas/ directory path. Update Paths.deinit() to free the new path field. Ensure ideas directory is created during initialization. Update tests to verify ideas_dir is properly set. Signed-off-by: leocavalcante <[email protected]>
1 parent 97ace89 commit 1c31bb6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/fs.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub const Paths = struct {
2424
cycle_log_dir: []const u8,
2525
alerts_file: []const u8,
2626
history_dir: []const u8,
27+
ideas_dir: []const u8,
2728
allocator: Allocator,
2829

2930
/// Free all allocated paths
@@ -35,6 +36,7 @@ pub const Paths = struct {
3536
self.allocator.free(self.cycle_log_dir);
3637
self.allocator.free(self.alerts_file);
3738
self.allocator.free(self.history_dir);
39+
self.allocator.free(self.ideas_dir);
3840
}
3941
};
4042

@@ -71,6 +73,9 @@ pub fn initDirectories(project_dir: []const u8, allocator: Allocator) !Paths {
7173
const history_dir = try std.fs.path.join(allocator, &.{ opencoder_dir, "history" });
7274
errdefer allocator.free(history_dir);
7375

76+
const ideas_dir = try std.fs.path.join(allocator, &.{ opencoder_dir, "ideas" });
77+
errdefer allocator.free(ideas_dir);
78+
7479
// Create directories with better error context
7580
ensureDir(opencoder_dir) catch |err| {
7681
if (@import("builtin").is_test == false) {
@@ -90,6 +95,7 @@ pub fn initDirectories(project_dir: []const u8, allocator: Allocator) !Paths {
9095
try ensureDir(logs_dir);
9196
try ensureDir(cycle_log_dir);
9297
try ensureDir(history_dir);
98+
try ensureDir(ideas_dir);
9399

94100
return Paths{
95101
.opencoder_dir = opencoder_dir,
@@ -99,6 +105,7 @@ pub fn initDirectories(project_dir: []const u8, allocator: Allocator) !Paths {
99105
.cycle_log_dir = cycle_log_dir,
100106
.alerts_file = alerts_file,
101107
.history_dir = history_dir,
108+
.ideas_dir = ideas_dir,
102109
.allocator = allocator,
103110
};
104111
}
@@ -252,6 +259,7 @@ test "Paths construction" {
252259
try std.testing.expectEqualStrings("/tmp/opencoder_test_paths/.opencoder/state.json", paths.state_file);
253260
try std.testing.expectEqualStrings("/tmp/opencoder_test_paths/.opencoder/current_plan.md", paths.current_plan);
254261
try std.testing.expectEqualStrings("/tmp/opencoder_test_paths/.opencoder/history", paths.history_dir);
262+
try std.testing.expectEqualStrings("/tmp/opencoder_test_paths/.opencoder/ideas", paths.ideas_dir);
255263

256264
// Clean up
257265
fs.cwd().deleteTree("/tmp/opencoder_test_paths") catch {};

0 commit comments

Comments
 (0)