Skip to content

Commit 0be6b75

Browse files
committed
round 2
1 parent 9e8409b commit 0be6b75

45 files changed

Lines changed: 303 additions & 269 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/cli/src/run.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,6 @@ export async function runScriptInternal(
733733
stats.log()
734734
if (outTraceFilename) logVerbose(` trace: ${outTraceFilename}`)
735735
if (outputFilename) logVerbose(` output: ${outputFilename}`)
736-
if (outTraceFilename)
737-
logVerbose(
738-
` viewer: ${SERVER_LOCALHOST}:${SERVER_PORT}/#runid=${runId} (to start server, run 'genaiscript serve')`
739-
)
740736

741737
if (result.status !== "success" && result.status !== "cancelled") {
742738
const msg =

packages/core/src/annotations.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ const SEV_EMOJI_MAP: Record<string, string> = Object.freeze({
5252
/**
5353
* Parses annotations from TypeScript, GitHub Actions, and Azure DevOps.
5454
*
55-
* @param text - The input text containing annotations to be parsed.
56-
* @returns An array of unique Diagnostic objects extracted from the text.
55+
* @param text - Input text containing annotations to parse.
56+
* @returns Array of unique Diagnostic objects extracted from the input text.
5757
*/
5858
export function parseAnnotations(text: string): Diagnostic[] {
5959
if (!text) return []
@@ -139,8 +139,8 @@ export function convertDiagnosticToGitHubActionCommand(d: Diagnostic) {
139139
/**
140140
* Converts a Diagnostic object to an Azure DevOps log issue command string.
141141
*
142-
* @param d - The Diagnostic object to convert. Includes severity, message, filename, and range.
143-
* @returns A formatted Azure DevOps command string or debug message for "info" severity.
142+
* @param d - The Diagnostic object containing severity, message, filename, and range.
143+
* @returns A formatted Azure DevOps command string for warnings and errors, or a debug message for info severity.
144144
*/
145145
export function convertDiagnosticToAzureDevOpsCommand(d: Diagnostic) {
146146
// Handle 'info' severity separately with a debug message.
@@ -151,10 +151,10 @@ export function convertDiagnosticToAzureDevOpsCommand(d: Diagnostic) {
151151
}
152152

153153
/**
154-
* Converts annotations in text to a Markdown representation.
154+
* Converts annotations in text to a Markdown representation with severity-based admonitions.
155155
*
156-
* @param text - Input text with annotations to be converted.
157-
* @returns Formatted string in Markdown with admonitions for severity levels.
156+
* @param text Input text containing annotations to be converted.
157+
* @returns Formatted Markdown string with severity levels mapped to admonitions.
158158
*/
159159
export function convertAnnotationsToMarkdown(text: string): string {
160160
// Maps severity levels to Markdown admonition types.

packages/core/src/ast.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export interface FileReference {
1818

1919
/**
2020
* Converts diagnostic data into a CSV-formatted string.
21-
* @param diagnostics - Array of diagnostic objects with severity, filename, range, code, and message.
22-
* @param sep - Separator for CSV fields.
23-
* @returns CSV string with each diagnostic entry on a new line.
21+
* @param diagnostics - Array of diagnostic objects containing severity, filename, range, code, and message.
22+
* @param sep - String used as the separator for CSV fields.
23+
* @returns CSV string with each diagnostic entry on a separate line.
2424
*/
2525
export function diagnosticsToCSV(diagnostics: Diagnostic[], sep: string) {
2626
return diagnostics
@@ -39,10 +39,10 @@ export function diagnosticsToCSV(diagnostics: Diagnostic[], sep: string) {
3939
}
4040

4141
/**
42-
* Determines the group name of a given template.
43-
* @param template - The template object to evaluate.
44-
* @returns Group name of the template, "system" if the ID starts with "system",
45-
* or "unassigned" if no group is set.
42+
* Determines the group name of a template.
43+
* @param template - The template to evaluate, containing an ID and optional group.
44+
* @returns The group name of the template. Returns "system" if the ID starts with "system",
45+
* the existing group if set, or "unassigned" if no group is determined.
4646
*/
4747
export function templateGroup(template: PromptScript) {
4848
return (
@@ -57,9 +57,9 @@ export const eolPosition = 0x3fffffff // End of line position, a large constant
5757
export const eofPosition: CharPosition = [0x3fffffff, 0] // End of file position, a tuple with a large constant
5858

5959
/**
60-
* Organizes templates by directory and identifies the presence of JS or TS files in each directory.
61-
* @param prj - The project containing the scripts to process.
62-
* @returns An array of objects, each representing a directory with its name and boolean flags for JS and TS file presence.
60+
* Organizes templates by directory and determines the presence of JavaScript or TypeScript files in each directory.
61+
* @param prj - The project containing the scripts to analyze.
62+
* @returns An array of objects, each representing a directory with its name and flags indicating the presence of JavaScript and TypeScript files.
6363
*/
6464
export function collectFolders(prj: Project) {
6565
const folders: Record<
@@ -80,9 +80,9 @@ export function collectFolders(prj: Project) {
8080

8181
/**
8282
* Retrieves a script by its ID from the project's scripts list.
83-
* @param prj - The project containing the scripts.
84-
* @param system - The system prompt instance with the script ID to find.
85-
* @returns The matching PromptScript or undefined if no match is found.
83+
* @param prj - The project containing the scripts to search.
84+
* @param system - The system prompt instance containing the script ID to match.
85+
* @returns The matching script or undefined if no match is found.
8686
*/
8787
export function resolveScript(prj: Project, system: SystemPromptInstance) {
8888
return prj?.scripts?.find((t) => t.id == system.id) // Find and return the template with the matching ID

packages/core/src/cancellation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class AbortSignalCancellationToken implements CancellationToken {
3232
}
3333

3434
/**
35-
* Converts a CancellationToken to an AbortSignal if it supports the conversion.
36-
* Returns undefined if the token does not have a compatible signal.
35+
* Converts a CancellationToken to an AbortSignal if supported.
36+
* Returns undefined if the token does not have a compatible signal property.
3737
*
3838
* @param token - The CancellationToken to convert.
39-
* @returns The associated AbortSignal, or undefined if unsupported.
39+
* @returns The associated AbortSignal or undefined if unsupported.
4040
*/
4141
export function toSignal(token: CancellationToken) {
4242
return (token as any)?.signal as AbortSignal

packages/core/src/chatrender.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export interface ChatRenderOptions extends CancellationOptions {
2525
}
2626

2727
/**
28-
* Renders the output of a shell command based on its components.
29-
* @param output - Contains exit code, stdout, and stderr from the shell execution.
30-
* @returns A formatted string summarizing the shell output, including non-zero exit code, stdout, or stderr.
28+
* Formats the output of a shell command.
29+
* @param output - Object containing exit code, stdout, and stderr from shell execution.
30+
* @returns A formatted string summarizing the shell output, including exit code (if non-zero), stdout, and stderr.
3131
*/
3232
export function renderShellOutput(output: ShellOutput) {
3333
// Destructure the output object to retrieve exitCode, stdout, and stderr.
@@ -51,9 +51,10 @@ export function renderShellOutput(output: ShellOutput) {
5151

5252
/**
5353
* Renders the content of a message into a formatted string.
54-
* @param msg - The message object, which may contain various content types (e.g., text, image, audio).
55-
* @param options - Configuration options for rendering, such as text language or image caching.
56-
* @returns A formatted string representation of the message content or undefined if content is invalid.
54+
*
55+
* @param msg - The message object containing content, which may include text, images, audio, or other types.
56+
* @param options - Configuration options for rendering, including text formatting, image caching, and language.
57+
* @returns A formatted string representation of the message content, or undefined if the content is invalid.
5758
*/
5859
export async function renderMessageContent(
5960
msg:
@@ -107,10 +108,10 @@ export function lastAssistantReasoning(messages: ChatCompletionMessageParam[]) {
107108
}
108109

109110
/**
110-
* Renders a list of chat messages into a markdown string.
111-
* @param messages - The list of chat messages to render.
112-
* @param options - Configuration options for filtering by roles and formatting.
113-
* @returns The rendered markdown string representation of the chat messages.
111+
* Renders a list of chat messages into a formatted markdown string.
112+
* @param messages - The list of chat messages to process and render.
113+
* @param options - Configuration options for filtering messages by roles, formatting, and tool inclusion.
114+
* @returns A markdown string representation of the chat messages.
114115
*/
115116
export async function renderMessagesToMarkdown(
116117
messages: ChatCompletionMessageParam[],

packages/core/src/chunkers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { assert } from "./assert"
22

3-
// chunk string into chunks of size n
3+
/**
4+
* // Splits a string into chunks of specified size.
5+
* // Parameters:
6+
* // - s: The input string to be chunked.
7+
* // - n: The maximum size of each chunk. Defaults to 2 << 14.
8+
*/
49
export function chunkString(s: string, n: number = 2 << 14) {
510
if (!s?.length) return []
611
if (s.length <= n) return [s]

packages/core/src/cleaners.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export function unmarkdown(text: string) {
8383
}
8484

8585
/**
86-
* Collapses sequences of 3 or more consecutive newlines to two newlines.
87-
* @param res The input string to process.
86+
* Collapses sequences of three or more consecutive newlines into two newlines.
87+
* @param res The input string to be processed.
8888
*/
8989
export function collapseNewlines(res: string): string {
9090
return res?.replace(/(\r?\n){3,}/g, "\n\n")

packages/core/src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ export async function readConfig(
165165
}
166166

167167
/**
168-
* Outputs environment information for model providers.
169-
* @param provider - The specific provider to filter by (optional).
170-
* @param options - Configuration options, including whether to show tokens.
168+
* Resolves and outputs environment information for language model providers.
169+
* @param provider - Specific provider to filter by (optional).
170+
* @param options - Configuration options, including whether to show tokens, errors, models, or hide hidden providers.
171171
*/
172172
export async function resolveLanguageModelConfigurations(
173173
provider: string,

packages/core/src/consolecolor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export let consoleColors = !!stdout.isTTY
66

77
/**
88
* Enables or disables console color output.
9-
* @param enabled - Whether to enable or disable console colors.
9+
* @param enabled - Indicates whether to enable or disable color output.
1010
*/
1111
export function setConsoleColors(enabled: boolean) {
1212
consoleColors = !!enabled
@@ -21,8 +21,8 @@ export function setConsoleColors(enabled: boolean) {
2121
*/
2222
/**
2323
* Wraps a message with ANSI escape codes for the specified color.
24-
* @param n - Color code or string to apply.
25-
* @param message - Text to be wrapped with color codes.
24+
* @param n - The ANSI color code or string to apply.
25+
* @param message - The text to wrap with color codes.
2626
*/
2727
export function wrapColor(n: number | string, message: string) {
2828
if (consoleColors) return `\x1B[${n}m${message}\x1B[0m`

packages/core/src/copy.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ function promptPath(id: string, options?: { javascript?: boolean }) {
2424

2525
/**
2626
* Copies a prompt script to a new location.
27-
* Can optionally fork the script if needed, ensuring that the new filename is unique.
27+
* Optionally forks the script, ensuring the new filename is unique if needed.
2828
*
29-
* @param t - The prompt script object
30-
* @param options - Configuration options for the copy
31-
* @param options.fork - Indicates if the script should be forked
32-
* @param options.name - Optional new name for the copied script
33-
* @returns The file path of the copied script
34-
* @throws If the file already exists in the target location
29+
* @param t - The prompt script object containing the source code.
30+
* @param options - Configuration options for the copy operation.
31+
* @param options.fork - Whether to fork the script by appending a unique suffix.
32+
* @param options.name - Optional new name for the copied script.
33+
* @param options.javascript - Whether to use the JavaScript file extension.
34+
* @returns The file path of the copied script.
35+
* @throws If the file already exists in the target location.
3536
*/
3637
export async function copyPrompt(
3738
t: PromptScript,

0 commit comments

Comments
 (0)