Skip to content

Commit

Permalink
chore: Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Aug 4, 2024
1 parent d7b3d54 commit d3bdc05
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default antfu({
},
typescript: true,
yaml: true,
markdown: false, // TODO: Temporary fix until code blocks are correctly read
markdown: true,
ignores: ['package.json', 'dist/', 'node_modules/', 'test/mocks/'],
rules: {
'unused-imports/no-unused-vars': 'warn',
Expand Down
9 changes: 3 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ const inDocker = isDocker()

try {
const port = inDocker ? 80 : parsedEnv.port
const host = inDocker ? '0.0.0.0' : parsedEnv.host
await checkPort(port, host)
app.listen({
hostname: parsedEnv.host,
port: parsedEnv.port,
})
const hostname = inDocker ? '0.0.0.0' : parsedEnv.host
await checkPort(port, hostname)
app.listen({ hostname, port })
await logWelcome()
}
catch (error) {
Expand Down
35 changes: 19 additions & 16 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,34 @@ From inside any hook, tool or form, you can access the current plugin informatio
```ts
// For example, in a hook
CatHook.add('agentPromptPrefix', (prefix, cat) => {
const info = cat.getPluginInfo()
if (!info) return prefix
return info.settings.prefix
const info = cat.getPluginInfo()
if (!info) return prefix
return info.settings.prefix
})

// For example, in a tool
CatTool.add('myToolName', 'myToolDescription', async (input, cat) => {
const info = cat.getPluginInfo()
// ...
const info = cat.getPluginInfo()
console.log(info)
// ...
}, {
direct: true,
startExamples: ['startExample1', 'startExample2'],
direct: true,
startExamples: ['startExample1', 'startExample2'],
})

// For example, in a form
CatForm.add('myFormName', {
myKey1: z.string().describe('myKey1Description'),
myKey2: z.number().describe('myKey2Description'),
myKey1: z.string().describe('myKey1Description'),
myKey2: z.number().describe('myKey2Description'),
}, {
description: 'myFormDescription',
startExamples: ['myFormExample1', 'myFormExample2'],
async onSubmit({ myKey1, myKey2 }, cat) {
const info = cat.getPluginInfo()
// ...
}
description: 'myFormDescription',
startExamples: ['myFormExample1', 'myFormExample2'],
async onSubmit({ myKey1, myKey2 }, cat) {
console.log(myKey1, myKey2)
const info = cat.getPluginInfo()
console.log(info)
// ...
}
})
```

Expand All @@ -66,7 +69,7 @@ For the plugin settings, you must use `zod`. Here is an example:
import { z } from 'zod'

CatPlugin.settings({
mySetting: z.string().default('default value')
mySetting: z.string().default('default value')
})
```

Expand Down
1 change: 0 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config'
import { join } from 'node:path'
import { readdir } from 'node:fs/promises'
import _SampleSize from 'lodash/sampleSize.js'
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({
plugins: [tsconfigPaths()],
test: {
name: 'src',
name: 'CheshireCat',
environment: 'node',
setupFiles: ['./test/env-mock.ts'],
},
Expand Down

0 comments on commit d3bdc05

Please sign in to comment.