@yorha2b-lab/autodev 4.1.1 → 5.0.0
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/.github/scripts/analyze/bot_detect.py +5 -5
- package/.github/scripts/analyze/cluster.py +5 -5
- package/.github/scripts/collect/traffic.py +11 -11
- package/.github/scripts/deploy/publish.py +15 -15
- package/.github/scripts/render/dashboard.py +4 -0
- package/.github/workflows/bunker-intelligence.yml +4 -4
- package/CONTRIBUTING.md +0 -18
- package/bin/autodev.js +9 -8
- package/config.js +3 -3
- package/package.json +1 -3
- package/src/bootstrap/handlebars.js +26 -0
- package/src/bootstrap/handlers.js +10 -0
- package/src/bootstrap/index.js +49 -0
- package/src/bootstrap/infrastructure.js +15 -0
- package/src/bootstrap/openai.js +13 -0
- package/src/bootstrap/prompt.js +10 -0
- package/src/commands/watch.js +21 -34
- package/{templates → src/framework}/react/components/MyModalForm.js +1 -1
- package/{templates → src/framework}/react/components/MyModalTable.js +1 -1
- package/{templates → src/framework}/react/components/index.js +2 -2
- package/src/framework/react/generator/index.js +82 -0
- package/{templates/react/handlebars → src/framework/react/handlebars/partials}/handleBlock.hbs +2 -2
- package/src/{prompts/react/watch-api.js → framework/react/prompts/api.js} +1 -1
- package/src/{prompts/react/api-linker.js → framework/react/prompts/linker.js} +1 -1
- package/src/{prompts → framework/react/prompts}/mock.js +1 -1
- package/src/{prompts/react/watch-page.js → framework/react/prompts/page.js} +1 -0
- package/src/{prompts/react/watch-part.js → framework/react/prompts/part.js} +2 -1
- package/{templates → src/framework}/react/utils/utils.js +1 -1
- package/src/{commands/handlers/api-handler.js → handlers/apiHandler.js} +15 -10
- package/src/{commands/handlers/page-handler.js → handlers/pageHandler.js} +22 -21
- package/src/{commands/handlers/part-handler.js → handlers/partHandler.js} +14 -11
- package/src/{services/api-linker.js → labs/linker.js} +20 -59
- package/src/{services/proxy-tower.js → labs/tower.js} +16 -12
- package/src/services/llm.js +64 -81
- package/src/utils/{utils.js → core.js} +38 -163
- package/src/utils/infrastructure.js +105 -0
- package/src/utils/ux.js +115 -0
- package/src/core/context.js +0 -106
- package/src/core/react-compiler.js +0 -98
- package/src/core/task-queue.js +0 -38
- /package/{templates → src/framework}/react/components/EditableCell.js +0 -0
- /package/{templates → src/framework}/react/components/MyBaseForm.js +0 -0
- /package/{templates → src/framework}/react/components/MyImage.js +0 -0
- /package/{templates → src/framework}/react/components/MySearchForm.js +0 -0
- /package/{templates → src/framework}/react/components/MyTable.js +0 -0
- /package/{templates/react → src/framework/react/handlebars}/index.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/AlertInfo.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/FunctionButtons.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/MySearchForm.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/MyTable.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/hookBlock.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/operateBlock.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/renderBlock.hbs +0 -0
- /package/{templates/react/handlebars → src/framework/react/handlebars/partials}/stateBlock.hbs +0 -0
- /package/{templates/react → src/framework/react/handlebars}/resource.hbs +0 -0
- /package/{templates → src/framework}/react/hooks/useTableQuery.js +0 -0
- /package/src/{prompts → framework/react/prompts}/system.js +0 -0
- /package/src/{schema/react → framework/react/schema}/page.json +0 -0
package/src/core/context.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const chalk = require('chalk')
|
|
4
|
-
const Handlebars = require('handlebars')
|
|
5
|
-
const stringify = require('json-stringify-pretty-compact')
|
|
6
|
-
|
|
7
|
-
Handlebars.registerHelper('raw', options => options.fn())
|
|
8
|
-
Handlebars.registerHelper('stringify', (context, maxLength = 200) => context ? new Handlebars.SafeString(stringify.default(context, { indent: 4, maxLength })) : '[]')
|
|
9
|
-
|
|
10
|
-
let instance = null // 💡 物理封存的全局实例
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
/**
|
|
14
|
-
* @description 执行中枢神经元初始化
|
|
15
|
-
*/
|
|
16
|
-
init: options => {
|
|
17
|
-
|
|
18
|
-
const { apiLinker, recognizePage, generateMock, alignResponseFields } = require('../services/llm')
|
|
19
|
-
const { language, getConfig, unwrapSignal, isQuerySignal, getExistingMenus } = require('../utils/utils')
|
|
20
|
-
|
|
21
|
-
const config = getConfig()
|
|
22
|
-
const menus = getExistingMenus()
|
|
23
|
-
const template = options.template
|
|
24
|
-
const apiHandler = require('../commands/handlers/api-handler')
|
|
25
|
-
const pageHandler = require('../commands/handlers/page-handler')
|
|
26
|
-
const partHandler = require('../commands/handlers/part-handler')
|
|
27
|
-
const tplDir = config.hbsDir !== '' ? path.join(process.cwd(), config.hbsDir) : path.join(__dirname, `../../templates/${template}`)
|
|
28
|
-
|
|
29
|
-
const compilerPath = path.join(__dirname, `./${template}-compiler.js`)
|
|
30
|
-
if (!fs.existsSync(compilerPath)) {
|
|
31
|
-
console.error(chalk.red(language(`❌ 暂不支持 [${template}] 框架。欢迎提交 Pull Request 贡献。`, `❌ [${template}] framework not supported. Welcome to contribute a Pull Request to help.`)))
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
const { index, resource } = require(compilerPath)
|
|
35
|
-
|
|
36
|
-
// 💡 物理扫描:把目录下所有的 .hbs 文件全部识别并自动注册
|
|
37
|
-
const partialsDir = config.hbsDir !== ''
|
|
38
|
-
? path.join(process.cwd(), config.hbsDir, 'handlebars')
|
|
39
|
-
: path.join(__dirname, `../../templates/${template}/handlebars`)
|
|
40
|
-
fs.readdirSync(partialsDir).forEach(file => {
|
|
41
|
-
if (file.endsWith('.hbs')) {
|
|
42
|
-
const name = path.basename(file, '.hbs') // 去掉后缀拿名字
|
|
43
|
-
const content = fs.readFileSync(path.join(partialsDir, file), 'utf-8')
|
|
44
|
-
Handlebars.registerPartial(name, `${content}\n`)
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const cliCtx = {
|
|
49
|
-
options,
|
|
50
|
-
template,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const llmCtx = {
|
|
54
|
-
apiLinker,
|
|
55
|
-
generateMock,
|
|
56
|
-
recognizePage,
|
|
57
|
-
alignResponseFields
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const utilsCtx = {
|
|
61
|
-
menus,
|
|
62
|
-
config,
|
|
63
|
-
language,
|
|
64
|
-
unwrapSignal,
|
|
65
|
-
isQuerySignal,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const handlerCtx = {
|
|
69
|
-
apiHandler,
|
|
70
|
-
pageHandler,
|
|
71
|
-
partHandler
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const compileCtx = {
|
|
75
|
-
index,
|
|
76
|
-
resource
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const promptCtx = {
|
|
80
|
-
pagePrompt: require(`../prompts/${template}/watch-page.js`),
|
|
81
|
-
partPrompt: require(`../prompts/${template}/watch-part.js`),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const templateCtx = {
|
|
85
|
-
indexTpl: Handlebars.compile(fs.readFileSync(path.join(tplDir, 'index.hbs'), 'utf-8')),
|
|
86
|
-
resourceTpl: Handlebars.compile(fs.readFileSync(path.join(tplDir, 'resource.hbs'), 'utf-8')),
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
instance = {
|
|
91
|
-
...cliCtx,
|
|
92
|
-
...llmCtx,
|
|
93
|
-
...utilsCtx,
|
|
94
|
-
...promptCtx,
|
|
95
|
-
...handlerCtx,
|
|
96
|
-
...compileCtx,
|
|
97
|
-
...templateCtx,
|
|
98
|
-
}
|
|
99
|
-
return instance
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @description 全频道信号接入:获取全局上下文
|
|
104
|
-
*/
|
|
105
|
-
get: () => instance
|
|
106
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const stringify = require('json-stringify-pretty-compact')
|
|
2
|
-
const { cleanCode, generateSmartImports, formatFormItemAndColumns } = require('../utils/utils.js')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 生成 resource.js 文件(表格列配置、表单配置、字典等)
|
|
6
|
-
* @param {Object} param0 - 函数参数
|
|
7
|
-
* @param {Object} param0.pageConfig - 页面配置对象(包含 tabs、formItems、table 等)
|
|
8
|
-
* @param {Object} param0.resourceTpl - Handlebars 模板函数
|
|
9
|
-
* @returns {string} 生成的 resource.js 代码
|
|
10
|
-
*/
|
|
11
|
-
const resource = ({ pageConfig, resourceTpl }) => {
|
|
12
|
-
|
|
13
|
-
const { formItems, processedColumns, dictBlocks } = formatFormItemAndColumns({ pageConfig })
|
|
14
|
-
|
|
15
|
-
const hasTabs = pageConfig.tabs?.length > 0
|
|
16
|
-
const hasFormItems = pageConfig.formItems?.length > 0
|
|
17
|
-
const tabKeys = pageConfig.tabs.map(tab => tab.key).sort((a, b) => a.length - b.length)
|
|
18
|
-
const optionDict = pageConfig.optionList?.reduce((acc, item) => ({ ...acc, [item.name]: item.options }), {})
|
|
19
|
-
|
|
20
|
-
const columnsData = processedColumns.map(item => {
|
|
21
|
-
delete item.type
|
|
22
|
-
return item
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const viewData = {
|
|
26
|
-
hasTabs,
|
|
27
|
-
columnsData,
|
|
28
|
-
hasFormItems,
|
|
29
|
-
tabs: pageConfig.tabs,
|
|
30
|
-
dictBlocks: dictBlocks.map(item => ({ name: item, data: optionDict[item] ?? [] })),
|
|
31
|
-
tabColumns: stringify.default(Object.fromEntries(tabKeys.map(tab => [tab, '_CODE_commonColumns_CODE_'])), { indent: 4, maxLength: 100 }),
|
|
32
|
-
formItemsData: !hasTabs ?
|
|
33
|
-
`export const formItems = ${stringify.default(formItems, { indent: 4, maxLength: 120 })}` :
|
|
34
|
-
`const searchItems = ${stringify.default(formItems, { indent: 4, maxLength: 120 })}\n\nexport const formItems = ${stringify.default(Object.fromEntries(tabKeys.map(tab => [tab, '_CODE_searchItems_CODE_'])), { indent: 4, maxLength: 100 })}`,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const bodyCode = resourceTpl(viewData)
|
|
38
|
-
const importsStr = generateSmartImports({ module: 'resource', hasTabs, bodyCode, hasFormItems })
|
|
39
|
-
return cleanCode(`${importsStr}\n\n${bodyCode}`)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 生成 index.js 文件(页面组件)
|
|
44
|
-
* @param {Object} param0 - 函数参数
|
|
45
|
-
* @param {string} param0.fileName - 页面文件名
|
|
46
|
-
* @param {Object} param0.indexTpl - Handlebars 模板函数
|
|
47
|
-
* @param {Object} param0.pageConfig - 页面配置对象
|
|
48
|
-
* @returns {string} 生成的 index.js 代码
|
|
49
|
-
*/
|
|
50
|
-
const index = ({ config, fileName, indexTpl, pageConfig }) => {
|
|
51
|
-
|
|
52
|
-
const hasTabs = pageConfig.tabs?.length > 0
|
|
53
|
-
const hasPagination = pageConfig.table.pagination
|
|
54
|
-
const hasFormItems = pageConfig.formItems?.length > 0
|
|
55
|
-
const hasOperate = pageConfig.table?.operation?.length > 0
|
|
56
|
-
const hasImageColumn = pageConfig.table?.columns?.some(item => item.type === 'image')
|
|
57
|
-
const renderTree = pageConfig.renderTree?.filter(item => item.toLowerCase() !== 'tabs') || []
|
|
58
|
-
const functionButtons = pageConfig.functionButton?.filter(item => !['查询', '重置', 'query', 'search', 'reset'].includes(item.btn.toLowerCase().replaceAll(' ', ''))) || []
|
|
59
|
-
const needRenderAction = hasImageColumn
|
|
60
|
-
|
|
61
|
-
const pageStruct = ['stateBlock', 'handleBlock', 'hookBlock', hasOperate ? 'operateBlock' : '', 'renderBlock'].filter(Boolean)
|
|
62
|
-
|
|
63
|
-
let columnsValue = hasTabs ? 'columns[activeKey]' : 'columns'
|
|
64
|
-
if (hasOperate) {
|
|
65
|
-
columnsValue = `${columnsValue}.concat(operate)`
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const imgAction = Object.fromEntries(pageConfig.table?.columns?.filter(item => item.type === 'image')?.map(item => [item.dataIndex, `_CODE_(_, record) => <a onClick={() => showImg(record, '${item.dataIndex}')}>查看图片</a>_CODE_`]))
|
|
69
|
-
const renderAction = `{${stringify.default({ ...imgAction }, { indent: 4, maxLength: 120 })}}`.replace(/\n/g, '\n ')
|
|
70
|
-
|
|
71
|
-
const viewData = {
|
|
72
|
-
hasTabs,
|
|
73
|
-
renderTree,
|
|
74
|
-
pageStruct,
|
|
75
|
-
columnsValue,
|
|
76
|
-
hasFormItems,
|
|
77
|
-
renderAction,
|
|
78
|
-
hasPagination,
|
|
79
|
-
hasImageColumn,
|
|
80
|
-
functionButtons,
|
|
81
|
-
needRenderAction,
|
|
82
|
-
tabs: pageConfig.tabs,
|
|
83
|
-
responseSuccess: config.responseSuccess,
|
|
84
|
-
hasExpandable: pageConfig.table.expandable,
|
|
85
|
-
staticInfoText: pageConfig.staticInfo?.text,
|
|
86
|
-
operations: pageConfig.table.operation || [],
|
|
87
|
-
hasRowSelection: pageConfig.table.rowSelection,
|
|
88
|
-
uri: config.needMock ? fileName : 'BUNKER_API_ANCHOR_pages',
|
|
89
|
-
formItems: hasFormItems ? (hasTabs ? 'formItems[activeKey]' : 'formItems') : '[]',
|
|
90
|
-
initParams: `{ ${hasTabs ? 'type: tabs[0].key ,' : ''}${hasPagination ? 'pageNo: 1 , pageSize: 10' : ''}}`,
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const bodyCode = indexTpl(viewData)
|
|
94
|
-
const importsStr = generateSmartImports({ module: 'index', hasTabs, bodyCode, hasFormItems })
|
|
95
|
-
return cleanCode(`${importsStr}\n\n${bodyCode}`)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
module.exports = { index, resource }
|
package/src/core/task-queue.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const createTaskQueue = (concurrency = 1) => {
|
|
2
|
-
|
|
3
|
-
let running = 0
|
|
4
|
-
let queue = []
|
|
5
|
-
let onIdleCallback = null
|
|
6
|
-
|
|
7
|
-
const next = async () => {
|
|
8
|
-
|
|
9
|
-
if (running >= concurrency || queue.length === 0) return
|
|
10
|
-
|
|
11
|
-
const task = queue.shift()
|
|
12
|
-
running++
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
await task()
|
|
16
|
-
} catch (err) {
|
|
17
|
-
console.error('任务执行异常:', err)
|
|
18
|
-
} finally {
|
|
19
|
-
running--
|
|
20
|
-
next()
|
|
21
|
-
if (running === 0 && queue.length === 0 && onIdleCallback) {
|
|
22
|
-
onIdleCallback()
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
add: (task) => {
|
|
29
|
-
queue.push(task)
|
|
30
|
-
next()
|
|
31
|
-
},
|
|
32
|
-
onIdle: (callback) => {
|
|
33
|
-
onIdleCallback = callback
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = { createTaskQueue }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/AlertInfo.hbs
RENAMED
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/FunctionButtons.hbs
RENAMED
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/MySearchForm.hbs
RENAMED
|
File without changes
|
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/hookBlock.hbs
RENAMED
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/operateBlock.hbs
RENAMED
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/renderBlock.hbs
RENAMED
|
File without changes
|
/package/{templates/react/handlebars → src/framework/react/handlebars/partials}/stateBlock.hbs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|