@equationalapplications/core-llm-wiki 7.11.1 → 7.11.2

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.
@@ -1843,12 +1843,24 @@ ${groundingEvidenceBlock(writer, cfg)}` : systemPrompt;
1843
1843
  hasOntologyPlaceholders(template) {
1844
1844
  return /\{\{\s*ontology(?:Manifest|ModeInstructions)\s*\}\}/.test(template);
1845
1845
  }
1846
+ /** Removes ontology placeholders until none remain, so a nested form cannot reassemble one (closes CodeQL #11). */
1847
+ stripOntologyPlaceholders(template) {
1848
+ let out = template;
1849
+ let prev;
1850
+ do {
1851
+ prev = out;
1852
+ out = out.replace(/\{\{\s*ontology(?:Manifest|ModeInstructions)\s*\}\}/g, "");
1853
+ } while (out !== prev);
1854
+ return out;
1855
+ }
1846
1856
  buildSystemPrompt(template, variables, ontologyContext) {
1857
+ const hasOntologyPlaceholders = this.hasOntologyPlaceholders(template);
1858
+ const effective = hasOntologyPlaceholders && ontologyContext == null ? this.stripOntologyPlaceholders(template) : template;
1847
1859
  const shouldHydrate = Object.keys(variables).some(
1848
- (key) => new RegExp(`\\{\\{\\s*${key}\\s*\\}\\}`).test(template)
1849
- ) || ontologyContext != null && this.hasOntologyPlaceholders(template);
1850
- const hydrated = shouldHydrate ? this.hydrate(template, { ...variables, ...ontologyContext ?? {} }) : template;
1851
- return this.hasOntologyPlaceholders(template) ? ontologyContext != null ? hydrated : hydrated.replace(/\{\{\s*ontology(?:Manifest|ModeInstructions)\s*\}\}/g, "") : this.appendOntology(hydrated, ontologyContext);
1860
+ (key) => new RegExp(`\\{\\{\\s*${key}\\s*\\}\\}`).test(effective)
1861
+ ) || ontologyContext != null && hasOntologyPlaceholders;
1862
+ const hydrated = shouldHydrate ? this.hydrate(effective, { ...variables, ...ontologyContext ?? {} }) : effective;
1863
+ return hasOntologyPlaceholders ? hydrated : this.appendOntology(hydrated, ontologyContext);
1852
1864
  }
1853
1865
  appendOntology(systemPrompt, ctx) {
1854
1866
  if (!ctx) return systemPrompt;
@@ -6771,5 +6783,5 @@ var WriteService = class {
6771
6783
  };
6772
6784
 
6773
6785
  export { BaseRepository, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EmbeddingService, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UsageMeter, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiParseError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, chunkText, configureRandomSource, edgeTripleAllowed, emptyManifest, entitySummaryMetaKey, extractSqliteCode, factTokenCost, generateId, isLiveAt, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, resolveEdgeDefinitions, resolveGrounding, resolveNodeType, safeSlice, typeSatisfies, validateInlineEdges, validateManifest };
6774
- //# sourceMappingURL=chunk-IJFOAWPS.mjs.map
6775
- //# sourceMappingURL=chunk-IJFOAWPS.mjs.map
6786
+ //# sourceMappingURL=chunk-522SCN2E.mjs.map
6787
+ //# sourceMappingURL=chunk-522SCN2E.mjs.map