@yorha2b-lab/autodev 7.5.2 → 7.5.4

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/bunker.js CHANGED
@@ -61,7 +61,6 @@ program
61
61
  return
62
62
  }
63
63
  require('../src/headquarters/observer')(bunker)
64
- result.yorha.operator6O.report(dialog.operator6O.call2B)
65
64
  process.on('SIGINT', async () => {
66
65
  if (isTerminating) return
67
66
  isTerminating = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "7.5.2",
3
+ "version": "7.5.4",
4
4
  "description": "基于 AI 视觉与语义协议的前端 (React+Antd) 代码构筑与旧系统重构引擎",
5
5
  "bin": {
6
6
  "bunker": "bin/bunker.js"
@@ -33,6 +33,7 @@ module.exports = {
33
33
 
34
34
  if (version) {
35
35
  await logistics.presenter.bootSequence(version, local)
36
+ yorha.operator6O.report(dialog.operator6O.call2B)
36
37
  }
37
38
 
38
39
  const llm = require('../gateway')(accessPoint)
@@ -29,7 +29,8 @@ module.exports = ({ yorha, sleep, dialog, openAI }) => {
29
29
  }
30
30
 
31
31
  yorha.commander.report(dialog.bunker.networkInstability(retryCount + 1))
32
- await sleep(1000)
32
+ const delay = Math.min(1000 * Math.pow(2, retryCount), 10000)
33
+ await sleep(delay)
33
34
  return askAI({ model, messages, response_format, retryCount: retryCount + 1 })
34
35
  }
35
36
  }
@@ -44,8 +44,19 @@ module.exports = async ({ llm, yorha, dialog, logistics }) => {
44
44
  const anchors = code.match(/BUNKER_API_ANCHOR_\w+/g) || []
45
45
  anchors.forEach(a => allAnchors.add(a))
46
46
 
47
- const chinese = code.match(/[\u4e00-\u9fa5][\u4e00-\u9fa5A-Za-z0-9?。,、:;!() ]*/g) || []
48
- allSemantics.push(...chinese)
47
+ const textMatches = code.match(/(?:['"`]([^'"`\n]{2,})['"`]|>([^<>{}\n]{2,})<)/g) || []
48
+ const uiSemantics = textMatches
49
+ .map(str => str.replace(/['"`><]/g, '').trim())
50
+ // 过滤掉纯代码路径(/api/xxx)、锚点占位符、纯数字和空字符
51
+ .filter(text => (
52
+ text.length >= 2 &&
53
+ !text.startsWith('/') &&
54
+ !text.startsWith('http') &&
55
+ !text.includes('BUNKER_API_ANCHOR') &&
56
+ !/^[0-9]+$/.test(text)
57
+ ))
58
+
59
+ allSemantics.push(...uiSemantics)
49
60
  }
50
61
 
51
62
  if (allAnchors.size > 0) {
@@ -93,8 +104,14 @@ module.exports = async ({ llm, yorha, dialog, logistics }) => {
93
104
  const pagesConfig = result?.['BUNKER_API_ANCHOR_pages']
94
105
  if (pagesConfig) {
95
106
  const { uri: pagesApi, method: pagesMethod } = pagesConfig
96
- const definitions = (apiData.paths[pagesApi]?.[pagesMethod] ?? apiData.paths[pagesApi]?.[pagesMethod?.toLowerCase()])?.parameters?.flatMap(item => Object.values(item.schema ?? {})?.flatMap(def => def?.split('/')?.at(-1))) || []
97
- const parameters = apiData.definitions?.[definitions[0]]?.properties ?? {}
107
+ const schemas = apiData.definitions || apiData.components?.schemas || {}
108
+ const methodObj = apiData.paths[pagesApi]?.[pagesMethod] ?? apiData.paths[pagesApi]?.[pagesMethod?.toLowerCase()]
109
+ let schemaName = methodObj?.parameters?.flatMap(item => Object.values(item.schema ?? {})?.flatMap(def => def?.split('/')?.at(-1)))?.[0]
110
+ if (!schemaName && methodObj?.requestBody) {
111
+ const bodySchema = methodObj.requestBody.content?.['application/json']?.schema
112
+ schemaName = (bodySchema?.$ref || bodySchema?.items?.$ref)?.split('/')?.at(-1)
113
+ }
114
+ const parameters = schemas[schemaName]?.properties ?? {}
98
115
  const enumParams = Object.entries(parameters)?.filter(([_, value]) => value.hasOwnProperty('enum')) || []
99
116
  enumParamsMap[fileName] = contextStringify({
100
117
  maxLength: 100,
@@ -52,14 +52,14 @@ module.exports = {
52
52
  } else {
53
53
  pod042.update(spinner, dialog.pod042.uploadVisualMetadata)
54
54
  pageConfig = await recognizePage({ prompt: striker, filePath: mission.input, schema: require(`../workshop/${template}/protocols/striker.json`) })
55
- }
56
-
57
- const { similarity } = await nameSimilarity({ fileName, english: pageConfig.title?.english })
58
- if (similarity === 0) {
59
- fileName = pageConfig.title?.english
60
- targetDir = path.join(process.cwd(), pagesDir, pageConfig.title?.english)
61
- if (fs.existsSync(targetDir)) {
62
- targetDir = `${targetDir}_temp`
55
+ const { similarity } = await nameSimilarity({ fileName, english: pageConfig.title?.english })
56
+ const isGarbageName = /^(image|img|screen|capture|pic|temp|test|新建|未命名|[\d_-]+$)/i.test(fileName)
57
+ if (similarity < 0.3 || isGarbageName) {
58
+ fileName = pageConfig.title?.english
59
+ targetDir = path.join(process.cwd(), pagesDir, pageConfig.title?.english)
60
+ if (fs.existsSync(targetDir)) {
61
+ targetDir = `${targetDir}_temp`
62
+ }
63
63
  }
64
64
  }
65
65
 
@@ -3,6 +3,13 @@ const initialParams = {{initParams}}
3
3
 
4
4
  const query = formatQuery(Object.fromEntries(new URLSearchParams(location.search).entries()), {{formItems}})
5
5
 
6
+ /**
7
+ * 💡 [BUNKER 战术锚点提示]
8
+ * 代码中带有 BUNKER_API_ANCHOR_ 前缀的为待通电接口。
9
+ * 1. 自动模式:配置 config.js 中的 apiDoc 后,系统将自动扫描 Swagger 并对齐真实路径;
10
+ * 2. 手动模式:搜索 BUNKER_API_ANCHOR 手动替换为真实接口。
11
+ */
12
+
6
13
  const { total, columns, loading, dataSource, search, setSearch, setDataSource, refresh } = useTableQuery({
7
14
  cols:tableColumns,
8
15
  initialParams: { ...initialParams, ...query },
@@ -111,7 +111,7 @@ module.exports = ({ template, logistics, headquarters }) => {
111
111
  },
112
112
  index: ({ fileName, pageConfig }) => {
113
113
  const hasTabs = pageConfig.tabs?.length > 0
114
- const hasPagination = pageConfig.table.pagination
114
+ const hasPagination = pageConfig.table?.pagination
115
115
  const hasFormItems = pageConfig.formItems?.length > 0
116
116
  const hasOperate = pageConfig.table?.operation?.length > 0
117
117
  const hasImageColumn = pageConfig.table?.columns?.some(item => item.type === 'image')