Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# AGENTS.md

## Purpose
This file provides operational guidance for agentic coding agents working in this repository.
It captures project architecture, build/lint/test commands, single-test workflows, and style conventions.
Follow these defaults unless the user explicitly asks for a different approach.

## Repository architecture
- Monorepo root: `/Users/Soumana.Amadou/Desktop/Projects/WrenAI`.
- `wren-ui/`: Next.js + TypeScript service (frontend plus GraphQL/server utilities).
- `wren-ai-service/`: Python service (FastAPI ecosystem, LLM pipelines, eval tooling).
- `wren-launcher/`: Go CLI for launching and dbt-related workflows.
- `wren-mdl/`: model schema artifacts (JSON schema and related metadata).
- `wren-engine/`: engine component (separate service module included in repo).
- `docker/`: docker-compose and config templates for local orchestration.
- `deployment/`: deployment docs/resources.

## Rule files (Cursor/Copilot)
- Cursor rules directory `.cursor/rules/`: not found.
- Cursor root rules file `.cursorrules`: not found.
- Copilot instructions `.github/copilot-instructions.md`: not found.
- If any of these files are later added, read and obey them before making changes.

## Global workflow expectations
- Prefer minimal, targeted edits over broad refactors.
- Keep changes scoped to one subproject unless cross-service work is required.
- Use existing scripts/Make targets/Just recipes rather than ad-hoc commands.
- Run lint/tests for touched components before finalizing when feasible.
- Never hardcode secrets or tokens.

## Build, lint, test commands

### wren-ui (Next.js + TypeScript)
Working dir: `wren-ui/`
- Install dependencies: `yarn`
- Start dev server: `yarn dev`
- Production build: `yarn build`
- Start built app: `yarn start`
- Lint + typecheck: `yarn lint`
- Typecheck only: `yarn check-types`
- Unit/integration tests: `yarn test`
- E2E tests: `yarn test:e2e`
- DB migrate: `yarn migrate`
- DB rollback: `yarn rollback`
- GraphQL codegen: `yarn generate-gql`

Run a single Jest test:
- Single test file: `yarn test path/to/file.test.ts`
- By test name: `yarn test path/to/file.test.ts -t "name fragment"`
- By pattern: `yarn test --testPathPattern=someFeature`

### wren-launcher (Go)
Working dir: `wren-launcher/`
- Build all binaries: `make build`
- Clean artifacts: `make clean`
- Rebuild: `make rebuild`
- Format: `make fmt`
- Import formatting: `make imports`
- Static checks: `make vet`
- Lint: `make lint`
- Lint with fixes: `make lint-fix`
- Combined checks: `make check`
- Run all tests: `make test`

Run a single Go test:
- Single package: `go test ./commands/dbt`
- Single test func regex: `go test -run TestDataSource ./commands/dbt`
- Verbose single package: `go test -v ./path/to/package`

### wren-ai-service (Python)
Working dir: `wren-ai-service/`
- Install deps: `poetry install`
- Initialize local files: `just init`
- Start service: `just start`
- Start dev stack: `just up`
- Stop dev stack: `just down`
- Run tests via Justfile: `just test`
- Run pytest directly: `poetry run pytest`
- Run usecase tests: `just test-usecases usecases='all' lang='en'`

Run a single pytest test:
- Single file: `poetry run pytest tests/path/test_file.py -q`
- Single test node: `poetry run pytest tests/path/test_file.py::test_name -q`
- Keyword match: `poetry run pytest -k "name_fragment" -q`

## Formatting and linting standards

### Shared basics
- Follow `.editorconfig` defaults: UTF-8, spaces, final newline, trim trailing whitespace.
- Markdown files may keep trailing whitespace disabled and no max line length.
- Makefiles require tab indentation.

### TypeScript/JavaScript style (wren-ui)
- Formatter: Prettier (`.prettierrc` sets `singleQuote: true`).
- Linter: ESLint (`next/core-web-vitals`, `@typescript-eslint/recommended`, `prettier`).
- Unused vars: underscore-prefixed names are allowed for intentional non-use.
- `any` is permitted by lint config, but prefer specific types where practical.
- Non-null assertions are allowed but should be rare and justified.
- TypeScript `strict` is currently `false`; still write defensively typed code.

Import conventions:
- Keep imports grouped logically: external packages, aliases/internal modules, relative imports.
- Remove unused imports.
- Prefer stable alias paths (`@/`, `@server`) over deep relative traversal when available.

Naming conventions:
- Variables/functions: `camelCase`.
- React components/types/interfaces/enums: `PascalCase`.
- Constants: `UPPER_SNAKE_CASE` for true constants.
- Test files: align with existing patterns (`*.test.ts`, `*.test.tsx`).

### Go style (wren-launcher)
- Formatting is mandatory through `go fmt`.
- Import order managed by `goimports`.
- Lint policy enforced via `.golangci.yml` with linters including:
`errcheck`, `govet`, `ineffassign`, `staticcheck`, `unused`, `misspell`,
`unconvert`, `gosec`, `dupl`, `goconst`, `gocyclo`, `bodyclose`, `whitespace`.
- Keep functions focused; extract helpers when cyclomatic complexity grows.

Naming conventions:
- Exported identifiers: `PascalCase`.
- Unexported identifiers: `camelCase`.
- Package names: short, lowercase, no underscores.

### Python style (wren-ai-service)
- Ruff config in `ruff.toml` controls lint + formatting behavior.
- Line length: 88, spaces for indentation, double quotes preferred by formatter.
- Import sorting rule `I001` is enabled; keep imports sorted and grouped.
- Target version in Ruff is `py38`, while project runtime in Poetry is Python 3.12.
Keep syntax compatible with the project runtime and existing codebase patterns.

Naming conventions:
- Functions/variables/modules: `snake_case`.
- Classes: `PascalCase`.
- Constants: `UPPER_SNAKE_CASE`.

## Error handling guidelines
- Do not swallow errors silently.
- Add context to errors before returning/raising.
- Prefer explicit, typed/domain exceptions over generic catch-all blocks.
- In Go, check returned `error` immediately and wrap with context.
- In TypeScript/Python, fail fast on invalid external input and surface actionable messages.
- Log useful diagnostic details without leaking secrets.

## Testing guidance
- Add or update tests for behavior changes and bug fixes.
- Keep tests deterministic and isolated; avoid time/network dependence unless intentional.
- Prefer focused single-test runs during iteration, then run broader suites before handoff.
- For wren-ui, include UI behavior assertions rather than implementation details.
- For wren-launcher and Python, verify error-path tests when touching error handling.

## Security and config guidance
- Never commit API keys, passwords, or tokens.
- Use env vars and existing config templates (`docker/.env.example`, `docker/config.example.yaml`).
- Validate and sanitize untrusted input, especially around SQL, shell, and file paths.
- Prefer least-privilege defaults for service integrations.

## Agent delivery checklist
- Confirm changed files belong to the intended subproject(s).
- Run formatter/linter for touched language(s).
- Run at least targeted tests (single test or package) related to the change.
- Summarize what was run and any skipped checks in the final handoff.
- If commands fail due to environment limits, report exact failure and suggested next command.
137 changes: 137 additions & 0 deletions Docs/kb_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Great request. I audited your current wren-ui and here’s the most practical i18n rollout plan for 2026 App Router standards using next-intl with strong type safety and RSC-first patterns.
Audit Findings
- You are currently on the Pages Router (wren-ui/src/pages/...), not App Router.
- Existing dynamic route needing localization support: wren-ui/src/pages/home/[id].tsx.
- Metadata/localization gaps:
- Global title hardcoded in wren-ui/src/pages/_app.tsx:19 (Wren AI).
- No locale-aware <html lang> in wren-ui/src/pages/_document.tsx:34.
- High-impact hardcoded UI strings in shared components:
- wren-ui/src/components/HeaderBar.tsx:56 (Home, Modeling, Knowledge, API)
- wren-ui/src/components/sidebar/Home.tsx:81 (Dashboard)
- wren-ui/src/components/sidebar/Knowledge.tsx:35 (Question-SQL pairs, Instructions)
- wren-ui/src/pages/home/index.tsx:31 (Know more about your data)
- High volume of localized notifications needed:
- wren-ui/src/pages/modeling.tsx:99+
- wren-ui/src/pages/knowledge/question-sql-pairs.tsx:52+
- wren-ui/src/pages/home/[id].tsx:91+
- Routing currently depends on static enum paths in wren-ui/src/utils/enum/path.ts:1, which must become locale-aware.
---
Target Architecture (Recommended)
Use App Router + locale segment + route groups:
wren-ui/src/
app/
[locale]/
(marketing)/
page.tsx
(dashboard)/
home/
page.tsx
[id]/
page.tsx
dashboard/
page.tsx
modeling/
page.tsx
knowledge/
question-sql-pairs/
page.tsx
instructions/
page.tsx
api-management/
history/
page.tsx
layout.tsx
not-found.tsx
i18n/
routing.ts
navigation.ts
request.ts
messages/
en.json
fr.json
Why this works well:
- [locale] enables locale-prefixed URLs and per-locale metadata.
- Route groups let you keep shared app shell (HeaderBar, sidebar layout) without duplicating layout logic.
- Keeps pages/api as-is during migration (safe hybrid migration path).
---
Phase 1 — Core i18n Foundation
1. Install next-intl and configure plugin in next.config.js.
2. Add wren-ui/src/i18n/routing.ts with:
- locales, defaultLocale, optional localePrefix.
- pathnames mapping for localized slugs (SEO-safe).
3. Add wren-ui/src/i18n/request.ts for server-side message loading.
4. Add middleware (wren-ui/src/middleware.ts) for locale detection:
- Detect from path → cookie → Accept-Language.
- Exclude _next, api, static assets in matcher.
5. Add wren-ui/src/app/[locale]/layout.tsx:
- <html lang={locale}>
- NextIntlClientProvider with server-fetched messages.
6. Type-safe keys (strict):
- Create global.d.ts module augmentation for next-intl with Messages from messages/en.json.
- This gives compile-time key checking for t('...').
---
Phase 2 — Localized Navigation + SEO
1. Replace next/link and next/router usage with next-intl/navigation wrappers.
2. Create wren-ui/src/i18n/navigation.ts via createNavigation(routing) and export:
- Link, useRouter, usePathname, redirect, getPathname.
3. Replace path enum usage gradually:
- Keep internal route IDs/constants.
- Resolve localized pathname via typed getPathname.
4. SEO requirements:
- In each route’s generateMetadata, output:
- localized title/description
- alternates.languages for all supported locales
- Keep canonical per locale.
5. Keep dynamic IDs untranslated (/en/home/123, /fr/accueil/123 if localized segment mapping enabled).
---
Phase 3 — Component Conversion Examples (RSC-first)
Server Component example (preferred for bundle size):
// src/app/[locale]/(dashboard)/home/page.tsx
import {getTranslations} from 'next-intl/server';
export default async function HomePage() {
const t = await getTranslations('Home');
return <h1>{t('title')}</h1>;
}
Client Component example:
'use client';
import {useTranslations} from 'next-intl';
export function HeaderNav() {
const t = useTranslations('Nav');
return (
<>
<button>{t('home')}</button>
<button>{t('modeling')}</button>
<button>{t('knowledge')}</button>
</>
);
}
Migration rule:
- Prefer getTranslations in RSC pages/layouts.
- Only use useTranslations in interactive client components.
- For notifications (message.success), pass translated strings from parent/server when possible, or use client hook if truly client-only.
---
Phase 4 — Automation for Existing Strings
Use a two-step codemod pipeline:
1. Extract strings (AST script with ts-morph or Babel):
- Scan .tsx/.ts.
- Capture JSX text nodes, string literals in UI props (title, label, placeholder) and toast messages.
- Ignore technical strings (URLs, class names, GraphQL names, route constants).
- Output to messages/en.json with namespaced keys (e.g., Header.nav.home).
2. Optional transform pass:
- Replace extracted literals with t('...').
- Insert useTranslations('Namespace') or getTranslations('Namespace') depending on component type.
- Mark low-confidence replacements for manual review.
Recommended script outputs:
- messages/en.json
- i18n-extract-report.md (file, line, key, confidence)
- i18n-todo.csv for unresolved strings
---
Important Notes for Your Current Codebase
- Because you’re on Pages Router, do a staged migration:
1) Introduce App Router + i18n scaffold,
2) Move shared shell (HeaderBar, sidebar layout),
3) Migrate high-traffic pages (home, modeling, knowledge),
4) Remove old Pages routes when parity is done.
- Keep pages/api/* unchanged until you intentionally migrate API handlers.
---
If you want, I can next produce a concrete file-by-file migration checklist for your exact routes (/home, /home/[id], /modeling, /knowledge/*, /api-management/history) with estimated effort and risk per file
Loading