Skip to content

Commit c82fd70

Browse files
Enhance CLI with transport functionality and logging support and added multiple provider versioning
1 parent 4951c00 commit c82fd70

34 files changed

Lines changed: 3707 additions & 1378 deletions

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ else
99
CFLAGS += -O2
1010
endif
1111

12-
LDFLAGS = -lm -lssl -lcrypto -lgit2 -lnpy_array
12+
# Add curl for HTTP transport
13+
LDFLAGS = -lm -lssl -lcrypto -lgit2 -lnpy_array -lcurl
1314

1415
# Installation paths - default to user-local installation
1516
PREFIX ?= $(HOME)/.local
@@ -31,6 +32,9 @@ CORE_OBJS = $(CORE_SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
3132
CLI_OBJS = $(CLI_SRCS:src/cli/%.c=$(OBJ_DIR)/cli_%.o)
3233
OBJS = $(CORE_OBJS) $(CLI_OBJS)
3334

35+
# Additional dependencies for transport
36+
TRANSPORT_DEPS = $(OBJ_DIR)/transport.o $(OBJ_DIR)/transport_ssh.o $(OBJ_DIR)/transport_http.o $(OBJ_DIR)/transport_local.o
37+
3438
# Test files
3539
TEST_SRCS = $(wildcard $(TEST_DIR)/*.c)
3640
TEST_OBJS = $(TEST_SRCS:$(TEST_DIR)/%.c=$(OBJ_DIR)/%.o)
@@ -41,7 +45,7 @@ TARGET = $(BIN_DIR)/embedding_bridge
4145
LIB_TARGET = $(LIB_DIR)/libembedding_bridge.so
4246

4347
# Main targets
44-
.PHONY: all clean test lib python-test valgrind memtest test-registry test-all test-c
48+
.PHONY: all clean test lib python-test valgrind memtest test-registry test-all test-c test-transport
4549

4650
all: $(TARGET) lib
4751

@@ -50,7 +54,7 @@ lib: $(LIB_TARGET)
5054
# Test targets organized by type
5155
test-all: test-c python-test
5256

53-
test-c: memtest test-registry
57+
test-c: memtest test-registry test-transport
5458
@echo "All C tests completed successfully"
5559

5660
test: test-all
@@ -59,6 +63,10 @@ test-registry: $(TEST_BIN_DIR)/test_model_registry
5963
@echo "Running model registry tests..."
6064
$(TEST_BIN_DIR)/test_model_registry
6165

66+
test-transport: $(TEST_BIN_DIR)/test_transport
67+
@echo "Running transport tests..."
68+
$(TEST_BIN_DIR)/test_transport
69+
6270
python-test: install
6371
@echo "Running Python CLI tests..."
6472
DEBUG=1 PYTHONPATH=src/python:. LD_LIBRARY_PATH=lib pytest tests/python/test_cli.py -v -s
@@ -71,6 +79,10 @@ $(TEST_BIN_DIR)/test_lib: $(OBJ_DIR)/test_lib.o $(OBJ_DIR)/store.o $(OBJ_DIR)/er
7179
@mkdir -p $(TEST_BIN_DIR)
7280
$(CC) $^ -o $@ $(LDFLAGS)
7381

82+
$(TEST_BIN_DIR)/test_transport: $(OBJ_DIR)/test_transport.o $(TRANSPORT_DEPS) $(OBJ_DIR)/error.o $(OBJ_DIR)/debug.o $(OBJ_DIR)/config.o $(OBJ_DIR)/fs.o
83+
@mkdir -p $(TEST_BIN_DIR)
84+
$(CC) $^ -o $@ $(LDFLAGS)
85+
7486
valgrind: memtest
7587
@echo "Running Valgrind memory leak check on library..."
7688
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 $(TEST_BIN_DIR)/test_lib

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ A command-line tool for managing and versioning embedding vectors. Think of it a
99
- Track embedding history and changes
1010
- Roll back to previous embedding versions
1111
- Support for multiple embedding models
12+
- Organize embeddings into sets for better management
13+
- Prepare for remote collaboration (coming soon)
1214

1315
## Installation
1416

@@ -21,6 +23,9 @@ make DEBUG=0 install
2123
## Quick Start
2224

2325
```bash
26+
# Initialize
27+
eb init
28+
2429
# Register a model
2530
eb model register text-embedding-3-small --dimensions 1536 --normalize
2631

@@ -35,6 +40,10 @@ eb diff <hash1> <hash2>
3540

3641
# Roll back to previous version
3742
eb rollback <hash> document.txt
43+
44+
# Create and manage sets
45+
eb set create experimental
46+
eb set switch experimental
3847
```
3948

4049
## Core Commands
@@ -67,6 +76,46 @@ eb diff <hash1> <hash2>
6776
eb rollback <hash> file.txt
6877
```
6978

79+
### Set Management
80+
```bash
81+
# Create a new set of embeddings
82+
eb set create <name> [--desc="Description"] [--base=<base-set>]
83+
84+
# List available sets
85+
eb set list
86+
eb set list --verbose
87+
88+
# Switch between sets
89+
eb set switch <name>
90+
91+
# Show current set status
92+
eb set status
93+
94+
# Compare differences between sets
95+
eb set diff <set1> <set2>
96+
97+
# Merge sets (future functionality)
98+
eb set merge <source-set> [--target=<target-set>] [--strategy=<strategy>]
99+
100+
# Delete a set
101+
eb set delete <name> [--force]
102+
```
103+
104+
### Remote Operations (Future Functionality)
105+
```bash
106+
# Add a remote
107+
eb remote add <name> <url>
108+
109+
# List remote sets
110+
eb remote sets <remote>
111+
112+
# Push a set to remote
113+
eb remote push <set-name> [remote]
114+
115+
# Pull a set from remote
116+
eb remote pull <set-name> [remote]
117+
```
118+
70119
## Contributing
71120

72121
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.

src/cli/cli.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "colors.h"
99
#include "../core/error.h"
1010
#include "rollback.h"
11+
#include "log.h"
1112

1213
bool has_option(int argc, char** argv, const char* option) {
1314
for (int i = 1; i < argc; i++) {
@@ -58,6 +59,15 @@ void cli_warning(const char* fmt, ...) {
5859
va_end(args);
5960
}
6061

62+
void cli_info(const char* fmt, ...) {
63+
va_list args;
64+
va_start(args, fmt);
65+
fprintf(stderr, "%sinfo:%s ", COLOR_BLUE, COLOR_RESET);
66+
vfprintf(stderr, fmt, args);
67+
fprintf(stderr, "\n");
68+
va_end(args);
69+
}
70+
6171
bool is_option_with_value(const char* arg) {
6272
return (strcmp(arg, "-m") == 0 || strcmp(arg, "--model") == 0 ||
6373
strcmp(arg, "-t") == 0 || strcmp(arg, "--threshold") == 0 ||
@@ -141,5 +151,6 @@ static const eb_command_t commands[] = {
141151
{"model", "Manage embedding models", cmd_model},
142152
{"rollback", "Revert to a previous embedding version", cmd_rollback},
143153
{"status", "Show embedding status for a source file", cmd_status},
154+
{"log", "Display embedding log for files", cmd_log},
144155
{NULL, NULL, NULL}
145156
};

src/cli/cli.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ typedef struct {
3131

3232
typedef struct {
3333
const char* model; // Model to use for embedding
34+
const char* models; // Models to use for diff (comma-separated)
35+
const char* second_model; // Second model parsed from models
3436
bool use_git; // Whether to use Git integration
3537
bool use_file; // Use file as input (for query)
3638
bool use_color; // Use colored output
@@ -56,6 +58,11 @@ int cmd_remote(int argc, char** argv);
5658
int cmd_model(int argc, char** argv);
5759
int cmd_rollback(int argc, char** argv);
5860
int cmd_status(int argc, char **argv);
61+
int cmd_log(int argc, char **argv);
62+
int cmd_set(int argc, char **argv);
63+
int cmd_switch(int argc, char **argv);
64+
int cmd_merge(int argc, char **argv);
65+
int cmd_gc(int argc, char **argv);
5966

6067
// Option parsing
6168
bool parse_cli_options(int argc, char** argv, eb_cli_options_t* opts);
@@ -71,15 +78,17 @@ const char* get_model(int argc, char** argv);
7178
void handle_error(eb_status_t status, const char* context);
7279
void cli_error(const char* fmt, ...);
7380
void cli_warning(const char* fmt, ...);
81+
void cli_info(const char* fmt, ...);
7482

7583
// Store operation functions
7684
/* Store precomputed embedding file
7785
* @param embedding_file: Path to the precomputed embedding (.bin or .npy)
7886
* @param dims: Number of dimensions (0 for .npy auto-detect)
7987
* @param source_file: Original source file
88+
* @param model: Model/provider name (can be NULL)
8089
* @return: 0 on success, 1 on error
8190
*/
82-
int store_precomputed(const char *embedding_file, size_t dims, const char *source_file);
91+
int store_precomputed(const char *embedding_file, size_t dims, const char *source_file, const char *model);
8392

8493
/* Store embedding from source file
8594
* @param source_file: Source file to generate embedding from

0 commit comments

Comments
 (0)