Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11e7dce791 | ||
|
|
eb7dabfba3 |
No files matched your search
@@ -31,11 +31,29 @@ If any are missing, ask the user or tell them to run plugin-researcher first.
|
||||
From the project root (`C:\dev\wwv\worldwideview`):
|
||||
|
||||
```bash
|
||||
node packages/wwv-cli/dist/index.js create <name> --local
|
||||
# Build the CLI first if dist/ is missing (dist is gitignored; fresh worktrees lack it):
|
||||
# pnpm --filter @worldwideview/wwv-cli build
|
||||
#
|
||||
# The CLI accepts flags for every prompt. Pass them all + --yes for a fully
|
||||
# non-interactive scaffold (omit any flag to be prompted for just that value):
|
||||
node packages/wwv-cli/dist/index.js create <name> \
|
||||
--display-name "<Display Name>" \
|
||||
--description "<short description>" \
|
||||
--category <aviation|maritime|space|weather|custom> \
|
||||
--architecture <polling|websocket> \
|
||||
--seeder-tier <community|private> \
|
||||
--render-style <billboard|model|point> \
|
||||
--yes
|
||||
pnpm install
|
||||
```
|
||||
|
||||
This creates `local-plugins/wwv-plugin-<name>/`. Verify it exists before proceeding.
|
||||
This creates `local-plugins/wwv-plugin-<name>/`. With `--architecture websocket` it also
|
||||
creates the seeder at `local-seeders/<tier>/packages/<name>/` (correct community/private
|
||||
layout: `package.json` + `tsup.config.ts` + `src/index.ts`). Verify both exist before proceeding.
|
||||
|
||||
> The CLI scaffolds the seeder into `local-seeders/<tier>/packages/<name>/` already —
|
||||
> no post-CLI move is required. (Older CLI versions dropped a bare `seeder.mjs` at
|
||||
> `local-seeders/<tier>/<name>/`; if you ever see that, the CLI is out of date — rebuild it.)
|
||||
|
||||
**NEVER:**
|
||||
- Scaffold manually (always use the CLI)
|
||||
|
||||
@@ -1,161 +1,8 @@
|
||||
param([string]$worktreePath)
|
||||
|
||||
# git-wt (Worktrunk) pre-start hook.
|
||||
# Per the per-worktree isolation model, each worktree gets its OWN real, isolated
|
||||
# .planning directory -- NEVER a junction to the shared root. A shared junction caused
|
||||
# GSD phase bleed across simultaneous worktree sessions. See worktree-bootstrap SKILL Step 5
|
||||
# and C:\dev\wwv\.planning\WORKSPACE-OPTIMIZATION-BACKLOG.md.
|
||||
#
|
||||
# This hook is idempotent:
|
||||
# - existing REAL .planning with a WORKSPACE.md -> left untouched (preserve phase history)
|
||||
# - existing REAL .planning missing manifests -> manifests seeded, contents preserved
|
||||
# - existing JUNCTION (old-model leftover) -> junction removed, real dir created
|
||||
# - nothing there -> real isolated dir created
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Convert Unix-style path (/c/dev/...) to Windows path (C:\dev\...) if needed
|
||||
if ($worktreePath -match '^/([a-zA-Z])/(.+)$') {
|
||||
$worktreePath = $matches[1].ToUpper() + ':/' + $matches[2]
|
||||
}
|
||||
|
||||
$sharedRoot = 'C:\dev\wwv\.planning'
|
||||
$target = Join-Path $worktreePath '.planning'
|
||||
|
||||
# If a junction/symlink leftover from the old model exists, remove only the reparse
|
||||
# point (never recurse into the shared root it points at).
|
||||
if (Test-Path $target) {
|
||||
$item = Get-Item -LiteralPath $target -Force
|
||||
$isReparse = ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -eq [IO.FileAttributes]::ReparsePoint
|
||||
if ($isReparse) {
|
||||
[System.IO.Directory]::Delete($target, $false)
|
||||
} elseif (Test-Path (Join-Path $target 'WORKSPACE.md')) {
|
||||
# Already a fully set-up real isolated dir -- preserve it, do nothing.
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
# Resolve the branch name (fall back to the worktree folder leaf).
|
||||
$branch = $null
|
||||
try { $branch = (& git -C $worktreePath rev-parse --abbrev-ref HEAD 2>$null) } catch {}
|
||||
if (-not $branch) { $branch = Split-Path $worktreePath -Leaf }
|
||||
$branch = $branch.Trim()
|
||||
|
||||
$date = (Get-Date).ToString('yyyy-MM-dd')
|
||||
$isoDate = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.000Z')
|
||||
|
||||
# Create the isolated structure.
|
||||
foreach ($d in @('phases', 'debug', 'surveys')) {
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $target $d) | Out-Null
|
||||
}
|
||||
|
||||
# Copy the GSD config from the shared root if present.
|
||||
$sharedConfig = Join-Path $sharedRoot 'config.json'
|
||||
$localConfig = Join-Path $target 'config.json'
|
||||
if ((Test-Path $sharedConfig) -and -not (Test-Path $localConfig)) {
|
||||
Copy-Item $sharedConfig $localConfig -Force
|
||||
}
|
||||
|
||||
# Seed the three manifest files (only if missing -- never overwrite existing).
|
||||
$workspaceFile = Join-Path $target 'WORKSPACE.md'
|
||||
if (-not (Test-Path $workspaceFile)) {
|
||||
$workspace = @"
|
||||
# Workspace: $branch
|
||||
|
||||
Created: $date
|
||||
Strategy: worktree (git-wt)
|
||||
Branch: $branch
|
||||
Repo: $worktreePath
|
||||
|
||||
## Isolation
|
||||
|
||||
This ``.planning`` is a REAL, isolated directory (not a junction to the shared root).
|
||||
Phases and STATE.md here are private to this worktree. Changes do NOT bleed into
|
||||
other worktrees or the shared root. Created automatically by the git-wt pre-start
|
||||
hook (link-planning.ps1), per the per-worktree isolation model.
|
||||
|
||||
## Member Repos
|
||||
|
||||
| Repo | Source | Branch | Strategy |
|
||||
|------|--------|--------|----------|
|
||||
| worldwideview | C:\dev\wwv\worldwideview | $branch | worktree |
|
||||
|
||||
## Notes
|
||||
|
||||
Cross-feature docs are NOT duplicated here. See SHARED-DOCS.md.
|
||||
"@
|
||||
Set-Content -LiteralPath $workspaceFile -Value $workspace -Encoding UTF8
|
||||
}
|
||||
|
||||
$stateFile = Join-Path $target 'STATE.md'
|
||||
if (-not (Test-Path $stateFile)) {
|
||||
$state = @"
|
||||
---
|
||||
gsd_state_version: 1.0
|
||||
milestone: none
|
||||
milestone_name: $branch
|
||||
status: idle
|
||||
last_updated: "$isoDate"
|
||||
last_activity: $date -- isolated .planning created (git-wt pre-start hook)
|
||||
progress:
|
||||
total_phases: 0
|
||||
completed_phases: 0
|
||||
total_plans: 0
|
||||
completed_plans: 0
|
||||
percent: 0
|
||||
---
|
||||
|
||||
# Project State
|
||||
|
||||
## Project Reference
|
||||
|
||||
This is an ISOLATED worktree workspace. Its planning state is private to the
|
||||
``$branch`` worktree and intentionally distinct from the shared root
|
||||
(C:\dev\wwv\.planning).
|
||||
|
||||
Cross-feature docs (ROADMAP, MILESTONES, research) are NOT duplicated here.
|
||||
See SHARED-DOCS.md for how to reach them.
|
||||
|
||||
## Current Position
|
||||
|
||||
No active milestone. Workspace is idle.
|
||||
"@
|
||||
Set-Content -LiteralPath $stateFile -Value $state -Encoding UTF8
|
||||
}
|
||||
|
||||
$sharedDocsFile = Join-Path $target 'SHARED-DOCS.md'
|
||||
if (-not (Test-Path $sharedDocsFile)) {
|
||||
$sharedDocs = @"
|
||||
# Shared Cross-Feature Docs
|
||||
|
||||
This worktree's ``.planning`` is isolated (phases + STATE are private). But some
|
||||
documents are cross-feature and must stay authoritative in ONE place rather than
|
||||
being copied per worktree (copies drift out of sync).
|
||||
|
||||
## Where they live
|
||||
|
||||
Shared root: ``C:\dev\wwv\.planning``
|
||||
|
||||
| Doc | Purpose |
|
||||
|-----|---------|
|
||||
| ROADMAP.md | Cross-milestone roadmap |
|
||||
| MILESTONES.md | Milestone definitions and ship status |
|
||||
| research/ | ARCHITECTURE / FEATURES / PITFALLS / STACK |
|
||||
| PROJECT.md | Project identity |
|
||||
| REQUIREMENTS.md | Cross-cutting requirements |
|
||||
|
||||
## How to reach them
|
||||
|
||||
A ``WWV_SHARED_PLANNING`` env var in each worktree's ``.env.local`` points at the
|
||||
shared root, and GSD skills that need a cross-feature doc read
|
||||
``\$WWV_SHARED_PLANNING/<doc>`` instead of the local ``.planning/<doc>``.
|
||||
|
||||
Do NOT copy these docs into this worktree. Single source of truth lives at the
|
||||
shared root.
|
||||
"@
|
||||
Set-Content -LiteralPath $sharedDocsFile -Value $sharedDocs -Encoding UTF8
|
||||
}
|
||||
|
||||
# Always report success: the internal git probe above may set a non-zero $LASTEXITCODE,
|
||||
# which would otherwise be propagated as this hook's exit code and read as a failure.
|
||||
exit 0
|
||||
if (Test-Path $target) { Remove-Item $target -Force }
|
||||
New-Item -ItemType Junction -Path $target -Target 'C:\dev\wwv\.planning' | Out-Null
|
||||
@@ -1,29 +1,7 @@
|
||||
param([string]$worktreePath)
|
||||
|
||||
# git-wt (Worktrunk) pre-remove hook.
|
||||
# Per the per-worktree isolation model, a worktree's .planning is a REAL isolated
|
||||
# directory (its phase history is archived by /branch-cleanup before removal, and the
|
||||
# directory itself is deleted along with the worktree by `git-wt remove`).
|
||||
#
|
||||
# This hook therefore ONLY cleans up a leftover JUNCTION from the old shared-link model.
|
||||
# It must NEVER recursively delete a real .planning directory -- doing so would destroy
|
||||
# phase history that /branch-cleanup is responsible for archiving.
|
||||
|
||||
# Convert Unix-style path (/c/dev/...) to Windows path (C:\dev\...) if needed
|
||||
if ($worktreePath -match '^/([a-zA-Z])/(.+)$') {
|
||||
$worktreePath = $matches[1].ToUpper() + ':/' + $matches[2]
|
||||
}
|
||||
$target = Join-Path $worktreePath '.planning'
|
||||
|
||||
if (Test-Path $target) {
|
||||
$item = Get-Item -LiteralPath $target -Force
|
||||
$isReparse = ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -eq [IO.FileAttributes]::ReparsePoint
|
||||
if ($isReparse) {
|
||||
# Old-model junction: remove only the reparse point (do not follow into the target).
|
||||
[System.IO.Directory]::Delete($target, $false)
|
||||
}
|
||||
# Real directory: leave it. git-wt remove deletes the worktree (and this dir) anyway;
|
||||
# /branch-cleanup is responsible for archiving its phase history first.
|
||||
}
|
||||
|
||||
exit 0
|
||||
if (Test-Path $target) { Remove-Item $target -Force }
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
name: plugin-new
|
||||
description: End-to-end pipeline that takes a WorldWideView plugin from idea to npm-published and cleaned up. Conducts an isolated worktree + scaffold, GSD research/plan/build/UAT, dual-repo PRs (plugin + seeder), npm publish, and teardown, with user gates only at plan approval, UAT sign-off, npm publish, and teardown. Use when the user says "/plugin-new", "new plugin", "build a plugin end to end", "ship a plugin", or "run the plugin pipeline".
|
||||
---
|
||||
|
||||
# Plugin Pipeline (`/plugin-new`)
|
||||
|
||||
A **conductor** skill: it runs the staged pipeline in the main conversation and **delegates** the real work to existing agents and GSD. It does not reimplement research, planning, execution, or worktree mechanics; it sequences them and enforces the gates.
|
||||
|
||||
## Principles
|
||||
|
||||
- **Don't reinvent GSD.** Research, spec, plan, execute, verify, and UAT are GSD phases (running in the plugin's own isolated `.planning`). The pipeline adds only the plugin-specific bookends: isolated-worktree scaffolding at the front, and dual-repo PR + npm publish + teardown at the back.
|
||||
- **Compose existing agents.** Reuse `plugin-researcher`, `plugin-implementer`, `worktree-manager`, `branch-finisher`, `branch-cleanup`. Never write logic these already provide.
|
||||
- **Gate only the irreversible.** Autonomous within a stage; stop for the user only at the 4 gates below.
|
||||
- **One isolated worktree per plugin**, with a project-per-plugin GSD project in its own real `.planning` (per the per-worktree isolation model). This keeps each plugin's planning private and teardown clean.
|
||||
- **Stop on red.** A failed stage halts the pipeline with a clear report. Never continue past a failed gate. Resume with `/gsd:resume-work`.
|
||||
|
||||
## Gates (the only stops)
|
||||
|
||||
| Stage | Gate | Why |
|
||||
|---|---|---|
|
||||
| 2 | Plan approval | Don't build the wrong thing |
|
||||
| 4 | UAT sign-off | Human judges the live result |
|
||||
| 6 | npm publish | Public, irreversible |
|
||||
| 7 | Teardown | Destroys worktree + Docker volume |
|
||||
|
||||
---
|
||||
|
||||
## Stage 0: Kickoff
|
||||
|
||||
1. Read the plugin name from the invocation (kebab-case). If missing, ask for it.
|
||||
2. Validate: name is kebab-case and not already present in `local-plugins/` or on npm. If taken, stop and ask.
|
||||
3. Capture the one-line idea (ask if not given).
|
||||
|
||||
## Stage 1: Isolated worktree + scaffold
|
||||
|
||||
1. Delegate worktree creation to the **worktree-manager** agent: a sibling worktree `feat/plugin-<name>` based off `origin/main`. (Delegating keeps the verbose git-wt/hook output out of the main session.)
|
||||
2. Bootstrap it with the **worktree-bootstrap** skill, ensuring its `.planning` is a REAL isolated directory (Step 5 of that skill), NOT a junction. If git-wt's `link_planning` hook left a junction, convert it to a real dir before proceeding (see worktree-bootstrap Step 5).
|
||||
3. Scaffold the plugin skeleton (`WorldPlugin` entry + seeder stub + `package.json`) using the **worldwideview-plugin-creation** skill / **plugin-implementer** agent.
|
||||
4. **Label Docker resources** for this plugin so teardown is exact: when the seeder/data-engine containers and volumes are created for this plugin, tag them with `wwv-plugin=<name>` (compose label or naming convention `wwv-<name>-*`). Record the labels in the worktree's `.planning/WORKSPACE.md`.
|
||||
5. Verify the scaffold builds clean. If it errors, STOP and report (do not limp forward).
|
||||
- **Gate:** none.
|
||||
|
||||
## Stage 2: Idea -> research -> plan (GSD, project-per-plugin)
|
||||
|
||||
1. In the worktree, run `/gsd:new-project` scoped to this plugin (its own GSD project in the isolated `.planning`).
|
||||
2. Run the **plugin-researcher** agent: find the data API, rate limits, auth, endpoints, update cadence; produce an implementation-ready research brief.
|
||||
3. Run GSD `discuss-phase` then `plan-phase` to produce the phase plan, weaving in the research.
|
||||
- **Gate: user approves the plan** (GSD plan-review). Do not proceed without it.
|
||||
|
||||
## Stage 3: Autonomous build + e2e test (handoff)
|
||||
|
||||
1. Run GSD `execute-phase`, which drives the **plugin-implementer** agent to build per the approved plan.
|
||||
2. Test end to end: `pnpm dev` (frontend), Docker (data engine + Redis + seeder), and Playwright (**playwright-testing** skill) for on-globe rendering.
|
||||
3. Loop on failures via GSD (`tdd-loop` / `code-review` / `autofix`) until green. No user intervention in this stage.
|
||||
- **Gate:** none (autonomous until all issues are fixed).
|
||||
|
||||
## Stage 4: UAT (servers already up)
|
||||
|
||||
1. Spin up the relevant servers (frontend + data engine + seeder) and run GSD `audit-uat`.
|
||||
2. Present the plugin live on the globe and ask the user to try it.
|
||||
- **Gate: user UAT sign-off.** If the user reports issues, loop back to Stage 3 (standard GSD fix cycle), then re-run UAT.
|
||||
|
||||
## Stage 5: Ship (dual PRs, independent versions)
|
||||
|
||||
1. The plugin (`local-plugins/`) and seeder (`local-seeders/`) are independent git repos with their own remotes. Bump each repo's semver **independently** (only bump the side that changed) and open a PR for each via the **branch-finisher** agent, once per repo.
|
||||
2. Wait for BOTH PRs' CI to pass. If either fails, STOP and report (do not publish a half-shipped pair).
|
||||
- **Gate:** none to open; the pipeline waits for both green.
|
||||
|
||||
## Stage 6: npm publish (user-confirmed)
|
||||
|
||||
1. After both PRs succeed, ASK the user whether to publish the plugin to npm.
|
||||
2. On confirm, publish with bundled assets for CDN distribution (reuse the existing publish workflow / the market-tracker v1.0.x package.json bundling config + `syncToPublic`).
|
||||
- **Gate: user confirms publish.** Never publish without it.
|
||||
|
||||
## Stage 7: Teardown (user-confirmed)
|
||||
|
||||
1. ASK the user if they are ready to clean up.
|
||||
2. On confirm, run **`/branch-cleanup`** (it archives the worktree's isolated `.planning` to the shared archive, then removes the worktree via worktree-manager).
|
||||
3. Tear down this plugin's Docker resources using the `wwv-plugin=<name>` labels from Stage 1 (containers + volumes). Verify nothing for this plugin remains.
|
||||
- **Gate: user confirms teardown.**
|
||||
|
||||
---
|
||||
|
||||
## State, resume, and failure handling
|
||||
|
||||
- State lives in the worktree's isolated `.planning` (GSD STATE.md + phases). After any interruption, resume with `/gsd:resume-work` without re-paying for completed stages.
|
||||
- A failed stage stops the pipeline with a clear report. The user fixes and resumes; nothing continues silently past a red gate.
|
||||
- Dual-PR coordination (Stage 5): if one PR's CI fails, report and pause; do not publish (Stage 6) until both are green.
|
||||
|
||||
## Reused components (must exist)
|
||||
|
||||
`worktree-manager`, `worktree-bootstrap`, `worldwideview-plugin-creation`, `plugin-researcher`, `plugin-implementer`, `branch-finisher`, `branch-cleanup`, GSD phase skills (`new-project`, `discuss-phase`, `plan-phase`, `execute-phase`, `tdd-loop`, `audit-uat`, `resume-work`), `playwright-testing`, and the npm publish workflow.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-cli",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0",
|
||||
"type": "module",
|
||||
"description": "WorldWideView CLI",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@@ -4,29 +4,74 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import prompts from 'prompts';
|
||||
|
||||
const VALID_CATEGORIES = ['aviation', 'maritime', 'space', 'weather', 'custom'];
|
||||
const VALID_ARCHITECTURES = ['polling', 'websocket'];
|
||||
const VALID_SEEDER_TIERS = ['community', 'private'];
|
||||
const VALID_RENDER_STYLES = ['billboard', 'model', 'point'];
|
||||
|
||||
interface CreateOptions {
|
||||
core?: boolean;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
category?: string;
|
||||
architecture?: string;
|
||||
seederTier?: string;
|
||||
renderStyle?: string;
|
||||
yes?: boolean;
|
||||
}
|
||||
|
||||
function assertChoice(label: string, value: string | undefined, valid: string[]): void {
|
||||
if (value !== undefined && !valid.includes(value)) {
|
||||
console.error(`Error: invalid --${label} "${value}". Valid values: ${valid.join(', ')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
export const createCommand = new Command('create')
|
||||
.description('Interactively scaffold a new WorldWideView plugin')
|
||||
.description('Scaffold a new WorldWideView plugin (flags skip the matching prompt; omit them for interactive mode)')
|
||||
.argument('[pluginId]', 'Unique kebab-case plugin ID (e.g. my-tracker)')
|
||||
.option('-c, --core', 'Create inside packages instead of local-plugins (for core contributors)')
|
||||
.action(async (options) => {
|
||||
const response = await prompts([
|
||||
{
|
||||
.option('-n, --display-name <name>', 'Display name (e.g. "My Live Tracker")')
|
||||
.option('-d, --description <text>', 'Short description')
|
||||
.option('--category <category>', `One of: ${VALID_CATEGORIES.join(', ')}`)
|
||||
.option('--architecture <architecture>', `One of: ${VALID_ARCHITECTURES.join(', ')}`)
|
||||
.option('--seeder-tier <tier>', `One of: ${VALID_SEEDER_TIERS.join(', ')} (websocket only)`)
|
||||
.option('--render-style <style>', `One of: ${VALID_RENDER_STYLES.join(', ')}`)
|
||||
.option('-y, --yes', 'Non-interactive: fail instead of prompting for missing values')
|
||||
.action(async (pluginIdArg: string | undefined, options: CreateOptions) => {
|
||||
// Validate any flags supplied up front so we fail fast and consistently.
|
||||
assertChoice('category', options.category, VALID_CATEGORIES);
|
||||
assertChoice('architecture', options.architecture, VALID_ARCHITECTURES);
|
||||
assertChoice('seeder-tier', options.seederTier, VALID_SEEDER_TIERS);
|
||||
assertChoice('render-style', options.renderStyle, VALID_RENDER_STYLES);
|
||||
|
||||
// Build the prompt list, skipping any value already supplied via flag/arg.
|
||||
// In --yes mode we never prompt; missing required values are an error.
|
||||
const promptList: prompts.PromptObject[] = [];
|
||||
|
||||
if (!pluginIdArg) {
|
||||
promptList.push({
|
||||
type: 'text',
|
||||
name: 'pluginId',
|
||||
message: 'What is the unique ID for your plugin? (e.g. my-tracker)',
|
||||
validate: value => value.length > 0 ? true : 'Plugin ID is required'
|
||||
},
|
||||
{
|
||||
validate: value => value.length > 0 ? true : 'Plugin ID is required',
|
||||
});
|
||||
}
|
||||
if (options.displayName === undefined) {
|
||||
promptList.push({
|
||||
type: 'text',
|
||||
name: 'displayName',
|
||||
message: 'What is the display name? (e.g. My Live Tracker)',
|
||||
initial: (prev: string) => prev.replace(/-/g, ' ').replace(/\b\w/g, (l: string) => l.toUpperCase())
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'description',
|
||||
message: 'Enter a short description:'
|
||||
},
|
||||
{
|
||||
initial: pluginIdArg
|
||||
? pluginIdArg.replace(/-/g, ' ').replace(/\b\w/g, (l: string) => l.toUpperCase())
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
if (options.description === undefined) {
|
||||
promptList.push({ type: 'text', name: 'description', message: 'Enter a short description:' });
|
||||
}
|
||||
if (options.category === undefined) {
|
||||
promptList.push({
|
||||
type: 'select',
|
||||
name: 'category',
|
||||
message: 'Which category does this plugin belong to?',
|
||||
@@ -35,46 +80,71 @@ export const createCommand = new Command('create')
|
||||
{ title: 'Maritime (Ship icon)', value: 'maritime' },
|
||||
{ title: 'Space (Satellite icon)', value: 'space' },
|
||||
{ title: 'Weather (Cloud icon)', value: 'weather' },
|
||||
{ title: 'Custom (Box icon)', value: 'custom' }
|
||||
]
|
||||
},
|
||||
{
|
||||
{ title: 'Custom (Box icon)', value: 'custom' },
|
||||
],
|
||||
});
|
||||
}
|
||||
if (options.architecture === undefined) {
|
||||
promptList.push({
|
||||
type: 'select',
|
||||
name: 'architecture',
|
||||
message: 'How will your plugin receive data?',
|
||||
choices: [
|
||||
{ title: 'REST Polling / Static Data (Frontend only)', value: 'polling' },
|
||||
{ title: 'Real-Time WebSockets (Generates backend seeder)', value: 'websocket' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: (prev: string) => prev === 'websocket' ? 'select' : null,
|
||||
{ title: 'Real-Time WebSockets (Generates backend seeder)', value: 'websocket' },
|
||||
],
|
||||
});
|
||||
}
|
||||
if (options.seederTier === undefined) {
|
||||
promptList.push({
|
||||
// Only ask about seeder tier when architecture resolves to websocket.
|
||||
type: (_prev, values) => {
|
||||
const arch = options.architecture ?? values.architecture;
|
||||
return arch === 'websocket' ? 'select' : null;
|
||||
},
|
||||
name: 'seederTier',
|
||||
message: 'Which tier should your backend seeder belong to?',
|
||||
choices: [
|
||||
{ title: 'Community (Open data, shared)', value: 'community' },
|
||||
{ title: 'Private (Requires API keys, restricted)', value: 'private' }
|
||||
]
|
||||
},
|
||||
{
|
||||
{ title: 'Private (Requires API keys, restricted)', value: 'private' },
|
||||
],
|
||||
});
|
||||
}
|
||||
if (options.renderStyle === undefined) {
|
||||
promptList.push({
|
||||
type: 'select',
|
||||
name: 'renderStyle',
|
||||
message: 'How should entities be rendered on the 3D globe?',
|
||||
choices: [
|
||||
{ title: '2D Billboard (Great for static icons)', value: 'billboard' },
|
||||
{ title: '3D Model with LOD (Transitions 2D to 3D)', value: 'model' },
|
||||
{ title: 'Simple Point (High performance dots)', value: 'point' }
|
||||
]
|
||||
}
|
||||
]);
|
||||
{ title: 'Simple Point (High performance dots)', value: 'point' },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
if (!response.pluginId) {
|
||||
if (options.yes && promptList.length > 0) {
|
||||
const missing = promptList.map(p => p.name).join(', ');
|
||||
console.error(`Error: --yes given but these required values are missing: ${missing}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const answers = promptList.length > 0 ? await prompts(promptList) : {};
|
||||
|
||||
// Merge flags/args (authoritative) over interactive answers.
|
||||
const pluginId: string | undefined = pluginIdArg ?? answers.pluginId;
|
||||
const displayName: string = options.displayName ?? answers.displayName ?? '';
|
||||
const description: string = options.description ?? answers.description ?? '';
|
||||
const category: string = options.category ?? answers.category;
|
||||
const architecture: string = options.architecture ?? answers.architecture;
|
||||
const seederTier: string | undefined = options.seederTier ?? answers.seederTier;
|
||||
const renderStyle: string = options.renderStyle ?? answers.renderStyle;
|
||||
|
||||
if (!pluginId) {
|
||||
console.log('Plugin creation cancelled.');
|
||||
return;
|
||||
}
|
||||
|
||||
const { pluginId, displayName, description, category, architecture, seederTier, renderStyle } = response;
|
||||
|
||||
const targetBaseDir = options.core ? 'packages' : 'local-plugins';
|
||||
const pluginDir = path.join(process.cwd(), targetBaseDir, `wwv-plugin-${pluginId}`);
|
||||
|
||||
@@ -85,21 +155,19 @@ export const createCommand = new Command('create')
|
||||
|
||||
fs.mkdirSync(pluginDir, { recursive: true });
|
||||
|
||||
// Determine category icon
|
||||
const iconMap: Record<string, string> = {
|
||||
aviation: 'Plane',
|
||||
maritime: 'Ship',
|
||||
space: 'Satellite',
|
||||
weather: 'Cloud',
|
||||
custom: 'Box'
|
||||
custom: 'Box',
|
||||
};
|
||||
const defaultIcon = iconMap[category] || 'Box';
|
||||
|
||||
// Package.json boilerplate
|
||||
const streamUrlField = architecture === 'websocket'
|
||||
? `\n "streamUrl": "wss://dataenginev2.worldwideview.dev/stream",`
|
||||
const streamUrlField = architecture === 'websocket'
|
||||
? `\n "streamUrl": "wss://dataenginev2.worldwideview.dev/stream",`
|
||||
: '';
|
||||
|
||||
|
||||
const packageJsonContent = `{
|
||||
"name": "@worldwideview/wwv-plugin-${pluginId}",
|
||||
"version": "1.0.0",
|
||||
@@ -131,7 +199,6 @@ export const createCommand = new Command('create')
|
||||
}
|
||||
`;
|
||||
|
||||
// index.ts boilerplate
|
||||
const renderBoilerplate = {
|
||||
billboard: `return {
|
||||
type: 'billboard',
|
||||
@@ -152,14 +219,14 @@ export const createCommand = new Command('create')
|
||||
size: 8,
|
||||
outlineColor: '#ffffff',
|
||||
outlineWidth: 2
|
||||
};`
|
||||
};`,
|
||||
}[renderStyle as string] || `return {};`;
|
||||
|
||||
const fetchBoilerplate = architecture === 'polling'
|
||||
const fetchBoilerplate = architecture === 'polling'
|
||||
? `\n async fetch(): Promise<GeoEntity[]> {
|
||||
// Implement REST polling logic here
|
||||
return [];
|
||||
}\n`
|
||||
}\n`
|
||||
: '';
|
||||
|
||||
const indexTsContent = `import { WorldPlugin, GeoEntity, CesiumEntityOptions } from '@worldwideview/wwv-plugin-sdk';
|
||||
@@ -195,41 +262,75 @@ ${fetchBoilerplate}
|
||||
|
||||
console.log(`\n✅ Successfully created plugin frontend at ${pluginDir}`);
|
||||
|
||||
// Generate seeder backend if requested
|
||||
// Generate seeder backend if requested. Matches the real community/private
|
||||
// seeder layout: local-seeders/<tier>/packages/<pluginId>/ with a tsup build
|
||||
// and a src/index.ts that exports the canonical { name, cron, fn } shape.
|
||||
if (architecture === 'websocket' && seederTier) {
|
||||
const seederDir = path.join(process.cwd(), 'local-seeders', seederTier, pluginId);
|
||||
|
||||
if (!fs.existsSync(seederDir)) {
|
||||
fs.mkdirSync(seederDir, { recursive: true });
|
||||
|
||||
const seederContent = `// WWV Data Engine Seeder for ${pluginId}
|
||||
export default async function run(context) {
|
||||
console.log('Starting ${displayName} seeder...');
|
||||
|
||||
// Example: Emit a mock entity to the engine
|
||||
setInterval(() => {
|
||||
context.emit({
|
||||
id: '${pluginId}-mock-1',
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
alt: 10000,
|
||||
heading: 0,
|
||||
velocity: 250,
|
||||
properties: {
|
||||
status: 'active'
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
const seederDir = path.join(process.cwd(), 'local-seeders', seederTier, 'packages', pluginId);
|
||||
|
||||
if (fs.existsSync(seederDir)) {
|
||||
console.error(`Warning: Seeder directory ${seederDir} already exists. Skipping seeder scaffold.`);
|
||||
} else {
|
||||
fs.mkdirSync(path.join(seederDir, 'src'), { recursive: true });
|
||||
|
||||
const seederPackageJson = `{
|
||||
"name": "@wwv-seeders/${pluginId}",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/index.mjs",
|
||||
"scripts": {
|
||||
"build": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"@worldwideview/seeder-sdk": "^1.0.0"
|
||||
}
|
||||
}
|
||||
`;
|
||||
fs.writeFileSync(path.join(seederDir, 'seeder.mjs'), seederContent);
|
||||
|
||||
const tsupConfig = `import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts'],
|
||||
format: ['esm'],
|
||||
clean: true,
|
||||
shims: true,
|
||||
noExternal: [/@wwv-seeders\\/.*/],
|
||||
external: [/^(?!@wwv-seeders)[a-z@].*/],
|
||||
});
|
||||
`;
|
||||
|
||||
// The seeder's exported `name` MUST equal the frontend plugin id
|
||||
// (kebab-case). See ADR-0002 / data-engine-architecture.md section 6.
|
||||
const seederIndexTs = `import { setLiveSnapshot, fetchWithTimeout, withRetry } from '@worldwideview/seeder-sdk';
|
||||
|
||||
async function seed${pluginId.replace(/-/g, '')}() {
|
||||
// TODO: fetch from the real data source and map into GeoEntity-shaped items.
|
||||
const items: Array<{ id: string; lat: number; lon: number; name: string }> = [];
|
||||
|
||||
await setLiveSnapshot('${pluginId}', {
|
||||
source: '${pluginId}',
|
||||
fetchedAt: new Date().toISOString(),
|
||||
items,
|
||||
totalCount: items.length,
|
||||
}, 3600);
|
||||
}
|
||||
|
||||
export default {
|
||||
name: '${pluginId}', // MUST match the frontend plugin id exactly (kebab-case)
|
||||
cron: '*/15 * * * *',
|
||||
fn: seed${pluginId.replace(/-/g, '')},
|
||||
};
|
||||
`;
|
||||
|
||||
fs.writeFileSync(path.join(seederDir, 'package.json'), seederPackageJson);
|
||||
fs.writeFileSync(path.join(seederDir, 'tsup.config.ts'), tsupConfig);
|
||||
fs.writeFileSync(path.join(seederDir, 'src', 'index.ts'), seederIndexTs);
|
||||
console.log(`✅ Successfully created plugin seeder at ${seederDir}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nNext steps:
|
||||
1. Run \`pnpm install\` from the project root.
|
||||
2. Edit \`index.ts\` in your plugin directory.
|
||||
${architecture === 'websocket' ? '3. Edit `seeder.mjs` in your local-seeders directory.' : ''}
|
||||
2. Edit \`src/index.ts\` in your plugin directory.
|
||||
${architecture === 'websocket' && seederTier ? `3. Edit \`src/index.ts\` in local-seeders/${seederTier}/packages/${pluginId}/, then \`pnpm build\` it.` : ''}
|
||||
`);
|
||||
});
|
||||
@@ -9,7 +9,7 @@ const program = new Command();
|
||||
program
|
||||
.name('wwv')
|
||||
.description('WorldWideView Plugin CLI')
|
||||
.version('1.1.2');
|
||||
.version('1.3.0');
|
||||
|
||||
program.addCommand(createCommand);
|
||||
program.addCommand(publishCommand);
|
||||
|
||||
Reference in new issue
Block a user