# AnythingLLM — sync after `git pull` ## Goal Upload files **added or modified** by a `git pull` (fast-forward or merge) to AnythingLLM without manual IDE actions. ## What it changes - Each target repo can install a Git **`post-merge`** hook that calls `scripts/anythingllm-pull-sync/sync.mjs`. - The same exclusions as **`.4nkaiignore`** (plus a few system patterns) apply. - Deletions/renames are not mirrored as deletions in AnythingLLM in this version (upload only). ## Implementation (smart_ide repo) - `scripts/anythingllm-pull-sync/`: Node (ESM) script + dependency `ignore`. - `scripts/install-anythingllm-post-merge-hook.sh`: installs `.git/hooks/post-merge` with an absolute path to `sync.mjs`. ## Repo configuration (workspace slug) Slug resolution order (first match wins): 1. `ANYTHINGLLM_WORKSPACE_SLUG` (env) 2. `.anythingllm.json` at repo root: `{ "workspaceSlug": "" }` 3. smart_ide `projects//conf.json` (matches `project_path` to the repo root; reads `smart_ide.anythingllm_workspace_slug[SMART_IDE_ENV]`, default env `test`) ## Deployment on the host 1. Run `npm install` in `scripts/anythingllm-pull-sync`. 2. Create `~/.config/4nk/anythingllm-sync.env` with: - `ANYTHINGLLM_BASE_URL` - `ANYTHINGLLM_API_KEY` 3. Install the hook: - per repo: `./scripts/install-anythingllm-post-merge-hook.sh /path/to/repo` - or for configured clones: `./scripts/install-anythingllm-post-merge-hook.sh --all` ## Observability - stderr summary: `uploaded=`, `skipped=`, `errors=`, plus up to 20 error lines. - If `ORIG_HEAD` is missing, or if URL/key/slug is missing: explicit message and exit code `0` (does not block the pull).