@promptbook/markdown-utils 0.100.3-0 → 0.101.0-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.
Files changed (62) hide show
  1. package/esm/index.es.js +127 -3
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  4. package/esm/typings/src/_packages/markdown-utils.index.d.ts +14 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +4 -6
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +21 -0
  7. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentModelRequirements.d.ts +1 -1
  8. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentSourceParseResult.d.ts +3 -1
  9. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirements.d.ts +2 -2
  10. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirementsWithCommitments.d.ts +3 -3
  11. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createCommitmentRegex.d.ts +2 -2
  12. package/esm/typings/src/book-2.0/agent-source/extractMetaLinks.d.ts +8 -0
  13. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +4 -19
  14. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +9 -0
  15. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +1 -1
  16. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +1 -1
  17. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  18. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +1 -1
  19. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +1 -1
  20. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +1 -1
  21. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +1 -1
  22. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +1 -1
  23. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +1 -1
  24. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +1 -1
  25. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +1 -1
  26. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +1 -1
  27. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +1 -1
  28. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
  29. package/esm/typings/src/book-2.0/commitments/{_misc → _base}/ParsedCommitment.d.ts +1 -1
  30. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  31. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +17 -0
  32. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +12 -0
  33. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +10 -0
  34. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +10 -0
  35. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +1 -1
  36. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +2 -8
  37. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  38. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +1 -1
  40. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -1
  41. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -1
  42. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -1
  43. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -1
  44. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -0
  45. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -1
  46. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +12 -0
  47. package/esm/typings/src/utils/markdown/humanizeAiText.test.d.ts +1 -0
  48. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +12 -0
  49. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +12 -0
  50. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +12 -0
  51. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +12 -0
  52. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +11 -0
  53. package/esm/typings/src/utils/markdown/promptbookifyAiText.test.d.ts +1 -0
  54. package/esm/typings/src/utils/markdown/removeMarkdownLinks.d.ts +11 -0
  55. package/esm/typings/src/utils/markdown/removeMarkdownLinks.test.d.ts +4 -0
  56. package/esm/typings/src/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/umd/index.umd.js +133 -2
  59. package/umd/index.umd.js.map +1 -1
  60. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +0 -24
  61. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +0 -39
  62. /package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/removeCommentsFromSystemMessage.d.ts +0 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Removes Markdown link tags from a string.
3
+ *
4
+ * @param {string} str - The string to remove Markdown tags from.
5
+ * @returns {string} The input string with all Markdown tags removed.
6
+ * @public exported from `@promptbook/markdown-utils`
7
+ */
8
+ export declare function removeMarkdownLinks(str: string): string;
9
+ /**
10
+ * @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
11
+ */
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
4
+ */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.100.2`).
18
+ * It follows semantic versioning (e.g., `0.100.4-0`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.100.3-0",
3
+ "version": "0.101.0-0",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -26,7 +26,7 @@
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.100.3-0';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-0';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2680,7 +2680,7 @@
2680
2680
  };
2681
2681
  /**
2682
2682
  * TODO: Refactor this - each profile must be alongside the provider definition
2683
- * TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
2683
+ * TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
2684
2684
  * Note: [💞] Ignore a discrepancy between file name and entity name
2685
2685
  */
2686
2686
 
@@ -4889,6 +4889,7 @@
4889
4889
  }
4890
4890
  /**
4891
4891
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4892
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4892
4893
  */
4893
4894
 
4894
4895
  /**
@@ -4923,6 +4924,7 @@
4923
4924
  }
4924
4925
  /**
4925
4926
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4927
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4926
4928
  */
4927
4929
 
4928
4930
  /**
@@ -4937,6 +4939,7 @@
4937
4939
  }
4938
4940
  /**
4939
4941
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4942
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4940
4943
  */
4941
4944
 
4942
4945
  /**
@@ -4949,6 +4952,7 @@
4949
4952
  }
4950
4953
  /**
4951
4954
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4955
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4952
4956
  */
4953
4957
 
4954
4958
  /**
@@ -4969,6 +4973,7 @@
4969
4973
  }
4970
4974
  /**
4971
4975
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4976
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4972
4977
  */
4973
4978
 
4974
4979
  /**
@@ -4985,6 +4990,8 @@
4985
4990
  }
4986
4991
  /**
4987
4992
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
4993
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
4994
+ * TODO: [✌️] `countWords` should be just `splitWords(...).length`, and all other counters should use this pattern as well
4988
4995
  */
4989
4996
 
4990
4997
  /**
@@ -6773,6 +6780,108 @@
6773
6780
  * NOW we are working just with markdown string and its good enough
6774
6781
  */
6775
6782
 
6783
+ /**
6784
+ * Change ellipsis character to three dots `…` -> `...`
6785
+ *
6786
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6787
+ *
6788
+ * @public exported from `@promptbook/markdown-utils`
6789
+ */
6790
+ function humanizeAiTextEllipsis(aiText) {
6791
+ return aiText.replace(/…/g, '...');
6792
+ }
6793
+ /**
6794
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
6795
+ */
6796
+
6797
+ /**
6798
+ * Change em-dashes to regular dashes `—` -> `-`
6799
+ *
6800
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6801
+ *
6802
+ * @public exported from `@promptbook/markdown-utils`
6803
+ */
6804
+ function humanizeAiTextEmdashed(aiText) {
6805
+ return aiText.replace(/—/g, '-');
6806
+ }
6807
+ /**
6808
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
6809
+ */
6810
+
6811
+ /**
6812
+ * Change smart quotes to regular quotes
6813
+ *
6814
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6815
+ *
6816
+ * @public exported from `@promptbook/markdown-utils`
6817
+ */
6818
+ function humanizeAiTextQuotes(aiText) {
6819
+ return aiText
6820
+ .replace(/[“”]/g, '"')
6821
+ .replace(/[‚‘’]/g, "'")
6822
+ .replace(/«/g, '"')
6823
+ .replace(/»/g, '"')
6824
+ .replace(/„/g, '"')
6825
+ .replace(/‹/g, "'")
6826
+ .replace(/›/g, "'");
6827
+ }
6828
+ /**
6829
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
6830
+ */
6831
+
6832
+ /**
6833
+ * Change unprintable hard spaces to regular spaces
6834
+ *
6835
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6836
+ *
6837
+ * @public exported from `@promptbook/markdown-utils`
6838
+ */
6839
+ function humanizeAiTextWhitespace(aiText) {
6840
+ return aiText.replace(/\u00A0/g, ' ');
6841
+ }
6842
+ /**
6843
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
6844
+ */
6845
+
6846
+ /**
6847
+ * Function `humanizeAiText` will remove traces of AI text generation artifacts
6848
+ *
6849
+ * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
6850
+ *
6851
+ * @public exported from `@promptbook/markdown-utils`
6852
+ */
6853
+ function humanizeAiText(aiText) {
6854
+ let cleanedText = aiText;
6855
+ cleanedText = humanizeAiTextEllipsis(cleanedText);
6856
+ cleanedText = humanizeAiTextEmdashed(cleanedText);
6857
+ cleanedText = humanizeAiTextQuotes(cleanedText);
6858
+ cleanedText = humanizeAiTextWhitespace(cleanedText);
6859
+ return cleanedText;
6860
+ }
6861
+ /**
6862
+ * TODO: [🅾️] !!! Use this across the project where AI text is involved
6863
+ */
6864
+
6865
+ /**
6866
+ * Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
6867
+ *
6868
+ * @public exported from `@promptbook/markdown-utils`
6869
+ */
6870
+ function promptbookifyAiText(text) {
6871
+ // Note: Duplicating some spaces
6872
+ const words = text.split(' '); // <- Note: [✌️] Use `splitWords` when available
6873
+ const wordLength = words.length; // <- Note: [✌️] `countWords` should be just `splitWords(...).length`
6874
+ for (const wordIndex of [3, 7, 11, 19].filter((i) => i < wordLength)) {
6875
+ words[wordIndex] = ' ' + words[wordIndex];
6876
+ }
6877
+ const promptbookifiedText = words.join(' ');
6878
+ return promptbookifiedText;
6879
+ }
6880
+ /**
6881
+ * TODO: [🅾️]!!! Use this across the project where AI text is involved
6882
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
6883
+ */
6884
+
6776
6885
  /**
6777
6886
  * Removes Markdown formatting tags from a string.
6778
6887
  *
@@ -6790,6 +6899,21 @@
6790
6899
  return str;
6791
6900
  }
6792
6901
 
6902
+ /**
6903
+ * Removes Markdown link tags from a string.
6904
+ *
6905
+ * @param {string} str - The string to remove Markdown tags from.
6906
+ * @returns {string} The input string with all Markdown tags removed.
6907
+ * @public exported from `@promptbook/markdown-utils`
6908
+ */
6909
+ function removeMarkdownLinks(str) {
6910
+ // Use regular expressions to remove Markdown tags from the string
6911
+ return str.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1');
6912
+ }
6913
+ /**
6914
+ * @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
6915
+ */
6916
+
6793
6917
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
6794
6918
  exports.MarkdownScraper = MarkdownScraper;
6795
6919
  exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
@@ -6805,9 +6929,16 @@
6805
6929
  exports.extractJsonBlock = extractJsonBlock;
6806
6930
  exports.extractOneBlockFromMarkdown = extractOneBlockFromMarkdown;
6807
6931
  exports.flattenMarkdown = flattenMarkdown;
6932
+ exports.humanizeAiText = humanizeAiText;
6933
+ exports.humanizeAiTextEllipsis = humanizeAiTextEllipsis;
6934
+ exports.humanizeAiTextEmdashed = humanizeAiTextEmdashed;
6935
+ exports.humanizeAiTextQuotes = humanizeAiTextQuotes;
6936
+ exports.humanizeAiTextWhitespace = humanizeAiTextWhitespace;
6808
6937
  exports.parseMarkdownSection = parseMarkdownSection;
6938
+ exports.promptbookifyAiText = promptbookifyAiText;
6809
6939
  exports.removeMarkdownComments = removeMarkdownComments;
6810
6940
  exports.removeMarkdownFormatting = removeMarkdownFormatting;
6941
+ exports.removeMarkdownLinks = removeMarkdownLinks;
6811
6942
  exports.splitMarkdownIntoSections = splitMarkdownIntoSections;
6812
6943
 
6813
6944
  Object.defineProperty(exports, '__esModule', { value: true });