diff --git a/.gitignore b/.gitignore index ba6af995b..24789bd4a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,11 @@ integrations/hermes/__pycache__/ eval/reports/ # LongMemEval download is 278MB; fetched on demand eval/data/longmemeval/ + +# USB portable kit runtime (scripts/config are tracked) +agentmemory-portable/portable/ +agentmemory-portable/downloads/ +agentmemory-portable/home/ +agentmemory-portable/data/* +!agentmemory-portable/data/README.txt +agentmemory-portable/repo/ diff --git a/agentmemory-portable/.gitignore b/agentmemory-portable/.gitignore new file mode 100644 index 000000000..9d717111e --- /dev/null +++ b/agentmemory-portable/.gitignore @@ -0,0 +1,11 @@ +# Runtime (do not push) +portable/node/ +portable/npm-cache/ +portable/iii.exe +downloads/ +data/* +!data/README.txt +home/ +repo/ + +*.log diff --git a/agentmemory-portable/README.md b/agentmemory-portable/README.md new file mode 100644 index 000000000..7b544f32f --- /dev/null +++ b/agentmemory-portable/README.md @@ -0,0 +1,95 @@ +# agentmemory-portable — kit USB (vive dentro il repo agentmemory) + +Avvia agentmemory da pen drive / cartella locale **senza patchare** i sorgenti +upstream. Questa cartella fa parte del progetto e si puo pushare su git. + +## Posizione + +``` +agentmemory/ + agentmemory-portable/ <-- questo kit + src/ ... + package.json +``` + +In layout **in-tree** (default qui) il codice e la cartella padre del kit: +non serve un secondo clone in `repo\`. + +## Layout + +``` +agentmemory-portable\ + setup.cmd / start.cmd / start-clean.cmd / stop.cmd / status.cmd / update.cmd + mcp-launch.cmd + mcp-cursor.example.json + kit.config.ps1 + iii-config.yaml # SQLite -> .\data (cwd = kit root) + data\ # state_store.db + stream_store (DATI) + scripts\ + portable\node\ # Node portatile (non in git) + portable\iii.exe # backup (non in git) + home\.agentmemory\ # .env, pid, preferences (runtime, non in git) + home\cache\ + downloads\ # zip temporanei (non in git) +``` + +## Prerequisiti + +- Windows 10/11 x64 +- `git` sul PATH (setup/update) +- Porte libere: **3111**, **3112**, **3113**, **49134** +- USB 3.x consigliata se usi una pen drive + +## Prima installazione + +1. Dal clone del progetto: entra in `agentmemory-portable\` +2. Doppio-click **`setup.cmd`** (serve rete: Node + iii.exe + npm install/build) +3. Avvia con **`start.cmd`** + +Su pen drive: copia l'intero repo `agentmemory` (o almeno questa cartella + build), +poi `setup.cmd` / `start.cmd`. + +## Uso quotidiano + +| Comando | Effetto | +|--------|---------| +| `start.cmd` | Remappa home su `home\`, avvia daemon (dati in `data\`). Se trova Docker chiede A/B/C | +| `start-clean.cmd` | Opzione C automatica: ferma Docker agentmemory, ripulisce pid, avvia USB | +| `stop.cmd` | Ferma worker + iii-engine | +| `status.cmd` | `agentmemory status` | +| `update.cmd` | `git pull` sul repo padre + `npm install` + build | + +## Dati sulla pen drive / kit + +| Dato | Dove | +|------|------| +| SQLite + stream | `agentmemory-portable\data\` | +| Config / pid / snapshot / export | `home\.agentmemory\` | +| Cache embedding | `home\cache\` | +| Codice | repo padre (`..`) | + +## Docker in conflitto + +`start.cmd` offre: +- **A** istruzioni manuali +- **B** resta su Docker +- **C** pulizia auto (stop container, no delete volumi) + avvio kit + +## MCP Cursor + +Vedi `mcp-cursor.example.json`. Con daemon avviato: + +```json +"agentmemory": { + "command": "npx", + "args": ["-y", "@agentmemory/mcp"], + "env": { "AGENTMEMORY_URL": "http://127.0.0.1:3111" } +} +``` + +## Cosa viene committato + +Si pushano script, `iii-config.yaml`, `*.cmd`, README, esempi MCP. + +**Non** finiscono in git (vedi `.gitignore`): `portable/node`, `downloads`, +`data/*`, `home/**` runtime, `.env`. diff --git a/agentmemory-portable/iii-config.yaml b/agentmemory-portable/iii-config.yaml new file mode 100644 index 000000000..096acbaf3 --- /dev/null +++ b/agentmemory-portable/iii-config.yaml @@ -0,0 +1,60 @@ +# Portable kit iii-config: SQLite lives in this kit's ./data (cwd = kit root). +# Do not edit the upstream repo iii-config.yaml — this file is owned by the kit. +workers: + - name: iii-http + config: + port: 3111 + host: 127.0.0.1 + default_timeout: 180000 + cors: + allowed_origins: ["http://localhost:3111", "http://localhost:3113", "http://127.0.0.1:3111", "http://127.0.0.1:3113"] + allowed_methods: [GET, POST, PUT, DELETE, OPTIONS] + - name: iii-state + config: + adapter: + name: kv + config: + store_method: file_based + file_path: ./data/state_store.db + - name: iii-queue + config: + adapter: + name: builtin + - name: iii-pubsub + config: + adapter: + name: local + - name: iii-cron + config: + adapter: + name: kv + - name: iii-stream + config: + port: 3112 + host: 127.0.0.1 + adapter: + name: kv + config: + store_method: file_based + file_path: ./data/stream_store + - name: iii-observability + config: + enabled: true + service_name: agentmemory + exporter: memory + sampling_ratio: 0.1 + metrics_enabled: true + logs_enabled: true + logs_console_output: false + - name: iii-exec + config: + watch: + - ../src/**/*.ts + exec: + - node ../dist/index.mjs + + + + + + diff --git a/agentmemory-portable/kit.config.ps1 b/agentmemory-portable/kit.config.ps1 new file mode 100644 index 000000000..b1ff8b666 --- /dev/null +++ b/agentmemory-portable/kit.config.ps1 @@ -0,0 +1,6 @@ +# Optional overrides for the portable kit. +# Copy values as needed; unset variables keep the defaults from scripts\_env.ps1. + +# $RepoUrl = "https://github.com/rohitg00/agentmemory.git" +# $IiiVersion = "0.11.2" +# $NodeVersion = "22.16.0" diff --git a/agentmemory-portable/mcp-cursor.example.json b/agentmemory-portable/mcp-cursor.example.json new file mode 100644 index 000000000..0b98b2e41 --- /dev/null +++ b/agentmemory-portable/mcp-cursor.example.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "agentmemory": { + "command": "npx", + "args": ["-y", "@agentmemory/mcp"], + "env": { + "AGENTMEMORY_URL": "http://127.0.0.1:3111" + } + } + } +} diff --git a/agentmemory-portable/mcp-launch.cmd b/agentmemory-portable/mcp-launch.cmd new file mode 100644 index 000000000..29d3ae1e3 --- /dev/null +++ b/agentmemory-portable/mcp-launch.cmd @@ -0,0 +1,29 @@ +# Launcher MCP stdio che usa Node portatile + shim del clone (senza npx sul host). +# In Cursor mcp.json punta a questo .cmd con path assoluto aggiornato alla lettera unita. +@echo off +setlocal +cd /d "%~dp0" +set "KIT=%~dp0" +set "KIT=%KIT:~0,-1%" +set "PATH=%KIT%\portable\node;%PATH%" +set "AGENTMEMORY_URL=http://127.0.0.1:3111" +set "USERPROFILE=%KIT%\home" +set "HOME=%KIT%\home" + +if exist "%KIT%\repo\dist\standalone.mjs" ( + "%KIT%\portable\node\node.exe" "%KIT%\repo\dist\standalone.mjs" + exit /b %ERRORLEVEL% +) + +if exist "%KIT%\repo\dist\cli.mjs" ( + "%KIT%\portable\node\node.exe" "%KIT%\repo\dist\cli.mjs" mcp + exit /b %ERRORLEVEL% +) + +if exist "%KIT%\repo\packages\mcp\bin.mjs" ( + "%KIT%\portable\node\node.exe" "%KIT%\repo\packages\mcp\bin.mjs" + exit /b %ERRORLEVEL% +) + +echo [agentmemory-portable] MCP entry non trovata. Esegui setup.cmd / update.cmd 1>&2 +exit /b 1 diff --git a/agentmemory-portable/scripts/_env.ps1 b/agentmemory-portable/scripts/_env.ps1 new file mode 100644 index 000000000..4319f1909 --- /dev/null +++ b/agentmemory-portable/scripts/_env.ps1 @@ -0,0 +1,454 @@ +# Shared environment for the agentmemory USB portable kit. +# Dot-source from other scripts: . "$PSScriptRoot\_env.ps1" + +$ErrorActionPreference = "Stop" + +$script:KitRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path +$script:DataDir = Join-Path $KitRoot "data" +$script:IiiConfigPath = Join-Path $KitRoot "iii-config.yaml" +$script:HomeDir = Join-Path $KitRoot "home" +$script:PortableDir = Join-Path $KitRoot "portable" +$script:NodeDir = Join-Path $PortableDir "node" +$script:NodeExe = Join-Path $NodeDir "node.exe" +$script:AgentmemoryHome = Join-Path $HomeDir ".agentmemory" +$script:IiiBinDir = Join-Path $AgentmemoryHome "bin" +$script:IiiExe = Join-Path $IiiBinDir "iii.exe" +$script:DownloadsDir = Join-Path $KitRoot "downloads" + +# Host profile before remapping (needed for git credentials during update) +$script:RealUserProfile = $env:USERPROFILE +$script:RealHome = $env:HOME +$script:RealAppData = $env:APPDATA +$script:RealLocalAppData = $env:LOCALAPPDATA +$script:RealTemp = $env:TEMP +$script:RealTmp = $env:TMP + +$script:PinnedIiiVersion = "0.11.2" +$script:PinnedNodeVersion = "22.16.0" +$script:DefaultRepoUrl = "https://github.com/rohitg00/agentmemory.git" + +# Layout: +# - in-tree: kit lives at /agentmemory-portable (pushable with the project) +# - nested: standalone USB folder with its own repo\ clone +function Test-InTreeLayout { + $parent = Join-Path $KitRoot ".." + $pkg = Join-Path $parent "package.json" + if (-not (Test-Path $pkg)) { return $false } + try { + $raw = Get-Content -LiteralPath $pkg -Raw -ErrorAction Stop + return [bool]($raw -match '"name"\s*:\s*"@agentmemory/agentmemory"') + } catch { + return $false + } +} + +$script:InTree = Test-InTreeLayout +if ($InTree) { + $script:RepoDir = (Resolve-Path (Join-Path $KitRoot "..")).Path +} else { + $script:RepoDir = Join-Path $KitRoot "repo" +} +$script:CliEntry = Join-Path $RepoDir "dist\cli.mjs" + +function Write-KitInfo([string]$Message) { + Write-Host "[agentmemory-portable] $Message" -ForegroundColor Cyan +} + +function Write-KitWarn([string]$Message) { + Write-Host "[agentmemory-portable] $Message" -ForegroundColor Yellow +} + +function Write-KitError([string]$Message) { + Write-Host "[agentmemory-portable] $Message" -ForegroundColor Red +} + +function Get-KitConfig { + $cfgPath = Join-Path $KitRoot "kit.config.ps1" + $cfg = [ordered]@{ + RepoUrl = $DefaultRepoUrl + IiiVersion = $PinnedIiiVersion + NodeVersion = $PinnedNodeVersion + } + if (Test-Path $cfgPath) { + . $cfgPath + if ($RepoUrl) { $cfg.RepoUrl = $RepoUrl } + if ($IiiVersion) { $cfg.IiiVersion = $IiiVersion } + if ($NodeVersion) { $cfg.NodeVersion = $NodeVersion } + } + return $cfg +} + +function Assert-NodePresent { + if (-not (Test-Path $NodeExe)) { + Write-KitError "Node portatile non trovato: $NodeExe" + Write-KitError "Esegui prima setup.cmd" + exit 1 + } +} + +function Assert-RepoBuilt { + if (-not (Test-Path $RepoDir)) { + Write-KitError "Repo assente: $RepoDir" + Write-KitError "Esegui prima setup.cmd" + exit 1 + } + if (-not (Test-Path $CliEntry)) { + Write-KitError "Build assente: $CliEntry" + Write-KitError "Esegui setup.cmd oppure update.cmd" + exit 1 + } +} + +function Assert-IiiPresent { + if (-not (Test-Path $IiiExe)) { + Write-KitError "iii.exe non trovato: $IiiExe" + Write-KitError "Esegui prima setup.cmd" + exit 1 + } +} + +function Sync-IiiConfigForLayout { + if (-not (Test-Path $IiiConfigPath)) { return } + $raw = Get-Content -LiteralPath $IiiConfigPath -Raw + if ($InTree) { + $raw = $raw -replace '(?m)file_path:\s*\.\./data/', 'file_path: ./data/' + $raw = $raw -replace '(?m)-\s+node repo/dist/index\.mjs', '- node ../dist/index.mjs' + $raw = $raw -replace '(?m)-\s+src/\*\*/\*\.ts', '- ../src/**/*.ts' + } else { + $raw = $raw -replace '(?m)file_path:\s*\./data/', 'file_path: ./data/' + $raw = $raw -replace '(?m)-\s+node \.\./dist/index\.mjs', '- node repo/dist/index.mjs' + $raw = $raw -replace '(?m)-\s+\.\./src/\*\*/\*\.ts', '- repo/src/**/*.ts' + } + Set-Content -LiteralPath $IiiConfigPath -Value $raw -Encoding UTF8 +} + +function Assert-UsbDataLayout { + if (-not (Test-Path $IiiConfigPath)) { + Write-KitError "Missing kit iii-config.yaml at $IiiConfigPath" + Write-KitError "Re-copy the kit or re-run setup.cmd" + exit 1 + } + if (-not (Test-Path $DataDir)) { + New-Item -ItemType Directory -Force -Path $DataDir | Out-Null + } + Sync-IiiConfigForLayout +} + +function Show-DockerConflictMenu { + param( + [string[]]$ContainerNames + ) + + $names = @($ContainerNames | Where-Object { $_ } | Select-Object -Unique) + $stopCmd = if ($names.Count -gt 0) { + "docker stop $($names -join ' ')" + } else { + "docker stop " + } + + Write-Host "" + Write-Host "============================================================" -ForegroundColor Yellow + Write-Host " ATTENZIONE: Docker locale con agentmemory/iii attivo" -ForegroundColor Yellow + Write-Host "============================================================" -ForegroundColor Yellow + Write-Host "" + Write-Host "Il kit USB non puo avviarsi in sicurezza." -ForegroundColor White + Write-Host "Se proseguisse, agentmemory si aggancierebbe all'engine Docker" -ForegroundColor White + Write-Host "del PC e i dati finirebbero nel volume Docker, NON sulla pen drive." -ForegroundColor White + Write-Host "" + if ($names.Count -gt 0) { + Write-Host "Container rilevati:" -ForegroundColor Cyan + foreach ($n in $names) { + Write-Host " - $n" -ForegroundColor Cyan + } + Write-Host "" + } + Write-Host "Scegli un'opzione:" -ForegroundColor Green + Write-Host "" + Write-Host " A) Istruzioni manuali (fermo io Docker, poi rilancio start.cmd)" -ForegroundColor Green + Write-Host " Comando tipico: $stopCmd" -ForegroundColor DarkGray + Write-Host "" + Write-Host " B) Resta su Docker sul PC (non usare il kit USB adesso)" -ForegroundColor DarkYellow + Write-Host " Cursor: http://127.0.0.1:3111" -ForegroundColor DarkGray + Write-Host "" + Write-Host " C) Pulisci in automatico e avvia il kit USB" -ForegroundColor Cyan + Write-Host " - ferma i container Docker rilevati" -ForegroundColor DarkGray + Write-Host " - ripulisce pid/state del kit su questa pen drive" -ForegroundColor DarkGray + Write-Host " - NON cancella i volumi Docker (i dati sul PC restano)" -ForegroundColor DarkGray + Write-Host " - poi prosegue con start sulla USB (dati in data\)" -ForegroundColor DarkGray + Write-Host "" + Write-Host "============================================================" -ForegroundColor Yellow +} + +function Get-AgentmemoryDockerContainers { + $docker = Get-Command docker -ErrorAction SilentlyContinue + if (-not $docker) { return @() } + + $names = @() + $byName = docker ps --format "{{.Names}}" 2>$null | Where-Object { $_ -match "agentmemory|iii-engine|iii" } + if ($byName) { $names += @($byName) } + + $byPort = docker ps --format "{{.Names}}\t{{.Ports}}" 2>$null | ForEach-Object { + if ($_ -match "3111|3112|49134") { + ($_ -split "`t")[0] + } + } + if ($byPort) { $names += @($byPort) } + + return @($names | Where-Object { $_ } | Select-Object -Unique) +} + +function Clear-KitRuntimeState { + Write-KitInfo "Cleaning kit runtime state under home\.agentmemory ..." + foreach ($name in @("iii.pid", "worker.pid", "engine-state.json")) { + $p = Join-Path $AgentmemoryHome $name + if (Test-Path $p) { + Remove-Item -Force $p -ErrorAction SilentlyContinue + Write-KitInfo " removed $name" + } + } + + # Leftover portable processes from a previous USB session on this PC + Get-Process -ErrorAction SilentlyContinue | + Where-Object { + $_.Path -and ( + $_.Path -like "*\agentmemory-portable\*" -or + $_.Path -like "*\home\.agentmemory\bin\iii.exe" + ) + } | + ForEach-Object { + Write-KitInfo " stopping leftover $($_.ProcessName) pid $($_.Id)" + Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue + } +} + +function Stop-AgentmemoryDocker { + param( + [string[]]$ContainerNames + ) + + $names = @($ContainerNames | Where-Object { $_ } | Select-Object -Unique) + if ($names.Count -eq 0) { + Write-KitWarn "No Docker containers to stop." + return $true + } + + Write-KitInfo "Stopping Docker containers: $($names -join ', ')" + docker stop @names 2>&1 | ForEach-Object { Write-Host " $_" } + if ($LASTEXITCODE -ne 0) { + Write-KitWarn "docker stop returned $LASTEXITCODE - checking ports anyway..." + } + + # Best-effort compose down without -v (keeps PC volumes intact) + $composeCandidates = @( + (Join-Path $RepoDir "docker-compose.yml"), + (Join-Path $KitRoot "docker-compose.yml") + ) + foreach ($compose in $composeCandidates) { + if (Test-Path $compose) { + Write-KitInfo "docker compose -f `"$compose`" down (no volume delete)" + Push-Location (Split-Path -Parent $compose) + try { + docker compose -f $compose down 2>&1 | ForEach-Object { Write-Host " $_" } + } finally { + Pop-Location + } + break + } + } + + Start-Sleep -Seconds 2 + $still = Get-AgentmemoryDockerContainers + if ($still.Count -gt 0) { + Write-KitError "Containers still running after cleanup: $($still -join ', ')" + Write-KitError "Stop them manually, then re-run start.cmd" + return $false + } + + Write-KitInfo "Docker conflict cleared. USB data path will be used: $DataDir" + return $true +} + +function Resolve-DockerConflict { + param( + [switch]$AutoClean + ) + + $running = Get-AgentmemoryDockerContainers + if ($running.Count -eq 0) { return $true } + + if ($AutoClean) { + Write-KitWarn "AutoClean: Docker agentmemory detected - cleaning and continuing..." + Clear-KitRuntimeState + if (-not (Stop-AgentmemoryDocker -ContainerNames $running)) { return $false } + return $true + } + + Show-DockerConflictMenu -ContainerNames $running + + $choice = "" + try { + Write-Host "Digita A, B o C e premi Invio: " -NoNewline -ForegroundColor White + $choice = [System.Console]::ReadLine() + } catch { + Write-KitError "Interactive input unavailable. Re-run with start-clean.cmd for automatic cleanup." + return $false + } + + switch -Regex ($choice.Trim().ToUpperInvariant()) { + "^A" { + Write-Host "" + Write-Host "Procedura manuale:" -ForegroundColor Green + Write-Host " 1. docker stop $($running -join ' ')" -ForegroundColor White + Write-Host " 2. (opzionale) docker compose down nella cartella del progetto" -ForegroundColor White + Write-Host " 3. Rilancia start.cmd" -ForegroundColor White + Write-Host "" + Write-Host "Premi Invio per chiudere..." -ForegroundColor DarkGray + try { [void][System.Console]::ReadLine() } catch { Start-Sleep -Seconds 5 } + return $false + } + "^B" { + Write-Host "" + Write-Host "Ok: resto su Docker. Non avvio il kit USB." -ForegroundColor DarkYellow + Write-Host "MCP/Cursor: http://127.0.0.1:3111" -ForegroundColor DarkYellow + Write-Host "" + Write-Host "Premi Invio per chiudere..." -ForegroundColor DarkGray + try { [void][System.Console]::ReadLine() } catch { Start-Sleep -Seconds 5 } + return $false + } + "^C" { + Write-Host "" + Write-KitInfo "Opzione C: pulizia automatica in corso..." + Clear-KitRuntimeState + if (-not (Stop-AgentmemoryDocker -ContainerNames $running)) { + Write-Host "Premi Invio per chiudere..." -ForegroundColor DarkGray + try { [void][System.Console]::ReadLine() } catch { Start-Sleep -Seconds 5 } + return $false + } + Write-KitInfo "Pulizia completata. Avvio del daemon USB..." + return $true + } + default { + Write-KitError "Scelta non valida ('$choice'). Usa A, B o C." + Write-Host "Premi Invio per chiudere..." -ForegroundColor DarkGray + try { [void][System.Console]::ReadLine() } catch { Start-Sleep -Seconds 5 } + return $false + } + } +} + +function Assert-NoForeignEngine { + param( + [switch]$AutoClean + ) + + if (-not (Resolve-DockerConflict -AutoClean:$AutoClean)) { + exit 1 + } +} + +function Set-PortableRuntimeEnv { + param( + [switch]$ForDaemon + ) + + $env:PATH = "$NodeDir;$IiiBinDir;$env:PATH" + $env:npm_config_cache = Join-Path $PortableDir "npm-cache" + + if ($ForDaemon) { + $env:USERPROFILE = $HomeDir + $env:HOME = $HomeDir + $env:HOMEDRIVE = (Split-Path -Qualifier $HomeDir) + $env:HOMEPATH = ($HomeDir.Substring($env:HOMEDRIVE.Length)) + $env:APPDATA = Join-Path $HomeDir "AppData\Roaming" + $env:LOCALAPPDATA = Join-Path $HomeDir "AppData\Local" + $env:TEMP = Join-Path $HomeDir "Temp" + $env:TMP = Join-Path $HomeDir "Temp" + + $env:HF_HOME = Join-Path $HomeDir "cache\huggingface" + $env:TRANSFORMERS_CACHE = Join-Path $HomeDir "cache\transformers" + $env:XDG_CACHE_HOME = Join-Path $HomeDir "cache" + + $env:AGENTMEMORY_III_VERSION = (Get-KitConfig).IiiVersion + $env:AGENTMEMORY_URL = "http://127.0.0.1:3111" + $env:AGENTMEMORY_III_CONFIG = $IiiConfigPath + $env:AGENTMEMORY_USE_DOCKER = "0" + $env:AGENTMEMORY_EXPORT_ROOT = Join-Path $AgentmemoryHome "exports" + $env:SNAPSHOT_DIR = Join-Path $AgentmemoryHome "snapshots" + + foreach ($d in @( + $env:APPDATA, + $env:LOCALAPPDATA, + $env:TEMP, + $env:HF_HOME, + $env:TRANSFORMERS_CACHE, + $env:XDG_CACHE_HOME, + $AgentmemoryHome, + $IiiBinDir, + $DataDir, + $env:AGENTMEMORY_EXPORT_ROOT, + $env:SNAPSHOT_DIR + )) { + if (-not (Test-Path $d)) { + New-Item -ItemType Directory -Force -Path $d | Out-Null + } + } + } +} + +function Invoke-AgentmemoryCli { + param( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$CliArgs + ) + + Assert-NodePresent + Assert-RepoBuilt + Assert-UsbDataLayout + # cwd = kit root so iii-config ./data stays on the USB/kit folder + Set-Location $KitRoot + & $NodeExe $CliEntry @CliArgs + return $LASTEXITCODE +} + +function Complete-WindowsBuildArtifacts { + # package.json "build" uses Unix cp/mkdir/true; on Windows cmd that tail fails + # after tsdown already wrote dist/. Copy the runtime assets the CLI expects. + $dist = Join-Path $RepoDir "dist" + if (-not (Test-Path $dist)) { + New-Item -ItemType Directory -Force -Path $dist | Out-Null + } + foreach ($name in @("iii-config.yaml", "iii-config.docker.yaml", "docker-compose.yml", ".env.example")) { + $src = Join-Path $RepoDir $name + if (Test-Path $src) { + Copy-Item $src (Join-Path $dist $name) -Force + } + } + $viewerSrc = Join-Path $RepoDir "src\viewer" + $viewerDst = Join-Path $dist "viewer" + if (-not (Test-Path $viewerDst)) { + New-Item -ItemType Directory -Force -Path $viewerDst | Out-Null + } + foreach ($name in @("index.html", "favicon.svg")) { + $src = Join-Path $viewerSrc $name + if (Test-Path $src) { + Copy-Item $src (Join-Path $viewerDst $name) -Force + } + } +} + +function Invoke-RepoBuild { + $npmCmd = Join-Path $NodeDir "npm.cmd" + if (-not (Test-Path $npmCmd)) { throw "npm.cmd not found in portable Node: $npmCmd" } + Set-Location $RepoDir + Write-KitInfo "npm run build (tsdown) ..." + & $npmCmd run build + $buildCode = $LASTEXITCODE + Complete-WindowsBuildArtifacts + if (-not (Test-Path $CliEntry)) { + throw "Build incomplete: missing $CliEntry (npm exit $buildCode)" + } + if ($buildCode -ne 0) { + Write-KitWarn "npm run build exited $buildCode (Unix post-copy on Windows). Assets repaired; dist\cli.mjs OK." + } +} + diff --git a/agentmemory-portable/scripts/ready-banner.ps1 b/agentmemory-portable/scripts/ready-banner.ps1 new file mode 100644 index 000000000..44b016dee --- /dev/null +++ b/agentmemory-portable/scripts/ready-banner.ps1 @@ -0,0 +1,35 @@ +# Prints the viewer URL once agentmemory /health is healthy. +# Invoked as a sidecar from start.ps1 (same console, -NoNewWindow). +$ErrorActionPreference = "SilentlyContinue" + +for ($i = 0; $i -lt 120; $i++) { + Start-Sleep -Seconds 1 + try { + $h = Invoke-RestMethod -Uri "http://127.0.0.1:3111/agentmemory/health" -TimeoutSec 2 + $ok = ($h.status -eq "healthy") -or ($h.service -eq "agentmemory") + if (-not $ok) { continue } + + $vp = 3113 + if ($null -ne $h.viewerPort) { + $parsed = 0 + if ([int]::TryParse([string]$h.viewerPort, [ref]$parsed) -and $parsed -gt 0) { + $vp = $parsed + } + } + + Write-Host "" + Write-Host "============================================================" -ForegroundColor Green + Write-Host " agentmemory USB - PRONTO" -ForegroundColor Green + Write-Host "============================================================" -ForegroundColor Green + Write-Host (" Viewer: http://127.0.0.1:{0}" -f $vp) -ForegroundColor Cyan + Write-Host " REST: http://127.0.0.1:3111/agentmemory/*" -ForegroundColor Cyan + Write-Host " Health: http://127.0.0.1:3111/agentmemory/health" -ForegroundColor Cyan + Write-Host "============================================================" -ForegroundColor Green + Write-Host "" + exit 0 + } catch { + # keep polling + } +} + +exit 1 diff --git a/agentmemory-portable/scripts/setup.ps1 b/agentmemory-portable/scripts/setup.ps1 new file mode 100644 index 000000000..b4ccc16d7 --- /dev/null +++ b/agentmemory-portable/scripts/setup.ps1 @@ -0,0 +1,201 @@ +# Bootstrap one-shot: Node portable + iii.exe + clone + npm ci/build + seed config. +param( + [string]$UseExistingRepo = "", + [switch]$SkipNodeDownload, + [switch]$SkipIiiDownload, + [switch]$SkipClone, + [switch]$SkipBuild +) + +. "$PSScriptRoot\_env.ps1" + +$cfg = Get-KitConfig +$nodeVersion = $cfg.NodeVersion +$iiiVersion = $cfg.IiiVersion +$repoUrl = $cfg.RepoUrl + +Write-KitInfo "Kit root: $KitRoot" +Write-KitInfo "Repo dir: $RepoDir (in-tree=$InTree)" +Write-KitInfo "Node pin: v$nodeVersion | iii pin: v$iiiVersion" + +foreach ($d in @( + $HomeDir, + $AgentmemoryHome, + $IiiBinDir, + $PortableDir, + $DownloadsDir, + $DataDir, + (Join-Path $HomeDir "AppData\Roaming"), + (Join-Path $HomeDir "AppData\Local"), + (Join-Path $HomeDir "Temp"), + (Join-Path $HomeDir "cache") + )) { + if (-not (Test-Path $d)) { + New-Item -ItemType Directory -Force -Path $d | Out-Null + } +} + +# Ensure kit-owned iii-config (SQLite in ./data with cwd=kit root) +if (-not (Test-Path $IiiConfigPath)) { + $repoCfg = Join-Path $RepoDir "iii-config.yaml" + if (Test-Path $repoCfg) { + Copy-Item $repoCfg $IiiConfigPath + Write-KitWarn "Copied upstream iii-config.yaml - adjusting paths for kit layout" + } + else { + throw "Missing $IiiConfigPath - restore iii-config.yaml in the kit root" + } +} +Sync-IiiConfigForLayout + +# --- Node.js portable --- +if (-not $SkipNodeDownload) { + if (Test-Path $NodeExe) { + Write-KitInfo "Node already present: $NodeExe" + } + else { + $nodeZipName = "node-v$nodeVersion-win-x64.zip" + $nodeUrl = "https://nodejs.org/dist/v$nodeVersion/$nodeZipName" + $nodeZip = Join-Path $DownloadsDir $nodeZipName + Write-KitInfo "Downloading Node $nodeVersion ..." + Invoke-WebRequest -Uri $nodeUrl -OutFile $nodeZip -UseBasicParsing + $extractTmp = Join-Path $DownloadsDir "node-extract" + if (Test-Path $extractTmp) { Remove-Item -Recurse -Force $extractTmp } + Expand-Archive -Path $nodeZip -DestinationPath $extractTmp -Force + $inner = Get-ChildItem $extractTmp -Directory | Select-Object -First 1 + if (-not $inner) { throw "Node extract failed: inner folder missing" } + if (Test-Path $NodeDir) { Remove-Item -Recurse -Force $NodeDir } + Move-Item -Path $inner.FullName -Destination $NodeDir + Remove-Item -Recurse -Force $extractTmp -ErrorAction SilentlyContinue + Write-KitInfo "Node installed at $NodeDir" + } +} + +Assert-NodePresent +$env:PATH = "$NodeDir;$env:PATH" +$env:npm_config_cache = Join-Path $PortableDir "npm-cache" + +# --- iii-engine --- +if (-not $SkipIiiDownload) { + if (Test-Path $IiiExe) { + Write-KitInfo "iii.exe already present: $IiiExe" + } + else { + $iiiZipName = "iii-x86_64-pc-windows-msvc.zip" + $iiiUrl = "https://github.com/iii-hq/iii/releases/download/iii/v$iiiVersion/$iiiZipName" + $iiiZip = Join-Path $DownloadsDir $iiiZipName + Write-KitInfo "Downloading iii-engine v$iiiVersion ..." + Invoke-WebRequest -Uri $iiiUrl -OutFile $iiiZip -UseBasicParsing + $iiiExtract = Join-Path $DownloadsDir "iii-extract" + if (Test-Path $iiiExtract) { Remove-Item -Recurse -Force $iiiExtract } + Expand-Archive -Path $iiiZip -DestinationPath $iiiExtract -Force + $found = Get-ChildItem -Path $iiiExtract -Filter "iii.exe" -Recurse | Select-Object -First 1 + if (-not $found) { throw "iii.exe not found in downloaded zip" } + Copy-Item -Path $found.FullName -Destination $IiiExe -Force + Copy-Item -Path $found.FullName -Destination (Join-Path $PortableDir "iii.exe") -Force + Remove-Item -Recurse -Force $iiiExtract -ErrorAction SilentlyContinue + Write-KitInfo "iii.exe installed at $IiiExe" + } +} + +Assert-IiiPresent + +# --- repo --- +if ($InTree) { + Write-KitInfo "In-tree layout: using parent project as repo ($RepoDir)" +} +elseif (-not $SkipClone) { + if ($UseExistingRepo) { + $src = (Resolve-Path $UseExistingRepo).Path + if (Test-Path $RepoDir) { + Write-KitWarn "repo\ already exists - skipping junction to $src" + } + else { + Write-KitInfo "Linking existing repo via junction: $src" + cmd /c "mklink /J `"$RepoDir`" `"$src`"" + if ($LASTEXITCODE -ne 0) { throw "mklink /J failed" } + } + } + elseif (Test-Path (Join-Path $RepoDir ".git")) { + Write-KitInfo "Clone already present at $RepoDir" + } + else { + if (Test-Path $RepoDir) { + throw "repo\ exists but is not a git clone. Remove it or use -UseExistingRepo" + } + Write-KitInfo "Cloning $repoUrl ..." + git clone --depth 1 $repoUrl $RepoDir + if ($LASTEXITCODE -ne 0) { throw "git clone failed" } + } +} + +# --- seed config (do not overwrite existing .env) --- +$envTarget = Join-Path $AgentmemoryHome ".env" +$envExample = Join-Path $RepoDir ".env.example" +if (-not (Test-Path $envTarget)) { + if (Test-Path $envExample) { + Copy-Item $envExample $envTarget + } + else { + @( + "# agentmemory portable kit - minimal seed", + "EMBEDDING_PROVIDER=local", + "AGENTMEMORY_URL=http://127.0.0.1:3111" + ) | Set-Content -Path $envTarget -Encoding UTF8 + } + @( + "", + "# --- portable kit overrides ---", + "EMBEDDING_PROVIDER=local", + "AGENTMEMORY_URL=http://127.0.0.1:3111", + "AGENTMEMORY_USE_DOCKER=0" + ) | Add-Content -Path $envTarget -Encoding UTF8 + Write-KitInfo "Created $envTarget" +} +else { + Write-KitInfo ".env already present - left unchanged" +} + +$prefsPath = Join-Path $AgentmemoryHome "preferences.json" +if (-not (Test-Path $prefsPath)) { + $prefs = @{ + schemaVersion = 1 + lastAgent = $null + lastAgents = @() + lastProvider = $null + skipSplash = $true + skipNpxHint = $true + skipGlobalInstall = $true + skipConsoleInstall = $true + firstRunAt = (Get-Date).ToUniversalTime().ToString("o") + injectContextChosen = $true + } | ConvertTo-Json -Depth 4 + Set-Content -Path $prefsPath -Value $prefs -Encoding UTF8 + Write-KitInfo "Created preferences.json (onboarding skipped)" +} + +# --- build --- +if (-not $SkipBuild) { + if (-not (Test-Path $RepoDir)) { + throw "repo\ missing - cannot run npm install/build" + } + $npmCmd = Join-Path $NodeDir "npm.cmd" + if (-not (Test-Path $npmCmd)) { throw "npm.cmd not found in portable Node: $npmCmd" } + + Set-Location $RepoDir + Write-KitInfo "npm install ..." + & $npmCmd install + if ($LASTEXITCODE -ne 0) { throw "npm install failed" } + + Invoke-RepoBuild +} + +if (-not (Test-Path $CliEntry)) { + throw "Build incomplete: missing $CliEntry" +} + +Write-KitInfo "Setup complete." +Write-KitInfo "Start with start.cmd | Stop with stop.cmd | Update with update.cmd" +Write-Host "" +Write-Host "Default ports: REST 3111 | streams 3112 | viewer 3113 | engine WS 49134" +Write-Host "Cursor MCP config: see mcp-cursor.example.json and README.md" diff --git a/agentmemory-portable/scripts/start.ps1 b/agentmemory-portable/scripts/start.ps1 new file mode 100644 index 000000000..a687ef8f7 --- /dev/null +++ b/agentmemory-portable/scripts/start.ps1 @@ -0,0 +1,47 @@ +# Start the agentmemory daemon with home/cwd on the kit root. +param( + [switch]$VerboseCli, + [switch]$AutoCleanDocker +) + +. "$PSScriptRoot\_env.ps1" + +function Start-ReadyBannerWatcher { + $bannerScript = Join-Path $PSScriptRoot "ready-banner.ps1" + if (-not (Test-Path $bannerScript)) { return } + Start-Process -FilePath "powershell.exe" -ArgumentList @( + "-NoProfile", + "-ExecutionPolicy", "Bypass", + "-File", $bannerScript + ) -NoNewWindow | Out-Null +} + +Assert-NodePresent +Assert-IiiPresent +Assert-RepoBuilt +Assert-UsbDataLayout +Assert-NoForeignEngine -AutoClean:$AutoCleanDocker +Set-PortableRuntimeEnv -ForDaemon + +Write-KitInfo "USERPROFILE -> $env:USERPROFILE" +Write-KitInfo "kit root -> $KitRoot" +Write-KitInfo "repo -> $RepoDir" +Write-KitInfo "data -> $DataDir" +Write-KitInfo "iii-config -> $env:AGENTMEMORY_III_CONFIG" +Write-KitInfo "iii -> $IiiExe" +Write-KitInfo "Starting daemon (keep this window open)..." +Write-Host "" +Write-Host "All'avvio completo il viewer sara disponibile tipicamente su:" -ForegroundColor DarkGray +Write-Host " http://127.0.0.1:3113" -ForegroundColor DarkGray +Write-Host "" + +Start-ReadyBannerWatcher + +$cliArgs = @() +if ($VerboseCli) { $cliArgs += "--verbose" } + +$code = Invoke-AgentmemoryCli @cliArgs +if ($code -ne 0) { + Write-KitError "Start exited with code $code" + exit $code +} diff --git a/agentmemory-portable/scripts/status.ps1 b/agentmemory-portable/scripts/status.ps1 new file mode 100644 index 000000000..2fcc66401 --- /dev/null +++ b/agentmemory-portable/scripts/status.ps1 @@ -0,0 +1,14 @@ +# Daemon status / doctor against the portable home. +param( + [ValidateSet("status", "doctor")] + [string]$Mode = "status" +) + +. "$PSScriptRoot\_env.ps1" + +Assert-NodePresent +Assert-RepoBuilt +Set-PortableRuntimeEnv -ForDaemon + +$code = Invoke-AgentmemoryCli $Mode +exit $code diff --git a/agentmemory-portable/scripts/stop.ps1 b/agentmemory-portable/scripts/stop.ps1 new file mode 100644 index 000000000..fa5344fa2 --- /dev/null +++ b/agentmemory-portable/scripts/stop.ps1 @@ -0,0 +1,18 @@ +# Stop engine + worker started by the portable kit. +param( + [switch]$Force +) + +. "$PSScriptRoot\_env.ps1" + +Assert-NodePresent +Assert-RepoBuilt +Set-PortableRuntimeEnv -ForDaemon + +Write-KitInfo "Stopping daemon (home=$env:USERPROFILE)..." + +$cliArgs = @("stop") +if ($Force) { $cliArgs += "--force" } + +$code = Invoke-AgentmemoryCli @cliArgs +exit $code diff --git a/agentmemory-portable/scripts/update.ps1 b/agentmemory-portable/scripts/update.ps1 new file mode 100644 index 000000000..a33a639bc --- /dev/null +++ b/agentmemory-portable/scripts/update.ps1 @@ -0,0 +1,66 @@ +# Update upstream clone and rebuild without patching sources by hand. +param( + [switch]$SkipPull +) + +. "$PSScriptRoot\_env.ps1" + +Assert-NodePresent + +if (-not (Test-Path $RepoDir)) { + Write-KitError "repo\ missing - run setup.cmd first" + exit 1 +} + +# For git: keep host profile (SSH / credential manager). +# For npm: portable Node + cache on the kit root. +$env:PATH = "$NodeDir;$env:PATH" +$env:npm_config_cache = Join-Path $PortableDir "npm-cache" +$env:USERPROFILE = $RealUserProfile +if ($RealHome) { $env:HOME = $RealHome } +if ($RealAppData) { $env:APPDATA = $RealAppData } +if ($RealLocalAppData) { $env:LOCALAPPDATA = $RealLocalAppData } +if ($RealTemp) { $env:TEMP = $RealTemp } +if ($RealTmp) { $env:TMP = $RealTmp } + +Set-Location $RepoDir +$npmCmd = Join-Path $NodeDir "npm.cmd" +if (-not (Test-Path $npmCmd)) { + Write-KitError "npm.cmd not found in $NodeDir" + exit 1 +} + +if (-not $SkipPull) { + Write-KitInfo "git pull ..." + git pull --ff-only + if ($LASTEXITCODE -ne 0) { + Write-KitWarn "git pull --ff-only failed - retrying git pull" + git pull + if ($LASTEXITCODE -ne 0) { + Write-KitError "git pull failed (conflicts or network). Fix and re-run update.cmd" + exit $LASTEXITCODE + } + } +} + +$cfg = Get-KitConfig +$env:AGENTMEMORY_III_VERSION = $cfg.IiiVersion + +Write-KitInfo "npm install ..." +& $npmCmd install +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +Invoke-RepoBuild + +if (-not (Test-Path $IiiExe)) { + $portableIii = Join-Path $PortableDir "iii.exe" + if (Test-Path $portableIii) { + Copy-Item $portableIii $IiiExe -Force + Write-KitInfo "Restored iii.exe to $IiiExe" + } + else { + Write-KitWarn "iii.exe missing - re-run setup.cmd to download it" + } +} + +Write-KitInfo "Update complete. Restart with stop.cmd then start.cmd" diff --git a/agentmemory-portable/setup.cmd b/agentmemory-portable/setup.cmd new file mode 100644 index 000000000..78e11842a --- /dev/null +++ b/agentmemory-portable/setup.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal +cd /d "%~dp0" +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\setup.ps1" %* +exit /b %ERRORLEVEL% diff --git a/agentmemory-portable/start-clean.cmd b/agentmemory-portable/start-clean.cmd new file mode 100644 index 000000000..2d25945be --- /dev/null +++ b/agentmemory-portable/start-clean.cmd @@ -0,0 +1,6 @@ +@echo off +setlocal +cd /d "%~dp0" +REM Stop conflicting Docker + clean kit state, then start (no prompt). +start "agentmemory-portable" powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\start.ps1" -AutoCleanDocker %* +exit /b 0 diff --git a/agentmemory-portable/start.cmd b/agentmemory-portable/start.cmd new file mode 100644 index 000000000..6d61037b6 --- /dev/null +++ b/agentmemory-portable/start.cmd @@ -0,0 +1,6 @@ +@echo off +setlocal +cd /d "%~dp0" +REM Open a dedicated console so double-click keeps the daemon visible. +start "agentmemory-portable" powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\start.ps1" %* +exit /b 0 diff --git a/agentmemory-portable/status.cmd b/agentmemory-portable/status.cmd new file mode 100644 index 000000000..e77a858b4 --- /dev/null +++ b/agentmemory-portable/status.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal +cd /d "%~dp0" +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\status.ps1" %* +exit /b %ERRORLEVEL% diff --git a/agentmemory-portable/stop.cmd b/agentmemory-portable/stop.cmd new file mode 100644 index 000000000..5c4771ddb --- /dev/null +++ b/agentmemory-portable/stop.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal +cd /d "%~dp0" +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\stop.ps1" -Force %* +exit /b %ERRORLEVEL% diff --git a/agentmemory-portable/update.cmd b/agentmemory-portable/update.cmd new file mode 100644 index 000000000..4038d4bdf --- /dev/null +++ b/agentmemory-portable/update.cmd @@ -0,0 +1,5 @@ +@echo off +setlocal +cd /d "%~dp0" +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\update.ps1" %* +exit /b %ERRORLEVEL% diff --git a/plugin/scripts/notification.mjs b/plugin/scripts/notification.mjs index 0a814e892..c572c1bed 100755 --- a/plugin/scripts/notification.mjs +++ b/plugin/scripts/notification.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/notification.ts +//#region ../../agentmemory/src/hooks/notification.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/post-commit.mjs b/plugin/scripts/post-commit.mjs index 04cc62362..a020ae2a7 100755 --- a/plugin/scripts/post-commit.mjs +++ b/plugin/scripts/post-commit.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execFile } from "node:child_process"; import { promisify } from "node:util"; -//#region src/hooks/post-commit.ts +//#region ../../agentmemory/src/hooks/post-commit.ts const exec = promisify(execFile); function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; diff --git a/plugin/scripts/post-tool-failure.mjs b/plugin/scripts/post-tool-failure.mjs index 18782a561..62549139f 100755 --- a/plugin/scripts/post-tool-failure.mjs +++ b/plugin/scripts/post-tool-failure.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/post-tool-failure.ts +//#region ../../agentmemory/src/hooks/post-tool-failure.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/post-tool-use.mjs b/plugin/scripts/post-tool-use.mjs index 53853ee14..2b324b479 100755 --- a/plugin/scripts/post-tool-use.mjs +++ b/plugin/scripts/post-tool-use.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/post-tool-use.ts +//#region ../../agentmemory/src/hooks/post-tool-use.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/pre-compact.mjs b/plugin/scripts/pre-compact.mjs index c4b8cea1a..a83c80e20 100755 --- a/plugin/scripts/pre-compact.mjs +++ b/plugin/scripts/pre-compact.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/pre-compact.ts +//#region ../../agentmemory/src/hooks/pre-compact.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/pre-tool-use.mjs b/plugin/scripts/pre-tool-use.mjs index ad1094a11..27a35867d 100755 --- a/plugin/scripts/pre-tool-use.mjs +++ b/plugin/scripts/pre-tool-use.mjs @@ -1,5 +1,5 @@ #!/usr/bin/env node -//#region src/hooks/pre-tool-use.ts +//#region ../../agentmemory/src/hooks/pre-tool-use.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/prompt-submit.mjs b/plugin/scripts/prompt-submit.mjs index 3bb271ae0..4c813159a 100755 --- a/plugin/scripts/prompt-submit.mjs +++ b/plugin/scripts/prompt-submit.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/prompt-submit.ts +//#region ../../agentmemory/src/hooks/prompt-submit.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/session-end.mjs b/plugin/scripts/session-end.mjs index 811c1c262..899442714 100755 --- a/plugin/scripts/session-end.mjs +++ b/plugin/scripts/session-end.mjs @@ -1,5 +1,5 @@ #!/usr/bin/env node -//#region src/hooks/session-end.ts +//#region ../../agentmemory/src/hooks/session-end.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/session-start.mjs b/plugin/scripts/session-start.mjs index 8c1bb6477..061a5de04 100755 --- a/plugin/scripts/session-start.mjs +++ b/plugin/scripts/session-start.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/session-start.ts +//#region ../../agentmemory/src/hooks/session-start.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/stop.mjs b/plugin/scripts/stop.mjs index 0b1c43b0b..4519b9df0 100755 --- a/plugin/scripts/stop.mjs +++ b/plugin/scripts/stop.mjs @@ -1,5 +1,5 @@ #!/usr/bin/env node -//#region src/hooks/stop.ts +//#region ../../agentmemory/src/hooks/stop.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/subagent-start.mjs b/plugin/scripts/subagent-start.mjs index a089ae3d7..479c87b77 100755 --- a/plugin/scripts/subagent-start.mjs +++ b/plugin/scripts/subagent-start.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/subagent-start.ts +//#region ../../agentmemory/src/hooks/subagent-start.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/subagent-stop.mjs b/plugin/scripts/subagent-stop.mjs index 4e00f9d7b..27713e9ee 100755 --- a/plugin/scripts/subagent-stop.mjs +++ b/plugin/scripts/subagent-stop.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/subagent-stop.ts +//#region ../../agentmemory/src/hooks/subagent-stop.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false; diff --git a/plugin/scripts/task-completed.mjs b/plugin/scripts/task-completed.mjs index e8a5bfcca..3da0cbb83 100755 --- a/plugin/scripts/task-completed.mjs +++ b/plugin/scripts/task-completed.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execSync } from "node:child_process"; import { basename } from "node:path"; -//#region src/hooks/_project.ts +//#region ../../agentmemory/src/hooks/_project.ts function resolveProject(cwd) { const explicit = process.env["AGENTMEMORY_PROJECT_NAME"]; if (explicit && explicit.trim()) return explicit.trim(); @@ -21,7 +21,7 @@ function resolveProject(cwd) { return basename(dir); } //#endregion -//#region src/hooks/task-completed.ts +//#region ../../agentmemory/src/hooks/task-completed.ts function isSdkChildContext(payload) { if (process.env["AGENTMEMORY_SDK_CHILD"] === "1") return true; if (!payload || typeof payload !== "object") return false;