refactor: move app code into Max Avatar/ subfolder (monorepo prep for backend)

Step 1 of adding a backend proxy server (API keys held server-side instead
of shipped in the installer). Moves everything app-specific into
"Max Avatar/" via git mv (preserves history): src/, tests/, scripts/,
assets/, build/, resources/, package.json/-lock.json, electron-builder.yml,
electron.vite.config.ts, eslint.config.mjs, playwright.config.ts,
vitest.config.mts, sonar-project.properties, tsconfig*.json, Dockerfile,
.editorconfig/.env*/.gitignore/.prettier*.

CLAUDE.md, README.md, docs/, .claude/, .gitea/, .husky/, .vscode/, and the
docker-compose files stay at the repo root, since they'll apply to both the
app and the future backend.

No application code needed changes (all its internal paths are relative to
its own tree). Adjusted what referenced the old root from outside:
- .husky/pre-commit: cd into "Max Avatar" before lint-staged
- .gitea/workflows/*.yml: working-directory + cache-dependency-path +
  artifact paths + SonarQube projectBaseDir
- docker-compose.yml: build context -> ./Max Avatar
- Max Avatar/Dockerfile: node:20-alpine -> node:24-alpine (same node:sqlite
  issue already fixed elsewhere, never applied here before)
- .vscode/launch.json, README.md: updated paths/instructions

Verified from Max Avatar/ after the move: npm ci, typecheck, lint,
test:coverage (473/473, same coverage numbers), build, and dev all work
unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-10-31 12:15:30 +01:00
co-authored by Claude Sonnet 5
parent 60e2fb26af
commit 1c2f002eb3
224 changed files with 135 additions and 18 deletions
@@ -0,0 +1,137 @@
import { describe, it, expect, vi } from 'vitest'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
const tempDir = mkdtempSync(join(tmpdir(), 'forge-avatar-drawing-test-'))
vi.mock('electron', () => ({
app: { getPath: () => tempDir }
}))
const openDrawingWindow = vi.fn(async () => {})
const revealShape = vi.fn(async () => {})
const renderMermaid = vi.fn(async () => {})
const playCaption = vi.fn(async () => {})
vi.mock('../../src/main/coach/drawingWindow', () => ({
openDrawingWindow,
revealShape,
renderMermaid,
playCaption
}))
const synthesizeSpeech = vi.fn(async () => Buffer.from('audio'))
vi.mock('../../src/main/ai/elevenlabs', () => ({ synthesizeSpeech }))
const { getModuleDetail, createModules } = await import('../../src/main/coach/coachStore')
const { drawSchema } = await import('../../src/main/skills/coach/drawSchema')
const { drawFlowDiagram } = await import('../../src/main/skills/coach/drawFlowDiagram')
describe('draw_schema', () => {
it('should refuse when no valid shape is given', async () => {
await expect(drawSchema.execute({ title: 'Test', shapes: [] })).rejects.toThrow(
/Aucune forme valide/
)
})
it('should refuse when no shape has a caption', async () => {
await expect(
drawSchema.execute({
title: 'Test',
shapes: [{ type: 'circle', x: 10, y: 10, radius: 5 }]
})
).rejects.toThrow(/Aucune caption/)
})
it('should refuse an unknown preset name', async () => {
await expect(
drawSchema.execute({
title: 'Test',
shapes: [{ type: 'preset', preset: 'inexistant', caption: 'voila' }]
})
).rejects.toThrow(/Preset inconnu/)
})
it('should draw a manual shape with a caption, calling the drawing window and speech synthesis', async () => {
openDrawingWindow.mockClear()
revealShape.mockClear()
synthesizeSpeech.mockClear()
const result = await drawSchema.execute({
title: 'Mon dessin',
shapes: [{ type: 'circle', x: 10, y: 10, radius: 5, caption: 'Voici un cercle' }]
})
expect(result).toMatch(/termine/)
expect(openDrawingWindow).toHaveBeenCalledWith('Mon dessin', 700, 500)
expect(synthesizeSpeech).toHaveBeenCalledWith('Voici un cercle')
expect(revealShape).toHaveBeenCalled()
})
it('should expand a geometry preset into real shapes', async () => {
const result = await drawSchema.execute({
title: 'Triangle',
shapes: [
{
type: 'preset',
preset: 'right_triangle',
presetParams: { adjacentCaption: 'Le cote vertical' }
}
]
})
expect(result).toMatch(/termine/)
})
it('should persist the drawing to the module when subject and module are both given', async () => {
createModules('dessin-subject-test', [{ name: 'Module dessin' }])
await drawSchema.execute({
title: 'Sauvegarde',
subject: 'dessin-subject-test',
module: 'Module dessin',
shapes: [{ type: 'circle', x: 1, y: 1, radius: 1, caption: 'un cercle' }]
})
const detail = getModuleDetail('dessin-subject-test', 'Module dessin')
expect(detail?.diagrams).toHaveLength(1)
})
})
describe('draw_flow_diagram', () => {
it('should refuse missing mermaid code', async () => {
await expect(
drawFlowDiagram.execute({ title: 'Cycle', mermaid: '', captions: ['une etape'] })
).rejects.toThrow(/mermaid manquant/)
})
it('should refuse when no caption is provided', async () => {
await expect(
drawFlowDiagram.execute({ title: 'Cycle', mermaid: 'graph LR; A --> B', captions: [] })
).rejects.toThrow(/Aucune caption/)
})
it('should render the diagram and narrate each caption in sequence', async () => {
renderMermaid.mockClear()
playCaption.mockClear()
const result = await drawFlowDiagram.execute({
title: 'Cycle de l-eau',
mermaid: 'graph LR; Evaporation --> Condensation',
captions: ['Premiere etape', 'Deuxieme etape']
})
expect(result).toMatch(/affiche/)
expect(renderMermaid).toHaveBeenCalledWith(
'Cycle de l-eau',
'graph LR; Evaporation --> Condensation'
)
expect(playCaption).toHaveBeenCalledTimes(2)
})
it('should persist the diagram to the module when subject and module are both given', async () => {
createModules('diagramme-subject-test', [{ name: 'Module diagramme' }])
await drawFlowDiagram.execute({
title: 'Sauvegarde',
subject: 'diagramme-subject-test',
module: 'Module diagramme',
mermaid: 'graph LR; A --> B',
captions: ['une etape']
})
const detail = getModuleDetail('diagramme-subject-test', 'Module diagramme')
expect(detail?.diagrams).toHaveLength(1)
})
})