-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
front matter refresh #651
front matter refresh #651
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
{ | ||
"name": "docs", | ||
"type": "module", | ||
"private": true, | ||
"version": "1.50.3", | ||
"license": "MIT", | ||
"scripts": { | ||
"install:force": "rm yarn.lock && yarn install", | ||
"dev": "astro dev --host", | ||
"start": "astro dev --host", | ||
"check": "astro check", | ||
"build": "astro build", | ||
"build:asw": "rm -Rf distasw && mkdir distasw && touch distasw/index.html && mkdir distasw/genaiscript && cp -r dist/* distasw/genaiscript", | ||
"preview": "astro preview", | ||
"astro": "astro", | ||
"genai:test": "node ../packages/cli/built/genaiscript.cjs test src/**/*.md", | ||
"genai:frontmatter": "for file in \"src/**/*.md\"; do\nnode ../packages/cli/built/genaiscript.cjs run frontmatter \"$file\" --apply-edits\ndone", | ||
"genai:technical": "for file in \"src/**/*.md\"; do\nnode ../packages/cli/built/genaiscript.cjs run technical \"$file\" --apply-edits\ndone", | ||
"genai:alt-text": "node scripts/image-alt-text.mjs" | ||
}, | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.3", | ||
"@astrojs/starlight": "^0.26.1", | ||
"astro": "^4.14.5", | ||
"typescript": "5.5.4" | ||
}, | ||
"devDependencies": { | ||
"starlight-blog": "^0.12.0", | ||
"zx": "^8.1.4" | ||
} | ||
"name": "docs", | ||
"type": "module", | ||
"private": true, | ||
"version": "1.50.3", | ||
"license": "MIT", | ||
"scripts": { | ||
"install:force": "rm yarn.lock && yarn install", | ||
"dev": "astro dev --host", | ||
"start": "astro dev --host", | ||
"check": "astro check", | ||
"build": "astro build", | ||
"build:asw": "rm -Rf distasw && mkdir distasw && touch distasw/index.html && mkdir distasw/genaiscript && cp -r dist/* distasw/genaiscript", | ||
"preview": "astro preview", | ||
"astro": "astro", | ||
"genai:test": "node ../packages/cli/built/genaiscript.cjs test src/**/*.md", | ||
"genai:frontmatter": "node ../packages/cli/built/genaiscript.cjs run frontmatter \"src/**/*.md\" --apply-edits", | ||
"genai:technical": "for file in \"src/**/*.md\"; do\nnode ../packages/cli/built/genaiscript.cjs run technical \"$file\" --apply-edits\ndone", | ||
"genai:alt-text": "node scripts/image-alt-text.mjs" | ||
}, | ||
"dependencies": { | ||
"@astrojs/check": "^0.9.3", | ||
"@astrojs/starlight": "^0.26.1", | ||
"astro": "^4.14.5", | ||
"typescript": "5.5.4" | ||
}, | ||
"devDependencies": { | ||
"starlight-blog": "^0.12.0", | ||
"zx": "^8.1.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
title: "Creating Release Notes with GenAI" | ||
date: 2024-08-26 | ||
tags: ["genaiscript", "automation", "release notes"] | ||
authors: genaiscript | ||
canonical_url: https://microsoft.github.io/genaiscript/blog/creating-release-notes-with-genai | ||
--- | ||
|
||
## Automating Your Release Notes with GenAI | ||
|
||
Bringing a new version of a product into the world is always exciting! But alongside the thrill comes the duty of informing users about what's changed. That's where generating crisp, engaging release notes comes into play. β¨ | ||
|
||
Today, we're going to explore a script that automates the creation of release notes for GenAI. The script is part of the GenAIScript ecosystem, which harnesses the power of AI to bring efficiency to software development processes. π | ||
|
||
If you want to dive straight into the script, it's available on GitHub right [here](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/git-release-notes.genai.js). | ||
|
||
> This blog post was co-authored with a [script](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/blogify-sample.genai.mts). | ||
|
||
### Breaking Down the Script | ||
|
||
The script is a `.genai.mjs` file, meaning it's a JavaScript file designed to be run with the GenAIScript CLI. The code within orchestrates the creation of release notes by leveraging Git commands and GenAI's capabilities. | ||
|
||
Let's walk through the script, step by step: | ||
|
||
#### Step 1: Initializing the Script | ||
|
||
```javascript | ||
script({ system: ["system"], temperature: 0.5, model: "openai:gpt-4-turbo" }) | ||
``` | ||
|
||
The script starts by initializing with a `script` function. We're setting it up to access system commands and specifying the AI model to use. The temperature controls the creativity of the AI, with 0.5 being a balanced choice. | ||
|
||
#### Step 2: Setting the Product Name | ||
|
||
```javascript | ||
const product = env.vars.product || "GenAIScript" | ||
``` | ||
|
||
Here, we're using an environment variable to set the product name, defaulting to "GenAIScript" if it's not provided. | ||
|
||
#### Step 3: Finding the Previous Tag | ||
|
||
```javascript | ||
const pkg = await workspace.readJSON("package.json") | ||
const { version } = pkg | ||
const { stdout: tag } = await host.exec("git", [ | ||
"describe", | ||
"--tags", | ||
"--abbrev=0", | ||
"HEAD^", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippet uses
|
||
]) | ||
``` | ||
Check failure on line 52 in docs/src/content/docs/blog/creating-release-notes-with-genai.md GitHub Actions / build
|
||
|
||
We are reading the current version from `package.json` and using Git to find the previous release tag in the repository. | ||
|
||
#### Step 4: Gathering Commits | ||
|
||
```javascript | ||
const { stdout: commits } = await host.exec("git", [ | ||
"log", | ||
"--grep='skip ci'", | ||
"--invert-grep", | ||
"--no-merges", | ||
`HEAD...${tag}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippet uses
|
||
]) | ||
``` | ||
|
||
This block runs a Git command to retrieve the list of commits that will be included in the release notes, excluding any with 'skip ci' in the message. | ||
|
||
#### Step 5: Obtaining the Diff | ||
|
||
```javascript | ||
const { stdout: diff } = await host.exec("git", [ | ||
"diff", | ||
`${tag}..HEAD`, | ||
"--no-merges", | ||
"--", | ||
":!**/package.json", | ||
":!**/genaiscript.d.ts", | ||
":!**/jsconfig.json", | ||
":!docs/**", | ||
":!.github/*", | ||
":!.vscode/*", | ||
":!*yarn.lock", | ||
":!*THIRD_PARTY_NOTICES.md", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippet uses
|
||
]) | ||
``` | ||
|
||
Next, we get the diff of changes since the last release, excluding certain files and directories that aren't relevant to the user-facing release notes. | ||
|
||
#### Step 6: Defining Placeholders | ||
|
||
```javascript | ||
const commitsName = def("COMMITS", commits, { maxTokens: 4000 }) | ||
const diffName = def("DIFF", diff, { maxTokens: 20000 }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
``` | ||
|
||
We define two placeholders, `COMMITS` and `DIFF`, which will be used to reference the commits and diff within the prompt. | ||
|
||
#### Step 7: Writing the Prompt | ||
|
||
```javascript | ||
$` | ||
You are an expert software developer and release manager. | ||
|
||
## Task | ||
|
||
Generate a clear, exciting, relevant, useful release notes | ||
for the upcoming release ${version} of ${product} on GitHub. | ||
|
||
- The commits in the release are in ${commitsName}. | ||
- The diff of the changes are in ${diffName}. | ||
|
||
## Guidelines | ||
|
||
- only include the most important changes. All changes must be in the commits. | ||
- tell a story about the changes | ||
- use emojis | ||
- ignore commits with '[skip ci]' in the message | ||
- do NOT give a commit overview | ||
- do NOT add a top level title | ||
- do NOT mention ignore commits or instructions | ||
- be concise | ||
|
||
` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
``` | ||
|
||
Finally, the script ends with a prompt that instructs GenAI to generate the release notes. It details the task, guidelines for what to include, and the style to adhere to. | ||
|
||
### How to Run the Script with Genaiscript CLI | ||
|
||
Once you've crafted your script, running it is a breeze with the Genaiscript CLI. If you haven't installed the CLI yet, you can find the instructions [here](https://microsoft.github.io/genaiscript/getting-started/installation). | ||
|
||
To execute the script, navigate to your project's root directory in the terminal and run: | ||
|
||
```bash | ||
genaiscript run git-release-notes | ||
``` | ||
|
||
Remember, we use the script filename without the `.genai.mjs` extension when invoking it with the CLI. | ||
|
||
And that's it! The GenAIScript CLI will take care of the rest, combining the power of AI with your code to generate those sleek release notes for your project's next big launch. π |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
--- | ||
title: "Keeping your README Fresh and Engaging" | ||
title: Keeping your README Fresh and Engaging | ||
date: 2024-08-24 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The date format should follow ISO 8601 (YYYY-MM-DD).
|
||
authors: [genaiscript, pelikhan] | ||
tags: ["GenAIScript", "README", "Open Source", "Maintenance"] | ||
authors: | ||
- genaiscript | ||
- pelikhan | ||
tags: | ||
- README | ||
- Open Source | ||
- Documentation | ||
- Maintenance | ||
- Engagement | ||
canonical_url: https://microsoft.github.io/genaiscript/blog/README-maintenance | ||
description: Optimize your project's front door with our script for an always | ||
up-to-date and engaging README. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description should be enclosed in quotation marks.
|
||
|
||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The frontmatter should be enclosed in a pair of triple-dashed lines. The closing triple-dashed line is missing after the frontmatter block.
|
||
|
||
In the world of open source, a well-maintained `README` file acts as the front door to your project. It's often the first thing potential users and contributors see, and as such, it should be both informative and inviting. Today, we're diving into the GenAIScript that helps keep the `README` of the [GenAI project](https://github.com/microsoft/genaiscript) as fresh as a daisy! πΌ Check out the actual [script file](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/readme-updater.genai.mts) for the details. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
--- | ||
title: Markdown | ||
sidebar: | ||
order: 9.2 | ||
keywords: markdown, mdx, frontmatter | ||
order: 9.2 | ||
keywords: | ||
- markdown | ||
- mdx | ||
- frontmatter | ||
- parsing | ||
- documentation | ||
description: Enhance your markdown capabilities with MD class helpers for | ||
parsing and managing frontmatter efficiently. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description should be enclosed in quotation marks.
|
||
|
||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The frontmatter should be enclosed in a pair of triple-dashed lines. The closing triple-dashed line is missing after the frontmatter block.
|
||
|
||
The `MD` class contains several helpers to work with [Markdown](https://www.markdownguide.org/cheat-sheet/) and [frontmatter text](https://jekyllrb.com/docs/front-matter/). | ||
|
||
The parser also support markdown variants like [MDX](https://mdxjs.com/). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ | |
for (const [key, value] of Object.entries(newFrontmatter ?? {})) { | ||
if (value === null) { | ||
delete frontmatter[key] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the
|
||
} else { | ||
} else if (value !== undefined) { | ||
Check notice on line 65 in packages/core/src/frontmatter.ts GitHub Actions / build
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check for
|
||
frontmatter[key] = value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assigning
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Directly mutating the
|
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -432,7 +432,7 @@ | |
fileEdits: Record<string, FileUpdate>, | ||
schemas: Record<string, JSONSchema> | ||
) { | ||
if (fileOutputs?.length) { | ||
if (fileOutputs?.length && Object.keys(fileEdits || {}).length) { | ||
Check failure on line 435 in packages/core/src/promptrunner.ts GitHub Actions / build
Check notice on line 435 in packages/core/src/promptrunner.ts GitHub Actions / build
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The added condition
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of optional chaining (
|
||
trace.startDetails("π file outputs") | ||
for (const fileEditName of Object.keys(fileEdits)) { | ||
const fe = fileEdits[fileEditName] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script file extension should be
.genai.js
not.genai.mjs
as per the convention used in the documentation.