-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b85812
commit cb35d28
Showing
52 changed files
with
3,063 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { execSync } from 'child_process' | ||
import { writeFileSync } from 'fs' | ||
|
||
// `$ skeet --help`からコマンドのリストを取得 | ||
function getCommands(): string[] { | ||
const helpOutput = execSync('skeet --help').toString() | ||
|
||
// 正規表現を使用してコマンド名を抽出 (これは仮の正規表現で、実際の出力に合わせて調整が必要です) | ||
const commandMatches = helpOutput.match(/^\s*(\w+)\s+/gm) | ||
|
||
if (!commandMatches) return [] | ||
|
||
return commandMatches.map((cmd) => cmd.trim()) | ||
} | ||
|
||
// 各コマンドに対して詳細なヘルプを取得 | ||
function getDetailedHelpForCommand(command: string): string { | ||
return execSync(`skeet ${command} --help`).toString() | ||
} | ||
|
||
// 実行 | ||
const commands = getCommands() | ||
const detailedHelpArray: string[] = [] | ||
|
||
for (const command of commands) { | ||
const detailedHelp = getDetailedHelpForCommand(command) | ||
detailedHelpArray.push(detailedHelp) | ||
} | ||
|
||
writeFileSync('detailedHelpArray.txt', detailedHelpArray.join('\n\n')) | ||
console.log(detailedHelpArray) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { SkeetAiMode } from '@/types/skeetTypes' | ||
import { SkeetAIOptions } from '@skeet-framework/ai' | ||
import { utcNow } from '@skeet-framework/utils' | ||
import chalk from 'chalk' | ||
import CliTable3 from 'cli-table3' | ||
import { appendFileSync, existsSync, mkdirSync, readFileSync } from 'fs' | ||
|
||
export class AiLog { | ||
lang: string | ||
|
||
constructor(lang = 'en') { | ||
this.lang = lang | ||
} | ||
|
||
text = () => { | ||
const localeFile = JSON.parse( | ||
readFileSync(`src/cli/ai/locales/${this.lang}/skeetAi.json`, 'utf8') | ||
) as SkeetLog | ||
return localeFile | ||
} | ||
|
||
help = () => { | ||
console.log( | ||
chalk.white( | ||
`\n🤖 ${this.text().common.skeetAiModeText} 🤖\n\n` + | ||
'$ prisma\n' + | ||
'$ typedoc\n' + | ||
'$ translate\n' + | ||
'$ firestore\n' + | ||
'$ function\n' + | ||
'$ method\n' + | ||
'$ help\n' + | ||
'$ q\n' | ||
) | ||
) | ||
} | ||
|
||
aiOptionTable = (aiOptions: SkeetAIOptions) => { | ||
const table = new CliTable3({ | ||
head: [chalk.blue('Option'), chalk.blue('Value')], | ||
chars: { | ||
top: '═', | ||
'top-mid': '╤', | ||
'top-left': '╔', | ||
'top-right': '╗', | ||
bottom: '═', | ||
'bottom-mid': '╧', | ||
'bottom-left': '╚', | ||
'bottom-right': '╝', | ||
left: '│', | ||
'left-mid': '╟', | ||
mid: '─', | ||
'mid-mid': '┼', | ||
right: '│', | ||
'right-mid': '╢', | ||
middle: '│', | ||
}, // テーブルの罫線スタイルを指定 | ||
}) | ||
|
||
table.push( | ||
[this.text().common.aiType, aiOptions.ai], | ||
[this.text().common.model, aiOptions.model], | ||
[this.text().common.maxToken, aiOptions.maxTokens], | ||
[this.text().common.temperature, aiOptions.temperature] | ||
) | ||
|
||
console.log(table.toString()) | ||
} | ||
|
||
addJson = ( | ||
role: string, | ||
content: string, | ||
mode: SkeetAiMode, | ||
model: string | ||
) => { | ||
const tmpJson = `tmp/ai/history-${this.lang}.jsonl` | ||
if (!existsSync('tmp/ai')) { | ||
mkdirSync('tmp/ai', { recursive: true }) | ||
} | ||
const data = { | ||
role, | ||
content, | ||
mode, | ||
model, | ||
createdAt: utcNow(), | ||
} | ||
let insertData = '' | ||
if (existsSync(tmpJson) === false) { | ||
appendFileSync(tmpJson, '') | ||
insertData = JSON.stringify(data) | ||
} else { | ||
insertData = ',\n' + JSON.stringify(data) | ||
} | ||
appendFileSync(tmpJson, insertData) | ||
} | ||
} |
Oops, something went wrong.