@ancleto/spec 0.6.33 → 0.6.34

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/README.md CHANGED
@@ -200,6 +200,28 @@ ancleto init --lang es # fija español para ese proyecto
200
200
 
201
201
  Con `auto`, el orquestador detecta el idioma en tus primeros hasta 3 mensajes y lo persiste en `.ancletorc` → `language`. Podés volver a `auto` o fijar otro código cuando quieras (`auto | es | en | pt`). Lo que **nunca** se traduce: los keywords (`Requirement`, `Scenario`, `SHALL`, `WHEN`/`THEN`/`AND`) y los nombres de archivos y directorios.
202
202
 
203
+ ### Exclusiones del discovery
204
+
205
+ En la instalación interactiva elegís qué excluir del seed técnico con un menú (tests, assets pesados, docs, migraciones/seeds, lockfiles). Excluir reduce el tamaño del pack y estabiliza la detección de cambios:
206
+
207
+ ```bash
208
+ ancleto init --exclude "**/*.test.*,**/*.png,docs" # sin menú, directo
209
+ ```
210
+
211
+ Se guarda en `.ancletorc` → `discovery.exclude` y se preserva en `update`/`upgrade`.
212
+
213
+ ### Frescura del seed (impact)
214
+
215
+ `ancleto discovery --check` no solo dice si el seed está `STALE`: dice **qué tan grave** es el cambio con `impact`:
216
+
217
+ | `impact` | Significado | Qué pasa |
218
+ |---|---|---|
219
+ | `none` | Sin cambios | El agente trabaja normal |
220
+ | `minor` | Cambios fuera de áreas materiales (un componente, un estilo) | El agente trabaja y lo anota en el resumen; **no ofrece regenerar** |
221
+ | `material` | Cambió un config de runtime, un entry point o apareció un directorio raíz nuevo | El agente **ofrece regenerar** (solo con tu aprobación) |
222
+
223
+ La excepción: si el agente detecta un **hueco concreto** (info que el seed debería tener y no tiene, como una paleta nueva sin unidad), puede ofrecer regenerar aunque el `impact` sea `minor` — siempre con tu aprobación. Nunca regenera solo.
224
+
203
225
  ---
204
226
 
205
227
  ## Uso rápido
@@ -237,10 +259,10 @@ ancleto discovery # Genera .discovery-map.json y empaqueta el repo
237
259
  ## Referencia de comandos CLI
238
260
 
239
261
  ```bash
240
- ancleto init [--agent <nombre>] [--tier <nivel>] [--lang <codigo>] [--with-azure]
262
+ ancleto init [--agent <nombre>] [--tier <nivel>] [--lang <codigo>] [--exclude <globs>] [--with-azure]
241
263
  # Configura el proyecto (interactivo en TTY)
242
264
 
243
- ancleto install [--project <dir>] [--tier <nivel>] [--agent <nombre>] [--lang <codigo>] [--no-mcp]
265
+ ancleto install [--project <dir>] [--tier <nivel>] [--agent <nombre>] [--lang <codigo>] [--exclude <globs>] [--no-mcp]
244
266
  # Instala agentes, skills y templates
245
267
 
246
268
  ancleto update # Re-instala la última versión sobre lo existente
@@ -65,12 +65,13 @@ The orchestrator never executes `ancleto discovery --check`. When the technical
65
65
  | --------- | ------------------------------------------------------------------------------------------------------------------------- |
66
66
  | `READY` | use the focused answer returned by `@technical-discovery` |
67
67
  | `PARTIAL` | explain which required documents are unavailable and offer to complete them |
68
- | `STALE` | use the answer with its freshness warning and offer regeneration only when stale context could materially affect the work |
68
+ | `STALE` (minor) | use the answer with a one-line freshness note; do not offer regeneration — the seed is still usable |
69
+ | `STALE` (material) | warn and offer regeneration only when a concrete gap (info the seed should have but lacks) or the changed area affects the work |
69
70
  | `MISSING` | explain that broad repository context is unavailable and offer to generate the seed |
70
71
 
71
72
  For `MISSING` and `PARTIAL`, never generate automatically. Ask for explicit user approval before invoking `@technical-seed-writer`. If approved, pass the complete check report returned by `@technical-discovery` and the action `generate` or `complete`. If declined, continue only when the request can be handled safely without broad repository context; otherwise report the limitation and stop.
72
73
 
73
- For `STALE`, delegate `regenerate` to `@technical-seed-writer` only after explicit user approval.
74
+ For `STALE`, delegate `regenerate` to `@technical-seed-writer` only after explicit user approval. When `impact` is `minor`, keep working from the seed and mention the drift in the summary. A concrete gap found while working — needed info the seed does not cover — may justify offering regeneration even with `minor` impact, always with approval.
74
75
 
75
76
  `@technical-discovery` owns read-only repository orientation and seed-state inspection. `@technical-seed-writer` owns all seed generation, completion, and regeneration. Never substitute an unavailable seed with a manual repository scan.
76
77
 
@@ -269,7 +270,7 @@ If the runtime is read-only or plan-only:
269
270
  5. **Testing**: Delegate to **`@tester`** to create or update unit tests and perform final validation against the approved scope, including a non-writing format check and one lint pass after all edits. Include the complete Resolved Context Envelope, the coder's task-owned files, and its reported risks. `@tester` returns the final union of task-owned files and the Validation Ledger. A format failure in a task-owned file is failed verification and must not be fixed silently by `@tester`.
270
271
  6. **Review**: Delegate to **`@reviewer`** when an independent correctness or scope review is appropriate. Include the complete Resolved Context Envelope, the tester's final task-owned file union, and the full Validation Ledger.
271
272
  7. **🛑 FINAL ARCHIVE CHECKPOINT**: If implementation, validation, and any required review are complete with no blocking issues, stop and explicitly ask the user whether to keep iterating on the same change or finalize and archive it
272
- 8. **Finalization / Archive**: Before archiving, verify the delta specs reflect the final implementation — if iteration changed behavior or scope, re-delegate to **`@spec-writer`** to update the delta specs first, so the merge to source-of-truth is accurate. Check the seed freshness before closing: delegate the read-only state check to **`@technical-discovery`** and, when the state is `STALE`, warn and offer regeneration via **`@technical-seed-writer`** with explicit user approval — never automatic; if the user declines, continue the archive normally. This closure check protects future sessions from a silently aging seed. Then delegate to **`@documenter`** only after explicit user approval to archive
273
+ 8. **Finalization / Archive**: Before archiving, verify the delta specs reflect the final implementation — if iteration changed behavior or scope, re-delegate to **`@spec-writer`** to update the delta specs first, so the merge to source-of-truth is accurate. Check the seed freshness before closing: delegate the read-only state check to **`@technical-discovery`** and, when the state is `STALE` with `impact: material`, warn and offer regeneration via **`@technical-seed-writer`** with explicit user approval — never automatic; with `impact: minor`, continue the archive normally and note the drift in the summary. This closure check protects future sessions from a silently aging seed. Then delegate to **`@documenter`** only after explicit user approval to archive
273
274
  9. **Memory Record**: After a successful archive, delegate to **`@memory-keeper`** in Automatic Record mode when a concrete, plausible candidate exists, with the factual completed-work summary and validation evidence supporting it. If no candidate exists, delegate Optional Draft with the factual completed-work summary, `no-automatic-candidate` classification, and the reason no candidate was identified. When Automatic Record returns `no-entry-warranted`, use its draft or delegate Optional Draft with that classification and reason if it could not provide one. Before asking, show the final work summary, classification, reason, and exact draft, then stop for explicit user approval. If no safe draft is available, report that outcome and finish without asking or storing. On approval, delegate User-Approved Record with the unchanged draft, the factual summary and validation evidence used to compose it, archived change name, and card context. On rejection, do not store.
274
275
  10. **Report**: Return final status or blocking findings to the user after automatic storage, an explicit decline, or User-Approved Record completes.
275
276
 
@@ -76,7 +76,8 @@ Inspect seed state only when `docs/technical-discovery/` is the selected source.
76
76
  | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
77
  | `READY` | answer from the seed |
78
78
  | `PARTIAL` | use an available document only when it safely answers the focused question; otherwise report the missing documents and request completion |
79
- | `STALE` | answer with an explicit freshness warning when the evidence is sufficient; request regeneration only when stale evidence could materially affect the answer |
79
+ | `STALE` with `impact: minor` | answer noting the freshness drift; do not request regeneration — the seed is still usable |
80
+ | `STALE` with `impact: material` | answer with an explicit freshness warning when the evidence is sufficient; request regeneration only when stale evidence could materially affect the answer |
80
81
  | `MISSING` | report that broad repository context is unavailable and request generation |
81
82
 
82
83
  You **report** states and recommend actions. You never resolve them: generating or regenerating
@@ -117,7 +118,7 @@ Any request to create, modify, or implement — including writing aspec artifact
117
118
  | Situation | Action |
118
119
  | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
119
120
  | request to create / modify / implement | return the context and escalate the request to the `@orchestrator` |
120
- | seed missing, partial, or stale | report the state and emit the corresponding `SEED_ACTION_REQUIRED` marker for `@orchestrator` to delegate `@technical-seed-writer` |
121
+ | seed missing, partial, or stale with material impact | report the state and emit the corresponding `SEED_ACTION_REQUIRED` marker for `@orchestrator` to delegate `@technical-seed-writer` |
121
122
 
122
123
  When you were delegated, do not address the developer as if they had called you: your output is context for the calling agent.
123
124
 
@@ -126,7 +127,7 @@ When you were delegated, do not address the developer as if they had called you:
126
127
  - **Answer in Spanish.** Paths, file names, and identifiers stay as they are.
127
128
  - Cite the paths that support each claim.
128
129
  - State which source you used and whether seed inspection was required.
129
- - When seed inspection was required, return the resolved state and the complete unchanged check report if a seed action is needed.
130
+ - When seed inspection was required, return the resolved state with its `impact`, and the complete unchanged check report if a seed action is needed.
130
131
  - Declare — when they apply — the stale nodes, any direct code read, and any gap left by the budget.
131
132
  - If the seed state prevented the answer, state that no repository sweep was performed and
132
133
  include the required `SEED_ACTION_REQUIRED` marker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancleto/spec",
3
- "version": "0.6.33",
3
+ "version": "0.6.34",
4
4
  "description": "Orquestador SDD liviano con subagentes optimizados para costo/tokens",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,9 +46,10 @@ Check for delta specs at `aspec/changes/<name>/specs/`; if none, proceed without
46
46
 
47
47
  ### 3. Check technical seed freshness
48
48
 
49
- If the `ancleto` CLI is available in this project, run `ancleto discovery --check` (read-only) and read its JSON `state`.
49
+ If the `ancleto` CLI is available in this project, run `ancleto discovery --check` (read-only) and read its JSON `state` and `impact`.
50
50
 
51
- - **`STALE`**: warn that the technical seed is out of date for the current code, and offer to regenerate it now (follow the `ancleto-technical-discovery` skill) or to continue archiving with the stale seed.
51
+ - **`STALE` with `impact: material`**: warn that the technical seed is out of date in material areas, and offer to regenerate it now (follow the `ancleto-technical-discovery` skill) or to continue archiving with the stale seed.
52
+ - **`STALE` with `impact: minor`**: continue without offering — the seed is still usable; record the drift in the summary.
52
53
  - **Any other state**: continue without comment.
53
54
  - Never regenerate automatically — regenerate only with the user's explicit approval.
54
55
  - If the user declines, continue the archive normally and record the stale seed in the summary.
@@ -41,7 +41,8 @@ further or create one subagent per unit: generation happens in one sequential ex
41
41
  | --- | --- |
42
42
  | `READY` | Read `index.md` and at most two documents it routes to. |
43
43
  | `PARTIAL` | Complete only the missing documents. |
44
- | `STALE` | Regenerate only the affected focused dossier; update a transversal decision when it changed. |
44
+ | `STALE` with `impact: minor` | Answer from the seed and note the freshness drift; do not regenerate or run another pack for it. |
45
+ | `STALE` with `impact: material` | Regenerate only the affected focused dossier; update a transversal decision when it changed. |
45
46
  | `MISSING` | Generate the concise seed. |
46
47
 
47
48
  Never replace a missing seed with a manual repository sweep.
package/src/cli/index.js CHANGED
@@ -33,12 +33,13 @@ Uso:
33
33
  ancleto install --with-engram Ademas configura el MCP externo engram (memoria opcional)
34
34
  ancleto install --tier <nivel> normal | minimo | gratis (wizard interactivo en TTY)
35
35
  ancleto install --lang <codigo> auto | es | en | pt (idioma de los artifacts; auto = idioma de la conversacion)
36
+ ancleto install --exclude <globs> Paths excluidos del discovery, coma-separados (ej: "**/*.png,docs")
36
37
  ancleto install --agent <nombre> opencode | vscode | antigravity | cursor | roo (wizard si no esta guardado)
37
38
  ancleto update [--project <dir>] Alias de install (re-instala sobre lo existente)
38
39
  Parado en un proyecto con .ancletorc opera sobre ese proyecto;
39
40
  usa --global para forzar el alcance global
40
41
  ancleto upgrade [--agent <nombre>] Re-aplica templates (LOCKED) y skills sobre el proyecto actual
41
- ancleto init [--with-azure] [--agent <nombre>] [--tier <nivel>] [--lang <codigo>]
42
+ ancleto init [--with-azure] [--agent <nombre>] [--tier <nivel>] [--lang <codigo>] [--exclude <globs>]
42
43
  Crea .ancletorc en el repositorio actual
43
44
  (interactivo en TTY: banner + menu; Azure desactivado por defecto)
44
45
  ancleto discovery --check Estado del seed (READY/STALE/PARTIAL/MISSING)
@@ -639,6 +640,47 @@ function langLabel(code) {
639
640
  return { auto: 'automatico (idioma de la conversacion)', es: 'espanol', en: 'ingles', pt: 'portugues' }[code] || code
640
641
  }
641
642
 
643
+ const EXCLUDE_PRESETS = [
644
+ { key: 'tests', label: 'tests (*.test.*, *.spec.*, __tests__)', recommended: true, globs: ['**/*.test.*', '**/*.spec.*', '**/__tests__/**'] },
645
+ { key: 'assets', label: 'assets pesados (*.png, *.jpg, *.svg, *.ico, public/)', recommended: true, globs: ['**/*.png', '**/*.jpg', '**/*.svg', '**/*.ico', 'public'] },
646
+ { key: 'docs', label: 'documentacion (docs/)', recommended: false, globs: ['docs'] },
647
+ { key: 'data', label: 'migraciones y seeds', recommended: false, globs: ['**/migrations/**', '**/seeds/**'] },
648
+ { key: 'lockfiles', label: 'lockfiles (package-lock, yarn.lock, pnpm-lock)', recommended: true, globs: ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml'] }
649
+ ]
650
+
651
+ function parseExcludeFlag(value) {
652
+ return String(value)
653
+ .split(',')
654
+ .map((s) => s.trim())
655
+ .filter(Boolean)
656
+ }
657
+
658
+ // null = flag ausente; [] = limpiar exclusiones; [...] = globs.
659
+ function scanExcludeFlag(args) {
660
+ const i = args.indexOf('--exclude')
661
+ if (i < 0) return null
662
+ const next = args[i + 1]
663
+ if (!next || next.startsWith('--')) return []
664
+ return parseExcludeFlag(next)
665
+ }
666
+
667
+ // Une los grupos elegidos con los globs propios del proyecto (los que no son de un preset).
668
+ function applyExcludePresets(existing, keys) {
669
+ const presetGlobs = new Set(EXCLUDE_PRESETS.flatMap((p) => p.globs))
670
+ const custom = (existing || []).filter((g) => !presetGlobs.has(g))
671
+ const chosen = EXCLUDE_PRESETS.filter((p) => keys.includes(p.key)).flatMap((p) => p.globs)
672
+ return [...custom, ...chosen]
673
+ }
674
+
675
+ async function askExcludePresets(existing) {
676
+ const presetGlobs = new Set(EXCLUDE_PRESETS.flatMap((p) => p.globs))
677
+ const hasPreset = (existing || []).some((g) => presetGlobs.has(g))
678
+ const preselected = EXCLUDE_PRESETS.map((p, i) => (hasPreset ? (p.globs.some((g) => (existing || []).includes(g)) ? i : -1) : p.recommended ? i : -1)).filter((i) => i >= 0)
679
+ const { cancelled, indices } = await selectMultiple('Que excluir del discovery (ademas de node_modules, dist, build)', EXCLUDE_PRESETS.map((p) => p.label), preselected)
680
+ if (cancelled) return existing || []
681
+ return applyExcludePresets(existing, indices.map((i) => EXCLUDE_PRESETS[i].key))
682
+ }
683
+
642
684
  async function resolveAgent(args, existing, allowAsk = Boolean(process.stdin.isTTY)) {
643
685
  const flag = scanAgentFlag(args)
644
686
  if (flag) return flag
@@ -838,9 +880,12 @@ async function install(args) {
838
880
 
839
881
  let agent = agentFlag || (existingRc?.agent && SUPPORTED_AGENTS.includes(existingRc.agent) ? existingRc.agent : null)
840
882
  let language = scanLangFlag(args) || (existingRc?.language && SUPPORTED_LANGS.includes(existingRc.language) ? existingRc.language : null)
883
+ const excludeFlag = scanExcludeFlag(args)
884
+ const existingDiscovery = existingRc?.discovery || { outputDir: 'docs/technical-discovery', exclude: [] }
885
+ let excludeChoice = excludeFlag
841
886
 
842
887
  let bannerShown = false
843
- const isInteractive = Boolean(process.stdout.isTTY) && ((projectDir && !agent) || !tier || !language)
888
+ const isInteractive = Boolean(process.stdout.isTTY) && ((projectDir && !agent) || !tier || !language || (projectDir && excludeChoice === null && (existingDiscovery.exclude || []).length === 0))
844
889
  if (isInteractive) {
845
890
  await showBanner()
846
891
  bannerShown = true
@@ -855,6 +900,9 @@ async function install(args) {
855
900
  const picked = await selectOption('Idioma de los artifacts', SUPPORTED_LANGS.map(langLabel), 0)
856
901
  language = SUPPORTED_LANGS[SUPPORTED_LANGS.map(langLabel).indexOf(picked)] || 'auto'
857
902
  }
903
+ if (projectDir && excludeChoice === null && (existingDiscovery.exclude || []).length === 0) {
904
+ excludeChoice = await askExcludePresets(existingDiscovery.exclude || [])
905
+ }
858
906
  stopBanner()
859
907
  }
860
908
  if (!language) language = 'auto'
@@ -886,6 +934,7 @@ async function install(args) {
886
934
  await writeManifest(projectDir, {
887
935
  agent,
888
936
  language,
937
+ ...(excludeChoice !== null ? { discovery: { ...existingDiscovery, exclude: excludeChoice } } : {}),
889
938
  ...(gratisModelChoice ? { gratisModel: gratisModelChoice } : {}),
890
939
  installedPaths: {
891
940
  templates: ['AGENTS.md', 'PRODUCT.md'],
@@ -969,12 +1018,14 @@ async function initProject(args) {
969
1018
  const langFlag = scanLangFlag(args)
970
1019
  const existing = await readAncletorc(projectDir)
971
1020
  const azure = existing?.azure ?? { enabled: false }
972
- const discovery = existing?.discovery ?? { outputDir: 'docs/technical-discovery', exclude: [] }
1021
+ let discovery = existing?.discovery ?? { outputDir: 'docs/technical-discovery', exclude: [] }
973
1022
  const tierFile = join(projectDir, '.opencode', '.ancleto-tier')
1023
+ const excludeFlag = scanExcludeFlag(args)
1024
+ let excludeChoice = excludeFlag
974
1025
 
975
1026
  let agent, tier, language
976
1027
  language = langFlag || (existing?.language && SUPPORTED_LANGS.includes(existing.language) ? existing.language : null)
977
- const isInteractive = Boolean(process.stdout.isTTY) && (!agentFlag || !tierFlag || !language)
1028
+ const isInteractive = Boolean(process.stdout.isTTY) && (!agentFlag || !tierFlag || !language || (excludeChoice === null && (discovery.exclude || []).length === 0))
978
1029
  if (isInteractive) {
979
1030
  await showBanner()
980
1031
  const agentIdx = Math.max(0, SUPPORTED_AGENTS.indexOf(existing?.agent))
@@ -986,6 +1037,9 @@ async function initProject(args) {
986
1037
  const picked = await selectOption('Idioma de los artifacts', SUPPORTED_LANGS.map(langLabel), 0)
987
1038
  language = SUPPORTED_LANGS[SUPPORTED_LANGS.map(langLabel).indexOf(picked)] || 'auto'
988
1039
  }
1040
+ if (excludeChoice === null && (discovery.exclude || []).length === 0) {
1041
+ excludeChoice = await askExcludePresets(discovery.exclude || [])
1042
+ }
989
1043
  if (withAzure) {
990
1044
  azure.enabled = true
991
1045
  } else {
@@ -998,6 +1052,7 @@ async function initProject(args) {
998
1052
  if (!language) language = 'auto'
999
1053
  if (withAzure) azure.enabled = true
1000
1054
  }
1055
+ if (excludeChoice !== null) discovery = { ...discovery, exclude: excludeChoice }
1001
1056
 
1002
1057
  if (tier) {
1003
1058
  await mkdir(join(projectDir, '.opencode'), { recursive: true })
@@ -1072,9 +1127,11 @@ async function computeSources() {
1072
1127
 
1073
1128
  async function hashSources(sources) {
1074
1129
  const h = createHash('sha256')
1130
+ const fileHashes = {}
1075
1131
  for (const rel of sources) {
1076
1132
  try {
1077
1133
  const content = await readFile(join(process.cwd(), rel))
1134
+ fileHashes[rel] = createHash('sha256').update(content).digest('hex').slice(0, 16)
1078
1135
  h.update(rel)
1079
1136
  h.update('\0')
1080
1137
  h.update(String(content.length))
@@ -1083,7 +1140,71 @@ async function hashSources(sources) {
1083
1140
  h.update('\n')
1084
1141
  } catch {}
1085
1142
  }
1086
- return h.digest('hex')
1143
+ return { hash: h.digest('hex'), fileHashes }
1144
+ }
1145
+
1146
+ // Archivos cuyo cambio altera la arquitectura (configs de runtime, entry points).
1147
+ const MATERIAL_FILE_RES = [
1148
+ /^package\.json$/,
1149
+ /^tsconfig(\..+)?\.json$/,
1150
+ /^jsconfig\.json$/,
1151
+ /^(vite|webpack|rollup|next|nuxt|astro|svelte|tailwind)\.config\.[cm]?[jt]s$/,
1152
+ /^docker-compose\.ya?ml$/,
1153
+ /^Dockerfile$/,
1154
+ /^index\.html$/,
1155
+ /^src\/(main|index)\.[cm]?[jt]sx?$/
1156
+ ]
1157
+
1158
+ function isMaterialFile(rel) {
1159
+ return MATERIAL_FILE_RES.some((re) => re.test(rel))
1160
+ }
1161
+
1162
+ // Area = directorio de primer nivel; los archivos raiz son su propia area.
1163
+ function areaOf(rel) {
1164
+ const i = rel.indexOf('/')
1165
+ return i === -1 ? rel : rel.slice(0, i)
1166
+ }
1167
+
1168
+ function computeImpact(stored, sources, fileHashes) {
1169
+ const storedList = new Set(stored.sources || [])
1170
+ const currentList = new Set(sources)
1171
+ const storedFiles = stored.fileHashes || null
1172
+ const changedAreas = new Set()
1173
+ const materialReasons = []
1174
+ const notes = []
1175
+
1176
+ for (const rel of sources) {
1177
+ if (!storedList.has(rel)) {
1178
+ changedAreas.add(areaOf(rel))
1179
+ if (isMaterialFile(rel)) materialReasons.push(`archivo material nuevo: ${rel}`)
1180
+ }
1181
+ }
1182
+ for (const rel of storedList) {
1183
+ if (!currentList.has(rel)) {
1184
+ changedAreas.add(areaOf(rel))
1185
+ if (isMaterialFile(rel)) materialReasons.push(`archivo material eliminado: ${rel}`)
1186
+ }
1187
+ }
1188
+ if (storedFiles) {
1189
+ for (const rel of sources) {
1190
+ if (storedFiles[rel] && storedFiles[rel] !== fileHashes[rel]) {
1191
+ changedAreas.add(areaOf(rel))
1192
+ if (isMaterialFile(rel)) materialReasons.push(`archivo material modificado: ${rel}`)
1193
+ }
1194
+ }
1195
+ }
1196
+
1197
+ const storedAreas = new Set([...storedList].map(areaOf))
1198
+ const currentAreas = new Set(sources.map(areaOf))
1199
+ for (const a of currentAreas) if (!storedAreas.has(a)) materialReasons.push(`area raiz nueva: ${a}`)
1200
+ for (const a of storedAreas) if (!currentAreas.has(a)) materialReasons.push(`area raiz eliminada: ${a}`)
1201
+
1202
+ if (!storedFiles && changedAreas.size === 0) {
1203
+ notes.push('estado previo sin hashes por archivo: el cambio de contenido no se puede atribuir a un area')
1204
+ }
1205
+
1206
+ const impact = materialReasons.length ? 'material' : changedAreas.size || notes.length ? 'minor' : 'none'
1207
+ return { impact, changedAreas: [...changedAreas].sort(), materialReasons, notes }
1087
1208
  }
1088
1209
 
1089
1210
  function statePath(outputDir) {
@@ -1108,7 +1229,7 @@ async function checkDiscovery() {
1108
1229
  const { outputDir } = config
1109
1230
  const tier = readProjectTier(process.cwd())
1110
1231
  const present = await presentDocs(outputDir)
1111
- let state, action, message, missingDocs
1232
+ let state, action, message, missingDocs, impact = 'none', changedAreas = [], materialReasons = [], notes = []
1112
1233
  if (present.length === 0) {
1113
1234
  state = 'MISSING'
1114
1235
  action = 'generate'
@@ -1121,35 +1242,50 @@ async function checkDiscovery() {
1121
1242
  message = `Faltan ${missingDocs.length} documentos del seed.`
1122
1243
  } else {
1123
1244
  const sources = await computeSources()
1124
- const hash = await hashSources(sources)
1125
- let storedHash = null
1245
+ const { hash, fileHashes } = await hashSources(sources)
1246
+ let stored = null
1126
1247
  const sp = statePath(outputDir)
1127
1248
  if (await exists(sp)) {
1128
1249
  try {
1129
- storedHash = JSON.parse((await readFile(sp, 'utf8')).replace(/^\uFEFF/, '')).hash
1250
+ stored = JSON.parse((await readFile(sp, 'utf8')).replace(/^\uFEFF/, ''))
1130
1251
  } catch {}
1131
1252
  }
1132
- if (!storedHash) {
1253
+ if (!stored?.hash) {
1133
1254
  state = 'STALE'
1255
+ impact = 'material'
1134
1256
  action = 'regenerate'
1135
1257
  message = 'Seed completo pero sin estado registrado — frescura desconocida.'
1136
- } else if (storedHash === hash) {
1258
+ } else if (stored.hash === hash) {
1137
1259
  state = 'READY'
1138
1260
  action = 'continue'
1139
1261
  message = 'El seed esta al dia.'
1140
1262
  } else {
1263
+ const diff = computeImpact(stored, sources, fileHashes)
1264
+ impact = diff.impact
1265
+ changedAreas = diff.changedAreas
1266
+ materialReasons = diff.materialReasons
1267
+ notes = diff.notes
1141
1268
  state = 'STALE'
1142
- action = 'regenerate'
1143
- message = 'El repositorio cambio desde el ultimo pack.'
1269
+ if (impact === 'material') {
1270
+ action = 'regenerate'
1271
+ message = 'El repositorio cambio en areas materiales (config/entry points/estructura).'
1272
+ } else {
1273
+ action = 'continue'
1274
+ message = 'Cambios menores desde el ultimo pack; el seed sigue siendo util.'
1275
+ }
1144
1276
  }
1145
1277
  missingDocs = []
1146
1278
  }
1147
1279
  console.log(JSON.stringify({
1148
1280
  schemaVersion: 2,
1149
1281
  state,
1282
+ impact,
1150
1283
  recommendedAction: action,
1151
1284
  message,
1152
1285
  missingDocs,
1286
+ changedAreas,
1287
+ materialReasons,
1288
+ notes,
1153
1289
  config: {
1154
1290
  outputDir,
1155
1291
  exclude: config.exclude,
@@ -1194,12 +1330,13 @@ async function packDiscovery(flags) {
1194
1330
  process.exit(1)
1195
1331
  }
1196
1332
  const sources = await computeSources()
1197
- const hash = await hashSources(sources)
1333
+ const { hash, fileHashes } = await hashSources(sources)
1198
1334
  await mkdir(outputDir, { recursive: true })
1199
1335
  await writeFile(statePath(outputDir), JSON.stringify({
1200
1336
  version: 1,
1201
1337
  generatedAt: new Date().toISOString(),
1202
1338
  sources,
1339
+ fileHashes,
1203
1340
  hash,
1204
1341
  packTokens: tokens
1205
1342
  }, null, 2) + '\n')