@yorha2b-lab/autodev 7.1.0 → 7.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorha2b-lab/autodev",
3
- "version": "7.1.0",
3
+ "version": "7.3.0",
4
4
  "description": "基于 AI 视觉与语义协议的前端 (React+Antd) 代码构筑与旧系统重构引擎",
5
5
  "bin": {
6
6
  "bunker": "bin/bunker.js"
@@ -9,6 +9,7 @@ module.exports = {
9
9
 
10
10
  const recruiter = require('../headquarters/recruiter')
11
11
  const logistics = recruiter(path.join(__dirname, '../logistics'))
12
+ const constitution = recruiter(path.join(__dirname, '../constitution'))
12
13
  const headquarters = recruiter(path.join(__dirname, '../headquarters'))
13
14
 
14
15
  const yorha = logistics.presenter.yorha()
@@ -25,6 +26,7 @@ module.exports = {
25
26
  template,
26
27
  logistics,
27
28
  headquarters,
29
+ constitution,
28
30
  units: recruiter(path.join(__dirname, '../units')),
29
31
  briefings: recruiter(path.join(__dirname, `../workshop/${template}/briefings`)),
30
32
  }
@@ -0,0 +1,13 @@
1
+ module.exports = units => `
2
+ # Mission Classification
3
+ 分析输入图片,判断它适合以下哪一种unit执行:
4
+ 可选units: ${units.map(unit => `
5
+ Unit: ${unit.meta.name}
6
+ Mission:${unit.meta.mission}
7
+ Description: ${unit.meta.description}
8
+ Capabilities: ${unit.meta.capabilities.join(', ')}
9
+ `).join('\n')}
10
+
11
+ ## Result
12
+ return capabilities
13
+ `.trim()
@@ -1,11 +1,11 @@
1
- module.exports = ({ yorha, dialog, logistics, briefings }) => {
1
+ module.exports = ({ yorha, dialog, logistics, constitution }) => {
2
2
 
3
3
  const sharp = require('sharp')
4
4
 
5
5
  const { sleep } = logistics.presenter
6
- const { mock, council, similarity, reconciler } = briefings
7
6
  const { textModel, visionModel } = logistics.supporter.getConfig()
8
- const { UI_DESIGNER, API_DESIGNER, MOCK_DESIGNER } = briefings.system
7
+ const { council, similarity, reconciler, simulation } = constitution
8
+ const { UI_DESIGNER, API_DESIGNER, MOCK_DESIGNER } = constitution.system
9
9
 
10
10
  const openAI = require('./client')()
11
11
  const askAI = require('./protocol')({ yorha, sleep, dialog, openAI })
@@ -16,7 +16,7 @@ module.exports = ({ yorha, dialog, logistics, briefings }) => {
16
16
  model: textModel,
17
17
  messages: [
18
18
  { role: 'system', content: MOCK_DESIGNER },
19
- { role: 'user', content: mock({ columns, fileName }) }
19
+ { role: 'user', content: simulation({ columns, fileName }) }
20
20
  ]
21
21
  })
22
22
  },
@@ -11,19 +11,26 @@
11
11
  module.exports = bunker => {
12
12
 
13
13
  const acp = bunker.get()
14
+ const units = Object.values(acp.units)
14
15
  const dispatcher = acp.headquarters.dispatcher(acp, 2)
15
16
 
16
17
  dispatcher.onIdle(() => acp.yorha.commander.report(acp.dialog.bunker.systemStandby, 'gray'))
17
18
 
18
19
  return {
19
20
  receive: async mission => {
20
- const spinner = acp.yorha.commander.start(acp.dialog.bunker.detectedEnemy)
21
+ let unit
22
+ let spinner
21
23
  try {
22
- const result = await acp.llm.recognizePage({ filePath: mission.input, prompt: acp.briefings.visionType })
23
- acp.yorha.commander.success(spinner, acp.dialog.bunker.confirmEnemy)
24
- const unit = Object.values(acp.units).map(unit => ({ unit, score: unit.meta.capabilities.filter(cap => result.capabilities.includes(cap)).length }))
25
- .filter(item => item.score > 0)
26
- .sort((a, b) => b.score - a.score)[0]?.unit
24
+ if (acp.logistics.supporter.getConfig().useDemo) {
25
+ unit = units.find(unit => unit.meta.name === 'striker')
26
+ } else {
27
+ spinner = acp.yorha.commander.start(acp.dialog.bunker.detectedEnemy)
28
+ const result = await acp.llm.recognizePage({ filePath: mission.input, prompt: acp.constitution.commander(units) })
29
+ acp.yorha.commander.success(spinner, acp.dialog.bunker.confirmEnemy)
30
+ unit = units.map(unit => ({ unit, score: unit.meta.capabilities.filter(cap => result.capabilities.includes(cap)).length }))
31
+ .filter(item => item.score > 0)
32
+ .sort((a, b) => b.score - a.score)[0]?.unit
33
+ }
27
34
  if (!unit) {
28
35
  acp.yorha.commander.fail(spinner, acp.dialog.bunker.missionFailed)
29
36
  return
@@ -4,22 +4,22 @@ module.exports = bunker => {
4
4
  const chokidar = require('chokidar')
5
5
  const commander = require('../headquarters/commander')(bunker)
6
6
 
7
- const settingWatcher = chokidar.watch('./bunker/config.js', { persistent: true, ignoreInitial: true })
7
+ const settingObserver = chokidar.watch('./bunker/config.js', { persistent: true, ignoreInitial: true })
8
8
 
9
- const missionWatcher = chokidar.watch('./bunker/mission/', {
9
+ const missionObserver = chokidar.watch('./bunker/mission/', {
10
10
  persistent: true,
11
11
  ignoreInitial: true,
12
12
  ignored: /(^|[\/\\])\../,
13
13
  awaitWriteFinish: { stabilityThreshold: 500, pollInterval: 100 },
14
14
  })
15
15
 
16
- missionWatcher.on('add', filePath => {
16
+ missionObserver.on('add', filePath => {
17
17
  if (['.png', '.jpg', '.jpeg', '.webp'].includes(path.extname(filePath))) {
18
18
  commander.receive({ input: filePath })
19
19
  }
20
20
  })
21
21
 
22
- settingWatcher.on('change', file => {
22
+ settingObserver.on('change', file => {
23
23
  if (file.endsWith('config.js')) {
24
24
  bunker.reboot()
25
25
  }
@@ -5,6 +5,16 @@ module.exports = {
5
5
  outputs: ['component-config'],
6
6
  description: 'extract reusable UI component from visual input',
7
7
  capabilities: ['vision', 'component-analysis', 'component-generation'],
8
+ mission: `
9
+ ## Partial CRUD Page
10
+ 局部 CRUD 页面或 UI 碎片。
11
+ 例如:
12
+ - 仅包含表格
13
+ - 仅包含表单
14
+ - 仅包含筛选区域
15
+ - 仅包含某个 CRUD 功能区域
16
+ - 页面结构明显不完整
17
+ `
8
18
  },
9
19
  execute: async ({ acp, mission }) => {
10
20
 
@@ -5,6 +5,18 @@ module.exports = {
5
5
  outputs: ['page-config', 'artifacts'],
6
6
  description: 'reconstruct full UI from visual input',
7
7
  capabilities: ['vision', 'page-analysis', 'page-generation'],
8
+ mission: `
9
+ ## Full CRUD Page
10
+ 完整的 CRUD 页面。
11
+ 满足以下特征中的大部分:
12
+ - 页面结构完整
13
+ - 包含页面级功能区域
14
+ - 包含查询表单或筛选区域
15
+ - 包含表格主体
16
+ - 包含行操作
17
+ - 包含新增、编辑、删除等功能按钮
18
+ - 可能包含统计区域、导出按钮等页面级功能
19
+ `
8
20
  },
9
21
  execute: async ({ acp, mission }) => {
10
22
 
@@ -50,6 +50,10 @@ export const useTableQuery = ({ api, cols = [], initialParams = {}, formatRespon
50
50
  apiRef.current = api
51
51
  }, [api])
52
52
 
53
+ useEffect(() => {
54
+ formatResponseRef.current = formatResponse
55
+ }, [formatResponse])
56
+
53
57
  /**
54
58
  * @function getColumnSchema
55
59
  * @description [指纹识别协议] 对列配置执行“结构化脱水”。
@@ -104,7 +108,7 @@ export const useTableQuery = ({ api, cols = [], initialParams = {}, formatRespon
104
108
  setLoading(false)
105
109
  }
106
110
  }
107
- }, [search, isLocalPaging, dataSource.length])
111
+ }, [search, isLocalPaging])
108
112
 
109
113
  useEffect(() => {
110
114
  fetchData()
@@ -1,59 +0,0 @@
1
- module.exports = `
2
- # Mission Classification
3
-
4
- 分析输入图片,判断它属于以下哪一种任务类型:
5
-
6
- ## Full CRUD Page
7
-
8
- 完整的 CRUD 页面。
9
-
10
- 满足以下特征中的大部分:
11
- - 页面结构完整
12
- - 包含页面级功能区域
13
- - 包含查询表单或筛选区域
14
- - 包含表格主体
15
- - 包含行操作
16
- - 包含新增、编辑、删除等功能按钮
17
- - 可能包含统计区域、导出按钮等页面级功能
18
-
19
- 返回:
20
-
21
- {
22
- "capabilities": [
23
- "vision",
24
- "page-analysis",
25
- "page-generation"
26
- ]
27
- }
28
-
29
- ## Partial CRUD Page
30
-
31
- 局部 CRUD 页面或 UI 碎片。
32
-
33
- 例如:
34
- - 仅包含表格
35
- - 仅包含表单
36
- - 仅包含筛选区域
37
- - 仅包含某个 CRUD 功能区域
38
- - 页面结构明显不完整
39
-
40
- 返回:
41
-
42
- {
43
- "capabilities": [
44
- "vision",
45
- "component-analysis",
46
- "component-generation"
47
- ]
48
- }
49
-
50
- ## Result
51
-
52
- 只允许返回 JSON:
53
-
54
- {
55
- "capabilities": []
56
- }
57
-
58
- 不要返回任何额外文字。
59
- `.trim()