Files
gabrielvidalandClaude Opus 5.5 d880ab257f feat(form): YAML form files — sections keyed by title, fields by key, options by value
`ask-form create form.yaml` takes the whole form in one file: title,
description, lang and sections (each a page, keyed by its title), with
fields keyed by their key, options by their value and a table's columns by
their key, in the order written. A section takes an intro (markdown under
its title) and a showIf for the whole page. Plain lists of option texts and
the old lists (`key:` fields, `value:` options) are read too, and the flat
JSON field array still works byte for byte (--fields-file spec.json).

- internal/form/yaml.go: a strict YAML 1.2 subset reader, stdlib only.
  Ordered mappings (*form.Map), block and flow collections, | and >
  scalars, quotes, comments; refuses anchors, tags, ? keys, several
  documents, tab indentation and duplicate keys, with the line. Only
  true/false are booleans; a number keeps its text (json.Number).
- internal/form/doc.go: ParseDoc compiles a form file (YAML, or JSON of the
  same shape) into the flat field array: section title -> group, intro ->
  a markdown block, section showIf AND-ed into its fields'. The CLI does it
  before POST /v1/forms, so server, relay, store and MCP are unchanged and
  a new CLI works with an older serve.
- examples: spec.yaml + spec.fr.yaml replace the JSON specs (converted,
  each checked to normalise to the same fields); /spec.json still answers
  with the form compiled to JSON.
- SKILL.md, the claude.ai sandbox skill, agent-install, README and
  CLAUDE.md teach the YAML form file; a test keeps SKILL.md's YAML valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 11:52:10 +01:00

98 lines
5.3 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
title: 'Découper server.ts : le plan'
description: |-
`api/server.ts` a grossi jusqu'à 2 412 lignes : routes, validation, requêtes et e-mails dans un seul fichier. Voici comment je le découperais. Rien ne bouge avant votre réponse ; mes préférences sont pré-sélectionnées.
summary: |-
Valider un refactor avant de déplacer du code : le plan dessiné, puis le périmètre, la stratégie de PR et le niveau d'exigence sur le comportement.
order: 5
sections:
Le plan:
fields:
before-after:
type: html
label: Avant → après
html: |-
<svg viewBox="0 0 400 300" xmlns="http://www.w3.org/2000/svg" style="display:block;width:100%;max-width:520px;height:auto;margin:0 auto;font:14px system-ui,sans-serif">
<text x="8" y="16" fill="hsl(var(--muted-foreground))" font-size="12" letter-spacing=".06em">AUJOURD'HUI</text>
<rect x="8" y="26" width="384" height="52" rx="12" fill="hsl(var(--destructive) / .08)" stroke="hsl(var(--destructive) / .5)"/>
<text x="24" y="57" fill="hsl(var(--foreground))" font-weight="700" font-size="16">server.ts</text>
<text x="376" y="57" text-anchor="end" fill="hsl(var(--muted-foreground))">2 412 lignes · 38 routes · 0 test</text>
<path d="M200 86V104" stroke="hsl(var(--muted-foreground))" stroke-width="1.5"/><path d="M194 104l6 10 6-10z" fill="hsl(var(--muted-foreground))"/>
<text x="8" y="134" fill="hsl(var(--muted-foreground))" font-size="12" letter-spacing=".06em">APRÈS</text>
<rect x="8" y="144" width="384" height="34" rx="10" fill="hsl(var(--card))" stroke="hsl(var(--border))"/>
<text x="200" y="166" text-anchor="middle" fill="hsl(var(--foreground))">server.ts · app + middleware · 60 lignes</text>
<g fill="hsl(var(--primary) / .1)" stroke="hsl(var(--primary))">
<rect x="8" y="188" width="122" height="54" rx="10"/><rect x="139" y="188" width="122" height="54" rx="10"/><rect x="270" y="188" width="122" height="54" rx="10"/></g>
<g text-anchor="middle" fill="hsl(var(--foreground))" font-weight="600">
<text x="69" y="211">users/</text><text x="200" y="211">billing/</text><text x="331" y="211">projects/</text></g>
<g text-anchor="middle" fill="hsl(var(--muted-foreground))" font-size="12">
<text x="69" y="230">9 routes</text><text x="200" y="230">14 routes</text><text x="331" y="230">15 routes</text></g>
<rect x="8" y="252" width="384" height="34" rx="10" fill="hsl(var(--muted))" stroke="hsl(var(--border))"/>
<text x="200" y="274" text-anchor="middle" fill="hsl(var(--foreground))">shared/ · db · errors · validate · mail</text>
</svg>
what-changes:
type: markdown
label: Ce qui change
text: |-
| | Avant | Après |
|---|---|---|
| Plus gros fichier | 2 412 lignes | ~300 lignes |
| Routes avec un test | 0 sur 38 | 38 sur 38 (snapshot) |
| Imports circulaires | 4 | 0 |
Chaque route garde son chemin, son entrée et sa réponse. J'enregistre les réponses des 38 routes avant le déplacement et je les compare après.
layout:
type: radio
label: Comment regrouper le code ?
required: true
default: domain
options:
domain:
label: Par domaine
description: 'users/, billing/, projects/ : une modification de la facturation reste dans billing/'
layer:
label: Par couche
description: 'routes/, services/, repos/ : plus proche des habitudes actuelles'
Livraison:
fields:
delivery:
type: radio
label: Comment voulez-vous le relire ?
required: true
default: stacked
options:
one-pr: {label: Une seule PR, description: '~3 000 lignes déplacées, difficile à relire'}
stacked:
label: Quatre PR empilées
description: shared/ d'abord, puis une par domaine, chacune au vert indépendamment
main: {label: Directement sur main, description: 'Un commit par étape, sans PR'}
behaviour:
type: radio
label: Quel niveau d'exigence sur le comportement ?
required: true
default: identical
options:
identical:
label: Réponses identiques à l'octet près
description: Un simple déplacement ; les bugs que je trouve vont dans une liste
fixes:
label: Petits correctifs autorisés
description: Codes de statut et formats d'erreur, chacun listé dans la PR
extras:
type: multiselect
label: Tant que j'y suis
default: [snapshot-tests]
options:
snapshot-tests:
label: Garder les 38 tests snapshot
description: Ils ne coûtent rien une fois enregistrés
zod: Remplacer la validation écrite à la main par zod
kysely: Requêtes typées (Kysely) dans les repos
freeze:
type: radio
label: Autres branches qui touchent server.ts
default: rebase
help: '`feat/teams` et `fix/login-redirect` modifient toutes deux server.ts.'
options:
rebase: Je les rebase sur le découpage une fois celui-ci intégré
wait: Attendre qu'elles soient fusionnées, puis découper