@superdesign/cli 0.1.5 → 0.1.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Super Design
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -12,7 +12,7 @@ export declare const POLL_TIMEOUT_MS: number;
12
12
  export declare const AUTH_POLL_INTERVAL_MS = 2000;
13
13
  export declare const AUTH_POLL_TIMEOUT_MS: number;
14
14
  /** CLI version - should match package.json */
15
- export declare const CLI_VERSION = "0.1.5";
15
+ export declare const CLI_VERSION = "0.1.6";
16
16
  /** Config directory name */
17
17
  export declare const CONFIG_DIR_NAME = ".superdesign";
18
18
  /** Config file name */
@@ -31,3 +31,6 @@ export declare const EXIT_CODES: {
31
31
  export declare const SKILLS_DIR = ".claude/skills/superdesign";
32
32
  /** SKILL.md file name */
33
33
  export declare const SKILL_FILE_NAME = "SKILL.md";
34
+ /** PostHog analytics configuration */
35
+ export declare const POSTHOG_KEY: string;
36
+ export declare const POSTHOG_HOST: string;
package/dist/index.cjs CHANGED
@@ -91,8 +91,6 @@ var __webpack_exports__ = {};
91
91
  const external_url_namespaceObject = require("url");
92
92
  const external_path_namespaceObject = require("path");
93
93
  const external_commander_namespaceObject = require("commander");
94
- const external_fs_namespaceObject = require("fs");
95
- const external_os_namespaceObject = require("os");
96
94
  const CONFIG_DIR_NAME = '.superdesign';
97
95
  const CONFIG_FILE_NAME = 'config.json';
98
96
  const EXIT_CODES = {
@@ -106,6 +104,11 @@ var __webpack_exports__ = {};
106
104
  };
107
105
  const SKILLS_DIR = '.claude/skills/superdesign';
108
106
  const SKILL_FILE_NAME = 'SKILL.md';
107
+ const POSTHOG_KEY = process.env.POSTHOG_KEY || 'phc_oUcDklFBX3wy8eksSyEC0pataKCgSadur1sio5hBHg4';
108
+ const POSTHOG_HOST = process.env.POSTHOG_HOST || 'https://eu.i.posthog.com';
109
+ const external_fs_namespaceObject = require("fs");
110
+ const external_os_namespaceObject = require("os");
111
+ var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
109
112
  function getConfigDir() {
110
113
  return external_path_namespaceObject.join(external_os_namespaceObject.homedir(), CONFIG_DIR_NAME);
111
114
  }
@@ -313,7 +316,7 @@ var __webpack_exports__ = {};
313
316
  try {
314
317
  startSpinner('Creating auth session...');
315
318
  const session = await createSession({
316
- cliVersion: "0.1.5",
319
+ cliVersion: "0.1.6",
317
320
  os: `${external_os_namespaceObject.platform()} ${external_os_namespaceObject.release()}`,
318
321
  hostname: external_os_namespaceObject.hostname()
319
322
  });
@@ -512,269 +515,35 @@ var __webpack_exports__ = {};
512
515
  return `---
513
516
  name: superdesign
514
517
  description: Superdesign is a design agent, where it specialised in frontend UI/UX design; Use this skill before you implement any UI that require some design thinking
518
+ metadata:
519
+ author: superdesign
520
+ version: "0.0.1"
515
521
  ---
516
522
 
517
- SuperDesign helps you (1) find design inspirations/styles and (2) optionally generate/iterate design drafts on an infinite canvas.
518
-
519
- Each SuperDesign canvas run creates a new node and returns a \`previewUrl\`.
523
+ SuperDesign helps you (1) find design inspirations/styles and (2) generate/iterate design drafts on an infinite canvas.
520
524
 
521
525
  ---
522
526
 
523
- ## Core scenarios (what this skill handles)
527
+ # Core scenarios (what this skill handles)
524
528
 
525
529
  1. **Help me design X** (feature/page/flow)
526
530
  2. **Set design system**
527
531
  3. **Help me improve design of X**
528
532
 
529
- ---
530
-
531
- ## Tooling overview
532
-
533
- ### A) Inspiration & Style Tools (generic, always available)
534
- Use these to discover style direction, references, and brand context:
535
-
536
- - **Search prompt library** (style/components/pages)
537
- \`\`\`bash
538
- superdesign search-prompts --keyword "<keyword>" --json
539
- superdesign search-prompts --tags "style" --json
540
- superdesign search-prompts --tags "style" --keyword "<style keyword>" --json
541
- \`\`\`
542
-
543
- - **Get full prompt details**
544
- \`\`\`bash
545
- superdesign get-prompts --slugs "<slug1,slug2,...>" --json
546
- \`\`\`
547
-
548
- - **Extract brand guide from a URL**
549
- \`\`\`bash
550
- superdesign extract-brand-guide --url https://example.com --json
551
- \`\`\`
552
-
553
- ### B) Canvas Design Tools (specialised, optional)
554
-
555
- Use these when you want to explore multiple directions and show previews:
556
-
557
- - Create project (supports prompt / prompt file / HTML)
558
- - Create design draft
559
- - Iterate design draft (replace / branch)
560
- - Plan flow pages → execute flow pages
561
- - Fetch nodes, export HTML
562
-
563
- > Pixel-perfect HTML playground is ONLY required for Canvas workflows.
564
-
565
- ---
566
-
567
- ## Always-on rules
568
-
569
- - Design system should live at: \`.superdesign/design-system.md\`
570
- - If \`.superdesign/design-system.md\` is missing, run **Design System Setup** first.
571
- - Use \`askQuestion\` to ask high-signal questions (constraints, taste, tradeoffs).
572
- - For Canvas workflows: build a simplified/pixel-perfect prototype HTML in:
573
- - \`.superdesign/playgrounds/<name>.html\`
574
- - Always use \`--json\` for machine parsing.
575
-
576
- ---
577
-
578
- ## Playground rules (Canvas only)
579
-
580
- **Playground = BEFORE state (what exists now).** It provides context for SuperDesign agent.
581
- **Prompt = DESIRED CHANGE (what to add/modify).**
582
-
583
- The playground HTML must contain **ONLY UI that currently exists in the codebase**. For NEW features/sections, describe them entirely in the \`--prompt\` flag — do NOT add wireframes, placeholders, or sketches to the playground HTML.
584
-
585
- - **DO NOT** design or improve anything in the playground
586
- - **DO NOT** add placeholder sections like \`<!-- NEW FEATURE - DESIGN THIS -->\`
587
- - **DO** create pixel-perfect replica of current UI state
588
- - Valid formats:
589
- - **Component-only**: isolated component with enough markup to show core UX/states
590
- - **Full page**: replica of page where component operates (shows surrounding context)
591
- - Save to: \`.superdesign/playgrounds/<name>.html\`
592
-
593
- ### Example: Adding a "Book Demo" section to home page
594
-
595
- **BAD approach:**
596
- \`\`\`html
597
- <!-- playground includes a sketched Book Demo section -->
598
- <section class="book-demo">
599
- <!-- DESIGN THIS - Add CTA here -->
600
- <h3>Book a Demo</h3>
601
- <button>Schedule</button>
602
- </section>
603
- \`\`\`
604
-
605
- **GOOD approach:**
606
- \`\`\`html
607
- <!-- playground is pure replica of existing home page (hero + projects) -->
608
- <!-- NO book demo section in HTML -->
609
- \`\`\`
610
- Then in the iterate command:
611
- \`\`\`bash
612
- --prompt "Add a Book Demo section between the hero and projects sections. Requirements: minimal card style, horizontal layout..."
613
- \`\`\`
614
-
615
- ---
616
-
617
- # 1) Design System Setup
618
-
619
- ### Step 0 — Ask user (one question)
620
-
621
- "Do you want to **create a new design system** or **extract from the current codebase**?"
622
-
623
- ### A) Extract from codebase
624
-
625
- 1. Investigate codebase:
626
- - design tokens, typography, colors, spacing, radius, shadows
627
- - motion/animation patterns
628
- - example components usage + implementation patterns
629
- - core product functions + key pages
630
- 2. Write standalone design system to:
631
- - \`.superdesign/design-system.md\`
632
- - Must be implementable without the codebase
633
-
634
- ### B) Create a new design system (to improve current UI)
635
-
636
- 1. Investigate codebase to understand product + needed pages/components
637
- 2. Gather inspirations (generic tools):
638
- - \`superdesign search-prompts --tags "style" --json\`
639
- - \`superdesign get-prompts --slugs ... --json\`
640
- - optional: \`superdesign extract-brand-guide --url ... --json\`
641
- 3. Interview user (\`askQuestion\`) to choose direction
642
- 4. Write:
643
- - \`.superdesign/design-system.md\` (adapted to product + references)
644
-
645
- ---
646
-
647
- # 2) Designing X (feature/page/flow)
648
-
649
- ## A) If user wants references / direction only (no canvas)
650
-
651
- 1. Ensure \`.superdesign/design-system.md\` exists (setup if missing)
652
- 2. Use inspiration tools to collect references:
653
- - search prompts (style + component/page)
654
- - get prompts (full details)
655
- - extract brand guide if relevant
656
- 3. Provide a concrete design spec:
657
- - layout + hierarchy
658
- - component set + states
659
- - token guidance (typography/color/spacing/radius/motion)
660
- - interaction notes + edge cases
661
-
662
- ## B) If user wants visual exploration (canvas optional)
663
-
664
- Use canvas when direction is uncertain or multiple options are needed.
665
-
666
- ### Canvas workflow — Add feature to existing page
667
-
668
- 1. Ensure \`.superdesign/design-system.md\` exists (setup if missing)
669
- 2. Build prototype HTML playground (simplified + pixel-perfect enough):
670
- - \`.superdesign/playgrounds/<page>-<feature>.html\`
671
- 3. Ask targeted questions (\`askQuestion\`) about requirements + taste
672
- 4. Create project with playground HTML (returns \`draftId\`):
673
- \`\`\`bash
674
- superdesign create-project \\
675
- --title "<feature>" \\
676
- --html-file .superdesign/playgrounds/<file>.html \\
677
- --prompt-file .superdesign/design-system.md \\
678
- --json
679
- \`\`\`
680
- → Note: \`draftId\` in response is the baseline draft
681
- 5. Branch designs from baseline (use \`draftId\` from step 4):
682
- \`\`\`bash
683
- superdesign iterate-design-draft \\
684
- --draft-id <draftId> \\
685
- --prompt "<design requirements>" \\
686
- --mode branch \\
687
- --count 3 \\
688
- --json
689
- \`\`\`
690
- 6. Share \`previewUrl\` → collect feedback → iterate
691
-
692
- ### Canvas workflow — Add new page
693
-
694
- Same as above, but playground should include shared UI shell:
695
- - nav, layout container, spacing rhythm, shared components
696
-
697
- ### Canvas workflow — Improve current UI
698
-
699
- 1. Investigate product + current UI states
700
- 2. Ensure design system exists
701
- 3. Propose improvement options:
702
- - big restructure
703
- - style uplift
704
- - low-hanging polish
705
- 4. Pick one → build playground → create project (prompt-file design system) → branch drafts
706
- 5. Share \`previewUrl\` → iterate
707
-
708
- ### When to use create-design-draft
709
-
710
- Only use \`create-design-draft\` when creating from scratch (no HTML baseline).
711
-
712
- **Required in prompt:**
713
- - Full page structure (header, sidebar, main content areas)
714
- - Component environment/surroundings
715
- - Layout context (what's above/below/beside)
716
-
717
- \`\`\`bash
718
- superdesign create-design-draft \\
719
- --project-id <id> \\
720
- --title "Feature X" \\
721
- --prompt "Page has: fixed header 64px, left sidebar 240px, main content area. Design a settings panel in the main content area with..." \\
722
- --device desktop \\
723
- --json
533
+ # How it works
534
+ Fetch fresh guidelines below:
724
535
  \`\`\`
725
-
726
- ---
727
-
728
- # Advanced usage
729
-
730
- ### Plan + generate a full user journey
731
-
732
- Plan:
733
- \`\`\`bash
734
- superdesign plan-flow-pages \\
735
- --draft-id <draftId> \\
736
- --source-node-id <nodeId> \\
737
- --context "<flow context>" \\
738
- --json
536
+ https://raw.githubusercontent.com/superdesigndev/superdesign-skill/main/skills/superdesign/SUPERDESIGN.md
739
537
  \`\`\`
740
538
 
741
- Execute:
742
- \`\`\`bash
743
- superdesign execute-flow-pages \\
744
- --draft-id <draftId> \\
745
- --source-node-id <nodeId> \\
746
- --pages '[{"title":"Signup","prompt":"..."},{"title":"Payment","prompt":"..."}]' \\
747
- --json
748
- \`\`\`
539
+ Action accordingly based on instruction in the guidelines
749
540
 
750
- ### Get HTML reference from a draft
541
+ # Superdesign CLI
751
542
 
752
- \`\`\`bash
753
- superdesign get-design --draft-id <draftId> --output ./design.html
754
543
  \`\`\`
755
-
756
- ---
757
-
758
- ## Quick reference (key commands)
759
-
760
- \`\`\`bash
761
- # Inspirations
762
- superdesign search-prompts --keyword "<keyword>" --json
763
- superdesign search-prompts --tags "style" --json
764
- superdesign get-prompts --slugs "<slug1,slug2>" --json
765
- superdesign extract-brand-guide --url https://example.com --json
766
-
767
- # Canvas
768
- superdesign create-project --title "X" --prompt "..." --json
769
- superdesign create-project --title "X" --prompt-file .superdesign/design-system.md --json
770
- superdesign create-project --title "X" --html-file ./index.html --prompt-file .superdesign/design-system.md --json
771
-
772
- superdesign create-design-draft --project-id <id> --title "X" --prompt "..." --device desktop --json
773
- superdesign iterate-design-draft --draft-id <id> --prompt "..." --mode replace --json
774
- superdesign iterate-design-draft --draft-id <id> --prompt "..." --mode branch --count 3 --json
775
-
776
- superdesign fetch-design-nodes --project-id <id> --json
777
- superdesign get-design --draft-id <id> --json
544
+ npm install -g @superdesign/cli@latest
545
+ superdesign init
546
+ superdesign --help
778
547
  \`\`\`
779
548
  `;
780
549
  }
@@ -1509,15 +1278,104 @@ superdesign get-design --draft-id <id> --json
1509
1278
  });
1510
1279
  return command;
1511
1280
  }
1281
+ const external_posthog_node_namespaceObject = require("posthog-node");
1282
+ let posthogClient = null;
1283
+ function getPostHog() {
1284
+ if (!posthogClient && POSTHOG_KEY) posthogClient = new external_posthog_node_namespaceObject.PostHog(POSTHOG_KEY, {
1285
+ host: POSTHOG_HOST
1286
+ });
1287
+ return posthogClient;
1288
+ }
1289
+ function sanitizeOptions(options) {
1290
+ const sensitiveKeys = [
1291
+ 'token',
1292
+ 'key',
1293
+ 'secret',
1294
+ 'password',
1295
+ 'apiKey',
1296
+ 'api_key',
1297
+ 'apikey',
1298
+ 'auth',
1299
+ 'authorization',
1300
+ 'credential'
1301
+ ];
1302
+ const sanitized = {};
1303
+ for (const [key, value] of Object.entries(options)){
1304
+ const lowerKey = key.toLowerCase();
1305
+ if (!sensitiveKeys.some((sensitive)=>lowerKey.includes(sensitive))) {
1306
+ if ('string' != typeof value || !(value.length > 100)) sanitized[key] = value;
1307
+ }
1308
+ }
1309
+ return sanitized;
1310
+ }
1311
+ async function trackCommand(opts) {
1312
+ const config = loadConfig();
1313
+ const teamId = config.teamId;
1314
+ const metadata = {
1315
+ command: opts.command,
1316
+ success: opts.success,
1317
+ durationMs: opts.durationMs,
1318
+ errorCode: opts.errorCode,
1319
+ options: opts.options ? sanitizeOptions(opts.options) : void 0,
1320
+ cliVersion: "0.1.6",
1321
+ os: `${external_os_default().platform()} ${external_os_default().release()}`
1322
+ };
1323
+ const posthog = getPostHog();
1324
+ if (posthog) {
1325
+ const distinctId = teamId || `anon_${external_os_default().hostname()}`;
1326
+ posthog.capture({
1327
+ distinctId,
1328
+ event: 'cli_command',
1329
+ properties: {
1330
+ team_id: teamId,
1331
+ ...metadata
1332
+ }
1333
+ });
1334
+ }
1335
+ if (manager_isAuthenticated() && teamId) try {
1336
+ const client = getApiClient();
1337
+ await client.post('/external/track', {
1338
+ activityType: 'cli_command',
1339
+ metadata
1340
+ });
1341
+ } catch {}
1342
+ }
1343
+ async function shutdownAnalytics() {
1344
+ if (posthogClient) {
1345
+ await posthogClient.shutdown();
1346
+ posthogClient = null;
1347
+ }
1348
+ }
1512
1349
  const src_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
1513
1350
  const src_dirname = (0, external_path_namespaceObject.dirname)(src_filename);
1514
1351
  (0, external_dotenv_namespaceObject.config)({
1515
1352
  path: (0, external_path_namespaceObject.resolve)(src_dirname, '../.env')
1516
1353
  });
1517
1354
  (0, external_dotenv_namespaceObject.config)();
1355
+ let commandStartTime = 0;
1356
+ let currentCommand = '';
1357
+ function sanitizeCommandOptions(opts) {
1358
+ const sanitized = {};
1359
+ for (const [key, value] of Object.entries(opts))if (!('function' == typeof value || key.startsWith('_'))) sanitized[key] = value;
1360
+ return sanitized;
1361
+ }
1518
1362
  function createProgram() {
1519
1363
  const program = new external_commander_namespaceObject.Command();
1520
- program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.5");
1364
+ program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.6");
1365
+ program.hook('preAction', ()=>{
1366
+ commandStartTime = Date.now();
1367
+ currentCommand = process.argv[2] || 'unknown';
1368
+ });
1369
+ program.hook('postAction', async (_thisCommand, actionCommand)=>{
1370
+ const durationMs = Date.now() - commandStartTime;
1371
+ await trackCommand({
1372
+ command: currentCommand,
1373
+ success: true,
1374
+ durationMs,
1375
+ options: sanitizeCommandOptions(actionCommand.opts())
1376
+ });
1377
+ await shutdownAnalytics();
1378
+ });
1521
1379
  program.addCommand(createLoginCommand());
1522
1380
  program.addCommand(createLogoutCommand());
1523
1381
  program.addCommand(createInitCommand());
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@ import { fileURLToPath } from "url";
3
3
  import { dirname, join, resolve as external_path_resolve } from "path";
4
4
  import { Command } from "commander";
5
5
  import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
6
- import { homedir, hostname, platform, release } from "os";
6
+ import os, { homedir, hostname, platform, release } from "os";
7
7
  import axios from "axios";
8
8
  import ora from "ora";
9
9
  import { writeFile } from "fs/promises";
10
+ import { PostHog } from "posthog-node";
10
11
  const CONFIG_DIR_NAME = '.superdesign';
11
12
  const CONFIG_FILE_NAME = 'config.json';
12
13
  const EXIT_CODES = {
@@ -20,6 +21,8 @@ const EXIT_CODES = {
20
21
  };
21
22
  const SKILLS_DIR = '.claude/skills/superdesign';
22
23
  const SKILL_FILE_NAME = 'SKILL.md';
24
+ const POSTHOG_KEY = process.env.POSTHOG_KEY || 'phc_oUcDklFBX3wy8eksSyEC0pataKCgSadur1sio5hBHg4';
25
+ const POSTHOG_HOST = process.env.POSTHOG_HOST || 'https://eu.i.posthog.com';
23
26
  function getConfigDir() {
24
27
  return join(homedir(), CONFIG_DIR_NAME);
25
28
  }
@@ -223,7 +226,7 @@ async function runAuthFlow(options = {}) {
223
226
  try {
224
227
  startSpinner('Creating auth session...');
225
228
  const session = await createSession({
226
- cliVersion: "0.1.5",
229
+ cliVersion: "0.1.6",
227
230
  os: `${platform()} ${release()}`,
228
231
  hostname: hostname()
229
232
  });
@@ -422,269 +425,35 @@ function getSkillTemplate() {
422
425
  return `---
423
426
  name: superdesign
424
427
  description: Superdesign is a design agent, where it specialised in frontend UI/UX design; Use this skill before you implement any UI that require some design thinking
428
+ metadata:
429
+ author: superdesign
430
+ version: "0.0.1"
425
431
  ---
426
432
 
427
- SuperDesign helps you (1) find design inspirations/styles and (2) optionally generate/iterate design drafts on an infinite canvas.
428
-
429
- Each SuperDesign canvas run creates a new node and returns a \`previewUrl\`.
433
+ SuperDesign helps you (1) find design inspirations/styles and (2) generate/iterate design drafts on an infinite canvas.
430
434
 
431
435
  ---
432
436
 
433
- ## Core scenarios (what this skill handles)
437
+ # Core scenarios (what this skill handles)
434
438
 
435
439
  1. **Help me design X** (feature/page/flow)
436
440
  2. **Set design system**
437
441
  3. **Help me improve design of X**
438
442
 
439
- ---
440
-
441
- ## Tooling overview
442
-
443
- ### A) Inspiration & Style Tools (generic, always available)
444
- Use these to discover style direction, references, and brand context:
445
-
446
- - **Search prompt library** (style/components/pages)
447
- \`\`\`bash
448
- superdesign search-prompts --keyword "<keyword>" --json
449
- superdesign search-prompts --tags "style" --json
450
- superdesign search-prompts --tags "style" --keyword "<style keyword>" --json
451
- \`\`\`
452
-
453
- - **Get full prompt details**
454
- \`\`\`bash
455
- superdesign get-prompts --slugs "<slug1,slug2,...>" --json
456
- \`\`\`
457
-
458
- - **Extract brand guide from a URL**
459
- \`\`\`bash
460
- superdesign extract-brand-guide --url https://example.com --json
461
- \`\`\`
462
-
463
- ### B) Canvas Design Tools (specialised, optional)
464
-
465
- Use these when you want to explore multiple directions and show previews:
466
-
467
- - Create project (supports prompt / prompt file / HTML)
468
- - Create design draft
469
- - Iterate design draft (replace / branch)
470
- - Plan flow pages → execute flow pages
471
- - Fetch nodes, export HTML
472
-
473
- > Pixel-perfect HTML playground is ONLY required for Canvas workflows.
474
-
475
- ---
476
-
477
- ## Always-on rules
478
-
479
- - Design system should live at: \`.superdesign/design-system.md\`
480
- - If \`.superdesign/design-system.md\` is missing, run **Design System Setup** first.
481
- - Use \`askQuestion\` to ask high-signal questions (constraints, taste, tradeoffs).
482
- - For Canvas workflows: build a simplified/pixel-perfect prototype HTML in:
483
- - \`.superdesign/playgrounds/<name>.html\`
484
- - Always use \`--json\` for machine parsing.
485
-
486
- ---
487
-
488
- ## Playground rules (Canvas only)
489
-
490
- **Playground = BEFORE state (what exists now).** It provides context for SuperDesign agent.
491
- **Prompt = DESIRED CHANGE (what to add/modify).**
492
-
493
- The playground HTML must contain **ONLY UI that currently exists in the codebase**. For NEW features/sections, describe them entirely in the \`--prompt\` flag — do NOT add wireframes, placeholders, or sketches to the playground HTML.
494
-
495
- - **DO NOT** design or improve anything in the playground
496
- - **DO NOT** add placeholder sections like \`<!-- NEW FEATURE - DESIGN THIS -->\`
497
- - **DO** create pixel-perfect replica of current UI state
498
- - Valid formats:
499
- - **Component-only**: isolated component with enough markup to show core UX/states
500
- - **Full page**: replica of page where component operates (shows surrounding context)
501
- - Save to: \`.superdesign/playgrounds/<name>.html\`
502
-
503
- ### Example: Adding a "Book Demo" section to home page
504
-
505
- **BAD approach:**
506
- \`\`\`html
507
- <!-- playground includes a sketched Book Demo section -->
508
- <section class="book-demo">
509
- <!-- DESIGN THIS - Add CTA here -->
510
- <h3>Book a Demo</h3>
511
- <button>Schedule</button>
512
- </section>
513
- \`\`\`
514
-
515
- **GOOD approach:**
516
- \`\`\`html
517
- <!-- playground is pure replica of existing home page (hero + projects) -->
518
- <!-- NO book demo section in HTML -->
519
- \`\`\`
520
- Then in the iterate command:
521
- \`\`\`bash
522
- --prompt "Add a Book Demo section between the hero and projects sections. Requirements: minimal card style, horizontal layout..."
523
- \`\`\`
524
-
525
- ---
526
-
527
- # 1) Design System Setup
528
-
529
- ### Step 0 — Ask user (one question)
530
-
531
- "Do you want to **create a new design system** or **extract from the current codebase**?"
532
-
533
- ### A) Extract from codebase
534
-
535
- 1. Investigate codebase:
536
- - design tokens, typography, colors, spacing, radius, shadows
537
- - motion/animation patterns
538
- - example components usage + implementation patterns
539
- - core product functions + key pages
540
- 2. Write standalone design system to:
541
- - \`.superdesign/design-system.md\`
542
- - Must be implementable without the codebase
543
-
544
- ### B) Create a new design system (to improve current UI)
545
-
546
- 1. Investigate codebase to understand product + needed pages/components
547
- 2. Gather inspirations (generic tools):
548
- - \`superdesign search-prompts --tags "style" --json\`
549
- - \`superdesign get-prompts --slugs ... --json\`
550
- - optional: \`superdesign extract-brand-guide --url ... --json\`
551
- 3. Interview user (\`askQuestion\`) to choose direction
552
- 4. Write:
553
- - \`.superdesign/design-system.md\` (adapted to product + references)
554
-
555
- ---
556
-
557
- # 2) Designing X (feature/page/flow)
558
-
559
- ## A) If user wants references / direction only (no canvas)
560
-
561
- 1. Ensure \`.superdesign/design-system.md\` exists (setup if missing)
562
- 2. Use inspiration tools to collect references:
563
- - search prompts (style + component/page)
564
- - get prompts (full details)
565
- - extract brand guide if relevant
566
- 3. Provide a concrete design spec:
567
- - layout + hierarchy
568
- - component set + states
569
- - token guidance (typography/color/spacing/radius/motion)
570
- - interaction notes + edge cases
571
-
572
- ## B) If user wants visual exploration (canvas optional)
573
-
574
- Use canvas when direction is uncertain or multiple options are needed.
575
-
576
- ### Canvas workflow — Add feature to existing page
577
-
578
- 1. Ensure \`.superdesign/design-system.md\` exists (setup if missing)
579
- 2. Build prototype HTML playground (simplified + pixel-perfect enough):
580
- - \`.superdesign/playgrounds/<page>-<feature>.html\`
581
- 3. Ask targeted questions (\`askQuestion\`) about requirements + taste
582
- 4. Create project with playground HTML (returns \`draftId\`):
583
- \`\`\`bash
584
- superdesign create-project \\
585
- --title "<feature>" \\
586
- --html-file .superdesign/playgrounds/<file>.html \\
587
- --prompt-file .superdesign/design-system.md \\
588
- --json
589
- \`\`\`
590
- → Note: \`draftId\` in response is the baseline draft
591
- 5. Branch designs from baseline (use \`draftId\` from step 4):
592
- \`\`\`bash
593
- superdesign iterate-design-draft \\
594
- --draft-id <draftId> \\
595
- --prompt "<design requirements>" \\
596
- --mode branch \\
597
- --count 3 \\
598
- --json
599
- \`\`\`
600
- 6. Share \`previewUrl\` → collect feedback → iterate
601
-
602
- ### Canvas workflow — Add new page
603
-
604
- Same as above, but playground should include shared UI shell:
605
- - nav, layout container, spacing rhythm, shared components
606
-
607
- ### Canvas workflow — Improve current UI
608
-
609
- 1. Investigate product + current UI states
610
- 2. Ensure design system exists
611
- 3. Propose improvement options:
612
- - big restructure
613
- - style uplift
614
- - low-hanging polish
615
- 4. Pick one → build playground → create project (prompt-file design system) → branch drafts
616
- 5. Share \`previewUrl\` → iterate
617
-
618
- ### When to use create-design-draft
619
-
620
- Only use \`create-design-draft\` when creating from scratch (no HTML baseline).
621
-
622
- **Required in prompt:**
623
- - Full page structure (header, sidebar, main content areas)
624
- - Component environment/surroundings
625
- - Layout context (what's above/below/beside)
626
-
627
- \`\`\`bash
628
- superdesign create-design-draft \\
629
- --project-id <id> \\
630
- --title "Feature X" \\
631
- --prompt "Page has: fixed header 64px, left sidebar 240px, main content area. Design a settings panel in the main content area with..." \\
632
- --device desktop \\
633
- --json
443
+ # How it works
444
+ Fetch fresh guidelines below:
634
445
  \`\`\`
635
-
636
- ---
637
-
638
- # Advanced usage
639
-
640
- ### Plan + generate a full user journey
641
-
642
- Plan:
643
- \`\`\`bash
644
- superdesign plan-flow-pages \\
645
- --draft-id <draftId> \\
646
- --source-node-id <nodeId> \\
647
- --context "<flow context>" \\
648
- --json
446
+ https://raw.githubusercontent.com/superdesigndev/superdesign-skill/main/skills/superdesign/SUPERDESIGN.md
649
447
  \`\`\`
650
448
 
651
- Execute:
652
- \`\`\`bash
653
- superdesign execute-flow-pages \\
654
- --draft-id <draftId> \\
655
- --source-node-id <nodeId> \\
656
- --pages '[{"title":"Signup","prompt":"..."},{"title":"Payment","prompt":"..."}]' \\
657
- --json
658
- \`\`\`
449
+ Action accordingly based on instruction in the guidelines
659
450
 
660
- ### Get HTML reference from a draft
451
+ # Superdesign CLI
661
452
 
662
- \`\`\`bash
663
- superdesign get-design --draft-id <draftId> --output ./design.html
664
453
  \`\`\`
665
-
666
- ---
667
-
668
- ## Quick reference (key commands)
669
-
670
- \`\`\`bash
671
- # Inspirations
672
- superdesign search-prompts --keyword "<keyword>" --json
673
- superdesign search-prompts --tags "style" --json
674
- superdesign get-prompts --slugs "<slug1,slug2>" --json
675
- superdesign extract-brand-guide --url https://example.com --json
676
-
677
- # Canvas
678
- superdesign create-project --title "X" --prompt "..." --json
679
- superdesign create-project --title "X" --prompt-file .superdesign/design-system.md --json
680
- superdesign create-project --title "X" --html-file ./index.html --prompt-file .superdesign/design-system.md --json
681
-
682
- superdesign create-design-draft --project-id <id> --title "X" --prompt "..." --device desktop --json
683
- superdesign iterate-design-draft --draft-id <id> --prompt "..." --mode replace --json
684
- superdesign iterate-design-draft --draft-id <id> --prompt "..." --mode branch --count 3 --json
685
-
686
- superdesign fetch-design-nodes --project-id <id> --json
687
- superdesign get-design --draft-id <id> --json
454
+ npm install -g @superdesign/cli@latest
455
+ superdesign init
456
+ superdesign --help
688
457
  \`\`\`
689
458
  `;
690
459
  }
@@ -1418,15 +1187,103 @@ function createGetDesignCommand() {
1418
1187
  });
1419
1188
  return command;
1420
1189
  }
1190
+ let posthogClient = null;
1191
+ function getPostHog() {
1192
+ if (!posthogClient && POSTHOG_KEY) posthogClient = new PostHog(POSTHOG_KEY, {
1193
+ host: POSTHOG_HOST
1194
+ });
1195
+ return posthogClient;
1196
+ }
1197
+ function sanitizeOptions(options) {
1198
+ const sensitiveKeys = [
1199
+ 'token',
1200
+ 'key',
1201
+ 'secret',
1202
+ 'password',
1203
+ 'apiKey',
1204
+ 'api_key',
1205
+ 'apikey',
1206
+ 'auth',
1207
+ 'authorization',
1208
+ 'credential'
1209
+ ];
1210
+ const sanitized = {};
1211
+ for (const [key, value] of Object.entries(options)){
1212
+ const lowerKey = key.toLowerCase();
1213
+ if (!sensitiveKeys.some((sensitive)=>lowerKey.includes(sensitive))) {
1214
+ if ('string' != typeof value || !(value.length > 100)) sanitized[key] = value;
1215
+ }
1216
+ }
1217
+ return sanitized;
1218
+ }
1219
+ async function trackCommand(opts) {
1220
+ const config = loadConfig();
1221
+ const teamId = config.teamId;
1222
+ const metadata = {
1223
+ command: opts.command,
1224
+ success: opts.success,
1225
+ durationMs: opts.durationMs,
1226
+ errorCode: opts.errorCode,
1227
+ options: opts.options ? sanitizeOptions(opts.options) : void 0,
1228
+ cliVersion: "0.1.6",
1229
+ os: `${os.platform()} ${os.release()}`
1230
+ };
1231
+ const posthog = getPostHog();
1232
+ if (posthog) {
1233
+ const distinctId = teamId || `anon_${os.hostname()}`;
1234
+ posthog.capture({
1235
+ distinctId,
1236
+ event: 'cli_command',
1237
+ properties: {
1238
+ team_id: teamId,
1239
+ ...metadata
1240
+ }
1241
+ });
1242
+ }
1243
+ if (manager_isAuthenticated() && teamId) try {
1244
+ const client = getApiClient();
1245
+ await client.post('/external/track', {
1246
+ activityType: 'cli_command',
1247
+ metadata
1248
+ });
1249
+ } catch {}
1250
+ }
1251
+ async function shutdownAnalytics() {
1252
+ if (posthogClient) {
1253
+ await posthogClient.shutdown();
1254
+ posthogClient = null;
1255
+ }
1256
+ }
1421
1257
  const src_filename = fileURLToPath(import.meta.url);
1422
1258
  const src_dirname = dirname(src_filename);
1423
1259
  external_dotenv_config({
1424
1260
  path: external_path_resolve(src_dirname, '../.env')
1425
1261
  });
1426
1262
  external_dotenv_config();
1263
+ let commandStartTime = 0;
1264
+ let currentCommand = '';
1265
+ function sanitizeCommandOptions(opts) {
1266
+ const sanitized = {};
1267
+ for (const [key, value] of Object.entries(opts))if (!('function' == typeof value || key.startsWith('_'))) sanitized[key] = value;
1268
+ return sanitized;
1269
+ }
1427
1270
  function createProgram() {
1428
1271
  const program = new Command();
1429
- program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.5");
1272
+ program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.6");
1273
+ program.hook('preAction', ()=>{
1274
+ commandStartTime = Date.now();
1275
+ currentCommand = process.argv[2] || 'unknown';
1276
+ });
1277
+ program.hook('postAction', async (_thisCommand, actionCommand)=>{
1278
+ const durationMs = Date.now() - commandStartTime;
1279
+ await trackCommand({
1280
+ command: currentCommand,
1281
+ success: true,
1282
+ durationMs,
1283
+ options: sanitizeCommandOptions(actionCommand.opts())
1284
+ });
1285
+ await shutdownAnalytics();
1286
+ });
1430
1287
  program.addCommand(createLoginCommand());
1431
1288
  program.addCommand(createLogoutCommand());
1432
1289
  program.addCommand(createInitCommand());
@@ -0,0 +1,25 @@
1
+ /**
2
+ * CLI Analytics - Dual tracking with PostHog (real-time) and Backend (long-term storage)
3
+ */
4
+ export interface TrackCommandOptions {
5
+ command: string;
6
+ success: boolean;
7
+ durationMs: number;
8
+ errorCode?: string;
9
+ options?: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * Sanitize command options to remove sensitive values
13
+ */
14
+ declare function sanitizeOptions(options: Record<string, unknown>): Record<string, unknown>;
15
+ /**
16
+ * Track a CLI command execution
17
+ * Sends to both PostHog (real-time dashboards) and backend (long-term storage)
18
+ */
19
+ export declare function trackCommand(opts: TrackCommandOptions): Promise<void>;
20
+ /**
21
+ * Shutdown analytics and flush any pending events
22
+ * Should be called before CLI exits
23
+ */
24
+ export declare function shutdownAnalytics(): Promise<void>;
25
+ export { sanitizeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdesign/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for SuperDesign Platform - agent skills for Claude Code",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -20,16 +20,13 @@
20
20
  "dist",
21
21
  "bin"
22
22
  ],
23
- "scripts": {
24
- "build": "rslib build && chmod +x bin/superdesign.js",
25
- "dev": "rslib build --watch"
26
- },
27
23
  "dependencies": {
28
24
  "axios": "^1.6.0",
29
25
  "commander": "^11.1.0",
30
26
  "dotenv": "^16.3.0",
31
27
  "open": "^10.0.0",
32
- "ora": "^8.0.0"
28
+ "ora": "^8.0.0",
29
+ "posthog-node": "^4.0.0"
33
30
  },
34
31
  "devDependencies": {
35
32
  "@rslib/core": "0.15.1",
@@ -51,5 +48,9 @@
51
48
  "url": "https://github.com/superdesigndev/superdesign-platform.git",
52
49
  "directory": "packages/cli"
53
50
  },
54
- "license": "MIT"
55
- }
51
+ "license": "MIT",
52
+ "scripts": {
53
+ "build": "rslib build && chmod +x bin/superdesign.js",
54
+ "dev": "rslib build --watch"
55
+ }
56
+ }