From 7804894448d74aa7f49f111b5734c0b22871434d Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 27 Sep 2024 12:37:16 -0700 Subject: [PATCH] github.getfile, searchcode (#735) * Add getFileRevision method to GitHubClient for retrieving file content by ref * Add concurrency to workflow and refactor GitHub file retrieval method * Add code search functionality and sample script for GitHub integration * Remove env.secrets section and add defDiff documentation for comparing data * Add language specification for `def` in context documentation. * Add GitHub querying support with helper functions and examples --- .github/workflows/genai-investigator.yml | 4 + docs/genaisrc/genaiscript.d.ts | 32 +++++- .../content/docs/reference/scripts/context.md | 38 +++++-- .../content/docs/reference/scripts/github.md | 99 +++++++++++++++++++ genaisrc/genaiscript.d.ts | 32 +++++- packages/auto/genaiscript.d.ts | 32 +++++- packages/core/src/genaisrc/genaiscript.d.ts | 32 +++++- packages/core/src/github.ts | 51 +++++++++- packages/core/src/types/prompt_template.d.ts | 32 +++++- .../sample/genaisrc/blog/genaiscript.d.ts | 32 +++++- packages/sample/genaisrc/genaiscript.d.ts | 32 +++++- packages/sample/genaisrc/github.genai.mts | 27 +++++ .../sample/genaisrc/node/genaiscript.d.ts | 32 +++++- .../sample/genaisrc/python/genaiscript.d.ts | 32 +++++- .../sample/genaisrc/style/genaiscript.d.ts | 32 +++++- packages/sample/src/aici/genaiscript.d.ts | 32 +++++- packages/sample/src/errors/genaiscript.d.ts | 32 +++++- packages/sample/src/genaiscript.d.ts | 32 +++++- packages/sample/src/makecode/genaiscript.d.ts | 32 +++++- packages/sample/src/tla/genaiscript.d.ts | 32 +++++- packages/sample/src/vision/genaiscript.d.ts | 32 +++++- packages/vscode/genaisrc/genaiscript.d.ts | 32 +++++- slides/genaisrc/genaiscript.d.ts | 32 +++++- 23 files changed, 762 insertions(+), 33 deletions(-) create mode 100644 docs/src/content/docs/reference/scripts/github.md create mode 100644 packages/sample/genaisrc/github.genai.mts diff --git a/.github/workflows/genai-investigator.yml b/.github/workflows/genai-investigator.yml index 9ffafae486..08f5849704 100644 --- a/.github/workflows/genai-investigator.yml +++ b/.github/workflows/genai-investigator.yml @@ -4,6 +4,10 @@ on: workflows: ["build"] types: - completed +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.conclusion }} + cancel-in-progress: true + permissions: contents: read actions: read diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/docs/src/content/docs/reference/scripts/context.md b/docs/src/content/docs/reference/scripts/context.md index 3ab15657c9..0ee8ed6d16 100644 --- a/docs/src/content/docs/reference/scripts/context.md +++ b/docs/src/content/docs/reference/scripts/context.md @@ -70,16 +70,6 @@ const locale = env.vars.locale || "en-US" Read more about [variables](/genaiscript/reference/scripts/variables). -### `env.secrets` - -The `secrets` property contains the secrets that have been defined in the script execution context. - -```javascript -const token = env.secrets.SECRET_TOKEN -``` - -Read more about [secrets](/genaiscript/reference/scripts/secrets). - ## Definition (`def`) The `def("FILE", file)` function is a shorthand for generating a fenced variable output. @@ -104,6 +94,15 @@ The `def` function can also be used with an array of files, such as `env.files`. def("FILE", env.files) ``` +### Language + +You can specify the language of the text contained in `def`. This can help GenAIScript optimize the rendering of the text. + +```js 'language: "diff"' +// hint that the output is a diff +def("DIFF", gitdiff, { language: "diff" }) +``` + ### Referencing The `def` function returns a variable name that can be used in the prompt. @@ -210,3 +209,22 @@ defData("DATA", data, { sliceSample: 100, }) ``` + +## Diff Definition (`defDiff`) + +It is very common to compare two piece of data and ask the LLM to analyze the differences. Using diffs is a great way +to naturally compress the information since we only reason about differences! + +The `defDiff` takes care of formatting the diff in a way that helps LLM reason. It behaves similarly to `def` and assigns +a name to the diff. + +```js +// diff files +defDiff("DIFF", env.files[0], env.files[1]) + +// diff strings +defDiff("DIFF", "cat", "dog") + +// diff objects +defDiff("DIFF", { name: "cat" }, { name: "dog" }) +``` diff --git a/docs/src/content/docs/reference/scripts/github.md b/docs/src/content/docs/reference/scripts/github.md new file mode 100644 index 0000000000..6c9f839ea9 --- /dev/null +++ b/docs/src/content/docs/reference/scripts/github.md @@ -0,0 +1,99 @@ +--- +title: GitHub +description: Support for querying GitHub +sidebar: + order: 50 +--- + +The `github` provides several helper function to query github. It also provides the connection information for more advanced usage. + +## Configuration + +The `github` configuration is automatically sniffed from the environment and git. + +The GitHub token is read from the `GITHUB_TOKEN` environment variable. Some queries might work without authentication for public repositories. + +### GitHub CodeSpaces + +In a GitHub CodeSpace, the `GITHUB_TOKEN` is automatically provisioned. + +### GitHub Actions + +In GitHub Actions, you might will to add permissions to the +workspace to access workflow logs and pull requests. You also need to pass the `secret.GITHUB_TOKEN` to the genaiscript script run. + +```yml title="genai.yml" 'actions: read' 'GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}' +permissions: + contents: read + actions: read + pull-requests: read # or write if you plan to create comments +... + - run: npx --yes genaiscript ... + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ... +``` + +## Functions + +### Issues + +You can query issues and issue comments using `listIssues`, `listIssueComments`. + +```js +const issues = await github.listIssues({ per_page: 5 }) +console.log(issues.map((i) => i.title)) + +// use number! +const issueComments = await github.listIssueComments(issues[0].number) +console.log(issueComments) +``` + +### Pull Requests + +You can query pull requests and pull request reviews comments using `listPullRequests`, `listPullRequestReviewComments`. + +```js +const prs = await github.listPullRequests({ pre_page: 5 }) +console.log(prs.map((i) => i.title)) + +// use number! +const prcs = await github.listPullRequestReviewComments(prs[0].number) +console.log(prcs.map((i) => i.body)) +``` + +In GitHub Actions, you need to give the `pull-request: read` permission. + +### Workflow runs + +Access the log of workflow runs to analyze failures. + +```js +// list runs +const runs = await github.listWorkflowRuns("build.yml", { per_page: 5 }) +console.log(runs.map((i) => i.status)) + +const jobs = await github.listWorkflowJobs(runs[0].id) +// redacted job log +console.log(jobs[0].content) +``` + +In GitHub Actions, you need to give the `actions: read` permission. + +### Search Code + +Use `searchCode` for a code search on the default branch in the same repo. + +```js +const res = await github.searchCode("HTMLToText") +console.log(res) +``` + +### Get file content + +Gets the file content for a given ref, tag or commit sha. + +```js +const pkg = await github.getFile("package.json", "main") +console.log(pkg.content.slice(0, 50) + "...") +``` diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/core/src/github.ts b/packages/core/src/github.ts index 4b672eaffd..63a11d68c9 100644 --- a/packages/core/src/github.ts +++ b/packages/core/src/github.ts @@ -405,7 +405,7 @@ export async function githubCreatePullRequestReviews( export class GitHubClient implements GitHub { private _connection: Promise private _client: Promise< - { client: Octokit; owner: string; repo: string } | undefined + ({ client: Octokit } & GithubConnectionInfo) | undefined > constructor() {} @@ -420,15 +420,14 @@ export class GitHubClient implements GitHub { private async client() { if (!this._client) { this._client = new Promise(async (resolve) => { - const { owner, repo, token, apiUrl } = await this.connection() + const conn = await this.connection() + const { token, apiUrl } = conn const res = new Octokit({ userAgent: TOOL_ID, - owner, - repo, auth: token, baseUrl: apiUrl, }) - resolve({ client: res, owner: owner, repo: repo }) + resolve({ client: res, ...conn }) }) } return this._client @@ -615,4 +614,46 @@ export class GitHubClient implements GitHub { ) } } + + async getFile(filename: string, ref: string): Promise { + const { client, owner, repo } = await this.client() + const { data: content } = await client.rest.repos.getContent({ + owner, + repo, + path: filename, + ref, + }) + if ("content" in content) { + return { + filename, + content: Buffer.from(content.content, "base64").toString( + "utf-8" + ), + } + } else { + return undefined + } + } + + async searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise { + const { client, owner, repo } = await this.client() + const q = query + `+repo:${owner}/${repo}` + const { + data: { items }, + } = await client.rest.search.code({ + q, + ...(options || {}), + }) + return items.map(({ name, path, sha, html_url, score, repository }) => ({ + name, + path, + sha, + html_url, + score, + repository: repository.full_name, + })) + } } diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index bbd4612d74..69da5aa18e 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1078,7 +1078,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1327,6 +1327,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1399,6 +1408,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/genaisrc/github.genai.mts b/packages/sample/genaisrc/github.genai.mts new file mode 100644 index 0000000000..c7fb4c3f5b --- /dev/null +++ b/packages/sample/genaisrc/github.genai.mts @@ -0,0 +1,27 @@ +script({ + model: "openai:gpt-3.5-turbo", + tests: {}, +}) +const issues = await github.listIssues({ per_page: 5 }) +console.log(issues.map((i) => i.title)) +const issueComments = await github.listIssueComments(issues[0].number) +console.log(issueComments) + +const prs = await github.listPullRequests() +console.log(prs.slice(0, 5).map((i) => i.title)) + +const prcs = await github.listPullRequestReviewComments(prs[0].number) +console.log(prcs.map((i) => i.body)) + +const pkg = await github.getFile("package.json", "main") +console.log(pkg.content.slice(0, 50) + "...") + +const res = await github.searchCode("HTMLToText") +console.log(res) + +const runs = await github.listWorkflowRuns("build.yml", { per_page: 5 }) +console.log(runs.map((i) => i.status)) + +const jobs = await github.listWorkflowJobs(runs[0].id) +// redacted job log +console.log(jobs[0].content) \ No newline at end of file diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD { diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index 04197a895e..617bd46ccd 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1111,7 +1111,7 @@ interface Parsers { HTMLToText( content: string | WorkspaceFile, options?: HTMLToTextOptions - ): string + ): Promise /** * Convert HTML to markdown @@ -1360,6 +1360,15 @@ interface GitHubComment { interface GitHubPullRequest extends GitHubIssue {} +interface GitHubCodeSearchResult { + name: string + path: string + sha: string + html_url: string + score: number + repository: string +} + interface GitHub { /** * Gets connection information for octokit @@ -1432,6 +1441,27 @@ interface GitHub { pull_number: number, options?: { per_page?: number; page?: number } ): Promise + + /** + * Gets the content of a file from a GitHub repository + * @param filepath + * @param options + */ + getFile( + filepath: string, + /** + * commit sha, branch name or tag name + */ + ref: string + ): Promise + + /** + * Searches code in a GitHub repository + */ + searchCode( + query: string, + options?: { per_page?: number; page?: number } + ): Promise } interface MD {