Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "^3.564.0",
"@botpress/api": "1.70.2",
"@botpress/api": "1.71.0",
"@botpress/cli": "workspace:*",
"@botpress/client": "workspace:*",
"@botpress/sdk": "workspace:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cli",
"version": "5.5.0",
"version": "5.5.1",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
Expand All @@ -27,8 +27,8 @@
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"@botpress/chat": "0.5.4",
"@botpress/client": "1.31.0",
"@botpress/sdk": "5.3.2",
"@botpress/client": "1.32.0",
"@botpress/sdk": "5.3.3",
"@bpinternal/const": "^0.1.0",
"@bpinternal/tunnel": "^0.1.1",
"@bpinternal/verel": "^0.2.0",
Expand Down
28 changes: 22 additions & 6 deletions packages/cli/src/command-implementations/lint-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ import {
import * as apiUtils from '../api'
import type commandDefinitions from '../command-definitions'
import * as errors from '../errors'
import { BaseLinter } from '../linter/base-linter'
import { BotLinter } from '../linter/bot-linter'
import { IntegrationLinter } from '../linter/integration-linter'
import { InterfaceLinter } from '../linter/interface-linter'
import { ProjectCommand } from './project-command'

const _getIssuesDetectedMessage = (linter: BaseLinter<unknown>, nonEmptyPrefix: string = '') => {
const message = linter
.getIssuesCountBySeverity()
.map(({ name, count }) => `${count} ${name}(s)`)
.join(', ')

return message.length > 0 ? `${nonEmptyPrefix}${message}` : ''
}

export type LintCommandDefinition = typeof commandDefinitions.lint
export class LintCommand extends ProjectCommand<LintCommandDefinition> {
public async run(): Promise<void> {
Expand Down Expand Up @@ -59,11 +69,13 @@ export class LintCommand extends ProjectCommand<LintCommandDefinition> {
await linter.lint()
linter.logResults(this.logger)

const issueCountsSuffix = _getIssuesDetectedMessage(linter, ' - ')

if (linter.hasErrors()) {
throw new errors.BotpressCLIError('Interface definition contains linting errors')
throw new errors.BotpressCLIError(`Interface definition contains linting errors${issueCountsSuffix}`)
}

this.logger.success('Interface definition is valid')
this.logger.success(`Interface definition is valid${issueCountsSuffix}`)
}

private async _runLintForBot(definition: BotDefinition): Promise<void> {
Expand All @@ -74,11 +86,13 @@ export class LintCommand extends ProjectCommand<LintCommandDefinition> {
await linter.lint()
linter.logResults(this.logger)

const issueCountsSuffix = _getIssuesDetectedMessage(linter, ' - ')

if (linter.hasErrors()) {
throw new errors.BotpressCLIError('Bot definition contains linting errors')
throw new errors.BotpressCLIError(`Bot definition contains linting errors${issueCountsSuffix}`)
}

this.logger.success('Bot definition is valid')
this.logger.success(`Bot definition is valid${issueCountsSuffix}`)
}

private _stripAutoGeneratedContentFromBot(definition: BotDefinition) {
Expand All @@ -99,11 +113,13 @@ export class LintCommand extends ProjectCommand<LintCommandDefinition> {
await linter.lint()
linter.logResults(this.logger)

const issueCountsSuffix = _getIssuesDetectedMessage(linter, ' - ')

if (linter.hasErrors()) {
throw new errors.BotpressCLIError('Integration definition contains linting errors')
throw new errors.BotpressCLIError(`Integration definition contains linting errors${issueCountsSuffix}`)
}

this.logger.success('Integration definition is valid')
this.logger.success(`Integration definition is valid${issueCountsSuffix}`)
}

private _stripAutoGeneratedContentFromIntegration(definition: IntegrationDefinition) {
Expand Down
49 changes: 42 additions & 7 deletions packages/cli/src/linter/base-linter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Spectral, Document, type ISpectralDiagnostic, type RulesetDefinition } from '@stoplight/spectral-core'
import { Json as JsonParser, type JsonParserResult } from '@stoplight/spectral-parsers'
import { DiagnosticSeverity } from '@stoplight/types'
import { type Logger } from '../logger'
import { TRUTHY_WITH_MESSAGE_ID } from './spectral-functions'

type ProblemSeverity = 0 | 1 | 2 | 3
enum ProblemSeverity {
Error = 0,
Warning = 1,
Info = 2,
Debug = 3,
}

const _injectLoggerIntoRulesetOptions = (ruleset: RulesetDefinition, logger?: Logger) => {
// This is the most jankiest thing I've ever done but
Expand Down Expand Up @@ -62,11 +68,31 @@ export abstract class BaseLinter<TDefinition> {
return this._results.some((result) => result.severity === 0)
}

public getIssuesCountBySeverity() {
return Object.values(
this._getResults().reduce(
(acc, { severity }) => {
if (!acc.hasOwnProperty(severity)) {
acc[severity] = {
severityLevel: severity,
name: ProblemSeverity[severity] ?? 'Unknown',
count: 0,
}
}

acc[severity].count += 1
return acc
},
{} as Record<ProblemSeverity, ResultSeverityCount>
)
).toSorted((a, b) => a.severityLevel - b.severityLevel)
}

private _getResults() {
return this._results.map((result) => ({
message: result.message,
path: this._simplifyPath(result.path),
severity: result.severity as ProblemSeverity,
severity: result.severity as StoplightServerity,
}))
}

Expand All @@ -76,12 +102,21 @@ export abstract class BaseLinter<TDefinition> {

private _logResultMessage(logger: Logger, message: string, severity: ProblemSeverity) {
const logLevelMapping = {
0: logger.error,
1: logger.warn,
2: logger.log,
3: logger.debug,
} as const
[ProblemSeverity.Error]: logger.error,
[ProblemSeverity.Warning]: logger.warn,
[ProblemSeverity.Info]: logger.log,
[ProblemSeverity.Debug]: logger.debug,
} as const satisfies Record<StoplightServerity, Function>

logLevelMapping[severity].call(logger, message)
}
}

type ResultSeverityCount = {
severityLevel: ProblemSeverity
name: string
count: number
}

type EnumToIndices<T extends {}> = `${Extract<T, number>}` extends `${infer N extends number}` ? N : never
type StoplightServerity = EnumToIndices<DiagnosticSeverity>
4 changes: 2 additions & 2 deletions packages/cli/templates/empty-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.31.0",
"@botpress/sdk": "5.3.2"
"@botpress/client": "1.32.0",
"@botpress/sdk": "5.3.3"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/templates/empty-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.31.0",
"@botpress/sdk": "5.3.2"
"@botpress/client": "1.32.0",
"@botpress/sdk": "5.3.3"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/empty-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"private": true,
"dependencies": {
"@botpress/sdk": "5.3.2"
"@botpress/sdk": "5.3.3"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/templates/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.31.0",
"@botpress/sdk": "5.3.2"
"@botpress/client": "1.32.0",
"@botpress/sdk": "5.3.3"
},
"devDependencies": {
"@types/node": "^22.16.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/templates/webhook-message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
"private": true,
"dependencies": {
"@botpress/client": "1.31.0",
"@botpress/sdk": "5.3.2",
"@botpress/client": "1.32.0",
"@botpress/sdk": "5.3.3",
"axios": "^1.6.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/client",
"version": "1.31.0",
"version": "1.32.0",
"description": "Botpress Client",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/cognitive/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cognitive",
"version": "0.3.8",
"version": "0.3.9",
"description": "Wrapper around the Botpress Client to call LLMs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions packages/llmz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "llmz",
"type": "module",
"description": "LLMz - An LLM-native Typescript VM built on top of Zui",
"version": "0.0.46",
"version": "0.0.47",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -71,8 +71,8 @@
"tsx": "^4.19.2"
},
"peerDependencies": {
"@botpress/client": "1.31.0",
"@botpress/cognitive": "0.3.8",
"@botpress/client": "1.32.0",
"@botpress/cognitive": "0.3.9",
"@bpinternal/thicktoken": "^1.0.5",
"@bpinternal/zui": "^1.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/sdk",
"version": "5.3.2",
"version": "5.3.3",
"description": "Botpress SDK",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand All @@ -20,7 +20,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@botpress/client": "1.31.0",
"@botpress/client": "1.32.0",
"browser-or-node": "^2.1.1",
"semver": "^7.3.8"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/vai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/vai",
"version": "0.0.11",
"version": "0.0.12",
"description": "Vitest AI (vai) – a vitest extension for testing with LLMs",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"tsup": "^8.0.2"
},
"peerDependencies": {
"@botpress/client": "1.31.0",
"@botpress/client": "1.32.0",
"@bpinternal/thicktoken": "^1.0.1",
"@bpinternal/zui": "^1.3.2",
"lodash": "^4.17.21",
Expand Down
4 changes: 2 additions & 2 deletions packages/zai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@botpress/zai",
"description": "Zui AI (zai) – An LLM utility library written on top of Zui and the Botpress API",
"version": "2.5.11",
"version": "2.5.12",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@botpress/cognitive": "0.3.8",
"@botpress/cognitive": "0.3.9",
"json5": "^2.2.3",
"jsonrepair": "^3.10.0",
"lodash-es": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion plugins/conversation-insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"private": true,
"dependencies": {
"@botpress/cognitive": "0.3.8",
"@botpress/cognitive": "0.3.9",
"@botpress/sdk": "workspace:*",
"browser-or-node": "^2.1.1",
"jsonrepair": "^3.10.0"
Expand Down
Loading
Loading