This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository edi.

View the commit online.

commit 787549d3140ba7d42f044c8bdf17923a8f036ff3
Author: Alastair Poole <[email protected]>
AuthorDate: Thu Apr 23 14:03:10 2026 +0100

    ai: comments about AI.
---
 src/bin/edi_agent.c             | 21 +++++++++++++++++++++
 src/bin/edi_agent.h             |  8 ++++++++
 src/bin/edi_agent_parse.c       | 11 +++++++++++
 src/bin/edi_agent_parse.h       |  6 ++++++
 src/bin/edi_ai_command_policy.c | 12 ++++++++++++
 src/bin/edi_ai_command_policy.h |  6 ++++++
 src/bin/edi_aipanel.c           | 16 ++++++++++++++++
 src/bin/edi_aipanel.h           |  6 ++++++
 8 files changed, 86 insertions(+)

diff --git a/src/bin/edi_agent.c b/src/bin/edi_agent.c
index a194ffb..d98d815 100644
--- a/src/bin/edi_agent.c
+++ b/src/bin/edi_agent.c
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This agent transport layer was created with AI assistance and integrated
+ * into EDI by maintainers.
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -16,6 +21,7 @@
 
 struct _Edi_Agent_Request
 {
+   /* Kind is first so callbacks can dispatch by reading url user-data as int*. */
    int kind;
    Ecore_Con_Url *url;
    Ecore_Timer *timeout_timer;
@@ -36,6 +42,7 @@ struct _Edi_Agent_Request
 
 struct _Edi_Agent_Models_Request
 {
+   /* Kind is first so callbacks can dispatch by reading url user-data as int*. */
    int kind;
    Ecore_Con_Url *url;
    Ecore_Timer *timeout_timer;
@@ -55,6 +62,7 @@ enum
 
 static const Edi_Agent_Provider _edi_agent_providers[] =
 {
+   /* Default endpoints/models are fallback values from config. */
    { "google_codex", "Google Codex", "https://generativelanguage.googleapis.com/v1beta/models", "gemini-2.5-flash" },
    { "local_http", "Local HTTP Agent", "http://127.0.0.1:11434/v1/responses", "qwen2.5-coder:latest" },
    { "microsoft_copilot", "Microsoft Copilot", "https://api.githubcopilot.com/v1/responses", "gpt-4.1-mini" },
@@ -362,6 +370,7 @@ _edi_agent_models_parse_json(const char *provider_id, const char *json,
    if (!json || !json[0])
      return EINA_FALSE;
 
+   /* Providers usually expose model identifiers as "id". */
    p = json;
    while ((p = strstr(p, "\"id\"")))
      {
@@ -375,6 +384,7 @@ _edi_agent_models_parse_json(const char *provider_id, const char *json,
         free(name);
      }
 
+   /* Some providers use "name" instead; collect both and dedupe. */
    p = json;
    while ((p = strstr(p, "\"name\"")))
      {
@@ -570,6 +580,7 @@ _edi_agent_models_url_build(const Edi_Project_Config *config, const char *provid
    url = ""
    eina_strbuf_append(url, endpoint);
 
+   /* Normalize provider-specific base endpoints into concrete model-list URLs. */
    if (!strcmp(provider_id, "google_codex"))
      {
         marker = strstr(eina_strbuf_string_get(url), ":generateContent");
@@ -652,6 +663,7 @@ _edi_agent_parse_sse(Edi_Agent_Request *req)
 
    all = eina_strbuf_string_get(req->sse_buf);
    line_start = all;
+   /* Parse SSE by lines and emit only parsed text deltas. */
    while ((newline = strchr(line_start, '\n')))
      {
         int len = newline - line_start;
@@ -781,11 +793,13 @@ _edi_agent_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event
 
    if (!ev || !ev->url_con) return ECORE_CALLBACK_RENEW;
 
+   /* url user-data points to either request struct; both start with `kind`. */
    kind_ptr = ecore_con_url_data_get(ev->url_con);
    if (!kind_ptr) return ECORE_CALLBACK_RENEW;
 
    if (*kind_ptr == EDI_AGENT_URL_KIND_MODEL_LIST)
      {
+        /* Model list requests buffer raw JSON until completion. */
         models_req = (Edi_Agent_Models_Request *)kind_ptr;
         if (!models_req->response_buf)
           {
@@ -801,6 +815,7 @@ _edi_agent_url_data_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event
    req = (Edi_Agent_Request *)kind_ptr;
    if (req->stream && req->token_cb)
      {
+        /* Streaming responses are parsed incrementally from SSE chunks. */
         if (!req->sse_buf)
           {
              req->sse_buf = eina_strbuf_new();
@@ -843,11 +858,13 @@ _edi_agent_url_complete_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
 
    if (!ev || !ev->url_con) return ECORE_CALLBACK_RENEW;
 
+   /* url user-data points to either request struct; both start with `kind`. */
    kind_ptr = ecore_con_url_data_get(ev->url_con);
    if (!kind_ptr) return ECORE_CALLBACK_RENEW;
 
    if (*kind_ptr == EDI_AGENT_URL_KIND_MODEL_LIST)
      {
+        /* For model discovery, prefer remote parse and fall back to static list. */
         models_req = (Edi_Agent_Models_Request *)kind_ptr;
         if (models_req->timeout_timer)
           {
@@ -934,6 +951,7 @@ static void
 _edi_agent_runtime_ensure(void)
 {
    if (_url_inited) return;
+   /* One-time network runtime + global URL event handlers. */
    ecore_con_url_init();
    _url_data_hdl = ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _edi_agent_url_data_cb, NULL);
    _url_complete_hdl = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _edi_agent_url_complete_cb, NULL);
@@ -1206,6 +1224,7 @@ edi_agent_request_send_stream(const char *prompt, Edi_Agent_Token_Cb token_cb,
    project_id = (project_id_clean && project_id_clean[0]) ? project_id_clean : NULL;
    provider_id = provider->id;
 
+   /* Auto-route to OpenAI-compatible mode when endpoint shape indicates it. */
    if (!strcmp(provider_id, "google_codex") && endpoint &&
       (strstr(endpoint, "api.openai.com/") ||
        strstr(endpoint, "/chat/completions") ||
@@ -1247,6 +1266,7 @@ edi_agent_request_send_stream(const char *prompt, Edi_Agent_Token_Cb token_cb,
 
    if (!strcmp(provider_id, "google_codex"))
      {
+        /* Google endpoint format differs from Responses API shape. */
         eina_strbuf_append(url, endpoint);
         if (!strstr(endpoint, ":generateContent"))
           eina_strbuf_append_printf(url, "/%s:generateContent", model_esc);
@@ -1263,6 +1283,7 @@ edi_agent_request_send_stream(const char *prompt, Edi_Agent_Token_Cb token_cb,
      {
         const char *marker;
 
+        /* OpenAI-compatible providers are unified on /responses payloads. */
         eina_strbuf_append(url, endpoint);
         marker = strstr(eina_strbuf_string_get(url), "/v1/chat/completions");
         if (marker)
diff --git a/src/bin/edi_agent.h b/src/bin/edi_agent.h
index c96a290..f101a84 100644
--- a/src/bin/edi_agent.h
+++ b/src/bin/edi_agent.h
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This public agent API was introduced for AI-assisted features and is
+ * maintained as part of EDI.
+ */
 #ifndef _EDI_AGENT_H_
 # define _EDI_AGENT_H_ 1
 
@@ -10,6 +15,7 @@ typedef struct _Edi_Agent_Models_Request Edi_Agent_Models_Request;
 
 typedef struct _Edi_Agent_Provider
 {
+   /* Stable provider identifier used in config and routing logic. */
    const char *id;
    const char *name;
    const char *default_endpoint;
@@ -23,7 +29,9 @@ typedef struct _Edi_Agent_Model_List
 } Edi_Agent_Model_List;
 
 typedef void (*Edi_Agent_Response_Cb)(const char *response, const char *error, void *data);
+/* Token callback is used for streaming providers (SSE/chunked text). */
 typedef void (*Edi_Agent_Token_Cb)(const char *token, void *data);
+/* Model callback may return remote models or static fallback models. */
 typedef void (*Edi_Agent_Models_Cb)(const char *provider_id,
                                     const char **models,
                                     unsigned int count,
diff --git a/src/bin/edi_agent_parse.c b/src/bin/edi_agent_parse.c
index 0028afd..5bf76c3 100644
--- a/src/bin/edi_agent_parse.c
+++ b/src/bin/edi_agent_parse.c
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This provider-response parser was implemented with AI assistance and
+ * integrated into EDI by maintainers.
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -84,6 +89,7 @@ _edi_agent_json_unescape(const char *src)
    if (!src) return strdup("");
 
    buf = eina_strbuf_new();
+   /* Decode JSON escape sequences into plain UTF-8 text. */
    for (c = src; *c; c++)
      {
         if (*c == '\\' && *(c + 1))
@@ -178,6 +184,9 @@ _edi_agent_json_first_string_value_get(const char *json, const char *key)
    if (!json || !key) return NULL;
 
    p = json;
+   /* Minimal JSON scanner: find first quoted value for a key.
+    * This intentionally avoids a full JSON dependency in this path.
+    */
    while ((p = strstr(p, key)))
      {
         q = p + strlen(key);
@@ -228,6 +237,7 @@ edi_agent_error_parse_for_provider(const char *provider, const char *json, int h
      return strdup(eina_slstr_printf("%s request failed (HTTP %d).",
                                      provider ? provider : "Agent", http_code));
 
+   /* Pull common error fields used by OpenAI-style and compatible APIs. */
    msg = _edi_agent_json_first_string_value_get(json, "\"message\"");
    status = _edi_agent_json_first_string_value_get(json, "\"status\"");
    type = _edi_agent_json_first_string_value_get(json, "\"type\"");
@@ -282,6 +292,7 @@ edi_agent_response_parse_for_provider(const char *provider, const char *json)
    if (!json || !json[0])
      return NULL;
 
+   /* Providers return text in different fields; try them in useful order. */
    if (provider && !strcmp(provider, "google_codex"))
      text = _edi_agent_json_first_string_value_get(json, "\"text\"");
    else
diff --git a/src/bin/edi_agent_parse.h b/src/bin/edi_agent_parse.h
index fd585e8..409b6db 100644
--- a/src/bin/edi_agent_parse.h
+++ b/src/bin/edi_agent_parse.h
@@ -1,9 +1,15 @@
+/*
+ * AI-assisted feature note:
+ * This parser interface is part of AI-assisted feature work integrated into
+ * EDI.
+ */
 #ifndef _EDI_AGENT_PARSE_H_
 # define _EDI_AGENT_PARSE_H_ 1
 
 #include "edi_config.h"
 
 char *edi_agent_response_parse_for_provider(const char *provider, const char *json);
+/* Returns provider-specific error text suitable for direct UI display. */
 char *edi_agent_error_parse_for_provider(const char *provider, const char *json, int http_code);
 char *edi_agent_provider_validate_for_provider(const Edi_Project_Config *config,
                                                const char *provider_id,
diff --git a/src/bin/edi_ai_command_policy.c b/src/bin/edi_ai_command_policy.c
index c9cfac3..c30d86e 100644
--- a/src/bin/edi_ai_command_policy.c
+++ b/src/bin/edi_ai_command_policy.c
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This command-policy safety layer was created with AI assistance and then
+ * integrated into EDI by maintainers.
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -17,6 +22,7 @@ _edi_ai_command_token_get(const char *cmd, char *token, size_t token_len)
    if (!cmd || !token || token_len < 2)
      return EINA_FALSE;
 
+   /* Extract first command token after leading whitespace. */
    p = cmd;
    while (*p && isspace((unsigned char)*p))
      p++;
@@ -79,6 +85,7 @@ _edi_ai_path_is_safe_repo_target(const char *path)
    if (!strcmp(path, ".") || !strcmp(path, ".."))
      return EINA_FALSE;
 
+   /* Restrict to simple relative repo paths and reject traversal patterns. */
    p = path;
    while (*p)
      {
@@ -142,6 +149,7 @@ _edi_ai_redirections_validate(const char *cmd, Eina_Bool *has_redirection,
    if (!line)
      return EINA_FALSE;
 
+   /* Detect output redirects and validate the target path for repo safety. */
    for (p = line; *p; p++)
      {
         const char *t;
@@ -247,6 +255,7 @@ _edi_ai_command_has_forbidden_operators(const char *cmd)
    if (!cmd)
      return EINA_TRUE;
 
+   /* Block shell composition operators; only plain single commands are allowed. */
    for (p = cmd; *p; p++)
      {
         if (escaped)
@@ -302,6 +311,7 @@ _edi_ai_git_command_allowed(const char *cmd)
    if (!subcmd || !subcmd[0])
      goto end;
 
+   /* Keep git operations read-only-ish (plus add) for safety. */
    if (!strcmp(subcmd, "status") || !strcmp(subcmd, "diff") ||
        !strcmp(subcmd, "show") || !strcmp(subcmd, "log") ||
        !strcmp(subcmd, "add"))
@@ -327,6 +337,7 @@ _edi_ai_mutating_paths_validate(const char *cmd, const char *token)
    if (!strcmp(token, "git"))
      return _edi_ai_git_command_allowed(cmd);
 
+   /* Only validate path-bearing mutators; others pass through here. */
    if (strcmp(token, "mkdir") && strcmp(token, "touch") && strcmp(token, "cp") &&
        strcmp(token, "mv") && strcmp(token, "chmod") && strcmp(token, "tee"))
      return EINA_TRUE;
@@ -407,6 +418,7 @@ edi_ai_command_policy_check(const Eina_List *allowed_commands,
         return EINA_FALSE;
      }
 
+   /* Hard-deny known-dangerous fragments before allow-list checks. */
    EINA_LIST_FOREACH((Eina_List *)denied_patterns, l, entry)
      if (strstr(cmd, entry))
        {
diff --git a/src/bin/edi_ai_command_policy.h b/src/bin/edi_ai_command_policy.h
index a02f098..c52c3fc 100644
--- a/src/bin/edi_ai_command_policy.h
+++ b/src/bin/edi_ai_command_policy.h
@@ -1,8 +1,14 @@
+/*
+ * AI-assisted feature note:
+ * This command-policy API is part of AI-assisted feature work integrated into
+ * EDI.
+ */
 #ifndef EDI_AI_COMMAND_POLICY_H
 #define EDI_AI_COMMAND_POLICY_H
 
 #include <Eina.h>
 
+/* Returns EINA_FALSE with a short human-readable reason when blocked. */
 Eina_Bool
 edi_ai_command_policy_check(const Eina_List *allowed_commands,
                             const Eina_List *denied_patterns,
diff --git a/src/bin/edi_aipanel.c b/src/bin/edi_aipanel.c
index d2731fc..ad4c829 100644
--- a/src/bin/edi_aipanel.c
+++ b/src/bin/edi_aipanel.c
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This AI panel implementation was created with AI assistance and then
+ * integrated into EDI by maintainers.
+ */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -15,6 +20,7 @@
 
 #include "edi_private.h"
 
+/* UI and request lifecycle state for the embedded AI panel. */
 static Evas_Object *_edi_ai_widget;
 static Evas_Object *_edi_ai_button;
 static Evas_Object *_edi_ai_copy_button;
@@ -57,6 +63,7 @@ static Eina_Bool _edi_ai_edits_notice_enabled = EINA_FALSE;
 #define EDI_AI_RUN_MAX_STEPS_DEFAULT 256
 #define EDI_AI_RUN_MAX_OUTPUT 120000
 
+/* Appends one logical line into the panel output buffer/widget. */
 static void _edi_aipanel_append_line(const char *line);
 
 static Eina_Bool
@@ -102,6 +109,7 @@ _edi_aipanel_widget_text_normalize(const char *text)
    if (!buf)
      return strdup(text);
 
+   /* Keep only printable/control-safe text so the code widget stays stable. */
    for (p = (const unsigned char *)text; *p; p++)
      {
         if (*p == '\r')
@@ -200,6 +208,7 @@ _edi_aipanel_shell_quote(const char *src)
 
    buf = eina_strbuf_new();
    eina_strbuf_append_char(buf, '\'');
+   /* Single-quote escaping suitable for shell command interpolation. */
    for (p = src; *p; p++)
      {
         if (*p == '\'')
@@ -245,6 +254,7 @@ _edi_aipanel_repo_state_get(void)
      return strdup("Project path is not set.");
 
    project_quoted = _edi_aipanel_shell_quote(project);
+   /* Capture a compact, reproducible repo snapshot for prompt context. */
    script = eina_slstr_printf("cd %s && pwd && echo && git status --short --branch 2>&1",
                               project_quoted);
    script_quoted = _edi_aipanel_shell_quote(script);
@@ -274,6 +284,7 @@ _edi_aipanel_repo_inspection_get(void)
      return NULL;
 
    project_quoted = _edi_aipanel_shell_quote(project);
+   /* Mandatory initial inspection output used to ground edit requests. */
    script = eina_slstr_printf("cd %s && pwd && echo && ls -la && echo && "
                               "find . -type f | sed 's#^\\./##' | sort",
                               project_quoted);
@@ -403,6 +414,7 @@ _edi_aipanel_string_list_parse(const char *text)
                   return NULL;
                }
 
+             /* Prompt policy files allow blank lines and # comments. */
              if (entry[0] && entry[0] != '#')
                list = eina_list_append(list, entry);
              else
@@ -524,6 +536,7 @@ _edi_aipanel_prompt_template_render(const char *tmpl,
 
    buf = eina_strbuf_new();
    p = tmpl;
+   /* Replace {{KEY}} markers with provided values; unknown keys map to "". */
    while (p && *p)
      {
         const char *start = strstr(p, "{{");
@@ -1325,6 +1338,7 @@ _edi_aipanel_command_run(const char *command, int *exit_code)
    if (!raw)
      return strdup("Failed to run command.");
 
+   /* Parse the last sentinel to recover command exit status from captured output. */
    marker = strstr(raw, tag);
    while (marker)
      {
@@ -1609,6 +1623,7 @@ _edi_aipanel_response_cb(const char *response, const char *error, void *data EIN
              apply_response = EINA_FALSE;
           }
 
+        /* Agent loop: execute <edi-run>, then issue a follow-up prompt with results. */
         if (run_cmd && _edi_ai_agent_steps < _edi_aipanel_steps_max_get())
           {
 	             const char *deny_reason = NULL;
@@ -1809,6 +1824,7 @@ _edi_aipanel_send(Evas_Object *entry)
         _edi_ai_stream_buf = NULL;
      }
 
+   /* Resume mode lets the user ask "continue" without re-seeding the whole task. */
    continue_mode = edits_enabled &&
                    _edi_ai_last_stage_valid &&
                    _edi_aipanel_prompt_is_continue_request(prompt);
diff --git a/src/bin/edi_aipanel.h b/src/bin/edi_aipanel.h
index 028cf88..3480ed0 100644
--- a/src/bin/edi_aipanel.h
+++ b/src/bin/edi_aipanel.h
@@ -1,3 +1,8 @@
+/*
+ * AI-assisted feature note:
+ * This AI panel interface was introduced as part of AI-assisted feature work
+ * and integrated into EDI by maintainers.
+ */
 #ifndef EDI_AIPANEL_H_
 # define EDI_AIPANEL_H_
 
@@ -7,6 +12,7 @@
 extern "C" {
 #endif
 
+/* Creates and attaches the AI panel UI to the provided parent container. */
 void edi_aipanel_add(Evas_Object *parent);
 
 #ifdef __cplusplus

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to