chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:44:08 +08:00
commit 983960e2dd
1244 changed files with 281996 additions and 0 deletions
@@ -0,0 +1,52 @@
import crypto from 'node:crypto'
import dotenv from 'dotenv'
import { LogHelper } from '@/helpers/log-helper'
import { StringHelper } from '@/helpers/string-helper'
import { ProfileHelper } from '@/helpers/profile-helper'
import { PROFILE_DOT_ENV_PATH } from '@/constants'
dotenv.config({ path: PROFILE_DOT_ENV_PATH })
/**
* Generate Leon client interface token script
* save it in the .env file
*/
const generateClientInterfaceToken = () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Generating my client interface token...')
try {
const shasum = crypto.createHash('sha1')
const str = StringHelper.random(11)
const envVarKey = 'LEON_CLIENT_INTERFACE_TOKEN'
shasum.update(str)
const sha1 = shasum.digest('hex')
await ProfileHelper.updateDotEnvVariable(envVarKey, sha1)
LogHelper.success('Client interface token generated')
resolve()
} catch (e) {
LogHelper.error(e.message)
reject(e)
}
})
export default () =>
new Promise(async (resolve, reject) => {
try {
if (
!process.env.LEON_CLIENT_INTERFACE_TOKEN ||
process.env.LEON_CLIENT_INTERFACE_TOKEN === ''
) {
await generateClientInterfaceToken()
}
resolve()
} catch (e) {
reject(e)
}
})
+98
View File
@@ -0,0 +1,98 @@
import fs from 'node:fs'
import path from 'node:path'
import {
domainSchemaObject,
skillSchemaObject,
skillConfigSchemaObject,
skillLocaleConfigObject
} from '@/schemas/skill-schemas'
import { toolManifestSchemaObject } from '@/schemas/tool-schemas'
import { toolkitSchemaObject } from '@/schemas/toolkit-schemas'
import {
globalEntitySchemaObject,
globalResolverSchemaObject,
globalAnswersSchemaObject
} from '@/schemas/global-data-schemas'
import {
amazonVoiceConfiguration,
googleCloudVoiceConfiguration,
watsonVoiceConfiguration
} from '@/schemas/voice-config-schemas'
import { configSchemaObject } from '@/schemas/core-schemas'
import { createSetupStatus } from '../setup/setup-status'
/**
* Generate JSON schemas
* @param {string} categoryName
* @param {Map<string, Object>} schemas
*/
export const generateSchemas = async (categoryName, schemas) => {
const categorySchemasPath = path.join(process.cwd(), 'schemas', categoryName)
await fs.promises.mkdir(categorySchemasPath, { recursive: true })
for (const [schemaName, schemaObject] of schemas.entries()) {
const schemaPath = path.join(categorySchemasPath, `${schemaName}.json`)
await fs.promises.writeFile(
schemaPath,
JSON.stringify(
{
$schema: 'https://json-schema.org/draft-07/schema',
...schemaObject
},
null,
2
)
)
}
}
export default async () => {
const status = createSetupStatus('Generating JSON schemas...').start()
await Promise.all([
generateSchemas(
'core-schemas',
new Map([['config', configSchemaObject]])
),
generateSchemas(
'global-data',
new Map([
['global-entity', globalEntitySchemaObject],
['global-resolver', globalResolverSchemaObject],
['global-answers', globalAnswersSchemaObject]
])
),
generateSchemas(
'skill-schemas',
new Map([
['domain', domainSchemaObject],
['skill', skillSchemaObject],
['skill-config', skillConfigSchemaObject],
['skill-locale-config', skillLocaleConfigObject]
])
),
generateSchemas(
'tool-schemas',
new Map([['tool', toolManifestSchemaObject]])
),
generateSchemas(
'toolkit-schemas',
new Map([['toolkit', toolkitSchemaObject]])
),
generateSchemas(
'voice-config-schemas',
new Map([
['amazon', amazonVoiceConfiguration],
['google-cloud', googleCloudVoiceConfiguration],
['watson-stt', watsonVoiceConfiguration],
['watson-tts', watsonVoiceConfiguration]
])
)
])
status.succeed('JSON schemas: ready')
}
+99
View File
@@ -0,0 +1,99 @@
/**
* It will generate a prompt that can then
* be passed to an agentic coding solution as OpenCode.
*/
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { LogHelper } from '@/helpers/log-helper'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const TOOL_ALIAS_NAME = 'Qwen3-TTS'
const TOOL_NAME = 'qwen3_tts'
const TOOL_TS_FILE_NAME = `${TOOL_NAME}-tool.ts`
const TOOL_PYTHON_FILE_NAME = `${TOOL_NAME}_tool.py`
const TOOL_TOOLKIT_NAME = 'music_audio'
const TOOL_DESCRIPTION = `${TOOL_ALIAS_NAME} is a tool designed to facilitate text-to-speech (TTS) and voice design using the Qwen3-TTS model. This tool allows owners to convert text into natural-sounding speech, with the option to clone voices for personalized voice design.`
const TOOL_PURPOSE_REQUIREMENT = `The goal of this tool is to bind the functions of the CLI:
- synthesize_speech
- design_voice
- custom_voice
- design_then_synthesize
It provides functionalities for text-to-speech (with voice cloning support) and voice design using the official Qwen3-TTS models.`
const TEMPLATE_CONFIGS = {
'create-tool': {
templateFile: 'create-tool-template.md',
replacements: {
'{TOOL_ALIAS_NAME}': TOOL_ALIAS_NAME,
'{TOOL_NAME}': TOOL_NAME,
'{TOOL_TS_FILE_NAME}': TOOL_TS_FILE_NAME,
'{TOOL_PYTHON_FILE_NAME}': TOOL_PYTHON_FILE_NAME,
'{TOOL_TOOLKIT_NAME}': TOOL_TOOLKIT_NAME,
'{TOOL_DESCRIPTION}': TOOL_DESCRIPTION,
'{TOOL_PURPOSE_REQUIREMENT}': TOOL_PURPOSE_REQUIREMENT
}
},
'create-skill': {
templateFile: 'create-skill-template.md',
replacements: {
// TODO
}
}
}
/**
* Reads a markdown template file, replaces placeholders with actual values,
* and saves the result to the scripts/out folder
* @param {string} templateName
* @returns {string} Path to the generated output file
*/
export default async (templateName) => {
if (!templateName) {
throw new Error(
'Missing template name. Example: pnpm run generate:prompt create-tool'
)
}
const templateConfig = TEMPLATE_CONFIGS[templateName]
if (!templateConfig) {
const availableTemplates = Object.keys(TEMPLATE_CONFIGS).join(', ')
throw new Error(
`Unknown template "${templateName}". Available templates: ${availableTemplates}`
)
}
const templatePath = path.join(
dirname,
'..',
'prompt-templates',
templateConfig.templateFile
)
const templateContent = await fs.promises.readFile(templatePath, 'utf-8')
let outputContent = templateContent
for (const [placeholder, value] of Object.entries(
templateConfig.replacements
)) {
outputContent = outputContent.replaceAll(placeholder, value)
}
const outDir = path.join(dirname, '..', 'out')
await fs.promises.mkdir(outDir, { recursive: true })
const templateFileName = path.basename(templatePath, '.md')
const outputFileName = templateFileName.replace('-template', '') + '.md'
const outputPath = path.join(outDir, outputFileName)
await fs.promises.writeFile(outputPath, outputContent, 'utf-8')
LogHelper.success(`Prompt generated: ${outputPath}`)
return outputPath
}
@@ -0,0 +1,14 @@
import { LogHelper } from '@/helpers/log-helper'
import generateClientInterfaceToken from './generate-client-interface-token'
/**
* Execute the generating Leon client interface token script
*/
;(async () => {
try {
await generateClientInterfaceToken()
} catch (e) {
LogHelper.error(`Failed to generate the Leon client interface token: ${e}`)
}
})()
@@ -0,0 +1,14 @@
import { LogHelper } from '@/helpers/log-helper'
import generateJsonSchemas from './generate-json-schemas'
/**
* Execute the generating JSON schemas script
*/
;(async () => {
try {
await generateJsonSchemas()
} catch (error) {
LogHelper.error(`Failed to generate the json schemas: ${error}`)
}
})()
+16
View File
@@ -0,0 +1,16 @@
import { LogHelper } from '@/helpers/log-helper'
import generatePrompt from './generate-prompt'
/**
* Execute the generating prompt script
*/
;(async () => {
try {
const templateName = process.argv[2]
await generatePrompt(templateName)
} catch (error) {
LogHelper.error(`Failed to generate the prompt: ${error}`)
}
})()