Initial state: - ia_dev was historically referenced as ./ia_dev in docs and integrations, while the vendored module lives under services/ia_dev. - AnythingLLM sync and hook installation had error masking / weak exit signaling. - Proxy layers did not validate proxy path segments, allowing path normalization tricks. Motivation: - Make the IDE-oriented workflow usable (sync -> act -> deploy/preview) with explicit errors. - Reduce security footguns in proxying and script automation. Resolution: - Standardize IA_DEV_ROOT usage and documentation to services/ia_dev. - Add SSH remote data mirroring + optional AnythingLLM ingestion. - Extend AnythingLLM pull sync to support upload-all/prefix and fail on upload errors. - Harden smart-ide-sso-gateway and smart-ide-global-api proxying with safe-path checks and non-leaking error responses. - Improve ia-dev-gateway runner validation and reduce sensitive path leakage. - Add site scaffold tool (Vite/React) with OIDC + chat via sso-gateway -> orchestrator. Root cause: - Historical layout changes (submodule -> vendored tree) and missing central contracts for path resolution. - Missing validation for proxy path traversal patterns. - Overuse of silent fallbacks (|| true, exit 0 on partial failures) in automation scripts. Impacted features: - Project sync: git pull + AnythingLLM sync + remote data mirror ingestion. - Site frontends: SSO gateway proxy and orchestrator intents (rag.query, chat.local). - Agent execution: ia-dev-gateway script runner and SSE output. Code modified: - scripts/remote-data-ssh-sync.sh - scripts/anythingllm-pull-sync/sync.mjs - scripts/install-anythingllm-post-merge-hook.sh - cron/git-pull-project-clones.sh - services/smart-ide-sso-gateway/src/server.ts - services/smart-ide-global-api/src/server.ts - services/smart-ide-orchestrator/src/server.ts - services/ia-dev-gateway/src/server.ts - services/ia_dev/tools/site-generate.sh Documentation modified: - docs/** (architecture, API docs, ia_dev module + integration, scripts) Configurations modified: - config/services.local.env.example - services/*/.env.example Files in deploy modified: - services/ia_dev/deploy/* Files in logs impacted: - logs/ia_dev.log (runtime only) - .logs/* (runtime only) Databases and other sources modified: - None Off-project modifications: - None Files in .smartIde modified: - .smartIde/agents/*.md - services/ia_dev/.smartIde/** Files in .secrets modified: - None New patch version in VERSION: - 0.0.5 CHANGELOG.md updated: - yes
83 lines
3.1 KiB
Bash
Executable File
83 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bounded loop for chat: run mail retrieval N times, 1 minute between each.
|
|
# Use from Cursor chat when asked to "lance la boucle récupération emails puis attend 1 min et relance".
|
|
# Runs in foreground (no background); chat can run it for a few iterations to avoid timeout.
|
|
#
|
|
# Usage:
|
|
# ./git-issues/agent-loop-chat-iterations.sh [N] [--repeat]
|
|
# N = number of iterations (default 3). Each iteration: mail-list-unread.sh then sleep 60.
|
|
# --repeat = after N iterations, relaunch (infinite loop of N-by-N runs).
|
|
# Output and mail list (expéditeur, sujet) are appended to projects/<id>/logs/git-issues/agent-loop-chat-iterations.log.
|
|
#
|
|
set -euo pipefail
|
|
if [ -n "${HOME:-}" ] && [ -r "$HOME/.bashrc" ]; then
|
|
set +u
|
|
# shellcheck source=/dev/null
|
|
source "$HOME/.bashrc" 2>/dev/null || true
|
|
set -u
|
|
fi
|
|
[ -n "${HOME:-}" ] && [ -d "$HOME/.local/bin" ] && export PATH="$HOME/.local/bin:$PATH"
|
|
|
|
GIT_ISSUES_DIR="${GIT_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
|
ROOT="$(cd "${GIT_ISSUES_DIR}/../.." && pwd)"
|
|
export GIT_ISSUES_DIR
|
|
export REPO_ROOT="${ROOT}"
|
|
cd "$ROOT"
|
|
# shellcheck source=lib.sh
|
|
source "${GIT_ISSUES_DIR}/lib.sh" 2>/dev/null || true
|
|
LOGS_GIT_ISSUES="${PROJECT_LOGS_DIR:-$ROOT/logs}/git-issues"
|
|
|
|
REPEAT=""
|
|
if [ "${1:-}" = "--repeat" ]; then
|
|
REPEAT=1
|
|
N="${2:-3}"
|
|
else
|
|
N="${1:-3}"
|
|
fi
|
|
if ! [[ "$N" =~ ^[0-9]+$ ]] || [ "$N" -lt 1 ]; then
|
|
echo "Usage: $0 [N] [--repeat] — N positive integer (default 3). --repeat = relancer à la fin." >&2
|
|
exit 1
|
|
fi
|
|
|
|
LOG_DIR="${LOGS_GIT_ISSUES}"
|
|
LOG_FILE="${LOG_DIR}/agent-loop-chat-iterations.log"
|
|
mkdir -p "$LOG_DIR"
|
|
# Ensure absolute path so logs are always in the same place
|
|
[[ "$LOG_FILE" != /* ]] && LOG_FILE="$(cd "$LOG_DIR" && pwd)/agent-loop-chat-iterations.log"
|
|
|
|
log_and_echo() {
|
|
echo "$1" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
# Log path and start so logs are never "empty" from path confusion
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — log file: $LOG_FILE"
|
|
# Test send at launch: one test email to nicolas.cantu@pm.me
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — test d'envoi vers nicolas.cantu@pm.me"
|
|
"${GIT_ISSUES_DIR}/mail-send-reply.sh" --to "nicolas.cantu@pm.me" --subject "Test envoi - agent-loop-chat $(date +%Y-%m-%dT%H:%M:%S)" --body "Mail de test envoyé au lancement de agent-loop-chat-iterations.sh." 2>&1 | tee -a "$LOG_FILE"
|
|
if [ "${PIPESTATUS[0]:-0}" -eq 0 ]; then
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — test d'envoi OK"
|
|
else
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — test d'envoi échoué"
|
|
exit 1
|
|
fi
|
|
|
|
run_iterations() {
|
|
for i in $(seq 1 "$N"); do
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — iteration $i/$N"
|
|
"${GIT_ISSUES_DIR}/mail-list-unread.sh" 2>&1 | tee -a "$LOG_FILE" || true
|
|
if [ "$i" -lt "$N" ]; then
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — attente 60 s avant prochaine itération"
|
|
sleep 60
|
|
fi
|
|
done
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — $N itérations terminées"
|
|
}
|
|
|
|
while true; do
|
|
run_iterations
|
|
if [ -z "${REPEAT:-}" ]; then
|
|
break
|
|
fi
|
|
log_and_echo "[agent-loop-chat] $(date -Iseconds) — relance"
|
|
done
|