Skip to content

Commit 45da5bf

Browse files
authored
Merge pull request #39 from UiPath/feature/darwinimprovements
Darwin improvements: indexing scaling, retention, analytics dashboard, tests
2 parents 4110841 + da6650b commit 45da5bf

94 files changed

Lines changed: 16776 additions & 2434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/runtests.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
description: Run the project's automated checks (TypeScript, mypy, pytest if scoped) and summarise failures.
3+
allowed-tools: Bash, Read
4+
---
5+
6+
Run the standard validation suite for whatever scope the user gave (default: both backend + frontend). Output a tight summary with pass/fail counts and the first error per failing tool — don't paste full logs back unless the user asks.
7+
8+
# Steps
9+
10+
1. **Decide scope from the user's message.**
11+
- If they wrote `/runtests backend` → only backend checks.
12+
- If `/runtests web` or `/runtests frontend` → only frontend checks.
13+
- If `/runtests <path>` → only checks scoped to that path (mypy on Python files, tsc on TS files, pytest on tests dir).
14+
- Otherwise → run both backend and frontend.
15+
16+
2. **Backend checks (run sequentially, stop reporting on each):**
17+
- `cd backend && python -m mypy . 2>&1 | tail -50` — mypy across the whole backend.
18+
- `cd backend && pytest -x --tb=short 2>&1 | tail -50` — fast-fail pytest. Most modules don't have tests, so a "no tests collected" result is normal; that's not a failure.
19+
- `cd backend && alembic heads 2>&1` — confirm single head (multiple heads means a migration was added on a parallel branch and needs merging).
20+
21+
3. **Frontend checks:**
22+
- `cd web && npx tsc --noEmit --incremental 2>&1 | tail -40` — TypeScript across `web/src/`.
23+
- `cd web && npm run lint 2>&1 | tail -40` — ESLint.
24+
- `cd web && npx prettier --check "src/**/*.{ts,tsx,js,jsx}" 2>&1 | tail -20` — prettier formatting check.
25+
26+
4. **Skip what's not relevant.** Don't run frontend checks for backend-only changes and vice versa. If you can infer from `git diff --stat` that only `backend/` was touched, skip frontend.
27+
28+
5. **Summarise**, format like:
29+
30+
```
31+
Backend
32+
mypy ✓ clean (or ✗ N errors — first: <file:line — message>)
33+
pytest ✓ N passed (or ✗ N failed)
34+
alembic ✓ single head
35+
Frontend
36+
tsc ✓ clean (or ✗ N errors — first: <file:line — message>)
37+
lint ✓ clean
38+
prettier ✓ clean
39+
```
40+
41+
6. **If anything failed**, follow up with the user: "X failures above. Want me to fix them, or are you debugging a specific area?" Don't auto-fix unless explicitly told to.
42+
43+
# Notes
44+
45+
- Everything in this file's command list is in `.claude/settings.json`'s allow-list, so none of it should prompt for permission.
46+
- `pytest` runs against the live local stack (Postgres / Vespa / model server). If they're not running, integration-style tests will fail — flag that as "stack not running" rather than as test failures.
47+
- Don't run `npx playwright test` from this command. E2E is too slow for an inner-loop check; use it on demand only.
48+
- Don't run `pre-commit run --all-files` from here either — that's slow and overlaps with the per-tool checks above. The user can `pre-commit run` themselves before commit.

.claude/hooks/check_changed.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Stop hook: validates whatever Claude touched in the current working tree.
4+
# Runs once per Claude response (not per Edit), so a multi-file task
5+
# triggers a single type-check pass rather than N redundant ones.
6+
#
7+
# Scope:
8+
# - If any web/**/*.ts(x) is dirty -> run `tsc --noEmit --incremental`
9+
# across the whole web project (file-scoped tsc would need its own
10+
# tsconfig; full project + incremental cache is the right balance).
11+
# - If any backend/**/*.py is dirty -> run mypy *only on those files*
12+
# (file-scoped mypy is fast).
13+
#
14+
# Output is piped through `tail` so it can't dominate Claude's context.
15+
# Exits 0 even on failure — we want Claude to see the error in its next
16+
# turn, not block the response from completing.
17+
set -u
18+
19+
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}"
20+
[ -z "$PROJECT_DIR" ] && exit 0
21+
cd "$PROJECT_DIR" || exit 0
22+
23+
# Modified files in the working tree (staged + unstaged + untracked).
24+
# Filename is field 2 in `git status --porcelain` output. We strip the
25+
# "XY " prefix manually so paths with spaces survive.
26+
DIRTY=$(git status --porcelain 2>/dev/null | sed 's/^...//')
27+
[ -z "$DIRTY" ] && exit 0
28+
29+
ts_changed=false
30+
py_changed=()
31+
32+
while IFS= read -r f; do
33+
case "$f" in
34+
web/*.ts|web/*.tsx|web/**/*.ts|web/**/*.tsx) ts_changed=true ;;
35+
backend/*.py|backend/**/*.py) py_changed+=("${f#backend/}") ;;
36+
esac
37+
done <<< "$DIRTY"
38+
39+
# --- TypeScript ----------------------------------------------------------
40+
if [ "$ts_changed" = true ] && [ -d "web" ]; then
41+
echo "── tsc (web) ──"
42+
( cd web && npx --no-install tsc --noEmit --incremental 2>&1 | tail -40 ) || true
43+
fi
44+
45+
# --- Python (mypy on changed files only) ---------------------------------
46+
# Prefer the project venv's Python (where mypy is installed). Fall back to
47+
# python3 / python on PATH if the venv doesn't exist.
48+
PY=""
49+
if [ -x "$PROJECT_DIR/.venv/bin/python" ]; then
50+
PY="$PROJECT_DIR/.venv/bin/python"
51+
elif command -v python3 >/dev/null 2>&1; then
52+
PY="$(command -v python3)"
53+
elif command -v python >/dev/null 2>&1; then
54+
PY="$(command -v python)"
55+
fi
56+
57+
if [ "${#py_changed[@]}" -gt 0 ] && [ -d "backend" ] && [ -n "$PY" ]; then
58+
echo "── mypy (changed files) ──"
59+
( cd backend && "$PY" -m mypy --no-error-summary "${py_changed[@]}" 2>&1 | tail -25 ) || true
60+
fi
61+
62+
exit 0

.claude/settings.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
3+
"_comment": "Project-shared Claude Code settings. Commit this file. Personal overrides go in .claude/settings.local.json (gitignored). Permissions allow Claude to run validation commands without prompting; the deny list always wins. Hooks auto-run type-checkers after Edit/Write so type regressions surface immediately.",
4+
5+
"permissions": {
6+
"allow": [
7+
"Bash(git status:*)",
8+
"Bash(git diff:*)",
9+
"Bash(git log:*)",
10+
"Bash(git show:*)",
11+
"Bash(git branch:*)",
12+
"Bash(git stash list)",
13+
"Bash(git remote -v)",
14+
15+
"Bash(ls:*)",
16+
"Bash(grep:*)",
17+
"Bash(find:*)",
18+
"Bash(cat:*)",
19+
"Bash(head:*)",
20+
"Bash(tail:*)",
21+
"Bash(wc:*)",
22+
"Bash(tree:*)",
23+
"Bash(file:*)",
24+
25+
"Bash(ps aux)",
26+
"Bash(ps -ef)",
27+
"Bash(docker ps:*)",
28+
"Bash(docker logs:*)",
29+
"Bash(docker exec * psql:*)",
30+
"Bash(docker network inspect:*)",
31+
"Bash(redis-cli ping)",
32+
"Bash(redis-cli llen:*)",
33+
"Bash(redis-cli info:*)",
34+
35+
"Bash(python -m mypy:*)",
36+
"Bash(pytest:*)",
37+
"Bash(pre-commit run:*)",
38+
"Bash(black --check:*)",
39+
"Bash(alembic heads)",
40+
"Bash(alembic history:*)",
41+
"Bash(alembic current)",
42+
"Bash(alembic check)",
43+
"Bash(PYTHONPATH=* python -c:*)",
44+
"Bash(PYTHONPATH=* python -m:*)",
45+
46+
"Bash(npx tsc --noEmit:*)",
47+
"Bash(npx tsc --noEmit --incremental:*)",
48+
"Bash(npm run lint:*)",
49+
"Bash(npm run typecheck:*)",
50+
"Bash(npx prettier --check:*)",
51+
"Bash(npx playwright test --list:*)",
52+
53+
"Bash(gh api repos/:*)",
54+
"Bash(gh pr view:*)",
55+
"Bash(gh issue view:*)",
56+
"Bash(gh pr list:*)",
57+
"Bash(gh issue list:*)",
58+
"Bash(gh pr checks:*)",
59+
"Bash(gh run view:*)",
60+
"Bash(gh run list:*)"
61+
],
62+
63+
"deny": [
64+
"Bash(git push:*)",
65+
"Bash(git push --force:*)",
66+
"Bash(git push -f:*)",
67+
"Bash(git reset --hard:*)",
68+
"Bash(git checkout --:*)",
69+
"Bash(git clean -fd:*)",
70+
"Bash(git branch -D:*)",
71+
"Bash(rm -rf /:*)",
72+
"Bash(rm -rf ~:*)",
73+
"Bash(sudo:*)",
74+
"Bash(docker compose down -v:*)",
75+
"Bash(docker volume rm:*)",
76+
"Bash(docker rm -f:*)",
77+
"Bash(alembic downgrade:*)",
78+
"Bash(npm publish:*)",
79+
"Bash(gh pr merge:*)",
80+
"Bash(gh pr close:*)"
81+
]
82+
},
83+
84+
"env": {
85+
"PYTHONDONTWRITEBYTECODE": "1"
86+
},
87+
88+
"hooks": {
89+
"Stop": [
90+
{
91+
"hooks": [
92+
{
93+
"type": "command",
94+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/check_changed.sh\""
95+
}
96+
]
97+
}
98+
]
99+
}
100+
}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@
88
*.sw?
99
docker-compose.dev.yml
1010
venv/
11+
12+
# Claude Code: keep shared project settings (.claude/settings.json) but not
13+
# personal overrides or session state.
14+
.claude/settings.local.json
15+
.claude/projects/
16+
.claude/cache/
17+
18+
# Claude Code /export outputs (timestamped conversation transcripts).
19+
# Pattern: YYYY-MM-DD-HHMMSS-<slug>.txt — typically dropped into the cwd
20+
# from which Claude Code was launched.
21+
[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]-*.txt
22+
23+
# Stray LLM API request payloads sometimes dumped during local debugging.
24+
# These contain prompt content (chat history, internal references, names).
25+
backend/requestdata.json
26+
requestdata.json

0 commit comments

Comments
 (0)