Skip to content

Commit

Permalink
Update features section of readme automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
justyns committed Jul 4, 2024
1 parent 3d108de commit a273008
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ If you are new here, start with either the `AI: Chat on current page` command or

## Features

<!-- start-features -->

- **Summarize Note**: Summarizes the content of a note or selected text.
- **Replace with Summary**: Replaces the selected text with its summary.
- **Insert Summary**: Inserts a summary of the selected text or note at the cursor position.
- **Call OpenAI with Note Context**: Sends the note or selected text to OpenAI based on a user-defined prompt.
- **Generate Tags for Note**: Generates tags for the current note using AI.
- **Generate Tags for Note**: Generates tags for the current note using AI. Custom rules can also be specified to steer towards better tags.
- **Generate and Insert Image using Dall-E**: Generates an image based on a prompt and inserts it into the note.
- **Rename a note based on Note Context**: Sends the note, including enriched data, to the LLM and asks for a new note title. Custom rules or examples can also be provided to generate better titles.
<!-- end-features -->

### Available commands

Expand Down
7 changes: 7 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ ai:
userInstructions: >
Please give short and concise responses. When providing code, do so in python unless requested otherwise.
# Prompt Instructions are optional, but can help steer the LLM to more personalized results for built-in commands.
promptInstructions:
pageRenameRules: >
Include a random animal name in every note title.
tagRules: >
Tag every note with the current year.
```
42 changes: 35 additions & 7 deletions scripts/update-readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ async function updateReadme(tag: string) {
const readmePath = "./README.md";
const plugYamlPath = "./silverbullet-ai.plug.yaml";
const installationDocPath = "./docs/Installation.md";
const featuresDocPath = "./docs/Features.md";
let readmeContent = await Deno.readTextFile(readmePath);
const plugYamlContent = await Deno.readTextFile(plugYamlPath);
let installationDocContent = await Deno.readTextFile(installationDocPath);
const featuresDocContent = await Deno.readTextFile(featuresDocPath);

// Update the tag in the README
readmeContent = readmeContent.replace(
Expand Down Expand Up @@ -70,24 +72,50 @@ commandSummary: "${docs.replace(/"/g, '\\"')}"
}

// This "dynamic" part of the readme will be enclosed with comments to make it replaceable
const startMarker = "<!-- start-commands-and-functions -->";
const endMarker = "<!-- end-commands-and-functions -->";
const insertionSection = `${startMarker}\n${commandsMarkdown}\n${endMarker}`;
const startCommandsMarker = "<!-- start-commands-and-functions -->";
const endCommandsMarker = "<!-- end-commands-and-functions -->";
const commandsInsertionSection =
`${startCommandsMarker}\n${commandsMarkdown}\n${endCommandsMarker}`;

// Replace or insert the commands and functions section in the README
if (
readmeContent.includes(startMarker) && readmeContent.includes(endMarker)
readmeContent.includes(startCommandsMarker) &&
readmeContent.includes(endCommandsMarker)
) {
const start = readmeContent.indexOf(startMarker);
const end = readmeContent.indexOf(endMarker) + endMarker.length;
readmeContent = readmeContent.substring(0, start) + insertionSection +
const start = readmeContent.indexOf(startCommandsMarker);
const end = readmeContent.indexOf(endCommandsMarker) +
endCommandsMarker.length;
readmeContent = readmeContent.substring(0, start) +
commandsInsertionSection +
readmeContent.substring(end);
} else {
console.error(
"README does not contain the markers for commands and functions section.",
);
}

// Update the features section in the README
const startFeaturesMarker = "<!-- start-features -->";
const endFeaturesMarker = "<!-- end-features -->";
const featuresInsertionSection =
`${startFeaturesMarker}\n${featuresDocContent}\n${endFeaturesMarker}`;

if (
readmeContent.includes(startFeaturesMarker) &&
readmeContent.includes(endFeaturesMarker)
) {
const start = readmeContent.indexOf(startFeaturesMarker);
const end = readmeContent.indexOf(endFeaturesMarker) +
endFeaturesMarker.length;
readmeContent = readmeContent.substring(0, start) +
featuresInsertionSection +
readmeContent.substring(end);
} else {
console.error(
"README does not contain the markers for features section.",
);
}

await Deno.writeTextFile(readmePath, readmeContent);
await Deno.writeTextFile(installationDocPath, installationDocContent);
}
Expand Down

0 comments on commit a273008

Please sign in to comment.