Skip to content

Commit bbcfd23

Browse files
committed
Fix personal memory formatting
1 parent 5f0f4b6 commit bbcfd23

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/cli/cli.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,8 +2903,9 @@ int cbm_cmd_config(int argc, char **argv) {
29032903
cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX, "false"));
29042904
printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_INDEX_LIMIT,
29052905
cbm_config_get(cfg, CBM_CONFIG_AUTO_INDEX_LIMIT, "50000"));
2906-
printf(" %-25s = %-10s\n", CBM_CONFIG_UI_LANG,
2907-
cbm_config_get(cfg, CBM_CONFIG_UI_LANG, cbm_config_default_value(CBM_CONFIG_UI_LANG)));
2906+
printf(
2907+
" %-25s = %-10s\n", CBM_CONFIG_UI_LANG,
2908+
cbm_config_get(cfg, CBM_CONFIG_UI_LANG, cbm_config_default_value(CBM_CONFIG_UI_LANG)));
29082909
printf(" %-25s = %-10s\n", CBM_CONFIG_AUTO_UPDATE,
29092910
cbm_config_get(cfg, CBM_CONFIG_AUTO_UPDATE,
29102911
cbm_config_default_value(CBM_CONFIG_AUTO_UPDATE)));

src/mcp/mcp.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,18 @@ static const tool_def_t TOOLS[] = {
489489
{"manage_adr", "Manage ADR", "Create or update Architecture Decision Records",
490490
"{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"mode\":{\"type\":"
491491
"\"string\",\"enum\":[\"get\",\"update\",\"sections\"]},\"scope\":{\"type\":\"string\","
492-
"\"enum\":[\"project\",\"personal\"],\"default\":\"project\"},\"branch\":{\"type\":\"string\"},"
493-
"\"content\":{\"type\":\"string\"},\"sections\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},"
492+
"\"enum\":[\"project\",\"personal\"],\"default\":\"project\"},\"branch\":{\"type\":\"string\"}"
493+
","
494+
"\"content\":{\"type\":\"string\"},\"sections\":{\"type\":\"array\",\"items\":{\"type\":"
495+
"\"string\"}}},"
494496
"\"required\":[\"project\"]"
495497
"}"},
496498

497499
{"manage_memory", "Manage personal repo memory",
498500
"Create or update local personal memory stored outside source repos",
499501
"{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"mode\":{\"type\":"
500-
"\"string\",\"enum\":[\"get\",\"update\",\"sections\",\"settings\",\"bootstrap\",\"delete\",\"list\",\"promote\",\"sync\"]},"
502+
"\"string\",\"enum\":[\"get\",\"update\",\"sections\",\"settings\",\"bootstrap\",\"delete\","
503+
"\"list\",\"promote\",\"sync\"]},"
501504
"\"doc_type\":{\"type\":\"string\",\"default\":\"adr\"},\"branch\":{\"type\":\"string\"},"
502505
"\"content\":{\"type\":\"string\"},\"reveal_paths\":{\"type\":\"boolean\",\"default\":false},"
503506
"\"sections\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},"
@@ -5070,8 +5073,8 @@ static char *adr_read_legacy_file(const char *root_path) {
50705073
"then draft and store. Sections: PURPOSE, STACK, ARCHITECTURE, " \
50715074
"PATTERNS, TRADEOFFS, PHILOSOPHY."
50725075

5073-
#define MEMORY_EMPTY_HINT \
5074-
"No personal memory yet. Explore with get_architecture/search_graph, then " \
5076+
#define MEMORY_EMPTY_HINT \
5077+
"No personal memory yet. Explore with get_architecture/search_graph, then " \
50755078
"store a compact ADR with manage_memory(mode='update', content='...')."
50765079

50775080
static char *handle_manage_memory(cbm_mcp_server_t *srv, const char *args) {
@@ -5110,7 +5113,8 @@ static char *handle_manage_memory(cbm_mcp_server_t *srv, const char *args) {
51105113

51115114
cbm_git_context_t ctx = {0};
51125115
(void)cbm_git_context_resolve(root_path, &ctx);
5113-
const char *current_branch = branch_arg && branch_arg[0] ? branch_arg : cbm_memory_current_branch(&ctx);
5116+
const char *current_branch =
5117+
branch_arg && branch_arg[0] ? branch_arg : cbm_memory_current_branch(&ctx);
51145118
const char *base_branch = cbm_memory_default_branch(&ctx);
51155119
char *repo_id = cbm_memory_repo_id(project, root_path, &ctx);
51165120
char *key = cbm_memory_doc_key(repo_id, current_branch, doc_type);

src/personal_memory/memory.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@ char *cbm_memory_doc_key(const char *repo_id, const char *branch, const char *do
161161
return out;
162162
}
163163

164-
void cbm_memory_add_settings_json(struct cbm_config *cfg, yyjson_mut_doc *doc,
165-
yyjson_mut_val *root, const char *db_path,
166-
bool reveal_paths) {
164+
void cbm_memory_add_settings_json(struct cbm_config *cfg, yyjson_mut_doc *doc, yyjson_mut_val *root,
165+
const char *db_path, bool reveal_paths) {
167166
const char *cache_dir_resolved = cbm_resolve_cache_dir();
168167
const char *memory_dir_resolved = cbm_memory_resolve_dir(cfg);
169168
char memory_dir_buf[CBM_SZ_1K];
170169
snprintf(memory_dir_buf, sizeof(memory_dir_buf), "%s",
171170
memory_dir_resolved ? memory_dir_resolved : "");
172-
const char *default_scope = cfg ? cbm_config_get(cfg, CBM_CONFIG_MEMORY_DEFAULT_SCOPE, "personal")
173-
: "personal";
171+
const char *default_scope =
172+
cfg ? cbm_config_get(cfg, CBM_CONFIG_MEMORY_DEFAULT_SCOPE, "personal") : "personal";
174173
char default_scope_buf[CBM_SZ_256];
175-
snprintf(default_scope_buf, sizeof(default_scope_buf), "%s", default_scope ? default_scope : "");
174+
snprintf(default_scope_buf, sizeof(default_scope_buf), "%s",
175+
default_scope ? default_scope : "");
176176
yyjson_mut_obj_add_str(doc, root, "storage", "personal");
177177
yyjson_mut_obj_add_bool(doc, root, "local_only", true);
178178
yyjson_mut_obj_add_str(doc, root, "network_sync", "disabled");
@@ -184,14 +184,16 @@ void cbm_memory_add_settings_json(struct cbm_config *cfg, yyjson_mut_doc *doc,
184184
yyjson_mut_obj_add_str(doc, root, "dir_mode", "0700");
185185
yyjson_mut_obj_add_bool(doc, root, "paths_redacted", !reveal_paths);
186186
if (reveal_paths) {
187-
yyjson_mut_obj_add_str(doc, root, "cache_dir", cache_dir_resolved ? cache_dir_resolved : "");
187+
yyjson_mut_obj_add_str(doc, root, "cache_dir",
188+
cache_dir_resolved ? cache_dir_resolved : "");
188189
yyjson_mut_obj_add_strcpy(doc, root, "memory_dir", memory_dir_buf);
189190
yyjson_mut_obj_add_strcpy(doc, root, "memory_db", db_path ? db_path : "");
190191
} else {
191192
yyjson_mut_obj_add_str(doc, root, "cache_dir", "<redacted>");
192193
yyjson_mut_obj_add_str(doc, root, "memory_dir", "<redacted>");
193194
yyjson_mut_obj_add_str(doc, root, "memory_db", "<redacted>");
194-
yyjson_mut_obj_add_str(doc, root, "path_hint", "pass reveal_paths=true to show local filesystem paths");
195+
yyjson_mut_obj_add_str(doc, root, "path_hint",
196+
"pass reveal_paths=true to show local filesystem paths");
195197
}
196198
}
197199

@@ -219,8 +221,7 @@ void cbm_memory_add_list_json(cbm_store_t *store, const char *repo_id, yyjson_mu
219221
branch += strlen("::branch:");
220222
yyjson_mut_obj_add_strncpy(doc, item, "branch", branch,
221223
(size_t)(doc_type - branch));
222-
yyjson_mut_obj_add_strcpy(doc, item, "doc_type",
223-
doc_type + strlen("::doc:"));
224+
yyjson_mut_obj_add_strcpy(doc, item, "doc_type", doc_type + strlen("::doc:"));
224225
}
225226
yyjson_mut_obj_add_strcpy(doc, item, "updated_at", updated_at ? updated_at : "");
226227
yyjson_mut_arr_add_val(items, item);

src/personal_memory/memory.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ const char *cbm_memory_default_branch(const cbm_git_context_t *ctx);
2020
char *cbm_memory_repo_id(const char *project, const char *root_path, const cbm_git_context_t *ctx);
2121
char *cbm_memory_doc_key(const char *repo_id, const char *branch, const char *doc_type);
2222

23-
void cbm_memory_add_settings_json(struct cbm_config *cfg, yyjson_mut_doc *doc,
24-
yyjson_mut_val *root, const char *db_path,
25-
bool reveal_paths);
23+
void cbm_memory_add_settings_json(struct cbm_config *cfg, yyjson_mut_doc *doc, yyjson_mut_val *root,
24+
const char *db_path, bool reveal_paths);
2625
void cbm_memory_add_list_json(cbm_store_t *store, const char *repo_id, yyjson_mut_doc *doc,
2726
yyjson_mut_val *root);
2827

0 commit comments

Comments
 (0)