designkit-ai 1.3.0 → 1.4.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/bin/designkit.js CHANGED
@@ -9,6 +9,8 @@ import { convertCommand } from '../src/commands/convert.js'
9
9
  import { imagineCommand } from '../src/commands/imagine.js'
10
10
  import { projectCommand } from '../src/commands/project.js'
11
11
  import { autogenCommand } from '../src/commands/autogen.js'
12
+ import { configCommand } from '../src/commands/config.js'
13
+ import { getDefaultProvider, getDefaultPlatform } from '../src/lib/config.js'
12
14
  import { readFileSync } from 'fs'
13
15
  import { fileURLToPath } from 'url'
14
16
  import { dirname, join } from 'path'
@@ -51,17 +53,17 @@ program
51
53
  .command('design <prompt>')
52
54
  .description('Generate a UI component with AI')
53
55
  .option('-s, --skill <skill>', 'Skill: design, react, nextjs, vue, svelte, tailwind, flutter, swiftui, react-native', 'design')
54
- .option('-p, --provider <provider>', 'AI provider: anthropic, gemini, openai', 'anthropic')
56
+ .option('-p, --provider <provider>', `AI provider: anthropic, gemini, openai (default: ${getDefaultProvider()})`)
55
57
  .option('-o, --output <file>', 'Save output to file')
56
- .action(designCommand)
58
+ .action((prompt, opts) => designCommand(prompt, { ...opts, provider: opts.provider || getDefaultProvider() }))
57
59
 
58
60
  program
59
61
  .command('convert <file>')
60
62
  .description('Convert an HTML component to another framework with AI')
61
63
  .requiredOption('--to <framework>', 'Target: react, nextjs, vue, svelte, tailwind, flutter, swiftui, react-native')
62
- .option('-p, --provider <provider>', 'AI provider: anthropic, gemini, openai', 'anthropic')
64
+ .option('-p, --provider <provider>', `AI provider: anthropic, gemini, openai (default: ${getDefaultProvider()})`)
63
65
  .option('-o, --output <file>', 'Save output to file (default: same name, new extension)')
64
- .action(convertCommand)
66
+ .action((file, opts) => convertCommand(file, { ...opts, provider: opts.provider || getDefaultProvider() }))
65
67
 
66
68
  program
67
69
  .command('project')
@@ -87,11 +89,27 @@ program
87
89
  program
88
90
  .command('autogen <project>')
89
91
  .description('Generate a full design project: color spec + HTML files for every screen')
90
- .option('-p, --provider <provider>', 'AI provider: anthropic, gemini, openai', 'anthropic')
91
- .option('--platform <platform>', 'Target platform: mobile, web, both', 'mobile')
92
+ .option('-p, --provider <provider>', `AI provider: anthropic, gemini, openai (default: ${getDefaultProvider()})`)
93
+ .option('--platform <platform>', `Target platform: mobile, web (default: ${getDefaultPlatform()})`)
92
94
  .option('--screens <list>', 'Comma-separated screen/page names (auto-generated if omitted)')
93
95
  .option('--images <folder>', 'Path to local image assets folder (uses placehold.jp if omitted)')
94
96
  .option('-o, --output <dir>', 'Output directory (default: output/<project-slug>)')
95
- .action(autogenCommand)
97
+ .action((project, opts) => autogenCommand(project, {
98
+ ...opts,
99
+ provider: opts.provider || getDefaultProvider(),
100
+ platform: opts.platform || getDefaultPlatform()
101
+ }))
102
+
103
+ program
104
+ .command('config [action] [args...]')
105
+ .description('Get or set default config values (provider, platform)')
106
+ .addHelpText('after', `
107
+ Examples:
108
+ designkit config # show all config
109
+ designkit config set provider gemini # set default provider
110
+ designkit config set provider anthropic
111
+ designkit config set platform web
112
+ designkit config get provider`)
113
+ .action(configCommand)
96
114
 
97
115
  program.parse()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "designkit-ai",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "502 HTML UI components + AI skills for designing and building web and mobile apps",
5
5
  "keywords": [
6
6
  "design-system",
@@ -247,7 +247,6 @@ function generateIndexHtml(spec) {
247
247
  height: ${frameH}px;
248
248
  border: none;
249
249
  transform-origin: top left;
250
- transform: scale(calc(100% / ${frameW}));
251
250
  }
252
251
  .frame-overlay {
253
252
  position: absolute;
@@ -296,6 +295,18 @@ function generateIndexHtml(spec) {
296
295
  ${cards}
297
296
  </div>
298
297
  <footer>Generated by DesignKit AutoGen &middot; ${new Date().toLocaleDateString()}</footer>
298
+ <script>
299
+ function scaleFrames() {
300
+ document.querySelectorAll('.frame-wrap').forEach(wrap => {
301
+ const iframe = wrap.querySelector('iframe')
302
+ const w = wrap.offsetWidth
303
+ if (iframe && w > 0) iframe.style.transform = 'scale(' + (w / ${frameW}) + ')'
304
+ })
305
+ }
306
+ window.addEventListener('resize', scaleFrames)
307
+ window.addEventListener('load', scaleFrames)
308
+ requestAnimationFrame(scaleFrames)
309
+ </script>
299
310
  </body>
300
311
  </html>`
301
312
  }
@@ -0,0 +1,55 @@
1
+ import { readConfig, setConfigValue } from '../lib/config.js'
2
+
3
+ export function configCommand(action, args, options) {
4
+ // designkit config list (or just: designkit config)
5
+ if (!action || action === 'list') {
6
+ const config = readConfig()
7
+ console.log('\nDesignKit config (~/.designkit/config.json)\n')
8
+ console.log(` provider ${config.provider}`)
9
+ console.log(` platform ${config.platform}`)
10
+ console.log()
11
+ return
12
+ }
13
+
14
+ // designkit config get <key>
15
+ if (action === 'get') {
16
+ const key = args[0]
17
+ if (!key) {
18
+ console.error('Usage: designkit config get <key>')
19
+ process.exit(1)
20
+ }
21
+ const config = readConfig()
22
+ if (!(key in config)) {
23
+ console.error(`Unknown key: "${key}"`)
24
+ process.exit(1)
25
+ }
26
+ console.log(config[key])
27
+ return
28
+ }
29
+
30
+ // designkit config set <key> <value>
31
+ if (action === 'set') {
32
+ const key = args[0]
33
+ const value = args[1]
34
+ if (!key || !value) {
35
+ console.error('Usage: designkit config set <key> <value>')
36
+ console.error(' Keys: provider, platform')
37
+ console.error(' Examples:')
38
+ console.error(' designkit config set provider gemini')
39
+ console.error(' designkit config set provider anthropic')
40
+ console.error(' designkit config set platform web')
41
+ process.exit(1)
42
+ }
43
+ try {
44
+ setConfigValue(key, value)
45
+ console.log(`✓ Set ${key} = ${value}`)
46
+ } catch (err) {
47
+ console.error(`Error: ${err.message}`)
48
+ process.exit(1)
49
+ }
50
+ return
51
+ }
52
+
53
+ console.error(`Unknown subcommand: "${action}". Use: list, get, set`)
54
+ process.exit(1)
55
+ }
@@ -0,0 +1,54 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs'
2
+ import { join } from 'path'
3
+ import { homedir } from 'os'
4
+
5
+ const CONFIG_DIR = join(homedir(), '.designkit')
6
+ const CONFIG_PATH = join(CONFIG_DIR, 'config.json')
7
+
8
+ const DEFAULTS = {
9
+ provider: 'anthropic',
10
+ platform: 'mobile'
11
+ }
12
+
13
+ const VALID = {
14
+ provider: ['anthropic', 'gemini', 'openai'],
15
+ platform: ['mobile', 'web']
16
+ }
17
+
18
+ export function readConfig() {
19
+ if (!existsSync(CONFIG_PATH)) return { ...DEFAULTS }
20
+ try {
21
+ return { ...DEFAULTS, ...JSON.parse(readFileSync(CONFIG_PATH, 'utf8')) }
22
+ } catch {
23
+ return { ...DEFAULTS }
24
+ }
25
+ }
26
+
27
+ export function writeConfig(config) {
28
+ if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true })
29
+ writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf8')
30
+ }
31
+
32
+ export function getConfigValue(key) {
33
+ return readConfig()[key]
34
+ }
35
+
36
+ export function setConfigValue(key, value) {
37
+ if (!Object.keys(DEFAULTS).includes(key)) {
38
+ throw new Error(`Unknown config key: "${key}". Valid keys: ${Object.keys(DEFAULTS).join(', ')}`)
39
+ }
40
+ if (VALID[key] && !VALID[key].includes(value)) {
41
+ throw new Error(`Invalid value "${value}" for "${key}". Valid values: ${VALID[key].join(', ')}`)
42
+ }
43
+ const config = readConfig()
44
+ config[key] = value
45
+ writeConfig(config)
46
+ }
47
+
48
+ export function getDefaultProvider() {
49
+ return getConfigValue('provider') || 'anthropic'
50
+ }
51
+
52
+ export function getDefaultPlatform() {
53
+ return getConfigValue('platform') || 'mobile'
54
+ }