specbox 6.38.0 → 6.38.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.
@@ -211,9 +211,11 @@
211
211
  "5fe963aab5f24c2b50c9991f11dbda48440a98f7394e02c823a276ee1bb2d608"
212
212
  ],
213
213
  "lib/prd-locate.mjs": [
214
- "e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa"
214
+ "e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa",
215
+ "d4d7328f92436663cfaf913a76f1a0f8930475680d50f97a235e77d208afc7ec"
215
216
  ],
216
217
  "prd-sync-guard.mjs": [
217
- "0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8"
218
+ "0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8",
219
+ "959790ef27c79fc4b1603a53ca0f222dc4276aec91ca096c25a34e21cb1b4e96"
218
220
  ]
219
221
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.38.0",
2
+ "version": "6.38.1",
3
3
  "files": {
4
4
  "app-docs-fragment.mjs": "4efae124b02c12f87513e48ca6d4f2e96065c05ca6d8c74352592a8edb21695a",
5
5
  "app-docs-sync-guard.mjs": "71f09545b57c143b013c2e532366bfdd1e1a2ae49c7644c9e12e2ab5324d03d3",
@@ -21,7 +21,7 @@
21
21
  "on-session-end.mjs": "fd5b7cf3bf2c419fd4125e21b338c4c849a4daaef21d5e15253caed54965b40c",
22
22
  "pipeline-phase-guard.mjs": "761b82c8b0c4884eba54d529e1f726d547003a6efe05425b45a1a0b77b90fe0d",
23
23
  "post-implement-validate.mjs": "25e5ea280c945f707ca8476555fca7a44c93aec1018eef06702c908a071df0cd",
24
- "prd-sync-guard.mjs": "0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8",
24
+ "prd-sync-guard.mjs": "959790ef27c79fc4b1603a53ca0f222dc4276aec91ca096c25a34e21cb1b4e96",
25
25
  "pre-commit-lint.mjs": "348adbbfd29e52ebc6512a46b19f5e3c8bde4ae2139c013b96659fdc66456eab",
26
26
  "pre-prd-discovery-check.mjs": "2eda49648e31dd8720f70b3dcfca2782df9e950b6628ce0db8948c448253c2be",
27
27
  "pre-read-budget-guard.mjs": "76aeb98026f7fde19bb4d57749ff59b08cdfff0ba6f7188cafc28762773bed34",
@@ -51,7 +51,7 @@
51
51
  "lib/native-reservation-revalidate.mjs": "1b394e8eb5d01480b71ac0976d636814483891e9f862edd5ac0216ac0128b023",
52
52
  "lib/output.mjs": "a568c736917720349b2b2527eb5b480bb11059a9253f81473f5b5c2c164b04bc",
53
53
  "lib/ownership-map.mjs": "21946608331a39e8c76eb2ba3860b5ebb351aa154f31801e768703bc4ae66b9a",
54
- "lib/prd-locate.mjs": "e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa",
54
+ "lib/prd-locate.mjs": "d4d7328f92436663cfaf913a76f1a0f8930475680d50f97a235e77d208afc7ec",
55
55
  "lib/reservation-probe.mjs": "44566d2a92eb145a4a7252cfca8081e2101dc101bbc13faa77da8fa35b06dff0",
56
56
  "lib/roadmap.mjs": "0ff30f9d5707c89b8b43406e76f4870a39dd4f787221c32310ef6f9040879d8a",
57
57
  "lib/token-counter.mjs": "ca637273dcf731c7a951f28b8307d13de06d311cf85741ef56c4e3df9eaa231e",
@@ -1,17 +1,21 @@
1
1
  /**
2
- * lib/prd-locate.mjs — dónde está el PRD de una UC (UC-12211).
2
+ * lib/prd-locate.mjs — dónde está el PRD de una UC (UC-12211, UC-12219).
3
3
  *
4
4
  * Mismo orden que `find_prd_path` de server/prd_writer.py (una prueba lo compara):
5
5
  * 1. doc/prds/{feature}_prd.md o doc/prds/{feature}.md
6
6
  * 2. doc/prds/{us normalizada}_prd.md (US-01 → us_01)
7
- * 3. doc/prd/{feature}.md o doc/prd/{feature}/prd.md
8
- * 4. el único PRD que nombra la historia (doc/prd/*\/prd.md, doc/prd/*.md, doc/prds/*.md)
7
+ * 3. doc/prd/{feature}.md o la carpeta de la feature: doc/prd/{feature}/prd.md, PRD.md o
8
+ * {feature}_prd.md
9
+ * 4. el único PRD que define la historia (un encabezado o una línea «>» la nombra), o si no, el
10
+ * único que la nombra (prdCandidates)
9
11
  * 5. el único fichero de doc/prds/
10
- * Devuelve la ruta relativa a `root`, o null.
12
+ * Devuelve la ruta relativa a `root` con el nombre que tiene en disco (un disco que no distingue
13
+ * mayúsculas también «encuentra» PRD.md al pedir prd.md, y el hook la compara con los ficheros
14
+ * de la PR), o null.
11
15
  */
12
16
 
13
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
14
- import { join } from 'node:path';
17
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
18
+ import { basename, dirname, join } from 'node:path';
15
19
 
16
20
  const isFile = (path) => {
17
21
  try {
@@ -20,53 +24,73 @@ const isFile = (path) => {
20
24
  return false;
21
25
  }
22
26
  };
23
- const list = (dir) => {
27
+ /** Las entradas de `dir` tal como están en disco, ordenadas; [] si no existe. */
28
+ const names = (dir) => {
24
29
  try {
25
30
  return readdirSync(dir).sort();
26
31
  } catch {
27
32
  return [];
28
33
  }
29
34
  };
35
+ /** `rel` si existe un fichero con ese nombre exacto (mayúsculas incluidas). */
36
+ const exact = (root, rel) => {
37
+ const full = join(root, rel);
38
+ return names(dirname(full)).includes(basename(full)) && isFile(full) ? rel : null;
39
+ };
30
40
 
31
- /** Todos los PRD del proyecto, en orden estable (rutas relativas). */
41
+ /** Todos los PRD del proyecto, en orden estable (rutas relativas, nombres como en disco). */
32
42
  export function prdCandidates(root) {
33
43
  const out = [];
34
- for (const name of list(join(root, 'doc', 'prd'))) {
35
- if (isFile(join(root, 'doc', 'prd', name, 'prd.md'))) out.push(`doc/prd/${name}/prd.md`);
36
- }
37
- for (const name of list(join(root, 'doc', 'prd'))) {
38
- if (name.endsWith('.md') && isFile(join(root, 'doc', 'prd', name))) out.push(`doc/prd/${name}`);
44
+ const prdDir = join(root, 'doc', 'prd');
45
+ for (const folder of names(prdDir)) {
46
+ const inside = names(join(prdDir, folder));
47
+ for (const name of ['prd.md', 'PRD.md', `${folder}_prd.md`]) {
48
+ if (inside.includes(name) && isFile(join(prdDir, folder, name))) out.push(`doc/prd/${folder}/${name}`);
49
+ }
39
50
  }
40
- for (const name of list(join(root, 'doc', 'prds'))) {
41
- if (name.endsWith('.md') && isFile(join(root, 'doc', 'prds', name))) out.push(`doc/prds/${name}`);
51
+ for (const [dir, rel] of [[prdDir, 'doc/prd'], [join(root, 'doc', 'prds'), 'doc/prds']]) {
52
+ for (const name of names(dir)) {
53
+ if (name.endsWith('.md') && isFile(join(dir, name))) out.push(`${rel}/${name}`);
54
+ }
42
55
  }
43
56
  return out;
44
57
  }
45
58
 
46
59
  export function locatePrd({ root, feature = '', usId = '' } = {}) {
47
- const has = (rel) => existsSync(join(root, rel)) && isFile(join(root, rel));
60
+ const first = (rels) => rels.map((rel) => exact(root, rel)).find(Boolean) ?? null;
48
61
  if (feature) {
49
- for (const rel of [`doc/prds/${feature}_prd.md`, `doc/prds/${feature}.md`]) if (has(rel)) return rel;
62
+ const found = first([`doc/prds/${feature}_prd.md`, `doc/prds/${feature}.md`]);
63
+ if (found) return found;
50
64
  }
51
65
  if (usId) {
52
- const rel = `doc/prds/${usId.toLowerCase().replace(/-/g, '_')}_prd.md`;
53
- if (has(rel)) return rel;
66
+ const found = exact(root, `doc/prds/${usId.toLowerCase().replace(/-/g, '_')}_prd.md`);
67
+ if (found) return found;
54
68
  }
55
69
  if (feature) {
56
- for (const rel of [`doc/prd/${feature}.md`, `doc/prd/${feature}/prd.md`]) if (has(rel)) return rel;
70
+ const found = first([
71
+ `doc/prd/${feature}.md`,
72
+ `doc/prd/${feature}/prd.md`,
73
+ `doc/prd/${feature}/PRD.md`,
74
+ `doc/prd/${feature}/${feature}_prd.md`,
75
+ ]);
76
+ if (found) return found;
57
77
  }
58
78
  if (usId) {
59
79
  const word = new RegExp(`\\b${usId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`);
60
- const named = prdCandidates(root).filter((rel) => {
80
+ const texts = prdCandidates(root).map((rel) => {
61
81
  try {
62
- return word.test(readFileSync(join(root, rel), 'utf-8'));
82
+ return [rel, readFileSync(join(root, rel), 'utf-8')];
63
83
  } catch {
64
- return false;
84
+ return [rel, ''];
65
85
  }
66
86
  });
67
- if (named.length === 1) return named[0];
87
+ // El que define la historia (un encabezado o una línea «>» la nombra) gana al que solo la cita.
88
+ const defining = texts.filter(([, text]) => text.split('\n').some((line) => /^\s*[#>]/.test(line) && word.test(line)));
89
+ if (defining.length === 1) return defining[0][0];
90
+ const named = texts.filter(([, text]) => word.test(text));
91
+ if (named.length === 1) return named[0][0];
68
92
  }
69
- const prds = list(join(root, 'doc', 'prds')).filter((n) => n.endsWith('.md'));
93
+ const prds = names(join(root, 'doc', 'prds')).filter((n) => n.endsWith('.md') && isFile(join(root, 'doc', 'prds', n)));
70
94
  if (prds.length === 1) return `doc/prds/${prds[0]}`;
71
95
  return null;
72
96
  }
@@ -107,7 +107,7 @@ if (ok) {
107
107
 
108
108
  const where = prd
109
109
  ? `${satellite ? `${relative(root, canonRoot) || '.'}/` : ''}${prd}`
110
- : `un PRD de ${marker.us_id || 'la historia'} (doc/prd/<slug>/prd.md, doc/prd/<feature>.md o doc/prds/)`;
110
+ : `un PRD de ${marker.us_id || 'la historia'} (doc/prd/<slug>/prd.md, PRD.md o <slug>_prd.md, doc/prd/<feature>.md o doc/prds/; con la historia en un encabezado o una línea «>»)`;
111
111
  const reason = prd
112
112
  ? `la PR de ${marker.uc_id} no cambia el PRD de su historia (${where})${satellite ? ' ni enlaza una PR del orquestador que lo cambie' : ''}.`
113
113
  : `no se encontró ${where}.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specbox",
3
- "version": "6.38.0",
3
+ "version": "6.38.1",
4
4
  "description": "Conecta este ordenador a SpecBox sin copiar tokens (specbox login, status y logout) y actualiza los hooks del proyecto sin pisar los tuyos (specbox hooks).",
5
5
  "type": "module",
6
6
  "bin": {