Skip to content

VS Code extension: scaffold generation with context-aware UX#230

Open
clavery wants to merge 2 commits intomainfrom
feature/vscode-scaffold
Open

VS Code extension: scaffold generation with context-aware UX#230
clavery wants to merge 2 commits intomainfrom
feature/vscode-scaffold

Conversation

@clavery
Copy link
Collaborator

@clavery clavery commented Mar 3, 2026

Summary

  • Adds "New from Scaffold..." command to the VS Code extension with three entry points: command palette, explorer context menu (right-click folder → B2C-DX submenu), and File → New File... menu
  • Multi-step Quick Pick wizard that maps scaffold parameter types (string, boolean, choice, multi-choice) to idiomatic VS Code UI with validation, source resolution, and conditional parameter visibility
  • Context-aware cartridge detection: right-clicking inside a cartridge auto-detects it, pre-fills the cartridgeName parameter, filters the scaffold list to only cartridge-targeting templates (controller, custom-api, hook, etc.), and skips the cartridge selection prompt
  • Editor context: when invoked from command palette, uses the active editor's file path to detect cartridge context
  • SDK: adds detectSourceFromPath() for generalized source detection from filesystem paths, exports cartridgePathForDestination(), and adds builtInScaffoldsDir option to createScaffoldRegistry() for bundled consumers
  • Build: copies SDK scaffold template data into extension bundle at build time (esbuild copySdkScaffolds())

Test plan

  • Right-click cartridge folder → "New from Scaffold..." → list shows only cartridge-targeting scaffolds, cartridge auto-detected, no cartridge prompt
  • Right-click a subfolder within a cartridge (e.g. rest-apis/) → same behavior (walks up to cartridge root)
  • Right-click non-cartridge folder → full scaffold list, prompts for cartridge
  • Command palette with file open in cartridge → auto-detects cartridge context
  • Command palette with no file open → prompts for everything
  • File → New File... → "New from Scaffold..." appears, opens wizard with no folder context
  • Press Escape mid-wizard → silently aborts
  • Generate into folder with existing files → skipped files reported
  • pnpm --filter @salesforce/b2c-tooling-sdk run test:agent passes
  • pnpm --filter @salesforce/b2c-cli run test:agent passes

Add "New from Scaffold..." command to the VS Code extension, accessible from
the command palette, explorer context menu, and File > New File... menu.

Features:
- Multi-step Quick Pick wizard mapping scaffold parameter types to VS Code UI
- Context-aware cartridge detection: right-clicking inside a cartridge auto-fills
  the cartridge parameter and filters the scaffold list to relevant templates
- Editor context: command palette uses the active editor's file path for detection
- Built-in scaffold data copied into extension bundle at build time

SDK changes:
- Add detectSourceFromPath() for generalized source detection from filesystem paths
- Export cartridgePathForDestination() (moved from parameter-resolver to sources)
- Add builtInScaffoldsDir option to createScaffoldRegistry() for bundled consumers
- Export ScaffoldRegistryOptions and SourceDetectionResult types
@clavery clavery requested a review from wei-liu-sf as a code owner March 3, 2026 04:25
…ce guard

- Add $(file-code) icon to scaffold command
- Auto-open first generated file; offer "Reveal in Explorer" instead of "Open File"
- Show postInstructions as user-facing info message
- Simplify boolean prompt: always Yes/No order with (default) marker
- Guard against missing workspace with early warning
- Show step progress in Quick Pick titles (e.g. "Controller (1/3)")
- Add when clause to file/newFile entry to hide without workspace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant