main.cpp¶
examples/explorer/main.cpp
@file main.cpp @brief Entropic Explorer — interactive architecture guide.
Owners: @tvanfossen
explore_loop
static void explore_loop(entropic_handle_t handle)
Run the interactive exploration loop.
examples/explorer/main.cpp:132
Called by run_explorer
Calls entropic_last_error, entropic_run_streaming, on_token, read_input
Source · 26 lines
static void explore_loop(entropic_handle_t handle)
{
char input[4096];
std::printf("\n");
std::printf("Entropic Explorer — Repo Knowledge Assistant\n");
std::printf("============================================\n");
std::printf("Ask questions, review changes, learn architecture.\n");
std::printf(" 'review my changes' — adversarial change analysis\n");
std::printf(" 'teach me about X' — learn + quiz\n");
std::printf(" 'trace X' — follow execution paths\n");
std::printf(" 'quit' — exit\n\n");
while (read_input(input, sizeof(input))) {
if (input[0] == '\0') {
continue;
}
std::fprintf(stderr, "\n");
entropic_error_t err = entropic_run_streaming(
handle, input, on_token, nullptr, nullptr);
if (err != ENTROPIC_OK) {
std::fprintf(stderr, "\nError: %s\n", entropic_last_error(handle));
}
std::printf("\n\n");
}
}Activity · 17 steps
Flows
main
int main(int argc, char *argv[])
Entry point.
examples/explorer/main.cpp:194
Source · 6 lines
int main(int argc, char* argv[])
{
(void)argc;
(void)argv;
return run_explorer();
}Activity · 3 steps
Flows
run_explorer
static int run_explorer()
Run the explorer application.
examples/explorer/main.cpp:172
Source · 11 lines
static int run_explorer()
{
entropic_handle_t handle = setup_engine(".explorer");
if (!handle) {
return EXIT_FAILURE;
}
explore_loop(handle);
entropic_destroy(handle);
std::printf("Goodbye!\n");
return EXIT_SUCCESS;
}Activity · 7 steps
Flows
setup_engine
static entropic_handle_t setup_engine(const char *project_dir)
Create, configure, and wire up the entropic engine.
examples/explorer/main.cpp:92
Called by run_explorer, run_game
Calls entropic_configure_dir, entropic_create, entropic_destroy, entropic_last_error, entropic_register_mcp_server
Source · 26 lines
static entropic_handle_t setup_engine(const char* project_dir)
{
entropic_handle_t handle = nullptr;
entropic_create(&handle);
if (!handle) {
std::fprintf(stderr, "entropic_create failed\n");
return nullptr;
}
std::string docs_server = R"({"command":"python3","args":["servers/docs_server.py"]})";
// gh#154 (v2.13.0): the quiz grammar is registered during configure,
// from `config_dir/grammars` — it has to be, because the quizzer tier
// NAMES it and an unresolvable tier stem now fails configure. A
// post-configure register_file could only ever run too late, and
// re-registering the key here would now fail as a duplicate.
bool ok = (entropic_configure_dir(handle, project_dir) == ENTROPIC_OK)
&& (entropic_register_mcp_server(
handle, "docs", docs_server.c_str()) == ENTROPIC_OK);
if (!ok) {
std::fprintf(stderr, "Setup failed: %s\n", entropic_last_error(handle));
entropic_destroy(handle);
return nullptr;
}
return handle;
}