Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 084bb1b

Browse files
committed
docs
1 parent f31b7e3 commit 084bb1b

File tree

5 files changed

+106
-3
lines changed

5 files changed

+106
-3
lines changed

genaisrc/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
genaiscript.d.ts -diff merge=ours linguist-generated

genaisrc/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# auto-generated
2+
genaiscript.d.ts
3+
tsconfig.json
4+
jsconfig.json

genaisrc/gcm.genai.mjs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* Script to automate the git commit process with AI-generated commit messages.
3+
* It checks for staged changes, generates a commit message, and prompts the user to review or edit the message before committing.
4+
*/
5+
6+
script({
7+
title: "git commit message",
8+
description: "Generate a commit message for all staged changes",
9+
})
10+
11+
// Check for staged changes and stage all changes if none are staged
12+
const diff = await git.diff({
13+
staged: true,
14+
askStageOnEmpty: true,
15+
})
16+
17+
// If no staged changes are found, cancel the script with a message
18+
if (!diff) cancel("no staged changes")
19+
20+
// Display the diff of staged changes in the console
21+
console.log(diff)
22+
23+
let choice
24+
let message
25+
do {
26+
// Generate a conventional commit message based on the staged changes diff
27+
const res = await runPrompt(
28+
(_) => {
29+
_.def("GIT_DIFF", diff, { maxTokens: 10000, language: "diff" })
30+
_.$`Generate a git conventional commit message that summarizes the changes in GIT_DIFF.
31+
- GIT_DIFF is generated by "git diff"
32+
- do NOT use markdown syntax
33+
- do NOT add quotes or code blocks
34+
- keep it short, 1 line only, maximum 50 characters
35+
- use emojis
36+
- do NOT confuse delete lines starting with '-' and add lines starting with '+'
37+
`
38+
},
39+
{
40+
model: "large", // Specifies the LLM model to use for message generation
41+
label: "generate commit message", // Label for the prompt task
42+
system: [
43+
"system.safety_jailbreak",
44+
"system.safety_harmful_content",
45+
"system.safety_ungrounded_content_summarization",
46+
],
47+
}
48+
)
49+
if (res.error) throw res.error
50+
51+
message = res.text
52+
if (!message) {
53+
console.log("No message generated, did you configure the LLM model?")
54+
break
55+
}
56+
57+
// Prompt user to accept, edit, or regenerate the commit message
58+
choice = await host.select(message, [
59+
{
60+
value: "commit",
61+
description: "accept message and commit",
62+
},
63+
{
64+
value: "edit",
65+
description: "edit message and commit",
66+
},
67+
{
68+
value: "regenerate",
69+
description: "regenerate message",
70+
},
71+
])
72+
73+
// Handle user's choice for commit message
74+
if (choice === "edit") {
75+
message = await host.input("Edit commit message", {
76+
required: true,
77+
})
78+
choice = "commit"
79+
}
80+
// If user chooses to commit, execute the git commit and optionally push changes
81+
if (choice === "commit" && message) {
82+
console.log(await git.exec(["commit", "-m", message]))
83+
if (await host.confirm("Push changes?", { default: true }))
84+
console.log(await git.exec("push"))
85+
break
86+
}
87+
} while (choice !== "commit")

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"package:vscode": "cd vscode && yarn package",
4242
"processvideos": "node scripts/processvideos.mjs",
4343
"bumprelease": "node scripts/bump.mjs --cloud",
44-
"changelog": "auto-changelog -o ./vscode/CHANGELOG.md --hide-credit --hide-empty-releases --ignore-commit-pattern \"(skip ci|bump bytecode|bump to)\""
44+
"changelog": "auto-changelog -o ./vscode/CHANGELOG.md --hide-credit --hide-empty-releases --ignore-commit-pattern \"(skip ci|bump bytecode|bump to)\"",
45+
"genai": "npx --yes genaiscript run",
46+
"gcm": "npx --yes genaiscript run gcm"
4547
},
4648
"workspaces": [
4749
"interop",

website/docs/getting-started/vscode/index.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ import StaticVideo from "@site/src/components/StaticVideo"
88

99
The [Visual Studio Code](https://code.visualstudio.com/) extension provides the best developer experience for DeviceScript.
1010

11-
- **install the [DeviceScript extension](https://marketplace.visualstudio.com/items?itemName=devicescript.devicescript-vscode)**
11+
- **find the latest release at [https://github.com/microsoft/devicescript/releases](https://github.com/microsoft/devicescript/releases?expanded=true)**
12+
- download `devicescript.vsix` from **Assets**
13+
- install the .vsix file in code
14+
15+
:::tip
16+
17+
The DeviceScript extension is not available from the Marketplace anymore.
18+
19+
:::
20+
1221

1322
You will also need
1423

@@ -27,7 +36,7 @@ You will also need
2736
- Device, services, register [Explorer view](./vscode/user-interface)
2837
- Register and Event watch
2938

30-
### (Optional) Manual installation from the GitHub releases
39+
### Manual installation from the GitHub releases
3140

3241
- **find the latest release at [https://github.com/microsoft/devicescript/releases](https://github.com/microsoft/devicescript/releases?expanded=true)**
3342
- download `devicescript.vsix` from **Assets**

0 commit comments

Comments
 (0)