style: lint
This commit is contained in:
@@ -16,11 +16,11 @@ import { resolveComma, toArray } from './utils/general'
|
||||
interface Options {
|
||||
config?: string
|
||||
configLoader?: 'auto' | 'native' | 'unconfig'
|
||||
noConfig?: boolean
|
||||
debug?: boolean | string | string[]
|
||||
logLevel?: LogLevelString.Log | LogLevelString.Warning | LogLevelString.Error
|
||||
failOnWarn?: boolean
|
||||
env?: Record<string, string>
|
||||
failOnWarn?: boolean
|
||||
logLevel?: LogLevelString.Error | LogLevelString.Log | LogLevelString.Warning
|
||||
noConfig?: boolean
|
||||
quiet?: boolean
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ const cli = cac('airi-plugin-claude-code-cli')
|
||||
cli.help().version(version)
|
||||
|
||||
cli
|
||||
.command('send', 'Pass Claude Code hook event to Channel Server', { ignoreOptionDefaultValue: true, allowUnknownOptions: true })
|
||||
.command('send', 'Pass Claude Code hook event to Channel Server', { allowUnknownOptions: true, ignoreOptionDefaultValue: true })
|
||||
.option('-c, --config <filename>', 'Use a custom config file')
|
||||
.option('--config-loader <loader>', 'Config loader to use: auto, native, unconfig', { default: 'auto' })
|
||||
.option('--no-config', 'Disable config file')
|
||||
@@ -68,10 +68,10 @@ cli
|
||||
const hookEvent = JSON.parse(stdinInput) as HookInput
|
||||
|
||||
if (hookEvent.hook_event_name === 'UserPromptSubmit') {
|
||||
const channelServer = new Client({ name: 'proj-airi:plugin-claude-code', autoConnect: false })
|
||||
const channelServer = new Client({ autoConnect: false, name: 'proj-airi:plugin-claude-code' })
|
||||
await channelServer.connect()
|
||||
|
||||
channelServer.send({ type: 'input:text', data: { text: hookEvent.prompt } })
|
||||
channelServer.send({ data: { text: hookEvent.prompt }, type: 'input:text' })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,39 +1,3 @@
|
||||
/**
|
||||
* https://github.com/rolldown/tsdown/blob/a7e267ab7f4e836e836dab5cecf029fc35fd1939/src/utils/general.ts
|
||||
*/
|
||||
export function toArray<T>(
|
||||
val: T | T[] | null | undefined,
|
||||
defaultValue?: T,
|
||||
): T[] {
|
||||
if (Array.isArray(val)) {
|
||||
return val
|
||||
}
|
||||
else if (val == null) {
|
||||
if (defaultValue)
|
||||
return [defaultValue]
|
||||
return []
|
||||
}
|
||||
else {
|
||||
return [val]
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveComma<T extends string>(arr: T[]): T[] {
|
||||
return arr.flatMap(format => format.split(',') as T[])
|
||||
}
|
||||
|
||||
export function resolveRegex<T>(str: T): T | RegExp {
|
||||
if (
|
||||
typeof str === 'string'
|
||||
&& str.length > 2
|
||||
&& str[0] === '/'
|
||||
&& str.at(-1) === '/'
|
||||
) {
|
||||
return new RegExp(str.slice(1, -1))
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
export function debounce<T extends (...args: any[]) => any>(
|
||||
fn: T,
|
||||
wait: number,
|
||||
@@ -49,15 +13,51 @@ export function debounce<T extends (...args: any[]) => any>(
|
||||
} as T
|
||||
}
|
||||
|
||||
export function resolveComma<T extends string>(arr: T[]): T[] {
|
||||
return arr.flatMap(format => format.split(',') as T[])
|
||||
}
|
||||
|
||||
export function resolveRegex<T>(str: T): RegExp | T {
|
||||
if (
|
||||
typeof str === 'string'
|
||||
&& str.length > 2
|
||||
&& str[0] === '/'
|
||||
&& str.at(-1) === '/'
|
||||
) {
|
||||
return new RegExp(str.slice(1, -1))
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
export function slash(string: string): string {
|
||||
return string.replaceAll('\\', '/')
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/rolldown/tsdown/blob/a7e267ab7f4e836e836dab5cecf029fc35fd1939/src/utils/general.ts
|
||||
*/
|
||||
export function toArray<T>(
|
||||
val: null | T | T[] | undefined,
|
||||
defaultValue?: T,
|
||||
): T[] {
|
||||
if (Array.isArray(val)) {
|
||||
return val
|
||||
}
|
||||
else if (val == null) {
|
||||
if (defaultValue)
|
||||
return [defaultValue]
|
||||
return []
|
||||
}
|
||||
else {
|
||||
return [val]
|
||||
}
|
||||
}
|
||||
|
||||
export const noop = <T>(v: T): T => v
|
||||
|
||||
export function matchPattern(
|
||||
id: string,
|
||||
patterns: (string | RegExp)[],
|
||||
patterns: (RegExp | string)[],
|
||||
): boolean {
|
||||
return patterns.some((pattern) => {
|
||||
if (pattern instanceof RegExp) {
|
||||
|
||||
Reference in New Issue
Block a user