activeloopai / activeloopai/hivemind

test layout: move shared tests out of `claude-code/tests/` to a root-level `tests/` dir

Abierto
#123 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
1.6k
Forks
107
Merge medio
17 h 30 min
PR fusionados (30 d)
6

Descripción

## Problem

`claude-code/tests/` currently holds **107 test files** — but the overwhelming majority test code that has nothing to do with claude-code specifically:

- Tests for shared `src/` modules (auth, cli, deeplake-api, embeddings, hooks, skillify, notifications, …)
- Tests that exercise **other agents'** bundles (`cursor-session-start-hook.test.ts`, `hermes-session-start-hook.test.ts`, `cli-install-codex-fs.test.ts`, `cli-install-openclaw.test.ts`, etc.)

By contrast, the agent-specific test directories are tiny:
- `codex/tests/` — 4 files (codex hooks + capture integration)
- `openclaw/tests/` — 3 files (auto-recall, hivemind-tools, setup-command)
- `cursor/` / `hermes/` / `pi/` — no `tests/` dir at all; their tests live under `claude-code/tests/`

The root `vitest.config.ts:4-6` already acknowledges the oddity:

> The one in claude-code/ is a historical leftover and is not used by the root test script.

## Proposal

Move shared tests to a root-level `tests/` directory and keep `/tests/` for genuinely agent-specific integration tests.

### Target layout

```
tests/ <- new home for everything that tests shared src/
auth.test.ts
deeplake-api.test.ts
skillify-*.test.ts
embeddings/*.test.ts
...

claude-code/tests/ <- claude-code-specific only
session-start-hook.test.ts (the one that tests CC's own SessionStart bundle)
install-end-to-end.test.ts (if it really only exercises CC)
...

codex/tests/ <- unchanged
cursor/tests/ <- new home for cursor-session-start-hook.test.ts, etc.
hermes/tests/ <- new home for hermes-session-start-hook.test.ts, etc.
openclaw/tests/ <- unchanged
pi/tests/ <- new home for pi-* tests if they exist
```

### Steps

1. `git mv` the ~95 shared-module tests from `claude-code/tests/` to `tests/`
2. `git mv` cursor/hermes hook tests to their respective `/tests/` directories
3. Update import paths in moved tests (`../../src/...` → `../src/...` for `tests/`, stays `../../src/...` for `/tests/`)
4. Update `vitest.config.ts` `include` array:
```ts
include: [
"tests/**/*.test.ts",
"claude-code/tests/**/*.test.ts",
"codex/tests/**/*.test.ts",
"cursor/tests/**/*.test.ts",
"hermes/tests/**/*.test.ts",
"openclaw/tests/**/*.test.ts",
"pi/tests/**/*.test.ts",
],
```
5. Update the stale comment in `vitest.config.ts:4-6`
6. Grep CI workflows for hardcoded `claude-code/tests/` paths and update (`ci.yml` references it in the coverage step)
7. Update the testing-philosophy section in CLAUDE.md that names `claude-code/tests/upload-summary.test.ts` etc. — those paths will change

### Gotchas to handle in the PR

- **Big diff**: ~107 file moves, but mechanical — should be reviewable as a pure rename PR
- **Import paths**: relative `../../src/` becomes `../src/` for files moved to root `tests/`. Codemod-able with `sed -i`
- **Agent boundary judgment calls**: some tests live in `claude-code/tests/` but exercise generic shared code via a claude-code-bundled artifact (e.g. bundle-scan tests). These could go either way — root `tests/` if they cover all-agent invariants, `claude-code/tests/` if specifically about CC's bundle
- **Coverage thresholds in `vitest.config.ts`**: per-file `thresholds` block references `src/**` paths, not test paths — no change needed there
- **Pre-commit hook + lint-staged**: only target `*.ts` globally, unaffected

### Why now / why not later

- **Why now**: skillify code lives under `src/skillify/` (root), gets bundled into every agent, but its tests live under `claude-code/tests/skillify-*.test.ts` — actively confusing for anyone navigating the codebase. The wrong location reinforces the wrong mental model.
- **Why not later**: a refactor PR is cheaper to land in isolation than bundled with a feature change. Every PR that touches a test file under `claude-code/tests/` (i.e. most PRs) postpones this by burying it under reviewer fatigue.

## Out of scope

- Splitting tests by domain (`tests/auth/`, `tests/skillify/`, etc.) — possible follow-up; this issue just gets the wrong-named container fixed first.
- Migrating coverage thresholds — they key on `src/**`, unaffected.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.