@fugood/bricks-project 2.23.0-beta.51 → 2.23.0-beta.53

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,11 +1,12 @@
1
1
  {
2
2
  "name": "@fugood/bricks-project",
3
- "version": "2.23.0-beta.51",
3
+ "version": "2.23.0-beta.53",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "build": "bun scripts/build.js"
7
7
  },
8
8
  "dependencies": {
9
+ "@fugood/bricks-cli": "^2.23.0-beta.53",
9
10
  "@modelcontextprotocol/sdk": "^1.15.0",
10
11
  "@toon-format/toon": "^2.1.0",
11
12
  "@types/escodegen": "^0.0.10",
@@ -15,5 +16,5 @@
15
16
  "lodash": "^4.17.4",
16
17
  "uuid": "^8.3.1"
17
18
  },
18
- "gitHead": "9af0ee1ec599fe0514448aec3a29b4905eea5c80"
19
+ "gitHead": "2bb1ff8e2a614e0e82f612a760129ab3233f9fa4"
19
20
  }
package/tools/deploy.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import { $ } from 'bun'
2
2
  import { parseArgs } from 'util'
3
- import { deployApp, deployModule } from '../api'
4
3
 
5
4
  const cwd = process.cwd()
6
5
 
7
- // Parse command-line arguments
8
6
  const {
9
- values: { changelogs: changelogsArg, 'changelogs-file': changelogsFile },
7
+ values: { changelogs: changelogsArg, 'changelogs-file': changelogsFile, yes },
10
8
  } = parseArgs({
11
9
  args: Bun.argv.slice(2),
12
10
  options: {
13
11
  changelogs: { type: 'string' },
14
12
  'changelogs-file': { type: 'string' },
13
+ yes: { type: 'boolean', short: 'y' },
15
14
  },
16
15
  allowPositionals: true,
17
16
  })
18
17
 
18
+ // Check git status
19
19
  const { exitCode } = await $`cd ${cwd} && git status`.nothrow()
20
20
  const isGitRepo = exitCode === 0
21
21
 
@@ -26,20 +26,20 @@ if (isGitRepo) {
26
26
  throw new Error('Unstaged changes found, please commit or stash your changes before deploying')
27
27
 
28
28
  commitId = (await $`cd ${cwd} && git rev-parse HEAD`.text()).trim()
29
- } else {
29
+ } else if (!yes) {
30
30
  const confirmContinue = prompt('No git repository found, continue? (y/n)')
31
31
  if (confirmContinue !== 'y') throw new Error('Deployment cancelled')
32
32
  }
33
33
 
34
+ // Read application.json
34
35
  const app = await Bun.file(`${cwd}/application.json`).json()
35
- const stage = app.stage || 'production'
36
36
  const config = await Bun.file(`${cwd}/.bricks/build/application-config.json`).json()
37
37
 
38
38
  // Get version from project's package.json
39
39
  const pkgFile = Bun.file(`${cwd}/package.json`)
40
40
  const version = (await pkgFile.exists()) ? (await pkgFile.json()).version : undefined
41
41
 
42
- // Get changelog from flag, file, or prompt
42
+ // Get changelog from flag or file
43
43
  let changelogs = ''
44
44
  if (changelogsArg) {
45
45
  changelogs = changelogsArg
@@ -49,18 +49,49 @@ if (changelogsArg) {
49
49
  throw new Error(`Changelogs file not found: ${changelogsFile}`)
50
50
  }
51
51
  changelogs = await file.text()
52
- } else {
52
+ } else if (!yes) {
53
53
  changelogs = prompt('Enter changelogs (optional, press Enter to skip):') || ''
54
54
  }
55
55
 
56
- // ask for confirmation
57
- const confirm = prompt('Are you sure you want to deploy? (y/n)')
58
- if (confirm !== 'y') throw new Error('Deployment cancelled')
56
+ // Ask for confirmation
57
+ if (!yes) {
58
+ const confirm = prompt('Are you sure you want to deploy? (y/n)')
59
+ if (confirm !== 'y') throw new Error('Deployment cancelled')
60
+ }
61
+
62
+ const isModule = app.type === 'module'
63
+ const command = isModule ? 'module' : 'app'
64
+
65
+ // Add project-specific fields to config and write to temp file
66
+ const releaseConfig = {
67
+ ...config,
68
+ title: version || config.title,
69
+ bricks_project_last_commit_id: commitId || undefined,
70
+ }
71
+ const configPath = `${cwd}/.bricks/build/release-config.json`
72
+ await Bun.write(configPath, JSON.stringify(releaseConfig))
73
+
74
+ const args = ['bricks', command, 'release', app.id, '-c', configPath, '--json']
75
+
76
+ if (version) {
77
+ args.push('--version', version)
78
+ }
79
+
80
+ if (changelogs) {
81
+ args.push('--changelogs', changelogs)
82
+ }
59
83
 
60
- if (!app.type || app.type === 'application') {
61
- await deployApp(stage, app.id, config, commitId, changelogs, version)
62
- console.log('App deployed')
63
- } else if (app.type === 'module') {
64
- await deployModule(stage, app.id, config, commitId, changelogs, version)
65
- console.log('Module deployed')
84
+ const result = await $`${args}`.quiet().nothrow()
85
+
86
+ if (result.exitCode !== 0) {
87
+ const output = result.stderr.toString() || result.stdout.toString()
88
+ try {
89
+ const json = JSON.parse(output)
90
+ throw new Error(json.error || 'Release failed')
91
+ } catch {
92
+ throw new Error(output || 'Release failed')
93
+ }
66
94
  }
95
+
96
+ const output = JSON.parse(result.stdout.toString())
97
+ console.log(`${isModule ? 'Module' : 'App'} deployed: ${output.name}`)
package/tools/pull.ts CHANGED
@@ -1,24 +1,43 @@
1
1
  import { $ } from 'bun'
2
2
  import { format } from 'prettier'
3
- import { pullApplicationProject, pullModuleProject } from '../api'
4
3
 
5
4
  const cwd = process.cwd()
6
5
 
6
+ // Check git status
7
7
  const { exitCode } = await $`cd ${cwd} && git status`.nothrow()
8
8
  const isGitRepo = exitCode === 0
9
9
 
10
10
  if (isGitRepo) {
11
11
  const unstagedChanges = await $`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
12
12
  if (unstagedChanges)
13
- throw new Error('Unstaged changes found, please commit or stash your changes before deploying')
13
+ throw new Error('Unstaged changes found, please commit or stash your changes before pulling')
14
+ } else {
15
+ const confirmContinue = prompt(
16
+ 'No git repository found, so it will not be safe to pull, continue? (y/n)',
17
+ )
18
+ if (confirmContinue !== 'y') throw new Error('Pull cancelled')
14
19
  }
15
20
 
21
+ // Read application.json
16
22
  const app = await Bun.file(`${cwd}/application.json`).json()
17
- const stage = app.stage || 'production'
18
- const { files, lastCommitId } =
19
- app.type === 'module'
20
- ? await pullModuleProject(stage, app.id)
21
- : await pullApplicationProject(stage, app.id)
23
+
24
+ const isModule = app.type === 'module'
25
+ const command = isModule ? 'module' : 'app'
26
+
27
+ // Fetch project files using CLI
28
+ const result = await $`bricks ${command} project-pull ${app.id} --json`.quiet().nothrow()
29
+
30
+ if (result.exitCode !== 0) {
31
+ const output = result.stderr.toString() || result.stdout.toString()
32
+ try {
33
+ const json = JSON.parse(output)
34
+ throw new Error(json.error || 'Pull failed')
35
+ } catch {
36
+ throw new Error(output || 'Pull failed')
37
+ }
38
+ }
39
+
40
+ const { files, lastCommitId } = JSON.parse(result.stdout.toString())
22
41
 
23
42
  let useMain = false
24
43
  if (isGitRepo) {
@@ -30,7 +49,9 @@ if (isGitRepo) {
30
49
 
31
50
  if (commitId === lastCommitId) throw new Error('Commit not changed')
32
51
 
33
- const branchName = 'BRICKS_PROJECT_try-pull-application'
52
+ const branchName = isModule
53
+ ? 'BRICKS_PROJECT_try-pull-module'
54
+ : 'BRICKS_PROJECT_try-pull-application'
34
55
 
35
56
  await $`cd ${cwd} && git branch -D ${branchName}`.nothrow()
36
57
 
@@ -40,11 +61,6 @@ if (isGitRepo) {
40
61
  await $`cd ${cwd} && git checkout -b ${branchName}`
41
62
  useMain = true
42
63
  }
43
- } else {
44
- const confirmContinue = prompt(
45
- 'No git repository found, so it will not be safe to pull, continue? (y/n)',
46
- )
47
- if (confirmContinue !== 'y') throw new Error('Pull cancelled')
48
64
  }
49
65
 
50
66
  const prettierConfig = await Bun.file(`${cwd}/.prettierrc`)
@@ -58,7 +74,7 @@ const prettierConfig = await Bun.file(`${cwd}/.prettierrc`)
58
74
  }))
59
75
 
60
76
  await Promise.all(
61
- files.map(async (file) =>
77
+ files.map(async (file: { name: string; input: string; formatable?: boolean }) =>
62
78
  Bun.write(
63
79
  `${cwd}/${file.name}`,
64
80
  file.formatable
@@ -70,8 +86,13 @@ await Promise.all(
70
86
 
71
87
  if (isGitRepo) {
72
88
  await $`cd ${cwd} && git add .`
73
- await $`cd ${cwd} && git commit -m 'chore(project): apply file changes from BRICKS application'`
89
+ const commitMsg = isModule
90
+ ? 'chore(project): apply file changes from BRICKS module'
91
+ : 'chore(project): apply file changes from BRICKS application'
92
+ await $`cd ${cwd} && git commit -m ${commitMsg}`
74
93
  if (!useMain) {
75
94
  await $`cd ${cwd} && git merge main`
76
95
  }
77
96
  }
97
+
98
+ console.log(`${isModule ? 'Module' : 'App'} project pulled: ${files.length} files`)
@@ -477,6 +477,12 @@ Default property:
477
477
  mmprojHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
478
478
  /* Hash of mmproj file (PREVIEW FEATURE) */
479
479
  mmprojHash?: string | DataLink
480
+ /* Minimum tokens for image encoding in multimodal (PREVIEW FEATURE)
481
+ Useful for dynamic resolution models (e.g. Qwen-VL). Default: -1 (auto) */
482
+ imageMinTokens?: number | DataLink
483
+ /* Maximum tokens for image encoding in multimodal (PREVIEW FEATURE)
484
+ Limit tokens for dynamic resolution models to balance speed vs. detail. Default: -1 (auto) */
485
+ imageMaxTokens?: number | DataLink
480
486
  /* Chat Template (Jinja format) to override the default template from model */
481
487
  chatTemplate?: string | DataLink
482
488
  /* Context size (0 ~ 4096) (Default to 512) */