@velvetmonkey/vault-core 2.0.114 → 2.0.115

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/dist/entities.js CHANGED
@@ -159,11 +159,15 @@ function extractFrontmatterFields(content) {
159
159
  function isDotPath(pathStr) {
160
160
  return path.basename(pathStr).startsWith('.');
161
161
  }
162
+ /**
163
+ * Union of all exclude patterns, compiled once at module load for performance
164
+ */
165
+ const EXCLUDE_UNION = new RegExp(DEFAULT_EXCLUDE_PATTERNS.map(p => `(?:${p.source})`).join('|'), 'i');
162
166
  /**
163
167
  * Check if entity name matches any exclude pattern
164
168
  */
165
169
  function matchesExcludePattern(name) {
166
- return DEFAULT_EXCLUDE_PATTERNS.some(pattern => pattern.test(name));
170
+ return EXCLUDE_UNION.test(name);
167
171
  }
168
172
  /**
169
173
  * Organization suffixes for company/team detection
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  export type { EntityIndex, EntityCategory, EntityWithAliases, Entity, EntityWithType, ScanOptions, WikilinkOptions, WikilinkResult, ImplicitEntityConfig, ExtendedWikilinkOptions, ImplicitEntityMatch, ResolveAliasOptions, ProtectedZone, ProtectedZoneType, } from './types.js';
8
8
  export { scanVaultEntities, getAllEntities, getAllEntitiesWithTypes, getEntityName, getEntityAliases, loadEntityCache, saveEntityCache, ENTITY_CACHE_VERSION, } from './entities.js';
9
9
  export { applyWikilinks, processWikilinks, resolveAliasWikilinks, suggestWikilinks, detectImplicitEntities, findEntityMatches, IMPLICIT_EXCLUDE_WORDS, } from './wikilinks.js';
10
- export { getProtectedZones, getProtectedZonesRegex, isInProtectedZone, rangeOverlapsProtectedZone, } from './protectedZones.js';
10
+ export { getProtectedZones, getProtectedZonesRegex, isInProtectedZone, mergeOverlappingZones, rangeOverlapsProtectedZone, } from './protectedZones.js';
11
11
  export { parseMarkdown } from './parseMarkdown.js';
12
12
  export { getProtectedZonesFromAst } from './astProtectedZones.js';
13
13
  export { OperationLogger, createLoggerFromConfig, generateSessionId, getSessionId, setSessionId, } from './logging/index.js';
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export { scanVaultEntities, getAllEntities, getAllEntitiesWithTypes, getEntityNa
9
9
  // Wikilinks
10
10
  export { applyWikilinks, processWikilinks, resolveAliasWikilinks, suggestWikilinks, detectImplicitEntities, findEntityMatches, IMPLICIT_EXCLUDE_WORDS, } from './wikilinks.js';
11
11
  // Protected zones
12
- export { getProtectedZones, getProtectedZonesRegex, isInProtectedZone, rangeOverlapsProtectedZone, } from './protectedZones.js';
12
+ export { getProtectedZones, getProtectedZonesRegex, isInProtectedZone, mergeOverlappingZones, rangeOverlapsProtectedZone, } from './protectedZones.js';
13
13
  // AST parsing
14
14
  export { parseMarkdown } from './parseMarkdown.js';
15
15
  export { getProtectedZonesFromAst } from './astProtectedZones.js';
@@ -37,6 +37,11 @@ export declare function getProtectedZonesRegex(content: string): ProtectedZone[]
37
37
  * callouts, tables, and HTML comments. Falls back to regex on parse failure.
38
38
  */
39
39
  export declare function getProtectedZones(content: string): ProtectedZone[];
40
+ /**
41
+ * Merge overlapping or adjacent protected zones into a single list.
42
+ * Zones that touch (end === start) or overlap are collapsed.
43
+ */
44
+ export declare function mergeOverlappingZones(zones: ProtectedZone[]): ProtectedZone[];
40
45
  /**
41
46
  * Check if a position is within any protected zone
42
47
  */
@@ -100,9 +100,9 @@ export function getProtectedZonesRegex(content) {
100
100
  zones.push(...findPatternZones(content, /^#{1,6}\s+.+$/gm, 'header'));
101
101
  // 12. Obsidian callouts (> [!type] syntax)
102
102
  zones.push(...findPatternZones(content, /^>\s*\[![\w-]+\].*$/gm, 'obsidian_callout'));
103
- // Sort by start position
103
+ // Sort by start position and merge overlapping zones
104
104
  zones.sort((a, b) => a.start - b.start);
105
- return zones;
105
+ return mergeOverlappingZones(zones);
106
106
  }
107
107
  /**
108
108
  * Get all protected zones in content where wikilinks should not be applied.
@@ -113,11 +113,32 @@ export function getProtectedZonesRegex(content) {
113
113
  export function getProtectedZones(content) {
114
114
  const tree = parseMarkdown(content);
115
115
  if (tree) {
116
- return getProtectedZonesFromAst(tree, content);
116
+ return mergeOverlappingZones(getProtectedZonesFromAst(tree, content));
117
117
  }
118
118
  console.error('[ProtectedZones] AST parse failed, falling back to regex detection');
119
119
  return getProtectedZonesRegex(content);
120
120
  }
121
+ /**
122
+ * Merge overlapping or adjacent protected zones into a single list.
123
+ * Zones that touch (end === start) or overlap are collapsed.
124
+ */
125
+ export function mergeOverlappingZones(zones) {
126
+ if (zones.length <= 1)
127
+ return zones;
128
+ const sorted = [...zones].sort((a, b) => a.start - b.start || b.end - a.end);
129
+ const merged = [sorted[0]];
130
+ for (let i = 1; i < sorted.length; i++) {
131
+ const prev = merged[merged.length - 1];
132
+ const curr = sorted[i];
133
+ if (curr.start <= prev.end) {
134
+ prev.end = Math.max(prev.end, curr.end);
135
+ }
136
+ else {
137
+ merged.push(curr);
138
+ }
139
+ }
140
+ return merged;
141
+ }
121
142
  /**
122
143
  * Check if a position is within any protected zone
123
144
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velvetmonkey/vault-core",
3
- "version": "2.0.114",
3
+ "version": "2.0.115",
4
4
  "description": "Shared vault utilities for Flywheel ecosystem (entity scanning, wikilinks, protected zones)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",