Files
r/Makefile
T
retoor 216627e777 feat: add context overflow detection and automatic history shrinking in agent loop
Implement context manager integration that detects API errors indicating context length exceeded, then automatically shrinks message history and retries the request. Add new messages API functions (remove_range, get_object, replace_at) and a new R_ERROR_CONTEXT_TOO_LONG error code to support this functionality.
2026-01-28 19:15:02 +00:00

96 lines
2.2 KiB
Makefile
Executable File

# retoor <retoor@molodetz.nl>
CC = gcc
CFLAGS = -Ofast -Werror -Wall -I./include
LDFLAGS = -lreadline -lncurses -lcurl -ljson-c -lsqlite3 -lm -lpthread -lssl -lcrypto
SRCDIR = src
TOOLSDIR = src/tools
BUILDDIR = build
BINDIR = bin
SRC_CORE = $(SRCDIR)/r_error.c \
$(SRCDIR)/r_config.c \
$(SRCDIR)/tool_registry.c \
$(SRCDIR)/db.c \
$(SRCDIR)/http_client.c \
$(SRCDIR)/messages.c \
$(SRCDIR)/agent.c \
$(SRCDIR)/bash_executor.c \
$(SRCDIR)/context_manager.c \
$(SRCDIR)/main.c
SRC_TOOLS = $(TOOLSDIR)/tools_init.c \
$(TOOLSDIR)/tool_terminal.c \
$(TOOLSDIR)/tool_file.c \
$(TOOLSDIR)/tool_db.c \
$(TOOLSDIR)/tool_http.c \
$(TOOLSDIR)/tool_python.c \
$(TOOLSDIR)/tool_indexer.c
SRC = $(SRC_CORE) $(SRC_TOOLS)
OBJ_CORE = $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC_CORE))
OBJ_TOOLS = $(patsubst $(TOOLSDIR)/%.c,$(BUILDDIR)/tools/%.o,$(SRC_TOOLS))
OBJ = $(OBJ_CORE) $(OBJ_TOOLS)
.PHONY: all clean build build_legacy run
all: build
build: $(BINDIR)/r
cp $(BINDIR)/r r
$(BINDIR)/r: $(OBJ)
@mkdir -p $(BINDIR)
$(CC) $(OBJ) $(LDFLAGS) -o $@
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/tools/%.o: $(TOOLSDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
build_legacy:
@mkdir -p $(BINDIR)
$(CC) main.c $(CFLAGS) $(LDFLAGS) -o $(BINDIR)/r_legacy
cp $(BINDIR)/r_legacy r
build_rpylib:
$(CC) -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl -lsqlite3
run: build
./r --verbose
install:
cp ./r /usr/local/bin/r
clean:
rm -rf $(BUILDDIR) $(BINDIR)
rm -f r
appimage: build
-@rm -rf AppImage
mkdir -p AppImage/usr/bin
mkdir -p AppImage/lib
cp AppRun AppImage/AppRun
cp r.desktop AppImage/r.desktop
cp r.png AppImage/r.png
cp $(BINDIR)/r AppImage/usr/bin/r
./collect_so_files.sh
appimagetool-x86_64.AppImage AppImage
mv r-x86_64.AppImage r
docker: docker_make docker_run
docker_make:
docker build -t r .
docker_run:
docker run -v .:/app --rm -it r
build_deb:
dpkg-deb --build r_package