@yorha2b-lab/autodev 7.2.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.2.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
  },
@@ -13,31 +13,24 @@ module.exports = bunker => {
13
13
  const acp = bunker.get()
14
14
  const units = Object.values(acp.units)
15
15
  const dispatcher = acp.headquarters.dispatcher(acp, 2)
16
- const prompt = `
17
- # Mission Classification
18
- 分析输入图片,判断它适合以下哪一种unit执行:
19
- 可选units: ${units.map(unit => `
20
- Unit: ${unit.meta.name}
21
- Mission:${unit.meta.mission}
22
- Description: ${unit.meta.description}
23
- Capabilities: ${unit.meta.capabilities.join(', ')}
24
- `).join('\n')}
25
-
26
- ## Result
27
- return capabilities
28
- `.trim()
29
16
 
30
17
  dispatcher.onIdle(() => acp.yorha.commander.report(acp.dialog.bunker.systemStandby, 'gray'))
31
18
 
32
19
  return {
33
20
  receive: async mission => {
34
- const spinner = acp.yorha.commander.start(acp.dialog.bunker.detectedEnemy)
21
+ let unit
22
+ let spinner
35
23
  try {
36
- const result = await acp.llm.recognizePage({ filePath: mission.input, prompt })
37
- acp.yorha.commander.success(spinner, acp.dialog.bunker.confirmEnemy)
38
- const unit = units.map(unit => ({ unit, score: unit.meta.capabilities.filter(cap => result.capabilities.includes(cap)).length }))
39
- .filter(item => item.score > 0)
40
- .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
+ }
41
34
  if (!unit) {
42
35
  acp.yorha.commander.fail(spinner, acp.dialog.bunker.missionFailed)
43
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
  }
@@ -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()