-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
executable file
·409 lines (348 loc) · 17.3 KB
/
build.zig
File metadata and controls
executable file
·409 lines (348 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
// --- build.zig ---
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "localharness",
.root_module = b.createModule(.{
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
}),
});
// SQLite bindings module
const sqlite_module = b.createModule(.{
.root_source_file = b.path("sqlite.zig"),
});
// Conversation database module (needs sqlite, types, ollama, markdown)
const conversation_db_module = b.createModule(.{
.root_source_file = b.path("conversation_db.zig"),
});
conversation_db_module.addImport("sqlite", sqlite_module);
// Will add types, ollama, markdown after they're created
// Core lexer module (no dependencies)
const lexer_module = b.createModule(.{
.root_source_file = b.path("lexer.zig"),
});
// Text utilities module (no dependencies)
const text_utils_module = b.createModule(.{
.root_source_file = b.path("text_utils.zig"),
});
// HTML utilities module (no dependencies)
const html_utils_module = b.createModule(.{
.root_source_file = b.path("tools/html_utils.zig"),
});
// Markdown module (depends on lexer)
const markdown_module = b.createModule(.{
.root_source_file = b.path("markdown.zig"),
});
markdown_module.addImport("lexer", lexer_module);
// Tree utility module (shared by ui and tools)
const tree_module = b.createModule(.{
.root_source_file = b.path("tools/tree.zig"),
});
// UI module - will be updated after app_module is created
const ui_module = b.createModule(.{
.root_source_file = b.path("ui.zig"),
});
ui_module.addImport("tree", tree_module);
// New modular architecture modules
const ollama_module = b.createModule(.{
.root_source_file = b.path("ollama.zig"),
});
const lmstudio_module = b.createModule(.{
.root_source_file = b.path("lmstudio.zig"),
});
lmstudio_module.addImport("ollama", ollama_module);
const embeddings_module = b.createModule(.{
.root_source_file = b.path("embeddings.zig"),
});
const zvdb_module = b.createModule(.{
.root_source_file = b.path("zvdb/src/zvdb.zig"),
});
const embedder_interface_module = b.createModule(.{
.root_source_file = b.path("embedder_interface.zig"),
});
embedder_interface_module.addImport("embeddings", embeddings_module);
embedder_interface_module.addImport("lmstudio", lmstudio_module);
const llm_provider_module = b.createModule(.{
.root_source_file = b.path("llm_provider.zig"),
});
llm_provider_module.addImport("ollama", ollama_module);
llm_provider_module.addImport("lmstudio", lmstudio_module);
llm_provider_module.addImport("embeddings", embeddings_module);
const permission_module = b.createModule(.{
.root_source_file = b.path("permission.zig"),
});
permission_module.addImport("ollama", ollama_module);
const state_module = b.createModule(.{
.root_source_file = b.path("state.zig"),
});
const config_module = b.createModule(.{
.root_source_file = b.path("config.zig"),
});
config_module.addImport("permission", permission_module);
config_module.addImport("llm_provider", llm_provider_module);
// Note: profile_manager will be added later after it's created
const context_module = b.createModule(.{
.root_source_file = b.path("context.zig"),
});
context_module.addImport("state", state_module);
context_module.addImport("config", config_module);
context_module.addImport("llm_provider", llm_provider_module);
context_module.addImport("zvdb", zvdb_module);
context_module.addImport("embedder_interface", embedder_interface_module);
// Will add agents and types after they're created
// Agents module (needed by app)
const agents_module = b.createModule(.{
.root_source_file = b.path("agents.zig"),
});
agents_module.addImport("ollama", ollama_module);
agents_module.addImport("llm_provider", llm_provider_module);
agents_module.addImport("config", config_module);
agents_module.addImport("zvdb", zvdb_module);
agents_module.addImport("embedder_interface", embedder_interface_module);
// Will add tools after it's created
// Now add agents to context_module
context_module.addImport("agents", agents_module);
const tools_module = b.createModule(.{
.root_source_file = b.path("tools.zig"),
});
tools_module.addImport("ollama", ollama_module);
tools_module.addImport("permission", permission_module);
tools_module.addImport("context", context_module);
tools_module.addImport("state", state_module);
tools_module.addImport("agents", agents_module);
tools_module.addImport("tree", tree_module);
tools_module.addImport("html_utils", html_utils_module);
// Will add file_curator and types after they're created
// Now that tools_module is created, add it to agents_module
agents_module.addImport("tools", tools_module);
// Now add tools to agents (circular dependency is OK with modules)
agents_module.addImport("tools", tools_module);
// Tool executor module (manages async tool execution with permissions)
const tool_executor_module = b.createModule(.{
.root_source_file = b.path("tool_executor.zig"),
});
tool_executor_module.addImport("ollama", ollama_module);
tool_executor_module.addImport("permission", permission_module);
tool_executor_module.addImport("tools", tools_module);
tool_executor_module.addImport("markdown", markdown_module);
tool_executor_module.addImport("context", context_module);
// UI state modules (need to be after tools_module)
const config_editor_state_module = b.createModule(.{
.root_source_file = b.path("config_editor_state.zig"),
});
config_editor_state_module.addImport("config", config_module);
config_editor_state_module.addImport("llm_provider", llm_provider_module);
const agent_builder_state_module = b.createModule(.{
.root_source_file = b.path("agent_builder_state.zig"),
});
agent_builder_state_module.addImport("tools", tools_module);
const help_state_module = b.createModule(.{
.root_source_file = b.path("help_state.zig"),
});
// UI helper modules (renderer + input for each state)
const config_editor_renderer_module = b.createModule(.{
.root_source_file = b.path("config_editor_renderer.zig"),
});
config_editor_renderer_module.addImport("config_editor_state", config_editor_state_module);
config_editor_renderer_module.addImport("ui", ui_module);
config_editor_renderer_module.addImport("llm_provider", llm_provider_module);
config_editor_renderer_module.addImport("text_utils", text_utils_module);
// Note: profile_manager will be added later after it's created
const config_editor_input_module = b.createModule(.{
.root_source_file = b.path("config_editor_input.zig"),
});
config_editor_input_module.addImport("config_editor_state", config_editor_state_module);
config_editor_input_module.addImport("llm_provider", llm_provider_module);
const agent_builder_renderer_module = b.createModule(.{
.root_source_file = b.path("agent_builder_renderer.zig"),
});
agent_builder_renderer_module.addImport("agent_builder_state", agent_builder_state_module);
agent_builder_renderer_module.addImport("ui", ui_module);
const agent_builder_input_module = b.createModule(.{
.root_source_file = b.path("agent_builder_input.zig"),
});
agent_builder_input_module.addImport("agent_builder_state", agent_builder_state_module);
// Will add agent_writer after it's created
const help_renderer_module = b.createModule(.{
.root_source_file = b.path("help_renderer.zig"),
});
help_renderer_module.addImport("help_state", help_state_module);
help_renderer_module.addImport("ui", ui_module);
const help_input_module = b.createModule(.{
.root_source_file = b.path("help_input.zig"),
});
help_input_module.addImport("help_state", help_state_module);
// Profile management modules
const profile_manager_module = b.createModule(.{
.root_source_file = b.path("profile_manager.zig"),
});
// Note: dependencies will be added after those modules are created
const profile_commands_module = b.createModule(.{
.root_source_file = b.path("profile_commands.zig"),
});
profile_commands_module.addImport("profile_manager", profile_manager_module);
const profile_ui_state_module = b.createModule(.{
.root_source_file = b.path("profile_ui_state.zig"),
});
profile_ui_state_module.addImport("profile_manager", profile_manager_module);
const profile_ui_renderer_module = b.createModule(.{
.root_source_file = b.path("profile_ui_renderer.zig"),
});
profile_ui_renderer_module.addImport("profile_ui_state", profile_ui_state_module);
profile_ui_renderer_module.addImport("profile_manager", profile_manager_module);
profile_ui_renderer_module.addImport("text_utils", text_utils_module);
const profile_ui_input_module = b.createModule(.{
.root_source_file = b.path("profile_ui_input.zig"),
});
profile_ui_input_module.addImport("profile_ui_state", profile_ui_state_module);
profile_ui_input_module.addImport("profile_manager", profile_manager_module);
// Now add dependencies to profile_manager and add it to other modules
profile_manager_module.addImport("markdown", markdown_module);
profile_manager_module.addImport("ui", ui_module);
profile_manager_module.addImport("llm_provider", llm_provider_module);
profile_manager_module.addImport("config", config_module);
config_module.addImport("profile_manager", profile_manager_module);
config_editor_state_module.addImport("profile_manager", profile_manager_module);
config_editor_renderer_module.addImport("profile_manager", profile_manager_module);
// Agent system modules
const llm_helper_module = b.createModule(.{
.root_source_file = b.path("llm_helper.zig"),
});
llm_helper_module.addImport("ollama", ollama_module);
llm_helper_module.addImport("llm_provider", llm_provider_module);
const agent_writer_module = b.createModule(.{
.root_source_file = b.path("agent_writer.zig"),
});
// Now add agent_writer to agent_builder_input
agent_builder_input_module.addImport("agent_writer", agent_writer_module);
const agent_executor_module = b.createModule(.{
.root_source_file = b.path("agent_executor.zig"),
});
agent_executor_module.addImport("ollama", ollama_module);
agent_executor_module.addImport("llm_helper", llm_helper_module);
agent_executor_module.addImport("tools", tools_module);
agent_executor_module.addImport("context", context_module);
// Will add app after app_module is created
const agent_loader_module = b.createModule(.{
.root_source_file = b.path("agent_loader.zig"),
});
agent_loader_module.addImport("agent_writer", agent_writer_module);
agent_loader_module.addImport("agent_executor", agent_executor_module);
agent_loader_module.addImport("tools", tools_module);
agent_loader_module.addImport("ollama", ollama_module);
// Will add app after app_module is created
const message_renderer_module = b.createModule(.{
.root_source_file = b.path("message_renderer.zig"),
});
message_renderer_module.addImport("ui", ui_module);
message_renderer_module.addImport("markdown", markdown_module);
// Will add render, types and app after they're created
// New refactored modules
const types_module = b.createModule(.{
.root_source_file = b.path("types.zig"),
});
types_module.addImport("markdown", markdown_module);
types_module.addImport("ollama", ollama_module);
types_module.addImport("permission", permission_module);
// Now add dependencies to conversation_db_module
conversation_db_module.addImport("types", types_module);
conversation_db_module.addImport("ollama", ollama_module);
conversation_db_module.addImport("markdown", markdown_module);
// Now add types to context_module, message_renderer, and tools
context_module.addImport("types", types_module);
message_renderer_module.addImport("types", types_module);
tools_module.addImport("types", types_module);
const render_module = b.createModule(.{
.root_source_file = b.path("render.zig"),
});
render_module.addImport("ui", ui_module);
render_module.addImport("markdown", markdown_module);
render_module.addImport("types", types_module);
// Now add render to message_renderer_module
message_renderer_module.addImport("render", render_module);
// Will add app to message_renderer after app_module is created
const app_module = b.createModule(.{
.root_source_file = b.path("app.zig"),
});
app_module.addImport("ui", ui_module);
app_module.addImport("markdown", markdown_module);
app_module.addImport("ollama", ollama_module);
app_module.addImport("lmstudio", lmstudio_module);
app_module.addImport("embeddings", embeddings_module);
app_module.addImport("zvdb", zvdb_module);
app_module.addImport("embedder_interface", embedder_interface_module);
app_module.addImport("llm_provider", llm_provider_module);
app_module.addImport("permission", permission_module);
app_module.addImport("tools", tools_module);
app_module.addImport("tool_executor", tool_executor_module);
app_module.addImport("types", types_module);
app_module.addImport("state", state_module);
app_module.addImport("config_editor_state", config_editor_state_module);
app_module.addImport("config_editor_renderer", config_editor_renderer_module);
app_module.addImport("config_editor_input", config_editor_input_module);
app_module.addImport("agent_builder_state", agent_builder_state_module);
app_module.addImport("agent_builder_renderer", agent_builder_renderer_module);
app_module.addImport("agent_builder_input", agent_builder_input_module);
app_module.addImport("help_state", help_state_module);
app_module.addImport("help_renderer", help_renderer_module);
app_module.addImport("help_input", help_input_module);
app_module.addImport("profile_ui_state", profile_ui_state_module);
app_module.addImport("profile_ui_renderer", profile_ui_renderer_module);
app_module.addImport("profile_ui_input", profile_ui_input_module);
app_module.addImport("profile_manager", profile_manager_module);
app_module.addImport("context", context_module);
app_module.addImport("config", config_module);
app_module.addImport("render", render_module);
app_module.addImport("agents", agents_module);
app_module.addImport("agent_loader", agent_loader_module);
app_module.addImport("agent_writer", agent_writer_module);
app_module.addImport("agent_executor", agent_executor_module);
app_module.addImport("message_renderer", message_renderer_module);
app_module.addImport("llm_helper", llm_helper_module);
app_module.addImport("sqlite", sqlite_module);
app_module.addImport("conversation_db", conversation_db_module);
// Now add app and types to agents and agent modules (circular dependency is OK with modules)
agents_module.addImport("app", app_module);
agents_module.addImport("types", types_module);
agent_executor_module.addImport("app", app_module);
agent_loader_module.addImport("app", app_module);
message_renderer_module.addImport("app", app_module);
// UI module needs app, types, permission, markdown and state modules (circular dependency handled by Zig)
ui_module.addImport("app", app_module);
ui_module.addImport("types", types_module);
ui_module.addImport("permission", permission_module);
ui_module.addImport("markdown", markdown_module);
ui_module.addImport("config_editor_state", config_editor_state_module);
ui_module.addImport("agent_builder_state", agent_builder_state_module);
ui_module.addImport("help_state", help_state_module);
ui_module.addImport("profile_commands", profile_commands_module);
ui_module.addImport("profile_ui_state", profile_ui_state_module);
ui_module.addImport("profile_manager", profile_manager_module);
// Main executable imports
exe.root_module.addImport("ui", ui_module);
exe.root_module.addImport("markdown", markdown_module);
exe.root_module.addImport("ollama", ollama_module);
exe.root_module.addImport("permission", permission_module);
exe.root_module.addImport("tools", tools_module);
exe.root_module.addImport("types", types_module);
exe.root_module.addImport("state", state_module);
exe.root_module.addImport("context", context_module);
exe.root_module.addImport("config", config_module);
exe.root_module.addImport("render", render_module);
exe.root_module.addImport("app", app_module);
// Link system C library and SQLite
exe.linkSystemLibrary("c");
exe.linkSystemLibrary("sqlite3");
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the application");
run_step.dependOn(&run_cmd.step);
}