@sylad/cadence 1.40.0 → 1.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/agents/spec-writer.md +1 -0
- package/agents/ux-reviewer.md +2 -0
- package/dist/archive.js +103 -6
- package/dist/audit.js +2 -2
- package/dist/clean.js +0 -4
- package/dist/cli/context.js +129 -0
- package/dist/cli/deliver-commands.js +114 -0
- package/dist/cli/gates.js +234 -0
- package/dist/cli/lead-commands.js +161 -0
- package/dist/cli/lot-commands.js +257 -0
- package/dist/cli/read-commands.js +227 -0
- package/dist/cli/session-commands.js +152 -0
- package/dist/cli/setup-commands.js +72 -0
- package/dist/cli/spec-commands.js +298 -0
- package/dist/cli/stats-commands.js +138 -0
- package/dist/cli-add.js +37 -0
- package/dist/cli.js +85 -1669
- package/dist/config.js +21 -108
- package/dist/corrections.js +28 -42
- package/dist/deliver-lots.js +37 -0
- package/dist/deliver.js +15 -39
- package/dist/docs-ok-file.js +25 -0
- package/dist/docsync.js +15 -3
- package/dist/lead.js +6 -24
- package/dist/lot-lines.js +51 -0
- package/dist/orchestrate/attente.js +82 -0
- package/dist/orchestrate/command.js +26 -25
- package/dist/orchestrate/continue.js +6 -14
- package/dist/orchestrate/cycle.js +18 -27
- package/dist/orchestrate/integrate.js +7 -2
- package/dist/orchestrate/integration-vivante.js +138 -0
- package/dist/orchestrate/launch.js +6 -18
- package/dist/orchestrate/lock.js +3 -20
- package/dist/orchestrate/lot-budget.js +2 -2
- package/dist/orchestrate/maquette.js +3 -0
- package/dist/orchestrate/registry.js +8 -1
- package/dist/orchestrate/schemas.js +5 -1
- package/dist/orchestrate/snapshot.js +13 -0
- package/dist/orchestrate/spec.js +51 -6
- package/dist/orchestrate/state.js +17 -0
- package/dist/plan-extras.js +119 -0
- package/dist/plan-ids.js +95 -0
- package/dist/plan-read.js +146 -0
- package/dist/plan-states.js +119 -0
- package/dist/plan.js +119 -190
- package/dist/raf-close-checks.js +25 -0
- package/dist/raf-status.js +28 -0
- package/dist/ref/command.js +2 -3
- package/dist/resources.js +3 -9
- package/dist/state.js +31 -8
- package/dist/verify-gate.js +33 -2
- package/dist/verify.js +20 -3
- package/dist/yaml-keys.js +21 -0
- package/docs/cadence-hud.md +1 -1
- package/docs/deliver.md +25 -3
- package/docs/fonctionnement.md +9 -5
- package/docs/lead.md +9 -7
- package/docs/news.md +2 -0
- package/docs/orchestrate.md +24 -7
- package/docs/perf.md +1 -0
- package/docs/qualite.md +14 -4
- package/docs/raf.md +62 -7
- package/docs/spec.md +5 -2
- package/docs/whats-new.md +9 -0
- package/package.json +1 -1
- package/skills/lead/SKILL.md +1 -1
- package/templates/orchestrate/spec.md +2 -2
package/dist/config.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
|
|
3
|
-
import { parse } from 'yaml';
|
|
4
3
|
import { isDay } from './dates.js';
|
|
5
4
|
import { readGate } from './gate-config.js';
|
|
6
5
|
import { DEFAULT_TEST_PATTERNS } from './testgate.js';
|
|
6
|
+
import { readExtras } from './plan-extras.js';
|
|
7
7
|
import { gitRoot } from './git.js';
|
|
8
8
|
import { planCommitProblem } from './plan-commit.js';
|
|
9
|
+
import { parseStates } from './plan-states.js';
|
|
9
10
|
import { checkTestReplay, readGateTest } from './orchestrate/gate-parts.js';
|
|
10
|
-
import { booleanKey } from './yaml-keys.js';
|
|
11
|
-
import { FIELDS, Plan, RafError, STATUSES } from './plan.js';
|
|
12
|
-
const KEYS = ['path', 'project', 'since', 'ignore', 'files', 'lots', 'fields', 'statuses', 'estimates', 'add', 'onWrite', 'commit'];
|
|
11
|
+
import { booleanKey, isObject, list, readYamlFile, readYamlKey } from './yaml-keys.js';
|
|
12
|
+
import { FIELDS, Plan, RafError, readIdPattern, STATUSES } from './plan.js';
|
|
13
|
+
const KEYS = ['path', 'project', 'since', 'ignore', 'files', 'lots', 'fields', 'statuses', 'estimates', 'add', 'onWrite', 'commit', 'states', 'transitions', 'doneState', 'blockedState', 'extras', 'idPattern'];
|
|
13
14
|
const ON_WRITE_KEYS = ['command', 'files'];
|
|
14
15
|
const FORMAT_KEYS = ['lots', 'fields', 'statuses', 'estimates'];
|
|
15
|
-
const isObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
16
|
-
const list = (v) => (v == null ? [] : Array.isArray(v) ? v.map(String) : [String(v)]);
|
|
17
16
|
/** Chemin réel (liens symboliques résolus) du plus proche ancêtre existant, le reste rattaché tel quel. */
|
|
18
17
|
function realish(p) {
|
|
19
18
|
try {
|
|
@@ -72,15 +71,9 @@ function readOnWrite(v, cwd, bad) {
|
|
|
72
71
|
* Null quand le fichier ou la clé manque — le plan est alors .cadence/raf.yaml (ou docs/plan/raf.yaml hérité) au format de raf.
|
|
73
72
|
*/
|
|
74
73
|
export function readPlanConfig(file, root) {
|
|
75
|
-
|
|
74
|
+
const raw = readYamlFile(file);
|
|
75
|
+
if (raw === undefined)
|
|
76
76
|
return null;
|
|
77
|
-
let raw;
|
|
78
|
-
try {
|
|
79
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
83
|
-
}
|
|
84
77
|
const doc = raw;
|
|
85
78
|
const qa = readQa(doc?.qa, file, root);
|
|
86
79
|
const p = doc?.plan;
|
|
@@ -112,6 +105,7 @@ export function readPlanConfig(file, root) {
|
|
|
112
105
|
settings.onWrite = readOnWrite(p.onWrite, root ?? dirname(resolve(file)), bad);
|
|
113
106
|
if (FORMAT_KEYS.some((k) => p[k] != null))
|
|
114
107
|
settings.format = parseFormat(p, bad);
|
|
108
|
+
Object.assign(settings, parseStates(p, bad, settings.format !== undefined), readExtras(p.extras, !!settings.format, bad), readIdPattern(p.idPattern, bad));
|
|
115
109
|
if (p.path != null && String(p.path).trim() === '')
|
|
116
110
|
throw bad('path est vide');
|
|
117
111
|
if (p.add != null && (typeof p.add !== 'string' || !p.add.includes('{title}')))
|
|
@@ -174,16 +168,7 @@ function parseFormat(p, bad) {
|
|
|
174
168
|
}
|
|
175
169
|
/** Clé `news:` de cadence.yaml. */
|
|
176
170
|
export function readNewsConfig(file) {
|
|
177
|
-
|
|
178
|
-
return {};
|
|
179
|
-
let raw;
|
|
180
|
-
try {
|
|
181
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
182
|
-
}
|
|
183
|
-
catch (e) {
|
|
184
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
185
|
-
}
|
|
186
|
-
const n = raw?.news;
|
|
171
|
+
const n = readYamlKey(file, 'news');
|
|
187
172
|
if (n == null)
|
|
188
173
|
return {};
|
|
189
174
|
if (!isObject(n))
|
|
@@ -191,26 +176,16 @@ export function readNewsConfig(file) {
|
|
|
191
176
|
for (const k of Object.keys(n))
|
|
192
177
|
if (k !== 'publicTitleMax')
|
|
193
178
|
throw new RafError(`${file} : news.${k} inconnu (attendu : publicTitleMax)`);
|
|
194
|
-
|
|
195
|
-
if (max == null)
|
|
179
|
+
if (n.publicTitleMax == null)
|
|
196
180
|
return {};
|
|
197
|
-
if (typeof
|
|
181
|
+
if (typeof n.publicTitleMax !== 'number' || !Number.isInteger(n.publicTitleMax) || n.publicTitleMax < 1)
|
|
198
182
|
throw new RafError(`${file} : news.publicTitleMax : nombre entier de caractères (≥ 1) attendu`);
|
|
199
|
-
return { publicTitleMax:
|
|
183
|
+
return { publicTitleMax: n.publicTitleMax };
|
|
200
184
|
}
|
|
201
185
|
const AUTOSTART = ['warn', 'refuse', 'start'];
|
|
202
186
|
/** Clé `hook:` de cadence.yaml. */
|
|
203
187
|
export function readHookConfig(file) {
|
|
204
|
-
|
|
205
|
-
return {};
|
|
206
|
-
let raw;
|
|
207
|
-
try {
|
|
208
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
209
|
-
}
|
|
210
|
-
catch (e) {
|
|
211
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
212
|
-
}
|
|
213
|
-
const h = raw?.hook;
|
|
188
|
+
const h = readYamlKey(file, 'hook');
|
|
214
189
|
if (h == null)
|
|
215
190
|
return {};
|
|
216
191
|
if (!isObject(h))
|
|
@@ -229,16 +204,7 @@ const PRICED_MODELS = ['sonnet', 'opus', 'haiku'];
|
|
|
229
204
|
const PRICE_KEYS = ['input', 'output', 'cacheRead'];
|
|
230
205
|
/** Clé `perf.prices` de cadence.yaml : la grille de prix du coût par lot livré ; null sans grille (clé absente ou vide). */
|
|
231
206
|
export function readPerfConfig(file) {
|
|
232
|
-
|
|
233
|
-
return null;
|
|
234
|
-
let raw;
|
|
235
|
-
try {
|
|
236
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
237
|
-
}
|
|
238
|
-
catch (e) {
|
|
239
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
240
|
-
}
|
|
241
|
-
const perf = raw?.perf;
|
|
207
|
+
const perf = readYamlKey(file, 'perf');
|
|
242
208
|
if (perf == null)
|
|
243
209
|
return null;
|
|
244
210
|
if (!isObject(perf))
|
|
@@ -276,16 +242,7 @@ export function readPerfConfig(file) {
|
|
|
276
242
|
* joués par cadence au lieu d'être remplacés.
|
|
277
243
|
*/
|
|
278
244
|
export function readSessionConfig(file) {
|
|
279
|
-
|
|
280
|
-
return {};
|
|
281
|
-
let raw;
|
|
282
|
-
try {
|
|
283
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
284
|
-
}
|
|
285
|
-
catch (e) {
|
|
286
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
287
|
-
}
|
|
288
|
-
const s = raw?.session;
|
|
245
|
+
const s = readYamlKey(file, 'session');
|
|
289
246
|
if (s == null)
|
|
290
247
|
return {};
|
|
291
248
|
if (!isObject(s))
|
|
@@ -316,16 +273,7 @@ const EFFORTS = ['default', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
|
316
273
|
const EFFORT_STEPS = ['precheck', 'spec', 'maquette', 'fiche', 'accept', 'implement', 'probe', 'fix', 'review', 'ux'];
|
|
317
274
|
/** Clé `verify:` de cadence.yaml. Absente : `{}`. */
|
|
318
275
|
export function readVerifyConfig(file) {
|
|
319
|
-
|
|
320
|
-
return {};
|
|
321
|
-
let raw;
|
|
322
|
-
try {
|
|
323
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
324
|
-
}
|
|
325
|
-
catch (e) {
|
|
326
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
327
|
-
}
|
|
328
|
-
const v = raw?.verify;
|
|
276
|
+
const v = readYamlKey(file, 'verify');
|
|
329
277
|
if (v == null)
|
|
330
278
|
return {};
|
|
331
279
|
if (!isObject(v))
|
|
@@ -344,16 +292,7 @@ const ORCH_KEYS = ['start', 'verdict', 'test', 'testReplay', 'build', 'worktreeD
|
|
|
344
292
|
/** Clé `orchestrate:` de cadence.yaml. Absente : les défauts (auto, 45 min d'implémentation, 25 min de revue). */
|
|
345
293
|
export function readOrchestrateConfig(file) {
|
|
346
294
|
const config = { precheck: true, maquette: true, maquetteReviews: 3, fiche: true, precheckLocal: false, prodAccess: false, worktrees: false, spec: { dir: 'docs/specs' }, review: { threshold: 0.25, light: 'sonnet', full: 'opus' }, effort: { precheck: 'low', spec: 'medium', maquette: 'high', fiche: 'medium', accept: 'medium', implement: 'medium', probe: 'medium', fix: 'medium', review: 'high', ux: 'high' }, permissionMode: 'auto', addDirs: [], timeouts: { work: 45 * 60_000, review: 25 * 60_000 } };
|
|
347
|
-
|
|
348
|
-
return config;
|
|
349
|
-
let raw;
|
|
350
|
-
try {
|
|
351
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
352
|
-
}
|
|
353
|
-
catch (e) {
|
|
354
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
355
|
-
}
|
|
356
|
-
const o = raw?.orchestrate;
|
|
295
|
+
const o = readYamlKey(file, 'orchestrate');
|
|
357
296
|
if (o == null)
|
|
358
297
|
return config;
|
|
359
298
|
const bad = (what) => new RafError(`${file} : orchestrate.${what}`);
|
|
@@ -583,15 +522,7 @@ const DOCS_KEYS = ['sync', 'since', 'articles'];
|
|
|
583
522
|
/** Clé `docs:` de cadence.yaml : `docs.sync`, la documentation qui doit suivre le code. */
|
|
584
523
|
export function readDocsConfig(file) {
|
|
585
524
|
const none = { sync: [] };
|
|
586
|
-
|
|
587
|
-
return none;
|
|
588
|
-
let raw;
|
|
589
|
-
try {
|
|
590
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
591
|
-
}
|
|
592
|
-
catch (e) {
|
|
593
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
594
|
-
}
|
|
525
|
+
const raw = readYamlFile(file);
|
|
595
526
|
if (raw?.describedBy != null) {
|
|
596
527
|
throw new RafError(`${file} : describedBy n'existe plus (L308) : les documents hors dépôt se déclarent dans docs.articles, { repo, file } relatif au projet`);
|
|
597
528
|
}
|
|
@@ -650,16 +581,7 @@ export function readDocsConfig(file) {
|
|
|
650
581
|
}
|
|
651
582
|
/** Clé `references:` de cadence.yaml. */
|
|
652
583
|
export function readReferencesConfig(file) {
|
|
653
|
-
|
|
654
|
-
return {};
|
|
655
|
-
let raw;
|
|
656
|
-
try {
|
|
657
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
658
|
-
}
|
|
659
|
-
catch (e) {
|
|
660
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
661
|
-
}
|
|
662
|
-
const r = raw?.references;
|
|
584
|
+
const r = readYamlKey(file, 'references');
|
|
663
585
|
if (r == null)
|
|
664
586
|
return {};
|
|
665
587
|
if (!isObject(r))
|
|
@@ -676,16 +598,7 @@ export function readReferencesConfig(file) {
|
|
|
676
598
|
/** Clé `migrate:` de cadence.yaml (L284) : `migrate.keep`. */
|
|
677
599
|
export function readMigrateConfig(file) {
|
|
678
600
|
const none = { keep: [] };
|
|
679
|
-
|
|
680
|
-
return none;
|
|
681
|
-
let raw;
|
|
682
|
-
try {
|
|
683
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
684
|
-
}
|
|
685
|
-
catch (e) {
|
|
686
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
687
|
-
}
|
|
688
|
-
const m = raw?.migrate;
|
|
601
|
+
const m = readYamlKey(file, 'migrate');
|
|
689
602
|
if (m == null)
|
|
690
603
|
return none;
|
|
691
604
|
if (!isObject(m))
|
package/dist/corrections.js
CHANGED
|
@@ -198,32 +198,37 @@ Règle de départ : si le code livré ne fait pas ce que le lot ou le commit ann
|
|
|
198
198
|
- donnees-sql : requête, schéma, migration, format ou contenu de données faux ;
|
|
199
199
|
- test-manquant : le code est juste mais un comportement n'est pas couvert, ou un test ne vérifie pas ce que son titre promet ;
|
|
200
200
|
- faux-constat : la revue se trompe (le code était correct, constat infondé, hors lot, sans effet réel).`;
|
|
201
|
+
/** Appel `/api/chat` d'Ollama (température 0, sortie contrainte par `format`) : le texte du message, null sur réponse refusée ou échec réseau. Commun au classeur et au sous-classeur. */
|
|
202
|
+
async function ollamaChat(opts, format, system, user) {
|
|
203
|
+
const doFetch = opts.fetch ?? fetch;
|
|
204
|
+
try {
|
|
205
|
+
const res = await doFetch(`${opts.url.replace(/\/$/, '')}/api/chat`, {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
headers: { 'content-type': 'application/json' },
|
|
208
|
+
body: JSON.stringify({
|
|
209
|
+
model: opts.model,
|
|
210
|
+
stream: false,
|
|
211
|
+
options: { temperature: 0 },
|
|
212
|
+
format,
|
|
213
|
+
messages: [{ role: 'system', content: system }, { role: 'user', content: user }],
|
|
214
|
+
}),
|
|
215
|
+
});
|
|
216
|
+
if (!res.ok)
|
|
217
|
+
return null;
|
|
218
|
+
const body = (await res.json());
|
|
219
|
+
return body.message?.content ?? '';
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
201
225
|
/** Classeur sur un modèle local servi par Ollama (/api/chat, température 0, sortie contrainte par un schéma) : hors quota Anthropic. */
|
|
202
226
|
export function ollamaClassifier(opts) {
|
|
203
|
-
const doFetch = opts.fetch ?? fetch;
|
|
204
227
|
return async (pass) => {
|
|
205
228
|
const findings = pass.findings.length ? pass.findings.map((f, i) => `${i + 1}. ${f.slice(0, 1500)}`).join('\n') : '(aucun constat lisible)';
|
|
206
229
|
const user = `Lot ${pass.project} ${pass.lot}.\nConstats de la revue :\n${findings}\n\nCommits de la correction :\n${pass.commits.join('\n') || '(aucun)'}`;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
method: 'POST',
|
|
210
|
-
headers: { 'content-type': 'application/json' },
|
|
211
|
-
body: JSON.stringify({
|
|
212
|
-
model: opts.model,
|
|
213
|
-
stream: false,
|
|
214
|
-
options: { temperature: 0 },
|
|
215
|
-
format: { type: 'object', properties: { cause: { type: 'string', enum: [...CAUSES] }, raison: { type: 'string' } }, required: ['cause', 'raison'] },
|
|
216
|
-
messages: [{ role: 'system', content: SYSTEM }, { role: 'user', content: user }],
|
|
217
|
-
}),
|
|
218
|
-
});
|
|
219
|
-
if (!res.ok)
|
|
220
|
-
return null;
|
|
221
|
-
const body = (await res.json());
|
|
222
|
-
return parseCause(body.message?.content ?? '');
|
|
223
|
-
}
|
|
224
|
-
catch {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
230
|
+
const text = await ollamaChat(opts, { type: 'object', properties: { cause: { type: 'string', enum: [...CAUSES] }, raison: { type: 'string' } }, required: ['cause', 'raison'] }, SYSTEM, user);
|
|
231
|
+
return text === null ? null : parseCause(text);
|
|
227
232
|
};
|
|
228
233
|
}
|
|
229
234
|
/** Classe les passes absentes du cache, une à une ; un échec n'entre pas au cache (une relance le reprend). */
|
|
@@ -323,30 +328,11 @@ const SOUS_SYSTEM = `Tu sous-classes une passe de correction déjà classée «
|
|
|
323
328
|
${SOUS_CAUSES.map((s) => `- ${s} : ${SOUS_DEFINITIONS[s]} ;`).join('\n')}`;
|
|
324
329
|
/** Sous-classeur sur un modèle local servi par Ollama (comme `ollamaClassifier` : /api/chat, température 0, sortie contrainte par un schéma à sept valeurs). */
|
|
325
330
|
export function ollamaSousClassifier(opts) {
|
|
326
|
-
const doFetch = opts.fetch ?? fetch;
|
|
327
331
|
return async (pass) => {
|
|
328
332
|
const findings = pass.findings.map((f, i) => `${i + 1}. ${f.slice(0, 1500)}`).join('\n');
|
|
329
333
|
const user = `Lot ${pass.project} ${pass.lot}.\nConstats de la revue :\n${findings}\n\nCommits de la correction :\n${pass.commits.join('\n') || '(aucun)'}`;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
method: 'POST',
|
|
333
|
-
headers: { 'content-type': 'application/json' },
|
|
334
|
-
body: JSON.stringify({
|
|
335
|
-
model: opts.model,
|
|
336
|
-
stream: false,
|
|
337
|
-
options: { temperature: 0 },
|
|
338
|
-
format: { type: 'object', properties: { sous: { type: 'string', enum: [...SOUS_CAUSES] }, raison: { type: 'string' } }, required: ['sous', 'raison'] },
|
|
339
|
-
messages: [{ role: 'system', content: SOUS_SYSTEM }, { role: 'user', content: user }],
|
|
340
|
-
}),
|
|
341
|
-
});
|
|
342
|
-
if (!res.ok)
|
|
343
|
-
return null;
|
|
344
|
-
const body = (await res.json());
|
|
345
|
-
return parseSousCause(body.message?.content ?? '');
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
348
|
-
return null;
|
|
349
|
-
}
|
|
334
|
+
const text = await ollamaChat(opts, { type: 'object', properties: { sous: { type: 'string', enum: [...SOUS_CAUSES] }, raison: { type: 'string' } }, required: ['sous', 'raison'] }, SOUS_SYSTEM, user);
|
|
335
|
+
return text === null ? null : parseSousCause(text);
|
|
350
336
|
};
|
|
351
337
|
}
|
|
352
338
|
/** La cause retenue d'une passe à constats : la relecture à la main, sinon le modèle ; absente sans classement. */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isPlanOnly } from './audit.js';
|
|
2
|
+
import { isAncestor, readCommits } from './git.js';
|
|
3
|
+
import { citedRefs } from './link.js';
|
|
4
|
+
/**
|
|
5
|
+
* Ligne des lots cités depuis la livraison précédente, ou null (première livraison, rien de cité).
|
|
6
|
+
*
|
|
7
|
+
* Plan en lecture seule : seuls les lots EN COURS sont annoncés. Ses identifiants sont de forme libre, et
|
|
8
|
+
* un message cite volontiers un numéro qui en a la forme (réserve « R1 » d'une revue) ou un lot clos
|
|
9
|
+
* nommé pour le contexte — les annoncer « livrés » ferait fermer à tort. L'état est celui du départ de
|
|
10
|
+
* la livraison : le plan a été lu avant que le script du projet ne ferme lui-même les lots qu'il livre.
|
|
11
|
+
*/
|
|
12
|
+
/** Lots cités par les commits livrés depuis la livraison précédente ; vide quand elle est inconnue ou hors de l'historique. */
|
|
13
|
+
export function deliveredIds(ctx, prev, sha) {
|
|
14
|
+
if (!ctx.plan || !prev || prev === sha || !isAncestor(ctx.root, prev, sha))
|
|
15
|
+
return [];
|
|
16
|
+
const lots = ctx.plan.lots();
|
|
17
|
+
const known = new Set((ctx.plan.readonly ? lots.filter((l) => l.status === 'doing') : lots).map((l) => l.id));
|
|
18
|
+
const ids = new Set();
|
|
19
|
+
for (const c of readCommits(ctx.root, { range: `${prev}..${sha}` })) {
|
|
20
|
+
if (isPlanOnly(c.sha, ctx.plan, ctx.root))
|
|
21
|
+
continue; // entretien du plan : ne livre rien, même s'il cite des lots
|
|
22
|
+
for (const r of citedRefs(c, ctx.plan.refs))
|
|
23
|
+
if (known.has(r.lot))
|
|
24
|
+
ids.add(r.lot);
|
|
25
|
+
}
|
|
26
|
+
return [...ids].sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
27
|
+
}
|
|
28
|
+
export function deliveredLots(ctx, ids, prev, sha) {
|
|
29
|
+
if (!ctx.plan || !prev || prev === sha)
|
|
30
|
+
return null;
|
|
31
|
+
if (!isAncestor(ctx.root, prev, sha)) {
|
|
32
|
+
return `livraison précédente (${prev.slice(0, 7)}) hors de l'historique de ${sha.slice(0, 7)} (réécrit ?) : lots livrés non calculés`;
|
|
33
|
+
}
|
|
34
|
+
if (ids.length === 0)
|
|
35
|
+
return null;
|
|
36
|
+
return `livré : ${ids.join(', ')} — ${ctx.plan.readonly ? "à fermer avec l'outil du projet" : 'raf done'} si l'effet est celui attendu`;
|
|
37
|
+
}
|
package/dist/deliver.js
CHANGED
|
@@ -4,11 +4,11 @@ import { constants } from 'node:os';
|
|
|
4
4
|
import { join, relative } from 'node:path';
|
|
5
5
|
import { parse } from 'yaml';
|
|
6
6
|
import { onTermination, readProcs, SIGNAL_GRACE_MS, SIGNAL_PENDING_MS, TreeTracker } from './proc.js';
|
|
7
|
-
import { deliveryLots
|
|
8
|
-
import { commitPaths, dirtyPaths, headSha, isAncestor, onRemote,
|
|
7
|
+
import { deliveryLots } from './audit.js';
|
|
8
|
+
import { commitPaths, dirtyPaths, headSha, isAncestor, onRemote, repoStatus, resolveCommit } from './git.js';
|
|
9
9
|
import { planOnlySince, pollGithubCi, stamped, stepJournal } from './deliver-ci.js';
|
|
10
10
|
import { PLAN_ACTIONS, planCommitMessage } from './plan-commit.js';
|
|
11
|
-
import {
|
|
11
|
+
import { deliveredIds, deliveredLots } from './deliver-lots.js';
|
|
12
12
|
import { describeArticle, openArticleLots } from './articles.js';
|
|
13
13
|
import { RafError } from './plan.js';
|
|
14
14
|
import { appendDelivery, appendFailedDelivery, lastDelivery, lockAlive, lockFault, lockPath, readLock, releaseLock, removeStaleLock, writeLock } from './state.js';
|
|
@@ -422,8 +422,7 @@ export async function deliver(ctx, deps) {
|
|
|
422
422
|
how = 'moved';
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
const
|
|
426
|
-
const delivered = deliveredLots(ctx, ids, lastDelivery(ctx.state), final);
|
|
425
|
+
const prev = lastDelivery(ctx.state);
|
|
427
426
|
appendDelivery(ctx.state, ctx.today, final);
|
|
428
427
|
const took = `en ${Math.round((deps.now() - startedAt) / 1000)} s`;
|
|
429
428
|
if (how === 'declared')
|
|
@@ -432,9 +431,7 @@ export async function deliver(ctx, deps) {
|
|
|
432
431
|
out(stamped(deps, `✓ livré : ${final.slice(0, 7)} (tête déplacée par le script depuis ${env.CADENCE_SHORT}) ${took}`));
|
|
433
432
|
else
|
|
434
433
|
out(stamped(deps, `✓ livré${config.verify.length ? ' et vérifié' : ''} : ${env.CADENCE_SHORT} ${took}`));
|
|
435
|
-
|
|
436
|
-
out(delivered);
|
|
437
|
-
refreshArticles(ctx, ids, final);
|
|
434
|
+
announceDelivered(ctx, prev, final);
|
|
438
435
|
return 0;
|
|
439
436
|
}
|
|
440
437
|
finally {
|
|
@@ -504,38 +501,17 @@ async function verifyAll(ctx, deps, sha, env, step) {
|
|
|
504
501
|
return null;
|
|
505
502
|
}
|
|
506
503
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
* nommé pour le contexte — les annoncer « livrés » ferait fermer à tort. L'état est celui du départ de
|
|
512
|
-
* la livraison : le plan a été lu avant que le script du projet ne ferme lui-même les lots qu'il livre.
|
|
504
|
+
* Ce qui suit la ligne verte du journal, depuis la livraison verte précédente `prev` (celle d'AVANT la ligne écrite) : les lots cités
|
|
505
|
+
* par les commits livrés sont annoncés (« livré : L… »), puis le lot de l'article à rafraîchir est ouvert (L144). Partagé par deliver
|
|
506
|
+
* et par `cadence verify` (L435) : la ligne que verify écrit est une livraison, la suivante partira d'elle, les lots d'entre-deux se
|
|
507
|
+
* disent donc ici ou jamais.
|
|
513
508
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const ids = new Set();
|
|
521
|
-
for (const c of readCommits(ctx.root, { range: `${prev}..${sha}` })) {
|
|
522
|
-
if (isPlanOnly(c.sha, ctx.plan, ctx.root))
|
|
523
|
-
continue; // entretien du plan : ne livre rien, même s'il cite des lots
|
|
524
|
-
for (const r of citedRefs(c, ctx.plan.refs))
|
|
525
|
-
if (known.has(r.lot))
|
|
526
|
-
ids.add(r.lot);
|
|
527
|
-
}
|
|
528
|
-
return [...ids].sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
529
|
-
}
|
|
530
|
-
function deliveredLots(ctx, ids, prev, sha) {
|
|
531
|
-
if (!ctx.plan || !prev || prev === sha)
|
|
532
|
-
return null;
|
|
533
|
-
if (!isAncestor(ctx.root, prev, sha)) {
|
|
534
|
-
return `livraison précédente (${prev.slice(0, 7)}) hors de l'historique de ${sha.slice(0, 7)} (réécrit ?) : lots livrés non calculés`;
|
|
535
|
-
}
|
|
536
|
-
if (ids.length === 0)
|
|
537
|
-
return null;
|
|
538
|
-
return `livré : ${ids.join(', ')} — ${ctx.plan.readonly ? "à fermer avec l'outil du projet" : 'raf done'} si l'effet est celui attendu`;
|
|
509
|
+
export function announceDelivered(ctx, prev, sha) {
|
|
510
|
+
const ids = deliveredIds(ctx, prev, sha);
|
|
511
|
+
const delivered = deliveredLots(ctx, ids, prev, sha);
|
|
512
|
+
if (delivered)
|
|
513
|
+
ctx.out(delivered);
|
|
514
|
+
refreshArticles(ctx, ids, sha);
|
|
539
515
|
}
|
|
540
516
|
/**
|
|
541
517
|
* Livraison verte (L144) : les lots livrés dont le titre est public changent ce que les articles externes racontent, on ouvre
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { parseDocument } from 'yaml';
|
|
3
|
+
import { RafError } from './plan.js';
|
|
4
|
+
/** Fichier d'acquittement docs-ok d'un plan en lecture seule, relatif à la racine du dépôt (L386). */
|
|
5
|
+
export const DOCS_OK_FILE = '.cadence/docs-ok.yaml';
|
|
6
|
+
/** Les acquittements du fichier : lot → { date, reason }. Une entrée sans raison n'acquitte rien ; un fichier illisible est une erreur qui le nomme. */
|
|
7
|
+
export function readDocsOkFile(file) {
|
|
8
|
+
if (!file || !existsSync(file))
|
|
9
|
+
return {};
|
|
10
|
+
const doc = parseDocument(readFileSync(file, 'utf8'));
|
|
11
|
+
if (doc.errors.length > 0)
|
|
12
|
+
throw new RafError(`${file} : ${doc.errors[0].message}`);
|
|
13
|
+
const raw = doc.toJSON();
|
|
14
|
+
if (raw == null)
|
|
15
|
+
return {};
|
|
16
|
+
if (typeof raw !== 'object' || Array.isArray(raw))
|
|
17
|
+
throw new RafError(`${file} : la racine doit être un objet (lot → { date, reason })`);
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [id, v] of Object.entries(raw)) {
|
|
20
|
+
const e = v;
|
|
21
|
+
if (e && typeof e === 'object' && typeof e.reason === 'string' && e.reason.trim() !== '')
|
|
22
|
+
out[id] = { date: String(e.date ?? ''), reason: e.reason.trim() };
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
package/dist/docsync.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { changedFiles } from './git.js';
|
|
3
|
+
/**
|
|
4
|
+
* Commits dont les fichiers comptent pour `docs.sync` (L537) : ceux de type `refactor` (`refactor(L1): …`) sont un nettoyage ou
|
|
5
|
+
* un découpage déclaré sans changement de commande, de clé ni de sortie, donc sans document à écrire. `refactor!` et un refactor
|
|
6
|
+
* dont le corps porte le pied `BREAKING CHANGE:` restent un changement.
|
|
7
|
+
*/
|
|
8
|
+
function docSyncCommits(commits) {
|
|
9
|
+
return commits.filter((c) => !/^refactor(\([^)]*\))?:/.test(c.subject) || /^BREAKING[ -]CHANGE:/m.test(c.body));
|
|
10
|
+
}
|
|
11
|
+
/** Les écarts d'un lot : les fichiers de `paths` viennent des commits qui comptent, mais un document écrit dans un refactor reste écrit. */
|
|
12
|
+
export function lotDocSyncGaps(rules, root, commits) {
|
|
13
|
+
return docSyncGaps(rules, filesOf(root, docSyncCommits(commits)), filesOf(root, commits));
|
|
14
|
+
}
|
|
3
15
|
/** Motif de chemin : `*` reste dans un dossier, `**` le traverse, `?` un caractère, un `/` final prend tout le dossier ; sinon chemin exact. */
|
|
4
16
|
export function docSyncMatcher(pattern) {
|
|
5
17
|
const p = pattern.trim().replace(/\\/g, '/').replace(/^\.\//, '');
|
|
@@ -20,11 +32,11 @@ export function docSyncSet(patterns) {
|
|
|
20
32
|
export function filesOf(root, commits, opts = {}) {
|
|
21
33
|
return new Set(commits.flatMap((c) => changedFiles(root, c.sha, opts)));
|
|
22
34
|
}
|
|
23
|
-
/** Les règles que ces fichiers enfreignent : ils touchent `paths` sans qu'aucun `docs` ne soit parmi
|
|
24
|
-
|
|
35
|
+
/** Les règles que ces fichiers enfreignent : ils touchent `paths` sans qu'aucun `docs` ne soit parmi les fichiers `written`. */
|
|
36
|
+
function docSyncGaps(rules, files, written) {
|
|
25
37
|
const gaps = [];
|
|
26
38
|
for (const rule of rules) {
|
|
27
|
-
if ([...
|
|
39
|
+
if ([...written].some(docSyncSet(rule.docs)))
|
|
28
40
|
continue;
|
|
29
41
|
const inPaths = docSyncSet(rule.paths);
|
|
30
42
|
const touched = [...files].filter(inPaths).sort();
|
package/dist/lead.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readdirSync,
|
|
1
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, join, relative, sep } from 'node:path';
|
|
3
3
|
import { audit, gateWaiting, nextUp, planCommits, workByLot } from './audit.js';
|
|
4
4
|
import { PLAN_DEFAULT, PLAN_LEGACY, planLoader, readPlanConfig } from './config.js';
|
|
@@ -7,7 +7,7 @@ import { localRepoNotes } from './local-task.js';
|
|
|
7
7
|
import { gitRoot, repoStatus } from './git.js';
|
|
8
8
|
import { linkCommits } from './link.js';
|
|
9
9
|
import { commitCount, lastActivity, lockStatus } from './session.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isObject, readYamlFile, readYamlKey } from './yaml-keys.js';
|
|
11
11
|
import { isOpen, RafError } from './plan.js';
|
|
12
12
|
import { isRecurring } from './recurring.js';
|
|
13
13
|
import { priorityRank, readPriority } from './orchestrate/continue.js';
|
|
@@ -20,16 +20,7 @@ import { KEPT_TITLE, keptLine, keptTrees } from './orchestrate/worktree.js';
|
|
|
20
20
|
/** Le bloc `lead:` du cadence.yaml du dossier parent (absent = `undefined`) ; un `lead` qui n'est pas une table est refusé en nommant `key`. */
|
|
21
21
|
function readLeadBlock(parent, key, expected) {
|
|
22
22
|
const file = join(parent, 'cadence.yaml');
|
|
23
|
-
|
|
24
|
-
return undefined;
|
|
25
|
-
let raw;
|
|
26
|
-
try {
|
|
27
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
31
|
-
}
|
|
32
|
-
const l = raw?.lead;
|
|
23
|
+
const l = readYamlKey(file, 'lead');
|
|
33
24
|
if (l == null)
|
|
34
25
|
return undefined;
|
|
35
26
|
if (typeof l !== 'object' || Array.isArray(l))
|
|
@@ -52,8 +43,8 @@ export function findLeadDir(start) {
|
|
|
52
43
|
const file = join(dir, 'cadence.yaml');
|
|
53
44
|
if (existsSync(file)) {
|
|
54
45
|
try {
|
|
55
|
-
const raw =
|
|
56
|
-
if (raw &&
|
|
46
|
+
const raw = readYamlFile(file);
|
|
47
|
+
if (isObject(raw) && ('lead' in raw || 'priority' in raw))
|
|
57
48
|
return dir;
|
|
58
49
|
}
|
|
59
50
|
catch {
|
|
@@ -79,16 +70,7 @@ export function readLeadContextThreshold(parent) {
|
|
|
79
70
|
/** Clé `depth:` du cadence.yaml du dossier parent (L201, issue #8), à côté de `priority:` : combien de niveaux `lead tour` parcourt (1 : sous-dossiers directs, le défaut). */
|
|
80
71
|
export function readDepth(parent) {
|
|
81
72
|
const file = join(parent, 'cadence.yaml');
|
|
82
|
-
|
|
83
|
-
return 1;
|
|
84
|
-
let raw;
|
|
85
|
-
try {
|
|
86
|
-
raw = parse(readFileSync(file, 'utf8'));
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
throw new RafError(`${file} illisible : ${e.message.split('\n')[0]}`);
|
|
90
|
-
}
|
|
91
|
-
const d = raw?.depth;
|
|
73
|
+
const d = readYamlKey(file, 'depth');
|
|
92
74
|
if (d == null)
|
|
93
75
|
return 1;
|
|
94
76
|
if (typeof d !== 'number' || !Number.isInteger(d) || d < 1)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { gateProgress, gateText } from './audit.js';
|
|
2
|
+
/** Les lignes de tête de `raf show` : titre, état détaillé (L463), objectif, dates, dépendances, drapeaux, champs d'extension (L464), acquittement docs et condition de tirage. Une ligne par fait posé, aucune pour un fait absent. */
|
|
3
|
+
export function lotLines(plan, lot) {
|
|
4
|
+
const lines = [...headLines(lot), ...flagLines(lot)];
|
|
5
|
+
if (lot.docsOk)
|
|
6
|
+
lines.push(`docs-ok : ${lot.docsOk.date} — ${lot.docsOk.reason}`);
|
|
7
|
+
const gate = gateProgress(plan.lots(), lot);
|
|
8
|
+
if (lot.gate && gate)
|
|
9
|
+
lines.push(lot.gate.invalid ? `gate : ${gateText(gate)}` : `gate : ${gate.n} lots ${gate.label} faits`);
|
|
10
|
+
return lines;
|
|
11
|
+
}
|
|
12
|
+
function headLines(lot) {
|
|
13
|
+
const lines = [`${lot.id} ${lot.status} ${lot.title}`];
|
|
14
|
+
if (lot.state)
|
|
15
|
+
lines.push(`état : ${lot.state}`);
|
|
16
|
+
if (lot.goal)
|
|
17
|
+
lines.push(`goal : ${lot.goal}`);
|
|
18
|
+
const dates = [['créé', lot.created], ['démarré', lot.started], [lot.status === 'dropped' ? 'abandonné' : 'terminé', lot.finished]].filter(([, d]) => d);
|
|
19
|
+
if (dates.length)
|
|
20
|
+
lines.push(dates.map(([k, d]) => `${k} : ${d}`).join(' '));
|
|
21
|
+
if (lot.after.length)
|
|
22
|
+
lines.push(`after : ${lot.after.join(', ')}`);
|
|
23
|
+
if (lot.public)
|
|
24
|
+
lines.push(`public : ${lot.public}`);
|
|
25
|
+
return lines;
|
|
26
|
+
}
|
|
27
|
+
function flagLines(lot) {
|
|
28
|
+
const lines = [];
|
|
29
|
+
// L439 : le livreur lit ici si le lot est visible et s'il porte un verdict UX ; deux lignes stables, absentes d'un lot non visible.
|
|
30
|
+
if (lot.visible)
|
|
31
|
+
lines.push('visible : oui');
|
|
32
|
+
if (lot.screen)
|
|
33
|
+
lines.push(`screen : ${lot.screen}`);
|
|
34
|
+
if (lot.visible)
|
|
35
|
+
lines.push(lot.ux ? `ux : ${lot.ux.verdict}` : 'ux : absent');
|
|
36
|
+
if (lot.spec)
|
|
37
|
+
lines.push('spec : true');
|
|
38
|
+
if (lot.uses)
|
|
39
|
+
lines.push(`uses : ${lot.uses.join(', ')}`);
|
|
40
|
+
for (const [name, value] of Object.entries(lot.extras ?? {}))
|
|
41
|
+
lines.push(`${name} : ${value}`);
|
|
42
|
+
return lines;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Le lot tel que `raf list --json` l'exporte (L464) : les clés du fichier du plan (`docs_ok`, `state_before`, pas `docsOk` ni `stateBefore`), sans `problems` (diagnostic de `raf check`).
|
|
46
|
+
* Les noms exportés sont ceux que garantit docs/stabilite.md : renommer un champ du type interne `Lot` ne les change pas.
|
|
47
|
+
*/
|
|
48
|
+
export function lotJson(lot) {
|
|
49
|
+
const { docsOk, stateBefore, problems: _problems, ...rest } = lot;
|
|
50
|
+
return { ...rest, ...(docsOk ? { docs_ok: docsOk } : {}), ...(stateBefore ? { state_before: stateBefore } : {}) };
|
|
51
|
+
}
|