From 02594e842395a9f5d7c9b2b01a32a6c9a58574cc Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 3 Oct 2024 01:13:04 +0000 Subject: [PATCH 1/4] Refactor GitHub Actions integration to include 'llm_id' for improved tool interoperability --- docs/genaisrc/genaiscript.d.ts | 12 +- docs/src/components/BuiltinTools.mdx | 6 +- .../content/docs/reference/scripts/system.mdx | 24 ++-- genaisrc/genaiscript.d.ts | 12 +- packages/auto/genaiscript.d.ts | 12 +- packages/core/src/constants.ts | 6 + packages/core/src/genaisrc/genaiscript.d.ts | 12 +- .../genaisrc/system.github_actions.genai.mjs | 18 ++- packages/core/src/github.ts | 118 +++++++++++++++--- packages/core/src/llmid.ts | 22 ++++ packages/core/src/types/prompt_template.d.ts | 12 +- .../sample/genaisrc/blog/genaiscript.d.ts | 12 +- packages/sample/genaisrc/genaiscript.d.ts | 12 +- .../sample/genaisrc/node/genaiscript.d.ts | 12 +- .../sample/genaisrc/python/genaiscript.d.ts | 12 +- .../sample/genaisrc/style/genaiscript.d.ts | 12 +- packages/sample/src/aici/genaiscript.d.ts | 12 +- packages/sample/src/errors/genaiscript.d.ts | 12 +- packages/sample/src/genaiscript.d.ts | 12 +- packages/sample/src/makecode/genaiscript.d.ts | 12 +- packages/sample/src/tla/genaiscript.d.ts | 12 +- packages/sample/src/vision/genaiscript.d.ts | 12 +- packages/vscode/genaisrc/genaiscript.d.ts | 12 +- slides/genaisrc/genaiscript.d.ts | 12 +- 24 files changed, 322 insertions(+), 88 deletions(-) create mode 100644 packages/core/src/llmid.ts diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index 276a2e0a06..0c1973663e 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -20,9 +20,9 @@ import { LinkCard } from '@astrojs/starlight/components'; - - - + + + diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index ab360c9efd..f4c20a090c 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -961,9 +961,9 @@ github workflows Queries results from workflows in GitHub actions. -- tool `github_actions_workflows_list`: List all workflows as a list of 'id: name' pair. -- tool `github_actions_runs_list`: List all runs for a workflow. Use 'git_actions_list_workflows' to list workflows. -- tool `github_actions_jobs_list`: List all jobs for a run. +- tool `github_actions_workflows_list`: List all workflows. 'llm_id' is the ID used in other tools. +- tool `github_actions_runs_list`: List all runs for a workflow. 'llm_id' is the ID used in other tools. Use 'git_actions_list_workflows' to list workflows. +- tool `github_actions_jobs_list`: List all jobs for a run. 'llm_id' is the ID used in other tools. - tool `github_actions_job_logs_get`: Download workflow job log. If the log is too large, use 'github_actions_job_logs_diff' to compare logs. - tool `github_actions_job_logs_diff`: Diffs two workflow job logsr. @@ -975,14 +975,14 @@ system({ defTool( "github_actions_workflows_list", - "List all workflows as a list of 'id: name' pair.", + "List all workflows. 'llm_id' is the ID used in other tools.", {}, async (args) => { const { context } = args context.log("github action list workflows") const res = await github.listWorkflows() return CSV.stringify( - res.map(({ id, name, path }) => ({ id, name, path })), + res.map(({ llm_id, name, path }) => ({ llm_id, name, path })), { header: true } ) } @@ -990,7 +990,7 @@ defTool( defTool( "github_actions_runs_list", - "List all runs for a workflow. Use 'git_actions_list_workflows' to list workflows.", + "List all runs for a workflow. 'llm_id' is the ID used in other tools. Use 'git_actions_list_workflows' to list workflows.", { type: "object", properties: { @@ -1020,8 +1020,9 @@ defTool( status, }) return CSV.stringify( - res.map(({ id, name, conclusion, head_sha }) => ({ + res.map(({ id, llm_id, name, conclusion, head_sha }) => ({ id, + llm_id, name, conclusion, head_sha, @@ -1033,7 +1034,7 @@ defTool( defTool( "github_actions_jobs_list", - "List all jobs for a run.", + "List all jobs for a run. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -1050,7 +1051,12 @@ defTool( context.log(`github action list jobs for run ${run_id}`) const res = await github.listWorkflowJobs(run_id) return CSV.stringify( - res.map(({ id, name, status }) => ({ id, name, status })), + res.map(({ id, llm_id, name, status }) => ({ + id, + llm_id, + name, + status, + })), { header: true } ) } diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index aee86336ec..dddecf67d7 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -249,3 +249,9 @@ export const GITHUB_REST_API_CONCURRENCY_LIMIT = 8 export const GITHUB_REST_PAGE_DEFAULT = 50 export const TOKEN_TRUNCATION_THRESHOLD = 128 + +export const LLMID_GITHUB_WORKFLOW = "gh_workflow" +export const LLMID_GITHUB_WORKFLOW_RUN = "gh_run" +export const LLMID_GITHUB_WORKFLOW_JOB = "gh_job" +export const LLMID_GITHUB_ISSUE = "gh_issue" +export const LLMID_GITHUB_PULL_REQUEST = "gh_pull" diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/core/src/genaisrc/system.github_actions.genai.mjs b/packages/core/src/genaisrc/system.github_actions.genai.mjs index d5584152f6..4e2a770df7 100644 --- a/packages/core/src/genaisrc/system.github_actions.genai.mjs +++ b/packages/core/src/genaisrc/system.github_actions.genai.mjs @@ -5,14 +5,14 @@ system({ defTool( "github_actions_workflows_list", - "List all workflows as a list of 'id: name' pair.", + "List all workflows. 'llm_id' is the ID used in other tools.", {}, async (args) => { const { context } = args context.log("github action list workflows") const res = await github.listWorkflows() return CSV.stringify( - res.map(({ id, name, path }) => ({ id, name, path })), + res.map(({ llm_id, name, path }) => ({ llm_id, name, path })), { header: true } ) } @@ -20,7 +20,7 @@ defTool( defTool( "github_actions_runs_list", - "List all runs for a workflow. Use 'git_actions_list_workflows' to list workflows.", + "List all runs for a workflow. 'llm_id' is the ID used in other tools. Use 'git_actions_list_workflows' to list workflows.", { type: "object", properties: { @@ -50,8 +50,9 @@ defTool( status, }) return CSV.stringify( - res.map(({ id, name, conclusion, head_sha }) => ({ + res.map(({ id, llm_id, name, conclusion, head_sha }) => ({ id, + llm_id, name, conclusion, head_sha, @@ -63,7 +64,7 @@ defTool( defTool( "github_actions_jobs_list", - "List all jobs for a run.", + "List all jobs for a run. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -80,7 +81,12 @@ defTool( context.log(`github action list jobs for run ${run_id}`) const res = await github.listWorkflowJobs(run_id) return CSV.stringify( - res.map(({ id, name, status }) => ({ id, name, status })), + res.map(({ id, llm_id, name, status }) => ({ + id, + llm_id, + name, + status, + })), { header: true } ) } diff --git a/packages/core/src/github.ts b/packages/core/src/github.ts index 634202ce79..52d1e0b173 100644 --- a/packages/core/src/github.ts +++ b/packages/core/src/github.ts @@ -6,6 +6,11 @@ import { GITHUB_REST_API_CONCURRENCY_LIMIT, GITHUB_REST_PAGE_DEFAULT, GITHUB_TOKEN, + LLMID_GITHUB_ISSUE, + LLMID_GITHUB_PULL_REQUEST, + LLMID_GITHUB_WORKFLOW, + LLMID_GITHUB_WORKFLOW_JOB, + LLMID_GITHUB_WORKFLOW_RUN, TOOL_ID, } from "./constants" import { createFetch } from "./fetch" @@ -17,6 +22,7 @@ import { isGlobMatch } from "./glob" import { fetchText } from "./fetch" import { concurrentLimit } from "./concurrency" import { createDiff, llmifyDiff } from "./diff" +import { llmifyId, unllmifyId, unllmifyIntId } from "./llmid" export interface GithubConnectionInfo { token: string @@ -543,7 +549,19 @@ export class GitHubClient implements GitHub { ...rest, }) const res = await paginatorToArray(ite, count, (i) => i.data) - return res + return res.map( + ({ id, number, title, state, html_url, created_at }) => + { + id, + llm_id: llmifyId(id, LLMID_GITHUB_ISSUE), + number, + llm_number: llmifyId(number, LLMID_GITHUB_ISSUE), + title, + state, + html_url, + created_at, + } + ) } async getIssue(issue_number: number): Promise { @@ -553,7 +571,17 @@ export class GitHubClient implements GitHub { repo, issue_number, }) - return data + const { id, number, title, state, html_url, created_at } = data + return { + id, + llm_id: llmifyId(id, LLMID_GITHUB_ISSUE), + number, + llm_number: llmifyId(number, LLMID_GITHUB_ISSUE), + title, + state, + html_url, + created_at, + } } async listPullRequests( @@ -571,7 +599,19 @@ export class GitHubClient implements GitHub { ...rest, }) const res = await paginatorToArray(ite, count, (i) => i.data) - return res + return res.map( + ({ id, number, title, state, html_url, created_at }) => + { + id, + llm_id: llmifyId(id, LLMID_GITHUB_PULL_REQUEST), + number, + llm_number: llmifyId(number, LLMID_GITHUB_PULL_REQUEST), + title, + state, + html_url, + created_at, + } + ) } async getPullRequest(pull_number: number): Promise { @@ -581,7 +621,17 @@ export class GitHubClient implements GitHub { repo, pull_number, }) - return data + const { id, number, title, state, html_url, created_at } = data + return { + id, + llm_id: llmifyId(id, LLMID_GITHUB_PULL_REQUEST), + number, + llm_number: llmifyId(number, LLMID_GITHUB_PULL_REQUEST), + title, + state, + html_url, + created_at, + } } async listPullRequestReviewComments( @@ -637,7 +687,10 @@ export class GitHubClient implements GitHub { { owner, repo, - workflow_id: workflowIdOrFilename, + workflow_id: unllmifyId( + workflowIdOrFilename, + LLMID_GITHUB_WORKFLOW + ), per_page: 100, ...rest, } @@ -648,11 +701,34 @@ export class GitHubClient implements GitHub { (i) => i.data, ({ conclusion }) => conclusion !== "skipped" ) - return res + return res.map( + ({ + id, + name, + status, + conclusion, + html_url, + display_title, + created_at, + head_branch, + head_sha, + }) => ({ + id, + llm_id: llmifyId(id, LLMID_GITHUB_WORKFLOW), + name, + status, + conclusion, + html_url, + display_title, + created_at, + head_branch, + head_sha, + }) + ) } async listWorkflowJobs( - run_id: number, + run_id: number | string, options?: GitHubPaginationOptions ): Promise { // Get the jobs for the specified workflow run @@ -663,7 +739,7 @@ export class GitHubClient implements GitHub { { owner, repo, - run_id, + run_id: unllmifyIntId(run_id, LLMID_GITHUB_WORKFLOW), } ) const jobs = await paginatorToArray(ite, count, (i) => i.data) @@ -679,6 +755,8 @@ export class GitHubClient implements GitHub { const { text } = await fetchText(logs_url) res.push({ ...job, + llm_id: llmifyId(job.id, LLMID_GITHUB_WORKFLOW_JOB), + llm_run_id: llmifyId(job.run_id, LLMID_GITHUB_WORKFLOW_RUN), logs_url, logs: text, content: parseJobLog(text), @@ -700,7 +778,7 @@ export class GitHubClient implements GitHub { await client.rest.actions.downloadJobLogsForWorkflowRun({ owner, repo, - job_id, + job_id: unllmifyIntId(job_id, LLMID_GITHUB_WORKFLOW_JOB), }) let { text } = await fetchText(logs_url) if (options?.llmify) text = parseJobLog(text) @@ -722,8 +800,12 @@ export class GitHubClient implements GitHub { } async diffWorkflowJobLogs(job_id: number, other_job_id: number) { - const job = await this.downladJob(job_id) - const other = await this.downladJob(other_job_id) + const job = await this.downladJob( + unllmifyIntId(job_id, LLMID_GITHUB_WORKFLOW_JOB) + ) + const other = await this.downladJob( + unllmifyIntId(other_job_id, LLMID_GITHUB_WORKFLOW_JOB) + ) job.content = parseJobLog(job.content) other.content = parseJobLog(other.content) @@ -790,11 +872,15 @@ export class GitHubClient implements GitHub { } ) const workflows = await paginatorToArray(ite, count, (i) => i.data) - return workflows.map(({ id, name, path }) => ({ - id, - name, - path, - })) + return workflows.map( + ({ id, name, path }) => + { + id, + llm_id: llmifyId(id, LLMID_GITHUB_WORKFLOW), + name, + path, + } + ) } async listBranches(options?: GitHubPaginationOptions): Promise { diff --git a/packages/core/src/llmid.ts b/packages/core/src/llmid.ts new file mode 100644 index 0000000000..ac72080b49 --- /dev/null +++ b/packages/core/src/llmid.ts @@ -0,0 +1,22 @@ +export function llmifyId(id: number, prefix: string): string { + return `${prefix}_${id}` +} + +export function unllmifyIntId(llmid: string | number, prefix: string): number { + if (typeof llmid === "number") return llmid + const sid = llmid as string + const { p, id } = /^(?

\w+)_(?.*)$/.exec(sid)?.groups || {} + const i = parseInt(id) + return prefix === p && !isNaN(i) ? i : parseInt(llmid) +} + +export function unllmifyId( + llmid: string | number, + prefix: string +): number | string { + if (typeof llmid === "number") return llmid + const sid = llmid as string + const { p, id } = /^(?

\w+)_(?.*)$/.exec(sid)?.groups || {} + const i = parseInt(id) + return prefix === p && !isNaN(i) ? i : llmid +} diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 19d97f770e..6cfe772f0e 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1401,6 +1401,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1413,7 +1414,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1427,9 +1430,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1473,6 +1478,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1523,7 +1529,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1532,14 +1538,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index e1c93943fb..ee49c5dd0c 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1475,6 +1475,7 @@ type GitHubWorkflowRunStatus = interface GitHubWorkflowRun { id: number + llm_id: string name?: string display_title: string status: string @@ -1487,7 +1488,9 @@ interface GitHubWorkflowRun { interface GitHubWorkflowJob { id: number + llm_id: string run_id: number + llm_run_id: string status: string conclusion: string name: string @@ -1501,9 +1504,11 @@ interface GitHubWorkflowJob { interface GitHubIssue { id: number + llm_id: string body?: string title: string number: number + llm_number: string state: string state_reason?: "completed" | "reopened" | "not_planned" | null html_url: string @@ -1547,6 +1552,7 @@ interface GitHubCodeSearchResult { interface GitHubWorkflow { id: number + llm_id: string name: string path: string } @@ -1597,7 +1603,7 @@ interface GitHub { * @param runId */ listWorkflowJobs( - runId: number, + runId: number | string, options?: GitHubPaginationOptions ): Promise @@ -1606,14 +1612,14 @@ interface GitHub { * @param jobId */ downloadWorkflowJobLog( - jobId: number, + jobId: number | string, options?: { llmify?: boolean } ): Promise /** * Diffs two GitHub Action workflow job logs */ - diffWorkflowJobLogs(job_id: number, other_job_id: number): Promise + diffWorkflowJobLogs(job_id: number | string, other_job_id: number | string): Promise /** * Lists issues for a given repository From 7026599c66959db25e79b7a7b55008ab0a884984 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 3 Oct 2024 01:13:58 +0000 Subject: [PATCH 2/4] Add variable 'x' to poem.genai.mts file. --- packages/sample/genaisrc/poem.genai.mts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sample/genaisrc/poem.genai.mts b/packages/sample/genaisrc/poem.genai.mts index df55f31d3a..6e5e61cd09 100644 --- a/packages/sample/genaisrc/poem.genai.mts +++ b/packages/sample/genaisrc/poem.genai.mts @@ -1 +1,2 @@ $`Write a short poem.` +x \ No newline at end of file From 11e1fc7a17dc43f5588b85f53aa1dc09d3b5e75d Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 3 Oct 2024 01:22:22 +0000 Subject: [PATCH 3/4] Add LLM ID support to GitHub issue and pull request tools for integration --- docs/genaisrc/genaiscript.d.ts | 1 + docs/src/components/BuiltinTools.mdx | 12 ++--- .../content/docs/reference/scripts/system.mdx | 45 +++++++++++-------- genaisrc/genaiscript.d.ts | 1 + packages/auto/genaiscript.d.ts | 1 + packages/core/src/constants.ts | 2 + packages/core/src/genaisrc/genaiscript.d.ts | 1 + .../genaisrc/system.github_issues.genai.mjs | 19 +++++--- .../genaisrc/system.github_pulls.genai.mjs | 14 +++--- packages/core/src/github.ts | 42 ++++++++++++++--- packages/core/src/types/prompt_template.d.ts | 1 + .../sample/genaisrc/blog/genaiscript.d.ts | 1 + packages/sample/genaisrc/genaiscript.d.ts | 1 + .../sample/genaisrc/node/genaiscript.d.ts | 1 + .../sample/genaisrc/python/genaiscript.d.ts | 1 + .../sample/genaisrc/style/genaiscript.d.ts | 1 + packages/sample/src/aici/genaiscript.d.ts | 1 + packages/sample/src/errors/genaiscript.d.ts | 1 + packages/sample/src/genaiscript.d.ts | 1 + packages/sample/src/makecode/genaiscript.d.ts | 1 + packages/sample/src/tla/genaiscript.d.ts | 1 + packages/sample/src/vision/genaiscript.d.ts | 1 + packages/vscode/genaisrc/genaiscript.d.ts | 1 + slides/genaisrc/genaiscript.d.ts | 1 + 24 files changed, 110 insertions(+), 42 deletions(-) diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index 0c1973663e..68d285106a 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -27,12 +27,12 @@ import { LinkCard } from '@astrojs/starlight/components'; - - - - - - + + + + + + diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index f4c20a090c..e93c96c5d7 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -1189,9 +1189,9 @@ Tools to query GitHub issues. -- tool `github_issues_list`: List all issues in a repository. -- tool `github_issues_get`: Get a single issue by number. -- tool `github_issues_comments_list`: Get comments for an issue. +- tool `github_issues_list`: List all issues in a repository. 'llm_number' is the ID used in other tools. +- tool `github_issues_get`: Get a single issue by number. 'llm_number' is the ID used in other tools. +- tool `github_issues_comments_list`: Get comments for an issue. 'llm_id' is the ID used in other tools. `````js wrap title="system.github_issues" system({ @@ -1200,7 +1200,7 @@ system({ defTool( "github_issues_list", - "List all issues in a repository.", + "List all issues in a repository. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -1229,7 +1229,12 @@ defTool( context.log(`github issue list ${state ?? "all"}`) const res = await github.listIssues({ state, labels, sort, direction }) return CSV.stringify( - res.map(({ number, title, state }) => ({ number, title, state })), + res.map(({ number, llm_number, title, state }) => ({ + number, + llm_number, + title, + state, + })), { header: true } ) } @@ -1237,7 +1242,7 @@ defTool( defTool( "github_issues_get", - "Get a single issue by number.", + "Get a single issue by number. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -1251,10 +1256,11 @@ defTool( async (args) => { const { number: issue_number, context } = args context.log(`github issue get ${issue_number}`) - const { number, title, body, state, html_url, reactions } = + const { number, llm_number, title, body, state, html_url, reactions } = await github.getIssue(issue_number) return YAML.stringify({ number, + llm_number, title, body, state, @@ -1266,7 +1272,7 @@ defTool( defTool( "github_issues_comments_list", - "Get comments for an issue.", + "Get comments for an issue. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -1282,8 +1288,9 @@ defTool( context.log(`github issue list comments ${issue_number}`) const res = await github.listIssueComments(issue_number) return CSV.stringify( - res.map(({ id, body, updated_at }) => ({ + res.map(({ id, llm_id, body, updated_at }) => ({ id, + llm_id, body, updated_at, })), @@ -1301,9 +1308,9 @@ Tools to query GitHub pull requests. -- tool `github_pulls_list`: List all pull requests in a repository. -- tool `github_pulls_get`: Get a single pull request by number. -- tool `github_pulls_review_comments_list`: Get review comments for a pull request. +- tool `github_pulls_list`: List all pull requests in a repository. 'llm_number' is the ID used in other tools. +- tool `github_pulls_get`: Get a single pull request by number. 'llm_number' is the ID used in other tools. +- tool `github_pulls_review_comments_list`: Get review comments for a pull request. 'llm_id' is the ID used in other tools. `````js wrap title="system.github_pulls" system({ @@ -1312,7 +1319,7 @@ system({ defTool( "github_pulls_list", - "List all pull requests in a repository.", + "List all pull requests in a repository. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -1341,8 +1348,9 @@ defTool( context.log(`github pull list`) const res = await github.listPullRequests({ state, sort, direction }) return CSV.stringify( - res.map(({ number, title, state, body }) => ({ + res.map(({ number, llm_number, title, state, body }) => ({ number, + llm_number, title, state, })), @@ -1353,7 +1361,7 @@ defTool( defTool( "github_pulls_get", - "Get a single pull request by number.", + "Get a single pull request by number. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -1367,10 +1375,11 @@ defTool( async (args) => { const { number: pull_number, context } = args context.log(`github pull get ${pull_number}`) - const { number, title, body, state, html_url, reactions } = + const { number, llm_number, title, body, state, html_url, reactions } = await github.getPullRequest(pull_number) return YAML.stringify({ number, + llm_number, title, body, state, @@ -1382,7 +1391,7 @@ defTool( defTool( "github_pulls_review_comments_list", - "Get review comments for a pull request.", + "Get review comments for a pull request. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -1399,7 +1408,7 @@ defTool( context.log(`github pull comments list ${pull_number}`) const res = await github.listPullRequestReviewComments(pull_number) return CSV.stringify( - res.map(({ id, body }) => ({ id, body })), + res.map(({ id, llm_id, body }) => ({ id, llm_id, body })), { header: true } ) } diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index dddecf67d7..766bec880e 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -254,4 +254,6 @@ export const LLMID_GITHUB_WORKFLOW = "gh_workflow" export const LLMID_GITHUB_WORKFLOW_RUN = "gh_run" export const LLMID_GITHUB_WORKFLOW_JOB = "gh_job" export const LLMID_GITHUB_ISSUE = "gh_issue" +export const LLMID_GITHUB_ISSUE_COMMENT = "gh_issue_comment" export const LLMID_GITHUB_PULL_REQUEST = "gh_pull" +export const LLMID_GITHUB_PULL_REQUEST_REVIEW_COMMENT = "gh_pull_review_comment" diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/core/src/genaisrc/system.github_issues.genai.mjs b/packages/core/src/genaisrc/system.github_issues.genai.mjs index 767d6e7c17..d88442ba1a 100644 --- a/packages/core/src/genaisrc/system.github_issues.genai.mjs +++ b/packages/core/src/genaisrc/system.github_issues.genai.mjs @@ -4,7 +4,7 @@ system({ defTool( "github_issues_list", - "List all issues in a repository.", + "List all issues in a repository. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -33,7 +33,12 @@ defTool( context.log(`github issue list ${state ?? "all"}`) const res = await github.listIssues({ state, labels, sort, direction }) return CSV.stringify( - res.map(({ number, title, state }) => ({ number, title, state })), + res.map(({ number, llm_number, title, state }) => ({ + number, + llm_number, + title, + state, + })), { header: true } ) } @@ -41,7 +46,7 @@ defTool( defTool( "github_issues_get", - "Get a single issue by number.", + "Get a single issue by number. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -55,10 +60,11 @@ defTool( async (args) => { const { number: issue_number, context } = args context.log(`github issue get ${issue_number}`) - const { number, title, body, state, html_url, reactions } = + const { number, llm_number, title, body, state, html_url, reactions } = await github.getIssue(issue_number) return YAML.stringify({ number, + llm_number, title, body, state, @@ -70,7 +76,7 @@ defTool( defTool( "github_issues_comments_list", - "Get comments for an issue.", + "Get comments for an issue. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -86,8 +92,9 @@ defTool( context.log(`github issue list comments ${issue_number}`) const res = await github.listIssueComments(issue_number) return CSV.stringify( - res.map(({ id, body, updated_at }) => ({ + res.map(({ id, llm_id, body, updated_at }) => ({ id, + llm_id, body, updated_at, })), diff --git a/packages/core/src/genaisrc/system.github_pulls.genai.mjs b/packages/core/src/genaisrc/system.github_pulls.genai.mjs index f61a82f184..a3d2ec9a8e 100644 --- a/packages/core/src/genaisrc/system.github_pulls.genai.mjs +++ b/packages/core/src/genaisrc/system.github_pulls.genai.mjs @@ -4,7 +4,7 @@ system({ defTool( "github_pulls_list", - "List all pull requests in a repository.", + "List all pull requests in a repository. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -33,8 +33,9 @@ defTool( context.log(`github pull list`) const res = await github.listPullRequests({ state, sort, direction }) return CSV.stringify( - res.map(({ number, title, state, body }) => ({ + res.map(({ number, llm_number, title, state, body }) => ({ number, + llm_number, title, state, })), @@ -45,7 +46,7 @@ defTool( defTool( "github_pulls_get", - "Get a single pull request by number.", + "Get a single pull request by number. 'llm_number' is the ID used in other tools.", { type: "object", properties: { @@ -59,10 +60,11 @@ defTool( async (args) => { const { number: pull_number, context } = args context.log(`github pull get ${pull_number}`) - const { number, title, body, state, html_url, reactions } = + const { number, llm_number, title, body, state, html_url, reactions } = await github.getPullRequest(pull_number) return YAML.stringify({ number, + llm_number, title, body, state, @@ -74,7 +76,7 @@ defTool( defTool( "github_pulls_review_comments_list", - "Get review comments for a pull request.", + "Get review comments for a pull request. 'llm_id' is the ID used in other tools.", { type: "object", properties: { @@ -91,7 +93,7 @@ defTool( context.log(`github pull comments list ${pull_number}`) const res = await github.listPullRequestReviewComments(pull_number) return CSV.stringify( - res.map(({ id, body }) => ({ id, body })), + res.map(({ id, llm_id, body }) => ({ id, llm_id, body })), { header: true } ) } diff --git a/packages/core/src/github.ts b/packages/core/src/github.ts index 52d1e0b173..d64ca388fa 100644 --- a/packages/core/src/github.ts +++ b/packages/core/src/github.ts @@ -7,7 +7,9 @@ import { GITHUB_REST_PAGE_DEFAULT, GITHUB_TOKEN, LLMID_GITHUB_ISSUE, + LLMID_GITHUB_ISSUE_COMMENT, LLMID_GITHUB_PULL_REQUEST, + LLMID_GITHUB_PULL_REQUEST_REVIEW_COMMENT, LLMID_GITHUB_WORKFLOW, LLMID_GITHUB_WORKFLOW_JOB, LLMID_GITHUB_WORKFLOW_RUN, @@ -569,7 +571,7 @@ export class GitHubClient implements GitHub { const { data } = await client.rest.issues.get({ owner, repo, - issue_number, + issue_number: unllmifyIntId(issue_number, LLMID_GITHUB_ISSUE), }) const { id, number, title, state, html_url, created_at } = data return { @@ -619,7 +621,7 @@ export class GitHubClient implements GitHub { const { data } = await client.rest.pulls.get({ owner, repo, - pull_number, + pull_number: unllmifyIntId(pull_number, LLMID_GITHUB_PULL_REQUEST), }) const { id, number, title, state, html_url, created_at } = data return { @@ -645,12 +647,29 @@ export class GitHubClient implements GitHub { { owner, repo, - pull_number, + pull_number: unllmifyIntId( + pull_number, + LLMID_GITHUB_PULL_REQUEST + ), ...rest, } ) const res = await paginatorToArray(ite, count, (i) => i.data) - return res + return res.map( + ({ id, body, created_at, user, updated_at, html_url }) => + { + id, + llm_id: llmifyId( + id, + LLMID_GITHUB_PULL_REQUEST_REVIEW_COMMENT + ), + body, + created_at, + user, + updated_at, + html_url, + } + ) } async listIssueComments( @@ -666,11 +685,22 @@ export class GitHubClient implements GitHub { const ite = client.paginate.iterator(client.rest.issues.listComments, { owner, repo, - issue_number, + issue_number: unllmifyIntId(issue_number, LLMID_GITHUB_ISSUE), ...rest, }) const res = await paginatorToArray(ite, count, (i) => i.data) - return res + return res.map( + ({ id, body, created_at, user, updated_at, html_url }) => + { + id, + llm_id: llmifyId(id, LLMID_GITHUB_ISSUE_COMMENT), + body, + created_at, + user, + updated_at, + html_url, + } + ) } async listWorkflowRuns( diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 6cfe772f0e..4eb00b1e98 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1457,6 +1457,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index ee49c5dd0c..3e5ae5a9c2 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1531,6 +1531,7 @@ interface GitHubReactions { interface GitHubComment { id: number + llm_id: string body?: string created_at: string updated_at: string From d3c39b7fc4c84e9813fb5ac4f0884a132a80d914 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 3 Oct 2024 01:24:41 +0000 Subject: [PATCH 4/4] Remove unused 'id' and 'number' fields and update sample poem file. --- .../src/content/docs/reference/scripts/system.mdx | 15 +++++---------- .../src/genaisrc/system.github_actions.genai.mjs | 6 ++---- .../src/genaisrc/system.github_issues.genai.mjs | 9 +++------ packages/sample/genaisrc/poem.genai.mts | 4 +++- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index e93c96c5d7..09518c1f77 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -1020,8 +1020,7 @@ defTool( status, }) return CSV.stringify( - res.map(({ id, llm_id, name, conclusion, head_sha }) => ({ - id, + res.map(({ llm_id, name, conclusion, head_sha }) => ({ llm_id, name, conclusion, @@ -1051,8 +1050,7 @@ defTool( context.log(`github action list jobs for run ${run_id}`) const res = await github.listWorkflowJobs(run_id) return CSV.stringify( - res.map(({ id, llm_id, name, status }) => ({ - id, + res.map(({ llm_id, name, status }) => ({ llm_id, name, status, @@ -1229,8 +1227,7 @@ defTool( context.log(`github issue list ${state ?? "all"}`) const res = await github.listIssues({ state, labels, sort, direction }) return CSV.stringify( - res.map(({ number, llm_number, title, state }) => ({ - number, + res.map(({ llm_number, title, state }) => ({ llm_number, title, state, @@ -1256,10 +1253,9 @@ defTool( async (args) => { const { number: issue_number, context } = args context.log(`github issue get ${issue_number}`) - const { number, llm_number, title, body, state, html_url, reactions } = + const { llm_number, title, body, state, html_url, reactions } = await github.getIssue(issue_number) return YAML.stringify({ - number, llm_number, title, body, @@ -1288,8 +1284,7 @@ defTool( context.log(`github issue list comments ${issue_number}`) const res = await github.listIssueComments(issue_number) return CSV.stringify( - res.map(({ id, llm_id, body, updated_at }) => ({ - id, + res.map(({ llm_id, body, updated_at }) => ({ llm_id, body, updated_at, diff --git a/packages/core/src/genaisrc/system.github_actions.genai.mjs b/packages/core/src/genaisrc/system.github_actions.genai.mjs index 4e2a770df7..88f6d68ec4 100644 --- a/packages/core/src/genaisrc/system.github_actions.genai.mjs +++ b/packages/core/src/genaisrc/system.github_actions.genai.mjs @@ -50,8 +50,7 @@ defTool( status, }) return CSV.stringify( - res.map(({ id, llm_id, name, conclusion, head_sha }) => ({ - id, + res.map(({ llm_id, name, conclusion, head_sha }) => ({ llm_id, name, conclusion, @@ -81,8 +80,7 @@ defTool( context.log(`github action list jobs for run ${run_id}`) const res = await github.listWorkflowJobs(run_id) return CSV.stringify( - res.map(({ id, llm_id, name, status }) => ({ - id, + res.map(({ llm_id, name, status }) => ({ llm_id, name, status, diff --git a/packages/core/src/genaisrc/system.github_issues.genai.mjs b/packages/core/src/genaisrc/system.github_issues.genai.mjs index d88442ba1a..ac8c6d4d6b 100644 --- a/packages/core/src/genaisrc/system.github_issues.genai.mjs +++ b/packages/core/src/genaisrc/system.github_issues.genai.mjs @@ -33,8 +33,7 @@ defTool( context.log(`github issue list ${state ?? "all"}`) const res = await github.listIssues({ state, labels, sort, direction }) return CSV.stringify( - res.map(({ number, llm_number, title, state }) => ({ - number, + res.map(({ llm_number, title, state }) => ({ llm_number, title, state, @@ -60,10 +59,9 @@ defTool( async (args) => { const { number: issue_number, context } = args context.log(`github issue get ${issue_number}`) - const { number, llm_number, title, body, state, html_url, reactions } = + const { llm_number, title, body, state, html_url, reactions } = await github.getIssue(issue_number) return YAML.stringify({ - number, llm_number, title, body, @@ -92,8 +90,7 @@ defTool( context.log(`github issue list comments ${issue_number}`) const res = await github.listIssueComments(issue_number) return CSV.stringify( - res.map(({ id, llm_id, body, updated_at }) => ({ - id, + res.map(({ llm_id, body, updated_at }) => ({ llm_id, body, updated_at, diff --git a/packages/sample/genaisrc/poem.genai.mts b/packages/sample/genaisrc/poem.genai.mts index 6e5e61cd09..d688fbd5a0 100644 --- a/packages/sample/genaisrc/poem.genai.mts +++ b/packages/sample/genaisrc/poem.genai.mts @@ -1,2 +1,4 @@ $`Write a short poem.` -x \ No newline at end of file +x: scsdfsd +as +defFileMergesdf