Skip to content

Commit cc33b4a

Browse files
committed
feat[github]: get commit tool
1 parent a12f234 commit cc33b4a

File tree

13 files changed

+1702
-186
lines changed

13 files changed

+1702
-186
lines changed

sim/app/blocks/blocks/github.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { GithubIcon } from '@/components/icons'
2-
import { CreateCommentResponse, PullRequestResponse } from '@/tools/github/types'
2+
import { CreateCommentResponse, LatestCommitResponse, PullRequestResponse, RepoInfoResponse } from '@/tools/github/types'
33
import { BlockConfig } from '../types'
44

5-
type GitHubResponse = PullRequestResponse | CreateCommentResponse
5+
type GitHubResponse = PullRequestResponse | CreateCommentResponse | LatestCommitResponse | RepoInfoResponse
66

77
export const GitHubBlock: BlockConfig<GitHubResponse> = {
88
type: 'github',
@@ -23,6 +23,7 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
2323
{ label: 'Get PR details', id: 'github_pr' },
2424
{ label: 'Create PR comment', id: 'github_comment' },
2525
{ label: 'Get repository info', id: 'github_repoinfo' },
26+
{ label: 'Get latest commit', id: 'github_latest_commit' },
2627
],
2728
value: () => 'github_pr',
2829
},
@@ -64,6 +65,14 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
6465
placeholder: 'e.g., 123',
6566
condition: { field: 'operation', value: 'github_comment' },
6667
},
68+
{
69+
id: 'branch',
70+
title: 'Branch Name',
71+
type: 'short-input',
72+
layout: 'half',
73+
placeholder: 'e.g., main (leave empty for default)',
74+
condition: { field: 'operation', value: 'github_latest_commit' },
75+
},
6776
{
6877
id: 'apiKey',
6978
title: 'GitHub Token',
@@ -115,7 +124,7 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
115124
},
116125
],
117126
tools: {
118-
access: ['github_pr', 'github_comment', 'github_repoinfo'],
127+
access: ['github_pr', 'github_comment', 'github_repoinfo', 'github_latest_commit'],
119128
config: {
120129
tool: (params) => {
121130
switch (params.operation) {
@@ -124,6 +133,9 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
124133
case 'github_comment':
125134
return 'github_comment'
126135
case 'github_repoinfo':
136+
return 'github_repoinfo'
137+
case 'github_latest_commit':
138+
return 'github_latest_commit'
127139
default:
128140
return 'github_repoinfo'
129141
}
@@ -142,26 +154,14 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
142154
line: { type: 'number', required: false },
143155
side: { type: 'string', required: false },
144156
commitId: { type: 'string', required: false },
157+
branch: { type: 'string', required: false },
145158
},
146159
outputs: {
147160
response: {
148161
type: {
149-
body: 'string',
150-
html_url: 'string',
151-
created_at: 'string',
152-
updated_at: 'string',
153-
number: 'number',
154-
title: 'string',
155-
state: 'string',
156-
diff_url: 'string',
157-
files: 'any',
158-
comments: 'any',
159-
id: 'number',
160-
path: 'any',
161-
line: 'any',
162-
side: 'any',
163-
commit_id: 'any',
164-
},
165-
},
162+
content: 'string',
163+
metadata: 'json'
164+
}
165+
}
166166
},
167167
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
CREATE TABLE "marketplace" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"workflow_id" text NOT NULL,
4+
"state" json NOT NULL,
5+
"name" text NOT NULL,
6+
"description" text,
7+
"author_id" text NOT NULL,
8+
"author_name" text NOT NULL,
9+
"stars" integer DEFAULT 0 NOT NULL,
10+
"executions" integer DEFAULT 0 NOT NULL,
11+
"category" text,
12+
"created_at" timestamp DEFAULT now() NOT NULL,
13+
"updated_at" timestamp DEFAULT now() NOT NULL
14+
);
15+
--> statement-breakpoint
16+
CREATE TABLE "marketplace_execution" (
17+
"id" text PRIMARY KEY NOT NULL,
18+
"marketplace_id" text NOT NULL,
19+
"user_id" text,
20+
"created_at" timestamp DEFAULT now() NOT NULL
21+
);
22+
--> statement-breakpoint
23+
CREATE TABLE "marketplace_star" (
24+
"id" text PRIMARY KEY NOT NULL,
25+
"marketplace_id" text NOT NULL,
26+
"user_id" text NOT NULL,
27+
"created_at" timestamp DEFAULT now() NOT NULL
28+
);
29+
--> statement-breakpoint
30+
ALTER TABLE "marketplace" ADD CONSTRAINT "marketplace_workflow_id_workflow_id_fk" FOREIGN KEY ("workflow_id") REFERENCES "public"."workflow"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
31+
ALTER TABLE "marketplace" ADD CONSTRAINT "marketplace_author_id_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
32+
ALTER TABLE "marketplace_execution" ADD CONSTRAINT "marketplace_execution_marketplace_id_marketplace_id_fk" FOREIGN KEY ("marketplace_id") REFERENCES "public"."marketplace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
33+
ALTER TABLE "marketplace_execution" ADD CONSTRAINT "marketplace_execution_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
34+
ALTER TABLE "marketplace_star" ADD CONSTRAINT "marketplace_star_marketplace_id_marketplace_id_fk" FOREIGN KEY ("marketplace_id") REFERENCES "public"."marketplace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
35+
ALTER TABLE "marketplace_star" ADD CONSTRAINT "marketplace_star_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
36+
CREATE UNIQUE INDEX "user_marketplace_idx" ON "marketplace_star" USING btree ("user_id","marketplace_id");

0 commit comments

Comments
 (0)