specbox 6.36.0 → 6.38.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.
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * app-docs-fragment.mjs — la zona «roadmap» de app_prd.md sigue al tablero (UC-12203, UC-12218).
4
+ *
5
+ * Tools: complete_uc, move_uc, add_uc, delete_uc y mark_ac_batch.
6
+ *
7
+ * PreToolUse: pide la zona al servidor (`with_roadmap: true`) solo si hace falta: el repositorio que
8
+ * guarda el canon (el orquestador en multirepo; el satélite no guarda copia) tiene
9
+ * doc/app/app_prd.md y está en su rama principal. Sin pedirla, el servidor responde como antes y la
10
+ * zona no gasta contexto (UC-12218). En FreeForm no se pide: la calcula este hook.
11
+ *
12
+ * PostToolUse: escribe en esa zona el cuerpo que devolvió el servidor (`app_docs_sync.roadmap_body`)
13
+ * y lo quita de la respuesta que ve el modelo. En FreeForm espera a que freeform-fragment haya
14
+ * fusionado items.json y calcula el mismo cuerpo con él (lib/roadmap.mjs).
15
+ *
16
+ * Solo en main o master: la zona sale del tablero, así que en una rama de trabajo se deja para el
17
+ * siguiente cambio en main y dos ramas no chocan al fusionar. Nunca bloquea.
18
+ */
19
+
20
+ import { execFileSync } from 'node:child_process';
21
+ import { existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
22
+ import { isAbsolute, join, resolve } from 'node:path';
23
+ import { parseToolName, pendingPath, withoutFields } from './lib/freeform-fragment.mjs';
24
+ import { readHookInput } from './lib/utils.mjs';
25
+ import { render, replaceZone, rowsFromItems } from './lib/roadmap.mjs';
26
+ import { topObject } from './lib/uc-state.mjs';
27
+
28
+ const TOOLS = new Set(['complete_uc', 'move_uc', 'add_uc', 'delete_uc', 'mark_ac_batch']);
29
+ const DOC = join('doc', 'app', 'app_prd.md');
30
+ const MERGE_WAIT_MS = 4000;
31
+
32
+ const { event, toolName, toolInput, cwd, payload } = readHookInput();
33
+ const parsed = parseToolName(toolName);
34
+ if (!parsed || !TOOLS.has(parsed.tool)) process.exit(0);
35
+
36
+ const git = (dir, args) => {
37
+ try {
38
+ return execFileSync('git', ['-C', dir, ...args], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
39
+ } catch {
40
+ return '';
41
+ }
42
+ };
43
+ const readJson = (path) => {
44
+ try {
45
+ return JSON.parse(readFileSync(path, 'utf-8'));
46
+ } catch {
47
+ return null;
48
+ }
49
+ };
50
+
51
+ const root = git(cwd, ['rev-parse', '--show-toplevel']) || cwd;
52
+ const settings = readJson(join(root, '.claude', 'settings.local.json')) || {};
53
+ const projectConfig = readJson(join(root, '.claude', 'project-config.json')) || {};
54
+ const backendType = projectConfig.backend_type || settings.backend_type || settings.specbox?.backend_type || '';
55
+ const freeform = backendType === 'freeform';
56
+ const mr = settings.multirepo || projectConfig.multirepo;
57
+ const canonRoot =
58
+ mr?.enabled && mr?.role === 'satellite' && mr?.orchestrator
59
+ ? isAbsolute(mr.orchestrator) ? mr.orchestrator : resolve(root, mr.orchestrator)
60
+ : root;
61
+ const docPath = join(canonRoot, DOC);
62
+ const wanted = () => existsSync(docPath) && ['main', 'master'].includes(git(canonRoot, ['branch', '--show-current']));
63
+
64
+ if (event === 'PreToolUse') {
65
+ // FreeForm: la zona la calcula el hook; además, freeform-fragment ya cambia la entrada.
66
+ if (!freeform && toolInput.with_roadmap !== true && wanted()) {
67
+ process.stdout.write(
68
+ JSON.stringify({ hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput: { ...toolInput, with_roadmap: true } } }),
69
+ );
70
+ }
71
+ process.exit(0);
72
+ }
73
+ if (event !== 'PostToolUse') process.exit(0);
74
+
75
+ const response = payload.tool_response;
76
+ const top = topObject(response);
77
+ const sync = top?.app_docs_sync;
78
+
79
+ const hide = () => {
80
+ if (typeof sync?.roadmap_body !== 'string') return;
81
+ process.stdout.write(
82
+ JSON.stringify({ hookSpecificOutput: { hookEventName: 'PostToolUse', updatedToolOutput: withoutFields(response, ['roadmap_body']) } }),
83
+ );
84
+ };
85
+
86
+ /** FreeForm: espera a que freeform-fragment fusione lo que cambió la tool en items.json. */
87
+ function waitForMerge() {
88
+ if (!payload.tool_use_id) return;
89
+ const pending = pendingPath(join(root, '.quality', 'freeform-fragments'), payload.tool_use_id);
90
+ const until = Date.now() + MERGE_WAIT_MS;
91
+ while (existsSync(pending) && Date.now() < until) {
92
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
93
+ }
94
+ }
95
+
96
+ try {
97
+ if (top && !top.error && top.success !== false && wanted()) {
98
+ let body = sync?.ok === true && typeof sync.roadmap_body === 'string' ? sync.roadmap_body : null;
99
+ if (body == null && freeform) {
100
+ waitForMerge();
101
+ const tracking = settings.specbox?.freeform_root_absolute;
102
+ const items = readJson(join(typeof tracking === 'string' && isAbsolute(tracking) ? tracking : join(root, 'doc', 'tracking'), 'items.json'));
103
+ if (Array.isArray(items)) body = render(rowsFromItems(items));
104
+ }
105
+ if (body != null) {
106
+ const current = readFileSync(docPath, 'utf-8');
107
+ const next = replaceZone(current, 'roadmap', body);
108
+ if (next != null && next !== current) {
109
+ const tmp = `${docPath}.${process.pid}.tmp`;
110
+ writeFileSync(tmp, next, 'utf-8');
111
+ renameSync(tmp, docPath);
112
+ }
113
+ }
114
+ }
115
+ } catch {
116
+ // el canon es una ayuda: nunca la razón de que falle una tool
117
+ }
118
+ hide();
119
+ process.exit(0);
@@ -3,7 +3,12 @@
3
3
  * commit-spec-guard.mjs — PreToolUse hook for `git commit`
4
4
  *
5
5
  * BLOCKING (exit 2, before the commit exists):
6
- * 1. Commit on main/master in a spec-driven project.
6
+ * 1. Commit on main/master in a spec-driven project, with the EP-20 measure `commit_on_main`
7
+ * in «block» (UC-12215): a project recognized by its usual configuration (first-level keys)
8
+ * keeps the block it always had; one recognized for the first time by the `specbox` block of
9
+ * settings.local.json takes the board's mode, «warn» unless a person changed it. A mode a
10
+ * person set with set_enforcement_mode wins in both cases. In «warn» it is a note; in «off»,
11
+ * nothing.
7
12
  * NOTE to the agent (additionalContext, the commit goes ahead):
8
13
  * 2. No active UC.
9
14
  * 3. No checkpoint saved for the active feature.
@@ -19,6 +24,7 @@
19
24
  import { readHookInput, gitDirForCommand, git, fileExists, readJsonFile } from './lib/utils.mjs';
20
25
  import { getProjectConfig } from './lib/config.mjs';
21
26
  import { blockWith, noteWith } from './lib/output.mjs';
27
+ import { leerPolitica, modoDe } from './lib/enforcement-policy.mjs';
22
28
 
23
29
  const { toolInput, cwd } = readHookInput();
24
30
  const command = String(toolInput.command || '');
@@ -29,19 +35,32 @@ try {
29
35
  process.exit(0);
30
36
  }
31
37
 
32
- const { boardId, isSpecDriven } = getProjectConfig();
38
+ const { boardId, backendType, isSpecDriven, recognizedBy, freeformRoot } = getProjectConfig();
33
39
  if (!isSpecDriven) process.exit(0);
34
40
 
41
+ const notes = [];
35
42
  const branch = git('branch --show-current');
36
43
  if (branch === 'main' || branch === 'master') {
37
- blockWith(`COMMIT BLOQUEADO: no se hace commit en ${branch}`, [
38
- 'Es un proyecto spec-driven: el trabajo va en una rama de la UC, nunca en main ni en master.',
39
- 'Para seguir: git checkout -b feature/{uc}-{nombre} (los cambios se van contigo) y haz el commit ahí.',
40
- ]);
44
+ // UC-12215: el modo de commit_on_main. Lo que puso una persona manda; si no, los proyectos de
45
+ // siempre conservan el bloqueo y los reconocidos por primera vez toman el modo del tablero.
46
+ const politica = await leerPolitica({ root: process.cwd(), backendType, boardId, trackingDir: freeformRoot });
47
+ const puesto = politica.explicitas?.includes('commit_on_main');
48
+ const modo = puesto || recognizedBy !== 'legacy' ? modoDe(politica, 'commit_on_main') : 'block';
49
+ if (modo === 'block') {
50
+ blockWith(`COMMIT BLOQUEADO: no se hace commit en ${branch}`, [
51
+ 'Es un proyecto spec-driven: el trabajo va en una rama de la UC, nunca en main ni en master.',
52
+ 'Para seguir: git checkout -b feature/{uc}-{nombre} (los cambios se van contigo) y haz el commit ahí.',
53
+ ]);
54
+ }
55
+ if (modo === 'warn') {
56
+ notes.push(
57
+ `- Commit en ${branch}: en un proyecto spec-driven el trabajo va en una rama de la UC. La medida commit_on_main ` +
58
+ 'está en «warn», así que el commit se hace. Para que bloquee: set_enforcement_mode(measure="commit_on_main", mode="block").',
59
+ );
60
+ }
41
61
  }
42
62
 
43
- const notes = [];
44
- const activeUC = fileExists('.quality/active_uc.json') ? readJsonFile('.quality/active_uc.json') : null;
63
+ const activeUC =fileExists('.quality/active_uc.json') ? readJsonFile('.quality/active_uc.json') : null;
45
64
  if (!activeUC) {
46
65
  notes.push(`- No hay UC activa (board ${boardId}): llama a start_uc antes de implementar y a mark_ac_batch al terminar.`);
47
66
  } else if (activeUC.feature && !fileExists(`.quality/evidence/${activeUC.feature}/checkpoint.json`)) {
@@ -1,42 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * context-budget-guard.mjs — PreToolUse hook for subagent launches (v5.32.0, UC-12208).
3
+ * context-budget-guard.mjs — PreToolUse hook for subagent launches (v5.32.0, UC-12208, UC-12210).
4
4
  *
5
- * Estimates tokens for the prompt of a subagent spawned by /implement
6
- * (or any other skill that delegates to a sub-agent) and reports
7
- * a note (default) or BLOCKS (strict mode) when the budget is exceeded.
5
+ * Estimates the tokens of the prompt of a subagent (/implement or any skill that delegates) and,
6
+ * when it exceeds the budget, notes it («warn», the default) or does not launch it («block»).
8
7
  *
9
- * Claude Code launches subagents with the «Agent» tool; older versions called
10
- * it «Task». The hook is registered with the matcher «Agent|Task» and accepts
11
- * both (until UC-12208 it only listened to «Task» and never ran).
8
+ * Claude Code launches subagents with the «Agent» tool; older versions called it «Task». The hook is
9
+ * registered with the matcher «Agent|Task» and accepts both (until UC-12208 it only listened to
10
+ * «Task» and never ran).
12
11
  *
13
- * Behaviour:
14
- * - mode=warn (default) → note to the agent (additionalContext), exit 0
15
- * - mode=strict → stderr BLOCKED, exit 2
16
- * - mode=off → no-op, exit 0
17
- *
18
- * Settings — `task_isolation.task_budget_tokens` (default 16000) and
19
- * `task_isolation.task_budget_mode` (default "warn"), read per key from:
20
- * 1. .claude/settings.local.json → specbox.implement.task_isolation (wins)
21
- * 2. .claude/settings.json → implement.task_isolation (where the
22
- * settings template writes it) or specbox.implement.task_isolation
12
+ * Mode (UC-12210) — the EP-20 measure `context_budget`:
13
+ * 1. `task_isolation.task_budget_mode` in .claude/settings.local.json (specbox.implement…) wins;
14
+ * 2. then in .claude/settings.json (implement…), unless it is the template's «warn», which is not
15
+ * a decision of the project;
16
+ * 3. otherwise the board's policy (lib/enforcement-policy.mjs), «warn» unless a person changed it.
17
+ * Values: off | warn | block (`strict`, the old name, means block).
18
+ * Budget: `task_isolation.task_budget_tokens` (default 16000), read the same way.
23
19
  *
24
20
  * Side-effects:
25
- * Updates .quality/task_isolation.json counters, plus `last_tool_name`
26
- * (the tool name the hook received), for local inspection and external
27
- * consumers (specbox_cloud, ad-hoc scripts).
21
+ * - every launch → one line in .quality/logs/context-budget.jsonl (tokens, budget, mode, outcome);
22
+ * - .quality/task_isolation.json counters and `last_tool_name`;
23
+ * - native: a block, and the next launch of that UC within budget, are recorded on the board
24
+ * (record_enforcement_event), so the impact report counts blocks and corrections (UC-12213);
25
+ * FreeForm: the same in doc/tracking/enforcement_events.jsonl.
28
26
  */
29
27
 
30
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
28
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
31
29
  import { dirname } from 'node:path';
32
30
  import { estimatePromptTokens } from './lib/token-counter.mjs';
33
31
  import { noteWith } from './lib/output.mjs';
32
+ import { getProjectConfig } from './lib/config.mjs';
33
+ import { leerPolitica, modoDe, textoDeMedida } from './lib/enforcement-policy.mjs';
34
+ import { recordCorrectionIfBlocked, recordEnforcementEvent } from './lib/enforcement-events.mjs';
34
35
 
35
36
  const DEFAULT_BUDGET = 16000;
36
- const DEFAULT_MODE = 'warn';
37
- // Local first: a key written in settings.local.json wins over settings.json.
38
- const SETTINGS_FILES = ['.claude/settings.local.json', '.claude/settings.json'];
37
+ const TEMPLATE_MODE = 'warn';
38
+ const MEASURE = 'context_budget';
39
39
  const TASK_ISOLATION_CACHE = '.quality/task_isolation.json';
40
+ const LOG = '.quality/logs/context-budget.jsonl';
40
41
  // The names Claude Code uses to launch a subagent: «Agent» today, «Task» before.
41
42
  const SUBAGENT_TOOLS = new Set(['Agent', 'Task']);
42
43
 
@@ -51,9 +52,13 @@ if (!SUBAGENT_TOOLS.has(toolName)) {
51
52
  process.exit(0);
52
53
  }
53
54
 
54
- // ── Resolve settings ───────────────────────────────────────────────────
55
+ // ── Resolve budget and mode ────────────────────────────────────────────
55
56
 
56
- const { budget, mode } = readSettings();
57
+ const local = taskIsolationOf(readJson('.claude/settings.local.json'));
58
+ const shared = taskIsolationOf(readJson('.claude/settings.json'));
59
+ const budget = [local?.task_budget_tokens, shared?.task_budget_tokens].find((v) => typeof v === 'number') ?? DEFAULT_BUDGET;
60
+ const config = getProjectConfig();
61
+ const { mode, source } = await resolveMode();
57
62
  if (mode === 'off') {
58
63
  process.exit(0);
59
64
  }
@@ -61,10 +66,12 @@ if (mode === 'off') {
61
66
  // ── Estimate ──────────────────────────────────────────────────────────
62
67
 
63
68
  const { total, breakdown } = estimatePromptTokens(payload);
69
+ const activeUc = readJson('.quality/active_uc.json')?.uc_id || '';
64
70
 
65
71
  if (total <= budget) {
66
- // Under budget → bump tasks_run_total counter and pass through.
67
72
  bumpCounter('tasks_run_total');
73
+ log('under');
74
+ await recordCorrectionIfBlocked({ config, measure: MEASURE, ucId: activeUc, by: 'context-budget-guard' });
68
75
  process.exit(0);
69
76
  }
70
77
 
@@ -76,22 +83,29 @@ const breakdownStr = Object.entries(breakdown)
76
83
  .map(([k, v]) => `${k}=${v}`)
77
84
  .join(', ');
78
85
  const overshoot = total - budget;
86
+ const how =
87
+ 'Recorta el encargo, pasa el contexto común a .quality/evidence/{feature}/execution_context.json ' +
88
+ 'o divide el trabajo en varios subagentes.';
79
89
 
80
- if (mode === 'strict') {
90
+ if (mode === 'block') {
91
+ log('blocked');
92
+ await recordEnforcementEvent({ config, measure: MEASURE, ucId: activeUc, outcome: 'blocked', by: 'context-budget-guard' });
81
93
  console.error(
82
- `[context-budget-guard] BLOCKED — the subagent prompt (${toolName}) is ~${total} tokens ` +
83
- `(budget ${budget}, overshoot ${overshoot}). Breakdown: ${breakdownStr}. ` +
84
- `Reduce the prompt body, move shared context to ` +
85
- `.quality/evidence/{feature}/execution_context.json, or split the work ` +
86
- `into several subagents.`
94
+ textoDeMedida({
95
+ medida: MEASURE,
96
+ modo: 'block',
97
+ motivo: `el encargo del subagente (${toolName}) tiene ~${total} tokens y el presupuesto es ${budget} (${overshoot} de más). Reparto: ${breakdownStr}.`,
98
+ comoSeguir: `${how} El subagente no se ha lanzado.`,
99
+ }),
87
100
  );
88
101
  process.exit(2);
89
102
  }
90
103
 
91
104
  // warn: a note to the agent (US-93/UC-9302: stderr with exit 0 reaches nobody).
105
+ log('warned');
92
106
  noteWith('PreToolUse', '[context-budget-guard] El encargo del subagente se pasa de presupuesto', [
93
107
  `~${total} tokens (presupuesto ${budget}, ${overshoot} de más). Reparto: ${breakdownStr}.`,
94
- 'Recórtalo o pasa el contexto común a .quality/evidence/{feature}/execution_context.json. La tarea sigue.',
108
+ `${how} La tarea sigue (medida context_budget en «warn»).`,
95
109
  ]);
96
110
 
97
111
  // ── Helpers ───────────────────────────────────────────────────────────
@@ -104,22 +118,44 @@ function readStdinSync() {
104
118
  }
105
119
  }
106
120
 
121
+ function readJson(path) {
122
+ try {
123
+ return existsSync(path) ? JSON.parse(readFileSync(path, 'utf-8')) : null;
124
+ } catch {
125
+ return null;
126
+ }
127
+ }
128
+
107
129
  function taskIsolationOf(settings) {
108
130
  return settings?.specbox?.implement?.task_isolation ?? settings?.implement?.task_isolation ?? null;
109
131
  }
110
132
 
111
- function readSettings() {
112
- let budget;
113
- let mode;
114
- for (const file of SETTINGS_FILES) {
115
- if (!existsSync(file)) continue;
116
- try {
117
- const ti = taskIsolationOf(JSON.parse(readFileSync(file, 'utf-8')));
118
- if (budget === undefined && typeof ti?.task_budget_tokens === 'number') budget = ti.task_budget_tokens;
119
- if (mode === undefined && typeof ti?.task_budget_mode === 'string') mode = ti.task_budget_mode;
120
- } catch { /* ignore an unreadable file */ }
121
- }
122
- return { budget: budget ?? DEFAULT_BUDGET, mode: mode ?? DEFAULT_MODE };
133
+ function normal(m) {
134
+ return m === 'strict' ? 'block' : ['off', 'warn', 'block'].includes(m) ? m : null;
135
+ }
136
+
137
+ /** The mode and where it comes from: local setting, the project's setting, or the board's policy. */
138
+ async function resolveMode() {
139
+ const fromLocal = normal(local?.task_budget_mode);
140
+ if (fromLocal) return { mode: fromLocal, source: 'settings.local.json' };
141
+ const fromShared = normal(shared?.task_budget_mode);
142
+ if (fromShared && fromShared !== TEMPLATE_MODE) return { mode: fromShared, source: 'settings.json' };
143
+ const politica = await leerPolitica({
144
+ root: process.cwd(),
145
+ backendType: config.backendType,
146
+ boardId: config.boardId,
147
+ trackingDir: config.freeformRoot,
148
+ });
149
+ return { mode: modoDe(politica, MEASURE), source: `política (${politica.fuente})` };
150
+ }
151
+
152
+ function log(outcome) {
153
+ try {
154
+ mkdirSync(dirname(LOG), { recursive: true });
155
+ const line = { at: new Date().toISOString(), tool: toolName, tokens: total, budget, mode, source, outcome };
156
+ if (activeUc) line.uc_id = activeUc;
157
+ appendFileSync(LOG, `${JSON.stringify(line)}\n`);
158
+ } catch { /* best-effort */ }
123
159
  }
124
160
 
125
161
  function bumpCounter(key) {
@@ -186,14 +186,12 @@ function pre() {
186
186
  );
187
187
  return result;
188
188
  });
189
- process.stdout.write(
190
- JSON.stringify({
191
- hookSpecificOutput: {
192
- hookEventName: 'PreToolUse',
193
- updatedInput: { ...toolInput, items_content: built.itemsContent },
194
- },
195
- }),
196
- );
189
+ const updatedInput = { ...toolInput, items_content: built.itemsContent };
190
+ // UC-12211: start_uc marks the UCs that predate a rule; it needs the board's policy.
191
+ if (parsed.tool === 'start_uc' && typeof toolInput.policy_content !== 'string' && existsSync(policyPath)) {
192
+ updatedInput.policy_content = readFileSync(policyPath, 'utf-8');
193
+ }
194
+ process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput } }));
197
195
  }
198
196
 
199
197
  function post() {
@@ -12,12 +12,14 @@
12
12
  ],
13
13
  "commit-spec-guard.mjs": [
14
14
  "0437bacef5d022512c37d3636bc4a9112b6bb0b13421ba35b3bb77a6eb82d900",
15
- "b8d79538f6627cb19a224399770a439b4e11cd70ee5c61673dfd6ed59a939395"
15
+ "b8d79538f6627cb19a224399770a439b4e11cd70ee5c61673dfd6ed59a939395",
16
+ "08564e245b86f0e2db189da296db5c54add735bef6930591069cb7699be118c0"
16
17
  ],
17
18
  "context-budget-guard.mjs": [
18
19
  "9714985624215ca43f78536b47254dde8f49bb56396a8c4c40740c5fb36a69dd",
19
20
  "a25ec6ccd8c290a8b7e2d2f7c282a57ba5a16aebbe0ce19b3981da3cba803479",
20
- "9f6f489967ca0093266decdee0880dd1bf08eff8b8fb89d51ffc1d7b8f50cde3"
21
+ "9f6f489967ca0093266decdee0880dd1bf08eff8b8fb89d51ffc1d7b8f50cde3",
22
+ "fa058d626a550d0bc5c72a09ecdc5f38bd213cf46a6f6514492f6defaa5e9ba8"
21
23
  ],
22
24
  "design-gate.mjs": [
23
25
  "82958af64ecbdba19dda1de39c5ebdf7cef5a4489a2269d503628297403af4f7",
@@ -57,7 +59,8 @@
57
59
  "317eabaed8dead40f3d55e642b7465a3ba4e884523e0ae7b933e197153fc6f95"
58
60
  ],
59
61
  "lib/config.mjs": [
60
- "bef622d06108aa64ec3c2d0edd1b1c82ad442476a1257b271c81838813ff1d57"
62
+ "bef622d06108aa64ec3c2d0edd1b1c82ad442476a1257b271c81838813ff1d57",
63
+ "a4458d02037cbba952a8f2240549859195788307c95b434e6fd9faa1a1591b85"
61
64
  ],
62
65
  "lib/design-gaps.mjs": [
63
66
  "d356d695d7afbafdc6fc420ed66603f11aa523be245bbd7a717d141a4a00701e"
@@ -140,7 +143,8 @@
140
143
  "spec-guard.mjs": [
141
144
  "8dccc74b4cf1986497c1db3b32ec52a5a842267e1ce3372b3d6fc10ba0c402e8",
142
145
  "3a0d19ecaf523d5bd220f1ba88902e43e56caa700f115a9d8b276e48b576a5da",
143
- "3524703693ef53fa3f4f9282b7bfc857ff89ce60212724526b1ed4a1fcd12563"
146
+ "3524703693ef53fa3f4f9282b7bfc857ff89ce60212724526b1ed4a1fcd12563",
147
+ "202257a18636597e7a9d1860d8ae160d7e51f9e8b5ccd539c3a5f49543bdbab7"
144
148
  ],
145
149
  "stripe-safety-guard.mjs": [
146
150
  "fd38c72e91c0e74ecb7dc8ccc0fa9a5f9aaa1ceeac583d13f342503f098f718a",
@@ -149,7 +153,8 @@
149
153
  "uc-lifecycle-guard.mjs": [
150
154
  "e5c31e58db639bd304faf244fd3c4ccecfc854beba2182ae6d940f52afc28808",
151
155
  "beca70f275b1974d6609ae47f9acdbc0842d3c21e01fe9852d3a7e536f501103",
152
- "2bedf19d5e36d13dff6d8cd95855ca2b5a7f47d662cc3a554c3e2f80ede199fd"
156
+ "2bedf19d5e36d13dff6d8cd95855ca2b5a7f47d662cc3a554c3e2f80ede199fd",
157
+ "606c4397200ffbc3b2c89c9af68c340692e6d48f6c792da1d6531b5215fb16e9"
153
158
  ],
154
159
  "design-review-gate.mjs": [
155
160
  "b2cc1ba81578102fdab4e559f8f4e8a0c37be41df75ef7ef4f531d766c1362d0"
@@ -171,7 +176,8 @@
171
176
  ],
172
177
  "freeform-fragment.mjs": [
173
178
  "fcb1fc9a1494c1c63870bdec08368bf3c815b1372e220a6311535b0431c86061",
174
- "c8c507e2bd1bfa11f681a70b0f236bbc0d23447140ee4424a25533669beb17b4"
179
+ "c8c507e2bd1bfa11f681a70b0f236bbc0d23447140ee4424a25533669beb17b4",
180
+ "c212b004d384feba728e0ee7e955bfb09fafe39112cad7c530620a1e932d169a"
175
181
  ],
176
182
  "lib/freeform-fragment.mjs": [
177
183
  "d30a15b495cf18cad571e8582b4ce943a75aa4ad8efc5fa11e22420b505dad12",
@@ -182,6 +188,32 @@
182
188
  "b05b7d9fe747524c7157c8c67979951affa234d771d3bdd038c9b58cc315f174"
183
189
  ],
184
190
  "lib/enforcement-policy.mjs": [
185
- "3fe25cc63c99d8afbc4dac8a34e142c44bd2d594efa89979993a97b8f48fe688"
191
+ "3fe25cc63c99d8afbc4dac8a34e142c44bd2d594efa89979993a97b8f48fe688",
192
+ "eed32e2ed08206d6ed22e47a0f61fb9230198376b03fab0be7fe3f54b0c2478a"
193
+ ],
194
+ "app-docs-fragment.mjs": [
195
+ "65b82476af664547e732ed0966b07f0126a1b85dbb7f71bfef29b7c04d1115c8",
196
+ "4efae124b02c12f87513e48ca6d4f2e96065c05ca6d8c74352592a8edb21695a"
197
+ ],
198
+ "lib/reservation-probe.mjs": [
199
+ "44566d2a92eb145a4a7252cfca8081e2101dc101bbc13faa77da8fa35b06dff0"
200
+ ],
201
+ "lib/roadmap.mjs": [
202
+ "0ff30f9d5707c89b8b43406e76f4870a39dd4f787221c32310ef6f9040879d8a"
203
+ ],
204
+ "lib/uc-state.mjs": [
205
+ "699786c91e83ad5b35b42f0ef812728e951be28a12ae0c037d1790795adc9e90"
206
+ ],
207
+ "uc-state-marker.mjs": [
208
+ "7c649407416f3837196c9cf8a0caf44b8aeead7e2da9eda55ee5526972630cb2"
209
+ ],
210
+ "lib/enforcement-events.mjs": [
211
+ "5fe963aab5f24c2b50c9991f11dbda48440a98f7394e02c823a276ee1bb2d608"
212
+ ],
213
+ "lib/prd-locate.mjs": [
214
+ "e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa"
215
+ ],
216
+ "prd-sync-guard.mjs": [
217
+ "0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8"
186
218
  ]
187
219
  }
@@ -1,17 +1,18 @@
1
1
  {
2
- "version": "6.36.0",
2
+ "version": "6.38.0",
3
3
  "files": {
4
+ "app-docs-fragment.mjs": "4efae124b02c12f87513e48ca6d4f2e96065c05ca6d8c74352592a8edb21695a",
4
5
  "app-docs-sync-guard.mjs": "71f09545b57c143b013c2e532366bfdd1e1a2ae49c7644c9e12e2ab5324d03d3",
5
6
  "branch-guard.mjs": "2185062de5f8672236a957a1ee4e7a6057c656a105bf886685f9e7bf8025c215",
6
7
  "checkpoint-freshness-guard.mjs": "b8b6f438b6943568682776177bdac6b778df4c464e3317eb2385ed2b1b6afa96",
7
- "commit-spec-guard.mjs": "b8d79538f6627cb19a224399770a439b4e11cd70ee5c61673dfd6ed59a939395",
8
- "context-budget-guard.mjs": "9f6f489967ca0093266decdee0880dd1bf08eff8b8fb89d51ffc1d7b8f50cde3",
8
+ "commit-spec-guard.mjs": "08564e245b86f0e2db189da296db5c54add735bef6930591069cb7699be118c0",
9
+ "context-budget-guard.mjs": "fa058d626a550d0bc5c72a09ecdc5f38bd213cf46a6f6514492f6defaa5e9ba8",
9
10
  "design-gate.mjs": "fef11c431c2f70218a3eca97c255c10585de0dbcfef1d4ec26fad0d4702a8dbb",
10
11
  "design-review-gate.mjs": "b2cc1ba81578102fdab4e559f8f4e8a0c37be41df75ef7ef4f531d766c1362d0",
11
12
  "design-system-gate.mjs": "419018cadb3e0a4fe0def1c423fed7013b76b2f121312acadbc99fc8e30b8ff5",
12
13
  "e2e-gate.mjs": "02e239816cb429f76034088a5370f63a08facce01b4ffd52b338a66acf13028d",
13
14
  "file-ownership-guard.mjs": "d8a84370766966cce70b76811de9dd150d170a79c4cb7b9e6b120cfad86a6932",
14
- "freeform-fragment.mjs": "c8c507e2bd1bfa11f681a70b0f236bbc0d23447140ee4424a25533669beb17b4",
15
+ "freeform-fragment.mjs": "c212b004d384feba728e0ee7e955bfb09fafe39112cad7c530620a1e932d169a",
15
16
  "freeform-path-guard.mjs": "9ded19e96b0738de5aaf43a97eaa1d88ecd3b341efd432c0b32eb312c4bf5e0a",
16
17
  "healing-budget-guard.mjs": "c49c6c34f99545e4009ad88ed9f7eef737e35ce39c11a05d41ad8f976ffae09f",
17
18
  "implement-checkpoint.mjs": "f3f219779a1ac4108bc3aabcc7311e9135d9c7795c126a2b5d659e743f5a5a64",
@@ -20,6 +21,7 @@
20
21
  "on-session-end.mjs": "fd5b7cf3bf2c419fd4125e21b338c4c849a4daaef21d5e15253caed54965b40c",
21
22
  "pipeline-phase-guard.mjs": "761b82c8b0c4884eba54d529e1f726d547003a6efe05425b45a1a0b77b90fe0d",
22
23
  "post-implement-validate.mjs": "25e5ea280c945f707ca8476555fca7a44c93aec1018eef06702c908a071df0cd",
24
+ "prd-sync-guard.mjs": "0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8",
23
25
  "pre-commit-lint.mjs": "348adbbfd29e52ebc6512a46b19f5e3c8bde4ae2139c013b96659fdc66456eab",
24
26
  "pre-prd-discovery-check.mjs": "2eda49648e31dd8720f70b3dcfca2782df9e950b6628ce0db8948c448253c2be",
25
27
  "pre-read-budget-guard.mjs": "76aeb98026f7fde19bb4d57749ff59b08cdfff0ba6f7188cafc28762773bed34",
@@ -27,15 +29,17 @@
27
29
  "read-tracker.mjs": "5a22248f9d39dcc5c71abb6e2c49b8d7be3860f399023ad59f3c50e92917c298",
28
30
  "session-heartbeat.mjs": "6aece1e95c2ef4dcb7e0f7699f5d1e75537857b863b34be108ed0fe67112781a",
29
31
  "session-start.mjs": "0f49298cec92141c9aa1748784080d0fd630643ab5827ae4313dab3036eee78c",
30
- "spec-guard.mjs": "3524703693ef53fa3f4f9282b7bfc857ff89ce60212724526b1ed4a1fcd12563",
32
+ "spec-guard.mjs": "202257a18636597e7a9d1860d8ae160d7e51f9e8b5ccd539c3a5f49543bdbab7",
31
33
  "stripe-safety-guard.mjs": "5d7c0a9524657fe47e6ec4ea0eeb055d238f133eeac488c145cb1d5ae88b96de",
32
- "uc-lifecycle-guard.mjs": "2bedf19d5e36d13dff6d8cd95855ca2b5a7f47d662cc3a554c3e2f80ede199fd",
34
+ "uc-lifecycle-guard.mjs": "606c4397200ffbc3b2c89c9af68c340692e6d48f6c792da1d6531b5215fb16e9",
35
+ "uc-state-marker.mjs": "7c649407416f3837196c9cf8a0caf44b8aeead7e2da9eda55ee5526972630cb2",
33
36
  "lib/app-spec-zones.mjs": "b05b7d9fe747524c7157c8c67979951affa234d771d3bdd038c9b58cc315f174",
34
37
  "lib/autopilot.mjs": "317eabaed8dead40f3d55e642b7465a3ba4e884523e0ae7b933e197153fc6f95",
35
- "lib/config.mjs": "bef622d06108aa64ec3c2d0edd1b1c82ad442476a1257b271c81838813ff1d57",
38
+ "lib/config.mjs": "a4458d02037cbba952a8f2240549859195788307c95b434e6fd9faa1a1591b85",
36
39
  "lib/decisiones.mjs": "6bed3bd37320b6d87f4c77fcac27ed55a6b37776d84a0d4eb2d9cab0c474a520",
37
40
  "lib/design-gaps.mjs": "d356d695d7afbafdc6fc420ed66603f11aa523be245bbd7a717d141a4a00701e",
38
- "lib/enforcement-policy.mjs": "3fe25cc63c99d8afbc4dac8a34e142c44bd2d594efa89979993a97b8f48fe688",
41
+ "lib/enforcement-events.mjs": "5fe963aab5f24c2b50c9991f11dbda48440a98f7394e02c823a276ee1bb2d608",
42
+ "lib/enforcement-policy.mjs": "eed32e2ed08206d6ed22e47a0f61fb9230198376b03fab0be7fe3f54b0c2478a",
39
43
  "lib/execution-context.mjs": "953eb7ec86f6893288df4e76c9c63c737c8e8ba4e337271402ce5eaca00330fa",
40
44
  "lib/freeform-fragment.mjs": "23be71af8423bf8fa48dc8519734ff2bef084523a33ece555e4f96bb52bc3141",
41
45
  "lib/freeform-path.mjs": "9ea85781821ae911873d1dbd13d58811a6c88e50480d2b3b378725ce2872be0c",
@@ -47,7 +51,11 @@
47
51
  "lib/native-reservation-revalidate.mjs": "1b394e8eb5d01480b71ac0976d636814483891e9f862edd5ac0216ac0128b023",
48
52
  "lib/output.mjs": "a568c736917720349b2b2527eb5b480bb11059a9253f81473f5b5c2c164b04bc",
49
53
  "lib/ownership-map.mjs": "21946608331a39e8c76eb2ba3860b5ebb351aa154f31801e768703bc4ae66b9a",
54
+ "lib/prd-locate.mjs": "e8456176706e8d70a64f75c5209873881d8f50ac2f8a993ea013b8a5b44cc7aa",
55
+ "lib/reservation-probe.mjs": "44566d2a92eb145a4a7252cfca8081e2101dc101bbc13faa77da8fa35b06dff0",
56
+ "lib/roadmap.mjs": "0ff30f9d5707c89b8b43406e76f4870a39dd4f787221c32310ef6f9040879d8a",
50
57
  "lib/token-counter.mjs": "ca637273dcf731c7a951f28b8307d13de06d311cf85741ef56c4e3df9eaa231e",
58
+ "lib/uc-state.mjs": "699786c91e83ad5b35b42f0ef812728e951be28a12ae0c037d1790795adc9e90",
51
59
  "lib/utils.mjs": "4c21939aac114a11a68e2519d5d99f7f0bf482f08af0dc9e51ac715cc93ddfa2"
52
60
  }
53
61
  }
@@ -7,17 +7,26 @@ import { readJsonFile, fileAge } from './utils.mjs';
7
7
 
8
8
  /**
9
9
  * Read project configuration from .claude/project-config.json and .claude/settings.local.json.
10
- * Returns { boardId, backendType, orchestratorRoot, isSpecDriven }.
10
+ * Returns { boardId, backendType, orchestratorRoot, isSpecDriven, recognizedBy, freeformRoot }.
11
11
  *
12
12
  * Multi-repo support (v5.20):
13
13
  * If the project declares multirepo.role = "satellite" with an orchestrator path,
14
14
  * orchestratorRoot resolves to that path. Otherwise defaults to '.' (current repo).
15
15
  * Hooks that need cross-repo paths (design-gate, e2e-gate) use orchestratorRoot.
16
+ *
17
+ * UC-12215: `onboard_project` and the VS Code extension write the backend inside the `specbox`
18
+ * block of settings.local.json (`specbox.backend_type`), which the hooks did not read: those
19
+ * projects were not spec-driven for spec-guard, commit-spec-guard and uc-lifecycle-guard.
20
+ * `recognizedBy` says how the project was recognized: 'legacy' (first-level keys, as always) or
21
+ * 'specbox' (only the `specbox` block). A hook that blocks uses it so that a project recognized for
22
+ * the first time starts in «warn» (the EP-20 coexistence rule, UC-12212), not blocked.
16
23
  */
17
24
  export function getProjectConfig() {
18
25
  let boardId = '';
19
26
  let backendType = '';
20
27
  let orchestratorRoot = '.';
28
+ let recognizedBy = '';
29
+ let freeformRoot = '';
21
30
 
22
31
  for (const configFile of ['.claude/project-config.json', '.claude/settings.local.json']) {
23
32
  const config = readJsonFile(configFile);
@@ -36,12 +45,26 @@ export function getProjectConfig() {
36
45
  orchestratorRoot = mr.orchestrator;
37
46
  }
38
47
  }
48
+ if (boardId || backendType) recognizedBy = 'legacy';
49
+
50
+ // UC-12215: the `specbox` block of settings.local.json (what onboard_project writes).
51
+ const specbox = readJsonFile('.claude/settings.local.json')?.specbox;
52
+ if (specbox && typeof specbox === 'object') {
53
+ if (!backendType && typeof specbox.backend_type === 'string') backendType = specbox.backend_type;
54
+ if (!boardId) {
55
+ boardId = specbox.board_id || specbox.trello_board_id || specbox.project_id || specbox.native_project_id || '';
56
+ }
57
+ if (typeof specbox.freeform_root_absolute === 'string') freeformRoot = specbox.freeform_root_absolute;
58
+ if (!recognizedBy && (boardId || backendType)) recognizedBy = 'specbox';
59
+ }
39
60
 
40
61
  return {
41
62
  boardId,
42
63
  backendType,
43
64
  orchestratorRoot,
44
65
  isSpecDriven: !!(boardId || backendType),
66
+ recognizedBy,
67
+ freeformRoot,
45
68
  };
46
69
  }
47
70