# anythingllm-pull-sync (`scripts/anythingllm-pull-sync/`) Triggered after `git pull` via the Git `post-merge` hook: uploads files changed between `ORIG_HEAD` and `HEAD` to an AnythingLLM workspace (`POST /api/v1/document/upload`). ## Requirements - AnythingLLM document processor reachable from the host. - Same `.4nkaiignore` rules as the legacy IDE extension (in the target repo root). ## Environment The generated hook sources `~/.config/4nk/anythingllm-sync.env` if present. Required variables: - `ANYTHINGLLM_BASE_URL` (no trailing `/`) - `ANYTHINGLLM_API_KEY` Optional variables: - `ANYTHINGLLM_SYNC_MAX_FILES` (default `200`) - `ANYTHINGLLM_SYNC_MAX_FILE_BYTES` (default `5242880`) - `SMART_IDE_ENV` (`test|pprod|prod`, default `test`) for smart_ide project config resolution (see below) ## Workspace slug resolution Order (first match wins): 1. `ANYTHINGLLM_WORKSPACE_SLUG` (env) 2. `repo/.anythingllm.json` with `{ "workspaceSlug": "…" }` 3. smart_ide `projects//conf.json`: - finds the project by matching `project_path` (resolved relative to the smart_ide root) to `--repo-root` - reads `smart_ide.anythingllm_workspace_slug[SMART_IDE_ENV]` (default env `test`) If no slug can be resolved, the script prints an explicit message and exits with code `0` (does not block the pull). ## Installing the hook Single repo: ```bash ./scripts/install-anythingllm-post-merge-hook.sh /path/to/repo ``` All configured project clones (from `projects/*/conf.json`): ```bash ./scripts/install-anythingllm-post-merge-hook.sh --all ``` Single configured project: ```bash ./scripts/install-anythingllm-post-merge-hook.sh --project enso ``` One-time setup on the host (from this repo): ```bash cd scripts/anythingllm-pull-sync && npm install ``` ## Behavior - Only uploads paths from `git diff --name-only --diff-filter=ACMRT ORIG_HEAD HEAD`. - If `ORIG_HEAD` is missing, or if AnythingLLM config is missing: explicit message, exit `0`. - Deletions/renames are not mirrored as deletions in AnythingLLM in this version (upload only). ## Uninstall ```bash rm -f /path/to/repo/.git/hooks/post-merge ``` ## Links [features/anythingllm-pull-sync-after-pull.md](../features/anythingllm-pull-sync-after-pull.md), [anythingllm-workspaces.md](../anythingllm-workspaces.md), [service-anythingllm-devtools.md](./service-anythingllm-devtools.md).