From ec6aeed04a03564922054b67ed6409c6ca7fe68d Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Thu, 2 May 2024 09:00:21 +0300 Subject: [PATCH] fix(#98): one suggestion --- src/formatted-summary.ts | 2 +- src/main.ts | 2 +- src/models.ts | 28 ++++++++++------ src/prompts/one-suggestion.ts | 61 +++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 src/prompts/one-suggestion.ts diff --git a/src/formatted-summary.ts b/src/formatted-summary.ts index 1637b29..8c8c351 100644 --- a/src/formatted-summary.ts +++ b/src/formatted-summary.ts @@ -43,7 +43,7 @@ export class FormattedSummary implements Scalar { ### Problems ${this.problems} - ### Suggestions + ### Suggestion ${this.suggestions} `; } diff --git a/src/main.ts b/src/main.ts index acd64c4..d2b433d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -178,7 +178,7 @@ async function run() { await new Feedback( new FormattedSummary( composed.problems, - composed.suggestions + composed.suggestion ), octokit, issue, diff --git a/src/models.ts b/src/models.ts index 9d4b713..1568437 100644 --- a/src/models.ts +++ b/src/models.ts @@ -31,6 +31,7 @@ import {MdSuggestions} from "./prompts/md-suggestions"; import {Suggestions} from "./prompts/suggestions"; import {Polish} from "./prompts/polish"; import {Top} from "./prompts/top"; +import {OneSuggestion} from "./prompts/one-suggestion"; /** * Models. @@ -85,25 +86,34 @@ export class Models { ).exec() ) ).exec(); - const suggestions = await new NamedGoal( - "suggestions.md", + const suggestion = await new NamedGoal( + "one", this.def, new Default(), - new MdSuggestions( + new OneSuggestion( + problems, await new NamedGoal( - "suggestions", + "suggestions.md", this.def, new Default(), - new Suggestions( - report, - problems + new MdSuggestions( + await new NamedGoal( + "suggestions", + this.def, + new Default(), + new Suggestions( + report, + problems + ) + ).exec() ) - ).exec() + ).exec(), + report ) ).exec(); return { problems: problems, - suggestions: suggestions + suggestion: suggestion } } } diff --git a/src/prompts/one-suggestion.ts b/src/prompts/one-suggestion.ts new file mode 100644 index 0000000..bde7561 --- /dev/null +++ b/src/prompts/one-suggestion.ts @@ -0,0 +1,61 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2023-2024 Tracehub.git + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * One suggestion. + */ +export class OneSuggestion implements Scalar { + + /** + * Ctor. + * @param probmels Problems + * @param suggestions Suggestions + * @param report Report + */ + constructor( + private readonly probmels: any, + private readonly suggestions: any, + private readonly report: string + ) { + } + + value(): string { + return ` + Take a look at suggestions we propose for solving outlined problems with quality + of following bug report. Such long list of suggestions is absolutely useless. + Nobody reads it and nobody pays attention. In order to be useful, + please suggest only one specific improvement to be made. + The suggestion must be short, less than 30 words. + + Suggestions: +${this.suggestions} + + Problems: +${this.probmels} + + Report: +${this.report} + ` + } +}