Skip to content

Commit 32cb0c7

Browse files
efraespadaactions-user
authored andcommitted
gh-action: updated compiled files
1 parent d378759 commit 32cb0c7

File tree

14 files changed

+651
-151
lines changed

14 files changed

+651
-151
lines changed

dist/index.js

Lines changed: 291 additions & 134 deletions
Large diffs are not rendered by default.

dist/src/actions/local_action.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const tokens_1 = require("../data/model/tokens");
2323
const workflows_1 = require("../data/model/workflows");
2424
const project_repository_1 = require("../data/repository/project_repository");
2525
const constants_1 = require("../utils/constants");
26+
const logger_1 = require("../utils/logger");
2627
const yml_utils_1 = require("../utils/yml_utils");
2728
const common_action_1 = require("./common_action");
2829
async function runLocalAction(additionalParams) {
@@ -391,5 +392,6 @@ async function runLocalAction(additionalParams) {
391392
const supabaseUrl = additionalParams[constants_1.INPUT_KEYS.SUPABASE_URL] ?? actionInputs[constants_1.INPUT_KEYS.SUPABASE_URL];
392393
const supabaseKey = additionalParams[constants_1.INPUT_KEYS.SUPABASE_KEY] ?? actionInputs[constants_1.INPUT_KEYS.SUPABASE_KEY];
393394
const execution = new execution_1.Execution(debug, new docker_config_1.DockerConfig(dockerContainerName, dockerDomain, dockerPort), new single_action_1.SingleAction(singleAction, singleActionIssue), commitPrefixBuilder, new issue_1.Issue(branchManagementAlways, reopenIssueOnPush, issueDesiredAssigneesCount, additionalParams), new pull_request_1.PullRequest(pullRequestDesiredAssigneesCount, pullRequestDesiredReviewersCount, pullRequestMergeTimeout, additionalParams), new emoji_1.Emoji(titleEmoji, branchManagementEmoji), new images_1.Images(imagesOnIssue, imagesOnPullRequest, imagesOnCommit, imagesIssueAutomatic, imagesIssueFeature, imagesIssueBugfix, imagesIssueDocs, imagesIssueChore, imagesIssueRelease, imagesIssueHotfix, imagesPullRequestAutomatic, imagesPullRequestFeature, imagesPullRequestBugfix, imagesPullRequestRelease, imagesPullRequestHotfix, imagesPullRequestDocs, imagesPullRequestChore, imagesCommitAutomatic, imagesCommitFeature, imagesCommitBugfix, imagesCommitRelease, imagesCommitHotfix, imagesCommitDocs, imagesCommitChore), new tokens_1.Tokens(token), new ai_1.Ai(openrouterApiKey, openrouterModel, aiPullRequestDescription, aiMembersOnly, aiIgnoreFiles, Object.keys(providerRouting).length > 0 ? providerRouting : undefined), new labels_1.Labels(branchManagementLauncherLabel, bugLabel, bugfixLabel, hotfixLabel, enhancementLabel, featureLabel, releaseLabel, questionLabel, helpLabel, deployLabel, deployedLabel, docsLabel, documentationLabel, choreLabel, maintenanceLabel, priorityHighLabel, priorityMediumLabel, priorityLowLabel, priorityNoneLabel, sizeXxlLabel, sizeXlLabel, sizeLLabel, sizeMLabel, sizeSLabel, sizeXsLabel), new issue_types_1.IssueTypes(issueTypeTask, issueTypeBug, issueTypeFeature, issueTypeDocumentation, issueTypeMaintenance, issueTypeHotfix, issueTypeRelease, issueTypeQuestion, issueTypeHelp), new locale_1.Locale(issueLocale, pullRequestLocale), new size_thresholds_1.SizeThresholds(new size_threshold_1.SizeThreshold(sizeXxlThresholdLines, sizeXxlThresholdFiles, sizeXxlThresholdCommits), new size_threshold_1.SizeThreshold(sizeXlThresholdLines, sizeXlThresholdFiles, sizeXlThresholdCommits), new size_threshold_1.SizeThreshold(sizeLThresholdLines, sizeLThresholdFiles, sizeLThresholdCommits), new size_threshold_1.SizeThreshold(sizeMThresholdLines, sizeMThresholdFiles, sizeMThresholdCommits), new size_threshold_1.SizeThreshold(sizeSThresholdLines, sizeSThresholdFiles, sizeSThresholdCommits), new size_threshold_1.SizeThreshold(sizeXsThresholdLines, sizeXsThresholdFiles, sizeXsThresholdCommits)), new branches_1.Branches(mainBranch, developmentBranch, featureTree, bugfixTree, hotfixTree, releaseTree, docsTree, choreTree), new release_1.Release(), new hotfix_1.Hotfix(), new workflows_1.Workflows(releaseWorkflow, hotfixWorkflow), new projects_1.Projects(projects, projectColumnIssueCreated, projectColumnPullRequestCreated, projectColumnIssueInProgress, projectColumnPullRequestInProgress), new supabase_config_1.SupabaseConfig(supabaseUrl, supabaseKey), additionalParams);
394-
await (0, common_action_1.mainRun)(execution);
395+
const results = await (0, common_action_1.mainRun)(execution);
396+
(0, logger_1.logInfo)(`Results: ${JSON.stringify(results, null, 2)}`);
395397
}

dist/src/cli.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function getGitInfo() {
6666
}
6767
}
6868
program
69-
.name('git-board-flow')
70-
.description('CLI tool for Git Board Flow')
69+
.name(constants_1.COMMAND)
70+
.description(`CLI tool for ${constants_1.TITLE}`)
7171
.version('1.0.0');
7272
program
7373
.command('build-ai')
@@ -84,7 +84,7 @@ program
8484
}
8585
const params = {
8686
[constants_1.INPUT_KEYS.DEBUG]: options.debug.toString(),
87-
[constants_1.INPUT_KEYS.SINGLE_ACTION]: 'vector_action',
87+
[constants_1.INPUT_KEYS.SINGLE_ACTION]: constants_1.ACTIONS.VECTOR,
8888
[constants_1.INPUT_KEYS.SINGLE_ACTION_ISSUE]: options.issue,
8989
[constants_1.INPUT_KEYS.SUPABASE_URL]: process.env.SUPABASE_URL,
9090
[constants_1.INPUT_KEYS.SUPABASE_KEY]: process.env.SUPABASE_KEY,
@@ -107,7 +107,58 @@ program
107107
margin: 1,
108108
borderStyle: 'round',
109109
borderColor: 'cyan',
110-
title: 'Git Board Flow',
110+
title: constants_1.TITLE,
111+
titleAlignment: 'center'
112+
}));
113+
(0, local_action_1.runLocalAction)(params);
114+
});
115+
program
116+
.command('ask-ai')
117+
.description('Ask AI')
118+
.option('-i, --issue <number>', 'Issue number to process', '1')
119+
.option('-b, --branch <name>', 'Branch name', 'master')
120+
.option('-d, --debug', 'Debug mode', false)
121+
.option('-t, --token <token>', 'Personal access token', process.env.PERSONAL_ACCESS_TOKEN)
122+
.action((options) => {
123+
const gitInfo = getGitInfo();
124+
if ('error' in gitInfo) {
125+
console.log(gitInfo.error);
126+
return;
127+
}
128+
const commentBody = `@landa-bot where is should add new constants?`;
129+
const params = {
130+
[constants_1.INPUT_KEYS.DEBUG]: options.debug.toString(),
131+
[constants_1.INPUT_KEYS.SINGLE_ACTION]: constants_1.ACTIONS.ASK,
132+
[constants_1.INPUT_KEYS.SINGLE_ACTION_ISSUE]: options.issue,
133+
[constants_1.INPUT_KEYS.SUPABASE_URL]: process.env.SUPABASE_URL,
134+
[constants_1.INPUT_KEYS.SUPABASE_KEY]: process.env.SUPABASE_KEY,
135+
[constants_1.INPUT_KEYS.TOKEN]: process.env.PERSONAL_ACCESS_TOKEN,
136+
[constants_1.INPUT_KEYS.AI_IGNORE_FILES]: 'dist/*,bin/*',
137+
repo: {
138+
owner: gitInfo.owner,
139+
repo: gitInfo.repo,
140+
},
141+
commits: {
142+
ref: `refs/heads/${options.branch}`,
143+
},
144+
eventName: 'issue_comment',
145+
comment: {
146+
body: commentBody,
147+
},
148+
pull_request_review_comment: {
149+
body: commentBody,
150+
},
151+
issue: {
152+
number: parseInt(options.issue),
153+
},
154+
};
155+
(0, logger_1.logInfo)((0, boxen_1.default)(chalk_1.default.cyan('🚀 Asking AI started\n') +
156+
chalk_1.default.gray(`Asking AI on ${gitInfo.owner}/${gitInfo.repo}/${options.branch}...`), {
157+
padding: 1,
158+
margin: 1,
159+
borderStyle: 'round',
160+
borderColor: 'cyan',
161+
title: constants_1.TITLE,
111162
titleAlignment: 'center'
112163
}));
113164
(0, local_action_1.runLocalAction)(params);

dist/src/data/model/single_action.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export declare class SingleAction {
77
isPush: boolean;
88
get isDeployedAction(): boolean;
99
get isVectorAction(): boolean;
10+
get isAskAction(): boolean;
1011
get enabledSingleAction(): boolean;
1112
get validSingleAction(): boolean;
1213
constructor(currentSingleAction: string, currentSingleActionIssue: string);

dist/src/data/model/single_action.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.SingleAction = void 0;
4+
const constants_1 = require("../../utils/constants");
45
const logger_1 = require("../../utils/logger");
5-
const deployedAction = 'deployed_action';
6-
const vectorAction = 'vector_action';
76
class SingleAction {
87
get isDeployedAction() {
9-
return this.currentSingleAction === deployedAction;
8+
return this.currentSingleAction === constants_1.ACTIONS.DEPLOYED;
109
}
1110
get isVectorAction() {
12-
return this.currentSingleAction === vectorAction;
11+
return this.currentSingleAction === constants_1.ACTIONS.VECTOR;
12+
}
13+
get isAskAction() {
14+
return this.currentSingleAction === constants_1.ACTIONS.ASK;
1315
}
1416
get enabledSingleAction() {
1517
return this.currentSingleAction.length > 0;
@@ -21,7 +23,7 @@ class SingleAction {
2123
}
2224
constructor(currentSingleAction, currentSingleActionIssue) {
2325
this.currentSingleActionIssue = -1;
24-
this.actions = [deployedAction, vectorAction];
26+
this.actions = [constants_1.ACTIONS.DEPLOYED, constants_1.ACTIONS.VECTOR, constants_1.ACTIONS.ASK];
2527
this.isIssue = false;
2628
this.isPullRequest = false;
2729
this.isPush = false;

dist/src/data/repository/ai_repository.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.AiRepository = void 0;
4+
const constants_1 = require("../../utils/constants");
45
const logger_1 = require("../../utils/logger");
56
class AiRepository {
67
constructor() {
@@ -29,8 +30,8 @@ class AiRepository {
2930
method: 'POST',
3031
headers: {
3132
Authorization: `Bearer ${apiKey}`,
32-
'HTTP-Referer': 'https://github.com/landamessenger/git-board-flow',
33-
'X-Title': 'Git Board Flow',
33+
'HTTP-Referer': constants_1.REPO_URL,
34+
'X-Title': constants_1.TITLE,
3435
'Content-Type': 'application/json',
3536
},
3637
body: JSON.stringify(requestBody),

dist/src/data/repository/supabase_repository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class SupabaseRepository {
7575
if (!data) {
7676
return [];
7777
}
78-
return data.map((doc) => new chunked_file_chunk_1.ChunkedFileChunk(doc.owner, doc.repository, doc.branch, doc.path, doc.type, doc.index, doc.chunk_index, doc.chunk, doc.shasum, doc.vector));
78+
return data.map((doc) => new chunked_file_chunk_1.ChunkedFileChunk(doc.owner, doc.repository, doc.branch, doc.path, doc.type, doc.index, doc.chunk_index, doc.content, doc.shasum, doc.vector));
7979
}
8080
catch (error) {
8181
(0, logger_1.logError)(`Error getting chunked file: ${JSON.stringify(error, null, 2)}`);
@@ -166,7 +166,7 @@ class SupabaseRepository {
166166
(0, logger_1.logError)(`Error matching chunks: ${JSON.stringify(error, null, 2)}`);
167167
throw error;
168168
}
169-
return data.map((doc) => new chunked_file_chunk_1.ChunkedFileChunk(doc.owner, doc.repository, doc.branch, doc.path, doc.type, doc.index, doc.chunk_index, doc.chunk, doc.shasum, doc.vector));
169+
return data.map((doc) => new chunked_file_chunk_1.ChunkedFileChunk(doc.owner, doc.repository, doc.branch, doc.path, doc.type, doc.index, doc.chunk_index, doc.content, doc.shasum, doc.vector));
170170
}
171171
catch (error) {
172172
(0, logger_1.logError)(`Error matching chunks: ${JSON.stringify(error, null, 2)}`);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Execution } from '../../data/model/execution';
2+
import { Result } from '../../data/model/result';
3+
import { ParamUseCase } from '../base/param_usecase';
4+
export declare class AskActionUseCase implements ParamUseCase<Execution, Result[]> {
5+
taskId: string;
6+
private dockerRepository;
7+
private fileRepository;
8+
private readonly CODE_INSTRUCTION_BLOCK;
9+
private readonly CODE_INSTRUCTION_LINE;
10+
private readonly CODE_INSTRUCTION_ASK;
11+
invoke(param: Execution): Promise<Result[]>;
12+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.AskActionUseCase = void 0;
4+
const result_1 = require("../../data/model/result");
5+
const docker_repository_1 = require("../../data/repository/docker_repository");
6+
const file_repository_1 = require("../../data/repository/file_repository");
7+
const supabase_repository_1 = require("../../data/repository/supabase_repository");
8+
const logger_1 = require("../../utils/logger");
9+
class AskActionUseCase {
10+
constructor() {
11+
this.taskId = 'AskActionUseCase';
12+
this.dockerRepository = new docker_repository_1.DockerRepository();
13+
this.fileRepository = new file_repository_1.FileRepository();
14+
this.CODE_INSTRUCTION_BLOCK = "Represent the code for semantic search";
15+
this.CODE_INSTRUCTION_LINE = "Represent each line of code for retrieval";
16+
this.CODE_INSTRUCTION_ASK = "Represent the question for retrieving relevant code snippets";
17+
}
18+
async invoke(param) {
19+
(0, logger_1.logInfo)(`Executing ${this.taskId}.`);
20+
const results = [];
21+
try {
22+
/**
23+
* Check if the user from the token is found.
24+
*/
25+
if (!param.tokenUser) {
26+
results.push(new result_1.Result({
27+
id: this.taskId,
28+
success: false,
29+
executed: false,
30+
errors: [
31+
`User from token not found.`,
32+
],
33+
}));
34+
return results;
35+
}
36+
/**
37+
* Get the comment body.
38+
*/
39+
let commentBody = '';
40+
if (param.issue.isIssueComment) {
41+
commentBody = param.issue.commentBody;
42+
}
43+
else if (param.pullRequest.isPullRequestReviewComment) {
44+
commentBody = param.pullRequest.commentBody;
45+
}
46+
else {
47+
(0, logger_1.logError)(`Not a valid comment body.`);
48+
results.push(new result_1.Result({
49+
id: this.taskId,
50+
success: true,
51+
executed: false,
52+
}));
53+
return results;
54+
}
55+
/**
56+
* Check if the comment body includes the user from the token.
57+
*/
58+
if (!commentBody.includes(param.tokenUser)) {
59+
results.push(new result_1.Result({
60+
id: this.taskId,
61+
success: true,
62+
executed: false,
63+
}));
64+
return results;
65+
}
66+
else {
67+
commentBody = commentBody.replace(param.tokenUser, '').trim();
68+
}
69+
/**
70+
* Check if the supabase config is found.
71+
*/
72+
if (!param.supabaseConfig) {
73+
results.push(new result_1.Result({
74+
id: this.taskId,
75+
success: false,
76+
executed: true,
77+
steps: [
78+
`Supabase config not found.`,
79+
],
80+
}));
81+
return results;
82+
}
83+
const supabaseRepository = new supabase_repository_1.SupabaseRepository(param.supabaseConfig);
84+
await this.dockerRepository.startContainer(param);
85+
const systemInfo = await this.dockerRepository.getSystemInfo(param);
86+
const chunkSize = systemInfo.parameters.chunk_size;
87+
const maxWorkers = systemInfo.parameters.max_workers;
88+
(0, logger_1.logInfo)(`🧑‍🏭 Max workers: ${maxWorkers}`);
89+
(0, logger_1.logInfo)(`🚚 Chunk size: ${chunkSize}`);
90+
(0, logger_1.logInfo)(`📦 Getting chunked files for ${param.owner}/${param.repo}/${param.commit.branch}`);
91+
const startTime = Date.now();
92+
const embeddings = await this.dockerRepository.getEmbedding(param, [
93+
[this.CODE_INSTRUCTION_ASK, commentBody]
94+
]);
95+
(0, logger_1.logInfo)(`🔎 Embeddings: ${JSON.stringify(embeddings, null, 2)}`);
96+
const types = ['line', 'block'];
97+
const chunks = [];
98+
for (const type of types) {
99+
(0, logger_1.logInfo)(`📦 🔎 Matching chunks for ${param.owner}/${param.repo}/${param.commit.branch}`);
100+
const foundChunks = await supabaseRepository.matchChunks(param.owner, param.repo, param.commit.branch, type, embeddings[0], 5);
101+
for (const chunk of foundChunks) {
102+
(0, logger_1.logDebugInfo)(`📦 🔎 Chunk type: ${type} - ${chunk.path}`);
103+
}
104+
chunks.push(...foundChunks);
105+
}
106+
const totalDurationSeconds = (Date.now() - startTime) / 1000;
107+
(0, logger_1.logInfo)(`📦 🔎 Matched chunks for ${param.owner}/${param.repo}/${param.commit.branch}:\n Total duration: ${Math.ceil(totalDurationSeconds)} seconds`);
108+
results.push(new result_1.Result({
109+
id: this.taskId,
110+
success: true,
111+
executed: true,
112+
steps: [
113+
`Vector action executed successfully.`,
114+
],
115+
}));
116+
}
117+
catch (error) {
118+
(0, logger_1.logError)(`Error in ${this.taskId}: ${JSON.stringify(error, null, 2)}`);
119+
results.push(new result_1.Result({
120+
id: this.taskId,
121+
success: false,
122+
executed: true,
123+
steps: [
124+
`Error in ${this.taskId}: ${JSON.stringify(error, null, 2)}`,
125+
],
126+
}));
127+
}
128+
finally {
129+
await this.dockerRepository.stopContainer(param);
130+
}
131+
return results;
132+
}
133+
}
134+
exports.AskActionUseCase = AskActionUseCase;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Execution } from '../../data/model/execution';
2+
import { Result } from '../../data/model/result';
3+
import { ParamUseCase } from '../base/param_usecase';
4+
export declare class VectorActionUseCase implements ParamUseCase<Execution, Result[]> {
5+
taskId: string;
6+
private dockerRepository;
7+
private fileRepository;
8+
private readonly CODE_INSTRUCTION_BLOCK;
9+
private readonly CODE_INSTRUCTION_LINE;
10+
invoke(param: Execution): Promise<Result[]>;
11+
}

0 commit comments

Comments
 (0)