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

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
lines 134–134char input[4096];lines 136–136std::printf("\n");lines 137–137std::printf("Entropic Explorer — Repo Knowledge Assistant\n");lines 138–138std::printf("============================================\n");lines 139–139std::printf("Ask questions, review changes, learn architecture.\n");lines 140–140std::printf(" 'review my changes' — adversarial change analysis\n");lines 141–141std::printf(" 'teach me about X' — learn + quiz\n");lines 142–142std::printf(" 'trace X' — follow execution paths\n");lines 143–143std::printf(" 'quit' — exit\n\n");lines 145–145◇ while (read_input(input, sizeof(input)))lines 146–146◇ if (input[0] == '\0')lines 147–147continue;lines 149–149std::fprintf(stderr, "\n");lines 150–151entropic_error_t err = entropic_run_streaming( handle, input, on_token, nullptr, nullptr);lines 152–152◇ if (err != ENTROPIC_OK)lines 153–153std::fprintf(stderr, "\nError: %s\n", entropic_last_error(handle));lines 155–155std::printf("\n\n");

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
lines 196–196(void)argc;lines 197–197(void)argv;lines 198–198return run_explorer();

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
lines 174–174entropic_handle_t handle = setup_engine(".explorer");lines 175–175◇ if (!handle)lines 176–176return EXIT_FAILURE;lines 178–178explore_loop(handle);lines 179–179entropic_destroy(handle);lines 180–180std::printf("Goodbye!\n");lines 181–181return EXIT_SUCCESS;

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

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;
}
Activity · 12 steps
lines 94–94entropic_handle_t handle = nullptr;lines 95–95entropic_create(&handle);lines 96–96◇ if (!handle)lines 97–97std::fprintf(stderr, "entropic_create failed\n");lines 98–98return nullptr;lines 101–101std::string docs_server = R"({"command":"python3","args":["servers/docs_server.py"]})";lines 107–109bool ok = (entropic_configure_dir(handle, project_dir) == ENTROPIC_OK) && (entropic_register_mcp_server( handle, "docs", docs_server.c_str()) == ENTROPIC_OK);lines 111–111◇ if (!ok)lines 112–112std::fprintf(stderr, "Setup failed: %s\n", entropic_last_error(handle));lines 113–113entropic_destroy(handle);lines 114–114return nullptr;lines 116–116return handle;

Flows