diff --git a/manifest.json b/manifest.json index 53f4839..f899bff 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,11 @@ { - "packageId": "Put_Package_Id_Here", - "name": "Name of your package", + "packageId": "Experimental", + "name": "Experimental Package", "version": "0.0.1", - "minTextGeneratorVersion": "0.1.0", - "description": "The description of the content of this package", - "author": "Your name", - "tags": "writing, brainstorming", - "authorUrl": "Support URL", - "repo": "username/repo" -} + "minTextGeneratorVersion": "0.6.6", + "description": "Contains experimental templates", + "author": "Noureddine", + "tags": "experiments", + "authorUrl": "https://www.buymeacoffee.com/haouarine", + "repo": "text-gen/experimental-package" +} \ No newline at end of file diff --git a/prompts/conceptLinker.md b/prompts/conceptLinker.md new file mode 100644 index 0000000..5c04c99 --- /dev/null +++ b/prompts/conceptLinker.md @@ -0,0 +1,66 @@ +--- +promptId: conceptLinker +name: 🗞️conceptLinker +description: Generate notes and links them from the current note's words +author: Noureddine +tags: + - notes + - linking + - brainStorming +version: 0.0.1 +disableProvider: true +commands: + - generate +--- +```handlebars +``` +*** +*** +{{#script}} +```js + // Uses an external function 'gen' to generate concepts and their definitions + async function extractAndDefineConcepts(text) { + const prompt = `Extract concepts from the following content and define them. Do not refer to the current note. do not refer to already refered concepts(contained in []). Return a json Record. Ensure the 'name' is exactly as it appears in the text, without any modifications: \n${text.replace(/\[\[.*?\]\]/g, '')}`; + + const conceptData = await genJSON(prompt); // returns object + + return Object.entries(conceptData).map(([name, definition]) => ({name, definition})); + } + + function replaceConceptsWithLinks(text, concepts) { + let modifiedText = text; + concepts.forEach(concept => { + modifiedText = modifiedText.replace(new RegExp(concept.name, 'g'), `[[${concept.name}]]`); + }); + return modifiedText; + } + + async function createConceptPages(concepts) { + const currentFolder = app.workspace.getActiveFile().parent.path; + for (const concept of concepts) { + const conceptFilePath = `${currentFolder}/${concept.name}.md`; + if (!await app.vault.exists(conceptFilePath)) { + await app.vault.create(conceptFilePath, `# ${concept.name}\n\n${concept.definition}`); + } + } + } + + async function extractConcepts() { + const activeFile = app.workspace.getActiveFile(); + if (!activeFile) return; + + const fileContent = (""+await app.vault.read(activeFile)) + + const concepts = await extractAndDefineConcepts(fileContent); + + const modifiedContent = replaceConceptsWithLinks(fileContent, concepts); + console.log({modifiedContent}) + await app.vault.modify(activeFile, modifiedContent); + + await createConceptPages(concepts); + } + + await extractConcepts(); + return ""; +``` +{{/script}} \ No newline at end of file diff --git a/prompts/getExample.md b/prompts/getExample.md deleted file mode 100644 index adbf70c..0000000 --- a/prompts/getExample.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -promptId: getExample -name: ✉️ Emoji + Short description -description: longer description -author: author Name -tags: tag1, tag2 -required_values: val1, val2 -version: 0.0.1 ---- -content: -{{context}} -prompt: -Write an example about content -example: