@bendyline/docblocks-react 2.7.6 → 2.7.7

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.
@@ -766,6 +766,17 @@ function isDiagramKind(value) {
766
766
  return typeof value === "string" && DIAGRAM_KINDS.includes(value);
767
767
  }
768
768
 
769
+ // src/Ai/document-title.ts
770
+ function documentTitle(source) {
771
+ const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(source)?.[1] ?? "";
772
+ const fromFrontmatter = /^title:\s*["']?(.+?)["']?\s*$/mu.exec(frontmatter)?.[1];
773
+ if (fromFrontmatter) return fromFrontmatter;
774
+ return /^#{1,6}\s+(.+?)\s*(\{.*)?$/mu.exec(source)?.[1] ?? "";
775
+ }
776
+
777
+ // src/Ai/ai-assistant.ts
778
+ import { AI_WIRE_LIMITS } from "@bendyline/docblocks/host";
779
+
769
780
  // src/Ai/ai-pictures.ts
770
781
  import {
771
782
  isSvgIslandLang,
@@ -915,6 +926,11 @@ var REVIEW_QUOTE_CHARACTERS = 2e3;
915
926
  var REVIEW_REPLACEMENT_CHARACTERS = 12e3;
916
927
  var REVIEW_MESSAGE_CHARACTERS = 1e3;
917
928
  var FACTS_RULE = `State a specific name, date, number, place or quotation only when the instructions, the document or a reference passage given with this request shows it. Memory of such details is often wrong even when it feels certain. If a detail is not shown, leave it out or say plainly that it could not be verified; never fill a gap with a plausible detail. Keep a source's certainty: if it says "about" or "disputed", so do you. `;
929
+ function knowledgeQuery(...parts) {
930
+ const query = parts.map((part) => part.trim()).filter(Boolean).join("\n").slice(0, AI_WIRE_LIMITS.knowledgeQueryCharacters);
931
+ return query ? { knowledgeQuery: query } : {};
932
+ }
933
+ var CITED = { knowledgeCitations: true };
918
934
  function boundedDocumentContext(source) {
919
935
  if (source.length <= DRAFT_DOCUMENT_CONTEXT_CHARACTERS) return source;
920
936
  return `${source.slice(0, DRAFT_DOCUMENT_CONTEXT_CHARACTERS)}
@@ -928,6 +944,8 @@ function buildDraftRequest(options) {
928
944
  return {
929
945
  purpose: "write",
930
946
  temperature: 0.35,
947
+ ...knowledgeQuery(instructions, options.selectedText),
948
+ ...CITED,
931
949
  messages: [
932
950
  {
933
951
  role: "system",
@@ -952,6 +970,8 @@ ${options.selectedText}
952
970
  return {
953
971
  purpose: "write",
954
972
  temperature: 0.7,
973
+ ...knowledgeQuery(instructions, documentTitle(options.documentSource)),
974
+ ...CITED,
955
975
  messages: [
956
976
  {
957
977
  role: "system",
@@ -1273,12 +1293,6 @@ function locatePassage(source, passage) {
1273
1293
  const start = findUniqueExcerpt(source, passage.text);
1274
1294
  return start === null ? null : { start, end: start + passage.text.length };
1275
1295
  }
1276
- function documentTitle(source) {
1277
- const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(source)?.[1] ?? "";
1278
- const fromFrontmatter = /^title:\s*["']?(.+?)["']?\s*$/mu.exec(frontmatter)?.[1];
1279
- if (fromFrontmatter) return fromFrontmatter;
1280
- return /^#{1,6}\s+(.+?)\s*(\{.*)?$/mu.exec(source)?.[1] ?? "";
1281
- }
1282
1296
  function idsIn(markdown) {
1283
1297
  return new Set([...markdown.matchAll(/\{#([A-Za-z0-9][\w-]*)/gu)].map((match) => match[1] ?? ""));
1284
1298
  }
@@ -2747,6 +2761,7 @@ export {
2747
2761
  contentTokens,
2748
2762
  describeSvgRemovals,
2749
2763
  validateSvgPicture,
2764
+ documentTitle,
2750
2765
  AI_INSTRUCTION_CHARACTERS,
2751
2766
  AI_REWRITE_SELECTION_CHARACTERS,
2752
2767
  AI_REVIEW_DOCUMENT_CHARACTERS,
@@ -2764,7 +2779,6 @@ export {
2764
2779
  segmentPassages,
2765
2780
  clipPassage,
2766
2781
  locatePassage,
2767
- documentTitle,
2768
2782
  idsIn,
2769
2783
  planInsertions,
2770
2784
  REALIZE_PASSAGE_CHARACTERS,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AiReportButton,
3
3
  chatOnce
4
- } from "./chunk-T42BH6YX.js";
4
+ } from "./chunk-N7AKLJPY.js";
5
5
  import {
6
6
  unavailableSentence,
7
7
  useAiStatus
package/dist/editor.js CHANGED
@@ -13,8 +13,8 @@ import {
13
13
  } from "./chunk-ACQF63SB.js";
14
14
  import {
15
15
  PresentationMaker
16
- } from "./chunk-PRUEYW3G.js";
17
- import "./chunk-T42BH6YX.js";
16
+ } from "./chunk-T2PA7QEF.js";
17
+ import "./chunk-N7AKLJPY.js";
18
18
  import "./chunk-K4I3NJFL.js";
19
19
  import "./chunk-VJPGZCFS.js";
20
20
  export {
@@ -12,7 +12,7 @@ import {
12
12
  } from "../chunk-5O5YTOXG.js";
13
13
  import {
14
14
  ExportDialog
15
- } from "../chunk-GFK4TCKN.js";
15
+ } from "../chunk-G63YXKBC.js";
16
16
  import "../chunk-H3BK5MK6.js";
17
17
  import {
18
18
  DEFAULT_OPTIONS,