@yorha2b-lab/autodev 5.2.1 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/autodev.js +1 -1
- package/package.json +1 -1
- package/src/bootstrap/index.js +1 -1
- package/src/bootstrap/labs.js +5 -10
- package/src/dialogs/EN-US.js +3 -2
- package/src/dialogs/ZH-CN.js +2 -1
- package/src/framework/react/handlebars/partials/handleBlock.hbs +2 -2
- package/src/framework/react/prompts/{linker.js → council.js} +1 -1
- package/src/handlers/api.js +11 -3
- package/src/labs/{linker.js → council.js} +20 -7
- package/src/labs/tower.js +2 -2
- package/src/services/llm.js +3 -3
- package/src/utils/ux.js +1 -1
package/bin/autodev.js
CHANGED
|
@@ -7,7 +7,7 @@ const { program } = require('commander')
|
|
|
7
7
|
const { local, matrixEffect, bootSequence } = require('../src/utils/ux')
|
|
8
8
|
|
|
9
9
|
const dialogs = require('../src/bootstrap/registry')({ dir: path.join(__dirname, '../src/dialogs') })
|
|
10
|
-
const dialog = dialogs[local]
|
|
10
|
+
const dialog = dialogs[local] ?? dialogs['EN-US']
|
|
11
11
|
|
|
12
12
|
program
|
|
13
13
|
.version(pkg.version)
|
package/package.json
CHANGED
package/src/bootstrap/index.js
CHANGED
|
@@ -56,7 +56,7 @@ module.exports = {
|
|
|
56
56
|
reboot() {
|
|
57
57
|
const { template, dialog } = instance
|
|
58
58
|
delete require.cache[require.resolve(path.join(process.cwd(), 'config.js'))]
|
|
59
|
-
instance.labs?.
|
|
59
|
+
instance.labs?.tower?.close()
|
|
60
60
|
instance = null
|
|
61
61
|
return this.init({ template }, dialog)
|
|
62
62
|
}
|
package/src/bootstrap/labs.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
let tower
|
|
2
|
-
|
|
3
1
|
module.exports = accessPoint => {
|
|
4
2
|
|
|
3
|
+
const labs = {}
|
|
4
|
+
|
|
5
5
|
const { apiDoc, needMock, proxyTarget, enableAutoAlignment } = accessPoint.config
|
|
6
6
|
|
|
7
7
|
if (!needMock && proxyTarget && enableAutoAlignment) {
|
|
8
|
-
tower = require('../labs/tower')(accessPoint)
|
|
8
|
+
labs.tower = require('../labs/tower')(accessPoint)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
if (apiDoc && enableAutoAlignment) {
|
|
12
|
-
require('../labs/
|
|
12
|
+
labs.council = require('../labs/council')(accessPoint)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return
|
|
16
|
-
shutdown() {
|
|
17
|
-
tower?.close()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
return labs
|
|
21
16
|
}
|
package/src/dialogs/EN-US.js
CHANGED
|
@@ -31,9 +31,9 @@ module.exports = {
|
|
|
31
31
|
bridgeProtocolComplete: (count, time) => `Semantic bridge protocol complete. Corrected ${count} field deviations. Elapsed: ${time}s`,
|
|
32
32
|
},
|
|
33
33
|
bunker: {
|
|
34
|
-
exit: 'Signal Lost',
|
|
35
|
-
envCopy: '.env storage complete',
|
|
34
|
+
exit: 'Signal Lost...',
|
|
36
35
|
envCheck: '.env already exists',
|
|
36
|
+
envCopy: '.env storage complete',
|
|
37
37
|
systemStandby: 'System is STANDBY',
|
|
38
38
|
configCheck: 'config.js already exists',
|
|
39
39
|
configCopy: 'config.js storage complete',
|
|
@@ -48,6 +48,7 @@ module.exports = {
|
|
|
48
48
|
systemOffline: 'Disconnecting Neural Link, Executing Physical Assembly...',
|
|
49
49
|
accessDenied: 'YoRHa Command Center Access Denied: Invalid API Key or quota exhausted!',
|
|
50
50
|
watchDesc: 'Start full-channel linked monitoring: Coordinated Page/Part/API construction',
|
|
51
|
+
copyEnum: `│ Backend Enums detected \n│ Weld the code below into the module's resource center`,
|
|
51
52
|
towerConnected: port => `Command: Please point your local proxy target to http://localhost:${port}`,
|
|
52
53
|
disclaimer: 'Match Result Reference Only. Not Final Decision. Each Unit should adjust based on battlefield conditions',
|
|
53
54
|
frameworkNotSupported: template => `[${template}] framework not supported. Welcome to contribute a Pull Request to help`,
|
package/src/dialogs/ZH-CN.js
CHANGED
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
|
31
31
|
bridgeProtocolComplete: (count, time) => `语义桥接协议执行完毕。已物理修正 ${count} 处字段偏差。耗时: ${time}s`,
|
|
32
32
|
},
|
|
33
33
|
bunker: {
|
|
34
|
-
exit: '
|
|
34
|
+
exit: '系统信号已丢失...',
|
|
35
35
|
envCopy: '.env 存储完毕',
|
|
36
36
|
argDesc: '指定前端框架模板',
|
|
37
37
|
systemStandby: '系统待机中...',
|
|
@@ -50,6 +50,7 @@ module.exports = {
|
|
|
50
50
|
accessDenied: '司令部拒绝访问:API Key 无效或额度耗尽,请检查!',
|
|
51
51
|
disclaimer: '匹配结果仅供参考,不构成最终决策,各机体需根据实际情况进行调整',
|
|
52
52
|
towerConnected: port => `指令:请将您的代理目标指向 http://localhost:${port}`,
|
|
53
|
+
copyEnum: '│ 侦察到后端原始基因(Enum) \n│ 建议:将下方代码片段物理焊接到该模块的资源中心',
|
|
53
54
|
networkInstability: count => `神经云网络连接不稳,正在尝试重新链接... (第 ${count} 次重试)`,
|
|
54
55
|
frameworkNotSupported: template => `暂不支持 [${template}] 框架。欢迎提交 Pull Request 贡献`,
|
|
55
56
|
strategicThreshold: (target, current) => `物理克隆总数已超越 ${target} 战略阈值!当前战力:${current}`,
|
|
@@ -38,9 +38,9 @@ const onTabChange = key => {
|
|
|
38
38
|
{{#if hasExpandable}}
|
|
39
39
|
const onExpand = async (expanded, record) => {
|
|
40
40
|
if (expanded) {
|
|
41
|
-
setExpandedRowKeys(prev=>[...prev, record
|
|
41
|
+
setExpandedRowKeys(prev=>[...prev, record[rowKey])
|
|
42
42
|
} else {
|
|
43
|
-
setExpandedRowKeys(prev=>prev.filter(item => item !== record
|
|
43
|
+
setExpandedRowKeys(prev=>prev.filter(item => item !== record[rowKey]))
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -12,7 +12,7 @@ ${realApis}
|
|
|
12
12
|
- 识别后缀(如 edit, delete, add)。
|
|
13
13
|
- 结合 UI 语义,在 API 库中寻找对应路径。
|
|
14
14
|
- **输出格式**:请只输出一个 JSON 映射表。
|
|
15
|
-
- **例如**:{"BUNKER_API_ANCHOR_editByRecord": "[method] /
|
|
15
|
+
- **例如**:{"BUNKER_API_ANCHOR_editByRecord": "[method] /v1/update-user"}
|
|
16
16
|
|
|
17
17
|
⚠️ 严禁解释,严禁输出 JSON 之外的内容。
|
|
18
18
|
`.trim()
|
package/src/handlers/api.js
CHANGED
|
@@ -6,16 +6,17 @@ module.exports = {
|
|
|
6
6
|
async handle(filePath, liveResponse = null) {
|
|
7
7
|
|
|
8
8
|
const chalk = require('chalk')
|
|
9
|
-
const { llm, core, yorha, dialog, config } = require('../bootstrap').get()
|
|
9
|
+
const { llm, core, labs, yorha, dialog, config } = require('../bootstrap').get()
|
|
10
10
|
|
|
11
11
|
const { pagesDir } = config
|
|
12
|
-
const { unwrapSignal } = core
|
|
13
12
|
const { nineS, pod153 } = yorha
|
|
14
13
|
const { alignResponseFields } = llm
|
|
14
|
+
const { cleanCode, unwrapSignal } = core
|
|
15
15
|
|
|
16
16
|
const startTime = Date.now()
|
|
17
17
|
const fileName = liveResponse?.fileName ?? path.basename(filePath, path.extname(filePath))
|
|
18
18
|
const resourcePath = path.join(process.cwd(), pagesDir, fileName, 'resource.js')
|
|
19
|
+
const enumParams = (await labs?.council)?.[fileName] ?? ''
|
|
19
20
|
|
|
20
21
|
const spinner = pod153.start(dialog.pod153.reconEncryptedData(fileName))
|
|
21
22
|
|
|
@@ -42,7 +43,7 @@ module.exports = {
|
|
|
42
43
|
while ((match = regex.exec(str)) !== null) {
|
|
43
44
|
keys.push(match[2])
|
|
44
45
|
}
|
|
45
|
-
return Array.from(new Set(keys))
|
|
46
|
+
return Array.from(new Set(keys.filter(key => key !== 'index')))
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const sampleData = coreArray && coreArray.length > 0 ? [coreArray[0]] : rawJson
|
|
@@ -78,6 +79,13 @@ module.exports = {
|
|
|
78
79
|
console.log(chalk.magenta(`└────────────────────────────────────────────────────┘`))
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
if (enumParams) {
|
|
83
|
+
console.log(chalk.magenta(`\n┌──────── [ YoRHa Physical Assembly: Enum Genomes ] ────────┐`))
|
|
84
|
+
console.log(chalk.gray(dialog.bunker.copyEnum))
|
|
85
|
+
console.log(chalk.white(cleanCode(enumParams)))
|
|
86
|
+
console.log(chalk.magenta(`├───────────────────────────────────────────────────────────┘`))
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
if (fs.existsSync(filePath)) {
|
|
82
90
|
fs.unlinkSync(filePath)
|
|
83
91
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
|
|
4
|
-
module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
4
|
+
module.exports = async ({ llm, core, yorha, dialog, config, foundation }) => {
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { apiParser } = llm
|
|
7
7
|
const { pod153, commander } = yorha
|
|
8
8
|
const { apiDoc, pagesDir } = config
|
|
9
|
+
const { contextStringify } = foundation
|
|
9
10
|
const { getLocalScore, getSemanticKeywords } = core
|
|
10
11
|
|
|
11
12
|
if (!apiDoc) return
|
|
@@ -27,6 +28,7 @@ module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
|
27
28
|
// 2. 战场侦察
|
|
28
29
|
const pages = path.join(process.cwd(), pagesDir)
|
|
29
30
|
const files = fs.readdirSync(pages)
|
|
31
|
+
const enumParamsMap = {}
|
|
30
32
|
|
|
31
33
|
for (const fileName of files) {
|
|
32
34
|
const indexPath = path.join(pages, fileName, 'index.js')
|
|
@@ -34,6 +36,7 @@ module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
|
34
36
|
|
|
35
37
|
if (fs.existsSync(indexPath) && fs.existsSync(resourcePath)) {
|
|
36
38
|
let indexCode = fs.readFileSync(indexPath, 'utf-8')
|
|
39
|
+
let resourceCode = fs.readFileSync(resourcePath, 'utf-8')
|
|
37
40
|
|
|
38
41
|
// 💡 锁定待通电锚点
|
|
39
42
|
if (indexCode.includes('BUNKER_API_ANCHOR')) {
|
|
@@ -59,15 +62,13 @@ module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
|
59
62
|
const finalCandidates = candidates.map(item => `${item.method} ${item.path} ${item.desc}`).join('\n')
|
|
60
63
|
pod153.report(dialog.pod153.inactiveModule(fileName), 'yellow')
|
|
61
64
|
// 3. 驱动 9S 最终裁决
|
|
62
|
-
const result = await
|
|
65
|
+
const result = await apiParser({ bunkerAnchors, realApis: finalCandidates })
|
|
63
66
|
|
|
64
67
|
if (result) {
|
|
65
68
|
// 💡 执行物理更替
|
|
66
69
|
Object.entries(result).forEach(([anchor, fullSignal]) => {
|
|
67
70
|
// 💡 1. 信号解压
|
|
68
|
-
const
|
|
69
|
-
const realMethod = parts[0].toUpperCase()
|
|
70
|
-
const realPath = parts[1]
|
|
71
|
+
const [realMethod, realPath] = fullSignal.split(' ')
|
|
71
72
|
|
|
72
73
|
// 💡 2. 路径清洗:确保路径拼接时不产生双斜杠 //
|
|
73
74
|
// 逻辑:如果 realPath 以 / 开头,咱们拼接时就得小心
|
|
@@ -82,11 +83,21 @@ module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
|
82
83
|
|
|
83
84
|
// 💡 4. 执行“全频道通电”
|
|
84
85
|
// $1 现在包含了 request('/api 这一串
|
|
85
|
-
indexCode = indexCode.replace(requestRegex, `$1${cleanPath}$2${realMethod}$4`)
|
|
86
|
+
indexCode = indexCode.replace(requestRegex, `$1${cleanPath}$2${realMethod.toUpperCase()}$4`)
|
|
86
87
|
// 💡 5. 兜底替换(针对没有 method 配置的简易请求)
|
|
87
88
|
// 同样保留 /api/ 前缀
|
|
88
89
|
indexCode = indexCode.replaceAll(`/api/${anchor}`, `/api${cleanPath}`)
|
|
89
90
|
})
|
|
91
|
+
|
|
92
|
+
const [pagesMethod, pagesApi] = result?.['BUNKER_API_ANCHOR_pages']?.split(' ')
|
|
93
|
+
const definitions = (apiData.paths[pagesApi]?.[pagesMethod] ?? apiData.paths[pagesApi]?.[pagesMethod.toLowerCase()])?.parameters?.flatMap(item => Object.values(item.schema)?.flatMap(def => def.split('/').at(-1))) || []
|
|
94
|
+
const parameters = apiData.definitions?.[definitions[0]]?.properties ?? {}
|
|
95
|
+
const enumParams = Object.entries(parameters)?.filter(([_, value]) => value.hasOwnProperty('enum')) || []
|
|
96
|
+
enumParamsMap[fileName] = contextStringify({
|
|
97
|
+
maxLength: 100,
|
|
98
|
+
context: Object.fromEntries(enumParams.map(([key, value]) => [`${key}Options`, value.enum?.map(opt => ({ label: opt, value: opt }))])),
|
|
99
|
+
})
|
|
100
|
+
|
|
90
101
|
fs.writeFileSync(indexPath, indexCode)
|
|
91
102
|
pod153.report(dialog.pod153.signalSynchronized(Object.keys(result).length))
|
|
92
103
|
// 💡 战术免责补丁:采用橙黄色高亮,提醒指挥官保持警惕
|
|
@@ -95,6 +106,8 @@ module.exports = async ({ llm, core, yorha, dialog, config }) => {
|
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
}
|
|
109
|
+
|
|
110
|
+
return enumParamsMap
|
|
98
111
|
} catch (e) {
|
|
99
112
|
pod153.report(dialog.pod153.signalLinkFault(e.message), 'red')
|
|
100
113
|
}
|
package/src/labs/tower.js
CHANGED
|
@@ -74,8 +74,8 @@ module.exports = ({ core, yorha, dialog, config, handlers }) => {
|
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
server.listen(TOWER_PORT, () => {
|
|
77
|
-
commander.report(dialog.bunker.towerOnline(
|
|
78
|
-
commander.report(dialog.bunker.towerConnected(
|
|
77
|
+
commander.report(dialog.bunker.towerOnline(TOWER_PORT), 'magenta')
|
|
78
|
+
commander.report(dialog.bunker.towerConnected(TOWER_PORT), 'magenta')
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
return server
|
package/src/services/llm.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = ({ config, yorha, openAI, dialog, prompts, template }) => {
|
|
|
37
37
|
const sharp = require('sharp')
|
|
38
38
|
|
|
39
39
|
const { textModel, visionModel } = config
|
|
40
|
-
const { api, mock, system,
|
|
40
|
+
const { api, mock, system, council } = prompts
|
|
41
41
|
const { UI_DESIGNER, API_DESIGNER, MOCK_DESIGNER } = system
|
|
42
42
|
|
|
43
43
|
return {
|
|
@@ -53,7 +53,7 @@ module.exports = ({ config, yorha, openAI, dialog, prompts, template }) => {
|
|
|
53
53
|
]
|
|
54
54
|
})
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
apiParser: async ({ bunkerAnchors, realApis }) => {
|
|
57
57
|
return askAI({
|
|
58
58
|
yorha,
|
|
59
59
|
openAI,
|
|
@@ -61,7 +61,7 @@ module.exports = ({ config, yorha, openAI, dialog, prompts, template }) => {
|
|
|
61
61
|
model: textModel,
|
|
62
62
|
messages: [
|
|
63
63
|
{ role: 'system', content: API_DESIGNER },
|
|
64
|
-
{ role: 'user', content:
|
|
64
|
+
{ role: 'user', content: council({ bunkerAnchors, realApis }) }
|
|
65
65
|
]
|
|
66
66
|
})
|
|
67
67
|
},
|
package/src/utils/ux.js
CHANGED
|
@@ -90,7 +90,7 @@ const matrixEffect = async (duration = 1500, dialog) => {
|
|
|
90
90
|
console.log(chalk.yellow(dialog.bunker.isLegendary(isLegendary, currentTotal, threshold)))
|
|
91
91
|
}
|
|
92
92
|
console.log(chalk.cyan(dialog.bunker.star))
|
|
93
|
-
console.log(chalk.
|
|
93
|
+
console.log(chalk.gray(dialog.bunker.exit))
|
|
94
94
|
process.exit(0)
|
|
95
95
|
return
|
|
96
96
|
}
|