specbox 6.38.0 → 6.39.0
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.
|
@@ -194,12 +194,45 @@ function pre() {
|
|
|
194
194
|
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput } }));
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
/**
|
|
198
|
+
* start_uc (UC-12301): a block it records (`event_line`) and a skip it spends (`policy_content`)
|
|
199
|
+
* go where the policy tools write them. Returns the note for the agent, or null.
|
|
200
|
+
*/
|
|
201
|
+
function saveStartUcEnforcement(response) {
|
|
202
|
+
if (parsed.tool !== 'start_uc') return null;
|
|
203
|
+
const saved = [];
|
|
204
|
+
try {
|
|
205
|
+
const lines = (extractField(response, 'event_line') || '').split('\n').filter((l) => l.trim());
|
|
206
|
+
if (lines.length) {
|
|
207
|
+
for (const line of lines) JSON.parse(line);
|
|
208
|
+
mkdirSync(dirname(eventsPath), { recursive: true });
|
|
209
|
+
appendFileSync(eventsPath, lines.map((l) => `${l}\n`).join(''), 'utf-8');
|
|
210
|
+
saved.push(`el registro en ${eventsPath.replace(`${root}/`, '')}`);
|
|
211
|
+
}
|
|
212
|
+
const policy = extractField(response, 'policy_content');
|
|
213
|
+
if (policy != null) {
|
|
214
|
+
JSON.parse(policy);
|
|
215
|
+
writeAtomic(policyPath, policy.endsWith('\n') ? policy : `${policy}\n`);
|
|
216
|
+
saved.unshift(`la política en ${policyPath.replace(`${root}/`, '')}`);
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
process.stderr.write(
|
|
220
|
+
`SpecBox freeform-fragment: no se pudo guardar lo que devolvió start_uc (${err.message}). ` +
|
|
221
|
+
'Repite la llamada antes de seguir.\n',
|
|
222
|
+
);
|
|
223
|
+
process.exit(2);
|
|
224
|
+
}
|
|
225
|
+
return saved.length ? `SpecBox: guardado ${saved.join(' y ')}. No lo escribas a mano.` : null;
|
|
226
|
+
}
|
|
227
|
+
|
|
197
228
|
function post() {
|
|
198
229
|
if (!existsSync(pending)) return;
|
|
199
230
|
const response = payload.tool_response;
|
|
231
|
+
const startNote = saveStartUcEnforcement(response);
|
|
200
232
|
const content = extractItemsContent(response);
|
|
201
233
|
if (content == null) {
|
|
202
234
|
unlinkSync(pending); // a read, or an error: nothing to merge
|
|
235
|
+
if (startNote) writeHidden(response, startNote); // a start_uc that a measure stopped
|
|
203
236
|
return;
|
|
204
237
|
}
|
|
205
238
|
try {
|
|
@@ -224,7 +257,8 @@ function post() {
|
|
|
224
257
|
`SpecBox: el tablero ya está guardado en ${itemsPath.replace(`${root}/`, '')}` +
|
|
225
258
|
(changes ? ` (${changes > 0 ? '+' : ''}${changes} elementos)` : '') +
|
|
226
259
|
(policySaved ? `, con su política en ${policyPath.replace(`${root}/`, '')}` : '') +
|
|
227
|
-
'. No lo escribas a mano.'
|
|
260
|
+
'. No lo escribas a mano.' +
|
|
261
|
+
(startNote ? ` ${startNote}` : ''),
|
|
228
262
|
},
|
|
229
263
|
}),
|
|
230
264
|
);
|
package/hooks/hooks-history.json
CHANGED
|
@@ -177,7 +177,8 @@
|
|
|
177
177
|
"freeform-fragment.mjs": [
|
|
178
178
|
"fcb1fc9a1494c1c63870bdec08368bf3c815b1372e220a6311535b0431c86061",
|
|
179
179
|
"c8c507e2bd1bfa11f681a70b0f236bbc0d23447140ee4424a25533669beb17b4",
|
|
180
|
-
"c212b004d384feba728e0ee7e955bfb09fafe39112cad7c530620a1e932d169a"
|
|
180
|
+
"c212b004d384feba728e0ee7e955bfb09fafe39112cad7c530620a1e932d169a",
|
|
181
|
+
"9ab7d65162056498f7c403eff0eb571b914b9d5c70b9bfdcd52b885c7bd20fef"
|
|
181
182
|
],
|
|
182
183
|
"lib/freeform-fragment.mjs": [
|
|
183
184
|
"d30a15b495cf18cad571e8582b4ce943a75aa4ad8efc5fa11e22420b505dad12",
|
|
@@ -211,9 +212,11 @@
|
|
|
211
212
|
"5fe963aab5f24c2b50c9991f11dbda48440a98f7394e02c823a276ee1bb2d608"
|
|
212
213
|
],
|
|
213
214
|
"lib/prd-locate.mjs": [
|
|
214
|
-
"e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa"
|
|
215
|
+
"e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa",
|
|
216
|
+
"d4d7328f92436663cfaf913a76f1a0f8930475680d50f97a235e77d208afc7ec"
|
|
215
217
|
],
|
|
216
218
|
"prd-sync-guard.mjs": [
|
|
217
|
-
"0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8"
|
|
219
|
+
"0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8",
|
|
220
|
+
"959790ef27c79fc4b1603a53ca0f222dc4276aec91ca096c25a34e21cb1b4e96"
|
|
218
221
|
]
|
|
219
222
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.39.0",
|
|
3
3
|
"files": {
|
|
4
4
|
"app-docs-fragment.mjs": "4efae124b02c12f87513e48ca6d4f2e96065c05ca6d8c74352592a8edb21695a",
|
|
5
5
|
"app-docs-sync-guard.mjs": "71f09545b57c143b013c2e532366bfdd1e1a2ae49c7644c9e12e2ab5324d03d3",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"design-system-gate.mjs": "419018cadb3e0a4fe0def1c423fed7013b76b2f121312acadbc99fc8e30b8ff5",
|
|
13
13
|
"e2e-gate.mjs": "02e239816cb429f76034088a5370f63a08facce01b4ffd52b338a66acf13028d",
|
|
14
14
|
"file-ownership-guard.mjs": "d8a84370766966cce70b76811de9dd150d170a79c4cb7b9e6b120cfad86a6932",
|
|
15
|
-
"freeform-fragment.mjs": "
|
|
15
|
+
"freeform-fragment.mjs": "9ab7d65162056498f7c403eff0eb571b914b9d5c70b9bfdcd52b885c7bd20fef",
|
|
16
16
|
"freeform-path-guard.mjs": "9ded19e96b0738de5aaf43a97eaa1d88ecd3b341efd432c0b32eb312c4bf5e0a",
|
|
17
17
|
"healing-budget-guard.mjs": "c49c6c34f99545e4009ad88ed9f7eef737e35ce39c11a05d41ad8f976ffae09f",
|
|
18
18
|
"implement-checkpoint.mjs": "f3f219779a1ac4108bc3aabcc7311e9135d9c7795c126a2b5d659e743f5a5a64",
|
|
@@ -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": "
|
|
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": "
|
|
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",
|
package/hooks/lib/prd-locate.mjs
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
41
|
-
|
|
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
|
|
60
|
+
const first = (rels) => rels.map((rel) => exact(root, rel)).find(Boolean) ?? null;
|
|
48
61
|
if (feature) {
|
|
49
|
-
|
|
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
|
|
53
|
-
if (
|
|
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
|
-
|
|
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
|
|
80
|
+
const texts = prdCandidates(root).map((rel) => {
|
|
61
81
|
try {
|
|
62
|
-
return
|
|
82
|
+
return [rel, readFileSync(join(root, rel), 'utf-8')];
|
|
63
83
|
} catch {
|
|
64
|
-
return
|
|
84
|
+
return [rel, ''];
|
|
65
85
|
}
|
|
66
86
|
});
|
|
67
|
-
|
|
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 =
|
|
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
|
}
|
package/hooks/prd-sync-guard.mjs
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "6.39.0",
|
|
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": {
|