diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/core/src/git.ts b/packages/core/src/git.ts index cd706e2327..4ed6b082e9 100644 --- a/packages/core/src/git.ts +++ b/packages/core/src/git.ts @@ -148,6 +148,8 @@ export class GitClient implements Git { excludedPaths: string[], args: string[] ) { + paths = paths || [] + excludedPaths = excludedPaths || [] if (paths.length > 0 || excludedPaths.length > 0) { if (!paths.length) paths.push(".") args.push("--") @@ -158,6 +160,50 @@ export class GitClient implements Git { } } + async lastTag(): Promise { + const res = await this.exec([ + "describe", + "--tags", + "--abbrev=0", + "HEAD^", + ]) + return res.split("\n")[0] + } + + async log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise { + const { base, head, merges, excludedGrep, paths, excludedPaths } = + options || {} + const args = ["log", "--pretty=oneline"] + if (!merges) args.push("--no-merges") + if (excludedGrep) { + const pattern = + typeof excludedGrep === "string" + ? excludedGrep + : excludedGrep.source + args.push(`--grep='${pattern}'`, "--invert-grep") + } + if (base && head) args.push(`${base}..${head}`) + GitClient.addFileFilters(paths, excludedPaths, args) + const res = await this.exec(args) + const commits = res + .split("\n") + .map( + (line) => + /^(?[a-z0-9]{40,40})\s+(?.*)$/.exec(line) + ?.groups + ) + .filter((g) => !!g) + .map((g) => { sha: g?.sha, message: g?.message }) + return commits + } + /** * Generates a diff of changes based on provided options. * @param options Options such as staged flag, base, head, paths, and exclusions. diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 5c6970e7d6..3979863329 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1274,12 +1274,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1334,6 +1344,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/genaisrc/git-release-notes.genai.mjs b/packages/sample/genaisrc/git-release-notes.genai.mjs index 6e400b9eec..aafad77d0f 100644 --- a/packages/sample/genaisrc/git-release-notes.genai.mjs +++ b/packages/sample/genaisrc/git-release-notes.genai.mjs @@ -1,4 +1,4 @@ -script({ system: ["system"], temperature: 0.5, model: "openai:gpt-4-turbo" }) +script({ system: ["system"], temperature: 0.5, model: "openai:gpt-4o" }) const product = env.vars.product || "GenAIScript" @@ -7,7 +7,7 @@ const { version } = await workspace.readJSON("package.json") const tag = await git.exec(["describe", "--tags", "--abbrev=0", "HEAD^"]) const commits = await git.exec([ "log", - "--grep='(skip ci|THIRD_PARTY_NOTICES)'", + "--grep='(skip ci|THIRD_PARTY_NOTICES|genai)'", "--invert-grep", "--no-merges", `HEAD...${tag}`, @@ -22,8 +22,8 @@ const diff = await git.diff({ "docs/**", ".github/*", ".vscode/*", - "*yarn.lock", - "*THIRD_PARTY_NOTICES.md", + "**/yarn.lock", + "THIRD_PARTY_NOTICES.md", ], }) diff --git a/packages/sample/genaisrc/git.genai.mts b/packages/sample/genaisrc/git.genai.mts index 60d298ec3f..87ffb44e0b 100644 --- a/packages/sample/genaisrc/git.genai.mts +++ b/packages/sample/genaisrc/git.genai.mts @@ -1,7 +1,8 @@ const defaultBranch = await git.defaultBranch() const branch = await git.branch() +const tag = await git.lastTag() const branches = await git.listBranches() -console.log({ defaultBranch, branch, branches }) +console.log({ defaultBranch, branch, branches, tag }) const mods = await git.listFiles("modified", { paths: ["**/*.ts"], @@ -20,3 +21,6 @@ const files = await git.listFiles("modified-base", { excludedPaths: ["**/genaiscript.d.ts"], }) console.log({ files }) + +const log = await git.log() +console.log({ log }) diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/genaisrc/pr-create.genai.mts b/packages/sample/genaisrc/pr-create.genai.mts index 5698c5c6a9..fb4293e2a3 100644 --- a/packages/sample/genaisrc/pr-create.genai.mts +++ b/packages/sample/genaisrc/pr-create.genai.mts @@ -16,7 +16,7 @@ const { text, error } = await runPrompt(async (_) => { "genaisrc/*", ".github/*", ".vscode/*", - "*yarn.lock", + "**/yarn.lock", "*THIRD_PARTY_LICENSES.md", ], }) diff --git a/packages/sample/genaisrc/pr-describe.genai.mjs b/packages/sample/genaisrc/pr-describe.genai.mjs index c7ee85f61c..b827b77507 100644 --- a/packages/sample/genaisrc/pr-describe.genai.mjs +++ b/packages/sample/genaisrc/pr-describe.genai.mjs @@ -23,7 +23,7 @@ const changes = await git.diff({ "genaisrc/*", ".github/*", ".vscode/*", - "*yarn.lock", + "**/yarn.lock", "*THIRD_PARTY_LICENSES.md", ], }) diff --git a/packages/sample/genaisrc/pr-review.genai.mjs b/packages/sample/genaisrc/pr-review.genai.mjs index b321b7e05c..20e0317562 100644 --- a/packages/sample/genaisrc/pr-review.genai.mjs +++ b/packages/sample/genaisrc/pr-review.genai.mjs @@ -16,7 +16,7 @@ const diff = await git.diff({ "genaisrc/*", ".github/*", ".vscode/*", - "*yarn.lock", + "**/yarn.lock", "*THIRD_PARTY_LICENSES.md", ], }) diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions { diff --git a/packages/vscode/genaisrc/prd.genai.mts b/packages/vscode/genaisrc/prd.genai.mts index 7aa853ee37..3b7f8cfacd 100644 --- a/packages/vscode/genaisrc/prd.genai.mts +++ b/packages/vscode/genaisrc/prd.genai.mts @@ -10,7 +10,7 @@ const changes = await git.diff({ base: defaultBranch, excludedPaths: [ ".vscode/*", - "*yarn.lock", + "**/yarn.lock", "**/genaiscript.d.ts", "*THIRD_PARTY_LICENSES.md", ], diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index f3d7f25f6e..8b2679f47d 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1335,12 +1335,22 @@ interface HTML { convertToMarkdown(html: string): Promise } +interface GitCommit { + sha: string + message: string +} + interface Git { /** * Resolves the default branch for this repository */ defaultBranch(): Promise + /** + * Gets the last tag in the repository + */ + lastTag(): Promise + /** * Gets the current branch of the repository */ @@ -1395,6 +1405,18 @@ interface Git { */ llmify?: boolean }): Promise + + /** + * Lists the commits in the git repository + */ + log(options?: { + base?: string + head?: string + merges?: boolean + excludedGrep?: string | RegExp + paths: string[] + excludedPaths: string[] + }): Promise } interface GitHubOptions {