create-vibemancer 0.1.4 → 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/README.md +6 -6
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@ npm run dev
|
|
|
13
13
|
|
|
14
14
|
Creates a project with:
|
|
15
15
|
|
|
16
|
-
- `src/bot.ts
|
|
17
|
-
- `tests/bot.test.ts
|
|
18
|
-
- `AGENTS.md
|
|
19
|
-
- `README.md
|
|
20
|
-
- `vibemancer.json
|
|
16
|
+
- `src/bot.ts`: starter wizard bot
|
|
17
|
+
- `tests/bot.test.ts`: vitest suite
|
|
18
|
+
- `AGENTS.md`: context file for AI coding assistants (Claude Code, Cursor, Copilot CLI, Codex)
|
|
19
|
+
- `README.md`: full development workflow guide
|
|
20
|
+
- `vibemancer.json`: CLI config
|
|
21
21
|
|
|
22
|
-
Prefer pnpm, yarn, or bun? They all work
|
|
22
|
+
Prefer pnpm, yarn, or bun? They all work: swap `npm` for your favourite.
|
|
23
23
|
|
|
24
24
|
## What's next
|
|
25
25
|
|
package/dist/index.js
CHANGED
|
@@ -31,10 +31,11 @@ function packageJson(projectName) {
|
|
|
31
31
|
test: "vibemancer test",
|
|
32
32
|
typecheck: "tsc --noEmit",
|
|
33
33
|
fight: "vibemancer fight",
|
|
34
|
-
trace: "vibemancer trace
|
|
34
|
+
trace: "vibemancer trace",
|
|
35
35
|
optimize: "vibemancer optimize",
|
|
36
36
|
upload: "vibemancer upload",
|
|
37
37
|
pull: "vibemancer pull",
|
|
38
|
+
feedback: "vibemancer feedback",
|
|
38
39
|
build: "vibemancer build --opponent Battlemage"
|
|
39
40
|
},
|
|
40
41
|
dependencies: {
|
|
@@ -74,13 +75,15 @@ function botTemplate(botName) {
|
|
|
74
75
|
return `import {
|
|
75
76
|
usePosition, useEnemy, useTicksUntilReady, useThreats,
|
|
76
77
|
missile, shield, move,
|
|
78
|
+
getMissileContext, turnToward, flyStraight,
|
|
77
79
|
// More actions (all importable from '@vibemancer/core'):
|
|
78
|
-
// blink, cancel, idle,
|
|
80
|
+
// blink, cancel, idle, turnToAngle,
|
|
79
81
|
// More hooks:
|
|
80
82
|
// useHealth, useBlinkCooldown, useStatus, useVelocity,
|
|
81
83
|
// useCastProgress, useMyProjectiles, useMyThreatsToEnemy,
|
|
82
84
|
// useClosestThreat, useShieldStrength, useCastingSpell,
|
|
83
85
|
// useTick, useArenaSize, useDamageDealt, useDamageTaken,
|
|
86
|
+
// useRandom,
|
|
84
87
|
// Utility functions:
|
|
85
88
|
// distanceTo, angleTo, directionTo, directionAway,
|
|
86
89
|
// getLeadPosition, fitMissileToBudget, getMissileCastTime,
|
|
@@ -117,7 +120,7 @@ function botTemplate(botName) {
|
|
|
117
120
|
* - speed: units/tick (min 1.5, player moves at 1). Range = speed x duration.
|
|
118
121
|
* - duration: ticks the missile lives (min 10). Longer = more range but slower cast.
|
|
119
122
|
* - turnRate: degrees/tick of homing (0 = straight, 3 = moderate, 5+ = strong).
|
|
120
|
-
* ai: called every tick to steer
|
|
123
|
+
* ai: hooks-style function called every tick to steer. Use getMissileContext() to read state, return turnToward(x,y), turnToAngle(deg), or flyStraight().
|
|
121
124
|
* direction: launch angle in degrees (0=right, 90=down, 180=left, 270=up).
|
|
122
125
|
* Cast time scales with all stats. Repeated similar missiles cast 20% faster (warmup).
|
|
123
126
|
* Chain .move(dx, dy) to walk at 50% speed while casting.
|
|
@@ -127,7 +130,7 @@ function botTemplate(botName) {
|
|
|
127
130
|
* 0.2s cast time. Immobile while channeling. Cancel with cancel().
|
|
128
131
|
*
|
|
129
132
|
* blink(x, y) \u2014 Teleport to ABSOLUTE position (not direction). Max 300 units.
|
|
130
|
-
* move(dx, dy) \u2014 Move in DIRECTION (not position).
|
|
133
|
+
* move(dx, dy) \u2014 Move in DIRECTION (not position). Speed clamped to [-1, 1].
|
|
131
134
|
* cancel() \u2014 Cancel current cast/channel. Chain .move() to dodge simultaneously.
|
|
132
135
|
* idle() \u2014 Do nothing this tick.
|
|
133
136
|
*
|
|
@@ -169,13 +172,14 @@ export function ${botName}()
|
|
|
169
172
|
// Chain .move() to walk toward enemy at 50% speed while casting
|
|
170
173
|
return missile(
|
|
171
174
|
{damage: 15, speed: 6, duration: Math.max(60, Math.ceil(dist / 6) + 20), turnRate: 3},
|
|
172
|
-
(
|
|
175
|
+
() =>
|
|
173
176
|
{
|
|
174
|
-
// Missile AI: called every tick to steer the missile
|
|
175
|
-
//
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
return
|
|
177
|
+
// Missile AI: hooks-style function called every tick to steer the missile
|
|
178
|
+
// Use getMissileContext() to read state, return turnToward/flyStraight
|
|
179
|
+
const ctx = getMissileContext();
|
|
180
|
+
const target = ctx.worldState.enemies[0];
|
|
181
|
+
if (!target) return flyStraight();
|
|
182
|
+
return turnToward(target.position.x, target.position.y);
|
|
179
183
|
},
|
|
180
184
|
angle, // Launch angle in degrees toward enemy
|
|
181
185
|
).move(dx, dy);
|
|
@@ -358,6 +362,9 @@ per second). It returns an action object \u2014 typically built by helpers:
|
|
|
358
362
|
- **Spells (only one per cast):**
|
|
359
363
|
- \`missile({damage, speed, duration, turnRate}, ai, angle)\` \u2014 fire a
|
|
360
364
|
projectile. Range = speed \xD7 duration. Higher damage = longer cast time.
|
|
365
|
+
The \`ai\` is a hooks-style function \`() => MissileAction\` \u2014 use
|
|
366
|
+
\`getMissileContext()\` to read state, return \`turnToward(x, y)\`,
|
|
367
|
+
\`turnToAngle(degrees)\`, or \`flyStraight()\`.
|
|
361
368
|
- \`shield()\` \u2014 channel a shield. Strongest at start (90% block),
|
|
362
369
|
decays. Cancel early to free up GCD.
|
|
363
370
|
- \`blink(x, y)\` \u2014 teleport to **absolute position** (NOT a direction).
|
|
@@ -368,6 +375,8 @@ per second). It returns an action object \u2014 typically built by helpers:
|
|
|
368
375
|
- \`useThreats()\` \u2014 incoming missiles you might want to dodge/shield.
|
|
369
376
|
- \`useTicksUntilReady()\` \u2014 GCD remaining. Cast attempts during GCD are
|
|
370
377
|
silently ignored \u2014 gate on this.
|
|
378
|
+
- \`useRandom()\` \u2014 seeded PRNG (\`() => number\`). Deterministic. Use
|
|
379
|
+
instead of \`Math.random()\` (blocked in sandbox).
|
|
371
380
|
- \`useParam(name, default, {min, max, step})\` \u2014 declare a tunable; the
|
|
372
381
|
optimizer's coordinate-descent will sweep it.
|
|
373
382
|
|
|
@@ -383,8 +392,8 @@ the monorepo, or jump-to-definition from any \`@vibemancer/core\` import.
|
|
|
383
392
|
- Returning nothing freezes the bot for that tick. Always return at least
|
|
384
393
|
\`move(0, 0)\`.
|
|
385
394
|
- The bot runs in a sandboxed Web Worker / isolated-vm \u2014 no \`fetch\`,
|
|
386
|
-
no DOM, no \`Math.random()\` (use
|
|
387
|
-
|
|
395
|
+
no DOM, no \`Math.random()\` (use \`useRandom()\` for a seeded,
|
|
396
|
+
deterministic PRNG).
|
|
388
397
|
|
|
389
398
|
## Don't
|
|
390
399
|
|
|
@@ -445,7 +454,7 @@ Usage:
|
|
|
445
454
|
npx create-vibemancer <project-name> [--name <BotName>]
|
|
446
455
|
|
|
447
456
|
Options:
|
|
448
|
-
--name <name> Bot
|
|
457
|
+
--name <name> Bot function name (also the leaderboard name; default: derived from project name)
|
|
449
458
|
|
|
450
459
|
Examples:
|
|
451
460
|
npx create-vibemancer my-wizard
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/scaffolder.ts"],"sourcesContent":["/**\r\n * create-vibemancer\r\n *\r\n * Scaffolds a new Vibemancer wizard bot project.\r\n *\r\n * Usage:\r\n * npx create-vibemancer my-wizard\r\n * npx create-vibemancer my-wizard --name MyWizard\r\n */\r\n\r\nimport fs from 'node:fs';\r\nimport path from 'node:path';\r\nimport {\r\n\ttoPascalCase,\r\n\tisValidIdentifier,\r\n\tisValidProjectName,\r\n\tscaffoldProject,\r\n} from './scaffolder.js';\r\n\r\nconst args = process.argv.slice(2);\r\n\r\nfunction printHelp(): void\r\n{\r\n\tconsole.log(`\r\ncreate-vibemancer - Create a new Vibemancer wizard bot project\r\n\r\nUsage:\r\n npx create-vibemancer <project-name> [--name <BotName>]\r\n\r\nOptions:\r\n --name <name> Bot export name (default: derived from project name)\r\n\r\nExamples:\r\n npx create-vibemancer my-wizard\r\n npx create-vibemancer fire-mage --name FireMage\r\n`);\r\n}\r\n\r\nfunction parseArgs(): {projectName: string; botName: string}\r\n{\r\n\tconst projectName = args.find((a) => !a.startsWith('-'));\r\n\tif (!projectName)\r\n\t{\r\n\t\tprintHelp();\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tif (!isValidProjectName(projectName))\r\n\t{\r\n\t\tconsole.error(`Error: \"${projectName}\" is not a valid project name.`);\r\n\t\tconsole.error('Project names must start and end with alphanumeric characters');\r\n\t\tconsole.error('and may contain letters, digits, dots, hyphens, and underscores.');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconst nameIdx = args.indexOf('--name');\r\n\tif (nameIdx !== -1 && !args[nameIdx + 1])\r\n\t{\r\n\t\tconsole.error('Error: --name requires a value.');\r\n\t\tconsole.error('Example: npx create-vibemancer my-bot --name MyBot');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconst botName = nameIdx !== -1 && args[nameIdx + 1]\r\n\t\t? args[nameIdx + 1]\r\n\t\t: toPascalCase(projectName);\r\n\r\n\tif (!isValidIdentifier(botName))\r\n\t{\r\n\t\tconsole.error(`Error: \"${botName}\" is not a valid JavaScript identifier.`);\r\n\t\tconsole.error('Bot names must start with a letter, underscore, or $');\r\n\t\tconsole.error('and contain only letters, digits, underscores, and $.');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\treturn {projectName, botName};\r\n}\r\n\r\nfunction main(): void\r\n{\r\n\tconst {projectName, botName} = parseArgs();\r\n\tconst projectDir = path.resolve(projectName);\r\n\r\n\tif (fs.existsSync(projectDir))\r\n\t{\r\n\t\tconsole.error(`Error: Directory \"${projectName}\" already exists.`);\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconsole.log(`\\nCreating Vibemancer project: ${projectName}`);\r\n\tconsole.log(`Bot name: ${botName}\\n`);\r\n\r\n\ttry\r\n\t{\r\n\t\tscaffoldProject(projectDir, projectName, botName);\r\n\r\n\t\tconst files = ['package.json', 'tsconfig.json', 'vibemancer.json', 'src/bot.ts', 'tests/bot.test.ts', 'README.md', '.gitignore'];\r\n\t\tfor (const filePath of files)\r\n\t\t{\r\n\t\t\tconsole.log(` Created ${filePath}`);\r\n\t\t}\r\n\t}\r\n\tcatch(err)\r\n\t{\r\n\t\tconsole.error(`\\nError creating project: ${err instanceof Error ? err.message : String(err)}`);\r\n\t\ttry\r\n\t\t{\r\n\t\t\tfs.rmSync(projectDir, {recursive: true, force: true});\r\n\t\t}\r\n\t\tcatch\r\n\t\t{\r\n\t\t\t// Best-effort cleanup\r\n\t\t}\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconsole.log(`\r\nDone! To get started:\r\n\r\n cd ${projectName}\r\n npm install\r\n npm test (verify everything works)\r\n npm run dev (start dev server + open browser)\r\n\r\nOther commands:\r\n npm run fight Fight against all 29 built-in bots\r\n npm run trace Per-tick debug trace (see exactly what your bot does)\r\n npm run optimize Auto-tune bot parameters\r\n\r\nEdit src/bot.ts to change your bot. Refresh the browser to see changes.\r\n`);\r\n}\r\n\r\nmain();\r\n","/**\r\n * Scaffolder - Core logic for creating a Vibemancer project.\r\n *\r\n * Pure functions for validation, naming, and template generation.\r\n * Separated from index.ts for testability.\r\n */\r\n\r\nimport fs from 'node:fs';\r\nimport path from 'node:path';\r\n\r\nexport function toPascalCase(str: string): string\r\n{\r\n\tlet result = str\r\n\t\t.replace(/[-_]+/g, ' ')\r\n\t\t.replace(/\\b\\w/g, (c) => c.toUpperCase())\r\n\t\t.replace(/\\s+/g, '');\r\n\r\n\t// Ensure starts with a letter (prepend underscore if starts with digit)\r\n\tif (/^\\d/.test(result))\r\n\t{\r\n\t\tresult = '_' + result;\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Validate that a string is a valid JavaScript identifier.\r\n */\r\nexport function isValidIdentifier(name: string): boolean\r\n{\r\n\treturn /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);\r\n}\r\n\r\n/**\r\n * Validate that a project name is safe for use as a directory name.\r\n */\r\nexport function isValidProjectName(name: string): boolean\r\n{\r\n\treturn /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/.test(name);\r\n}\r\n\r\nexport function packageJson(projectName: string): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tname: projectName,\r\n\t\tversion: '0.1.0',\r\n\t\tprivate: true,\r\n\t\ttype: 'module',\r\n\t\tscripts: {\r\n\t\t\tdev: 'vibemancer dev',\r\n\t\t\ttest: 'vibemancer test',\r\n\t\t\ttypecheck: 'tsc --noEmit',\r\n\t\t\tfight: 'vibemancer fight',\r\n\t\t\ttrace: 'vibemancer trace --opponent TargetDummy',\r\n\t\t\toptimize: 'vibemancer optimize',\r\n\t\t\tupload: 'vibemancer upload',\r\n\t\t\tpull: 'vibemancer pull',\r\n\t\t\tbuild: 'vibemancer build --opponent Battlemage',\r\n\t\t},\r\n\t\tdependencies: {\r\n\t\t\t'@vibemancer/core': '~0.1.0',\r\n\t\t},\r\n\t\tdevDependencies: {\r\n\t\t\t'vibemancer': '~0.1.0',\r\n\t\t\t'typescript': '^5.9.0',\r\n\t\t\t'vitest': '^3.0.0',\r\n\t\t},\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function tsconfigJson(): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tcompilerOptions: {\r\n\t\t\ttarget: 'ESNext',\r\n\t\t\tmodule: 'ESNext',\r\n\t\t\tlib: ['ESNext'],\r\n\t\t\tskipLibCheck: true,\r\n\t\t\tmoduleResolution: 'Bundler',\r\n\t\t\tstrict: true,\r\n\t\t\tnoUnusedLocals: true,\r\n\t\t\tnoUnusedParameters: true,\r\n\t\t\tisolatedModules: true,\r\n\t\t\tnoEmit: true,\r\n\t\t},\r\n\t\tinclude: ['src', 'tests'],\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function vibemancerJson(botName: string): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tbot: 'src/bot.ts',\r\n\t\texport: botName,\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function botTemplate(botName: string): string\r\n{\r\n\treturn `import {\r\n\tusePosition, useEnemy, useTicksUntilReady, useThreats,\r\n\tmissile, shield, move,\r\n\t// More actions (all importable from '@vibemancer/core'):\r\n\t// blink, cancel, idle,\r\n\t// More hooks:\r\n\t// useHealth, useBlinkCooldown, useStatus, useVelocity,\r\n\t// useCastProgress, useMyProjectiles, useMyThreatsToEnemy,\r\n\t// useClosestThreat, useShieldStrength, useCastingSpell,\r\n\t// useTick, useArenaSize, useDamageDealt, useDamageTaken,\r\n\t// Utility functions:\r\n\t// distanceTo, angleTo, directionTo, directionAway,\r\n\t// getLeadPosition, fitMissileToBudget, getMissileCastTime,\r\n\t// predictPosition, interceptAngle, clampPositionToArena,\r\n\t// Persistence hooks (React-style, state preserved across ticks):\r\n\t// useState, useRef, useMemo, useEffect\r\n\t// Parameter tuning (for optimizer):\r\n\t// useParam\r\n} from '@vibemancer/core';\r\n\r\n/**\r\n * ${botName} - Your custom wizard bot!\r\n *\r\n * === HOW IT WORKS ===\r\n * Your function is called EVERY TICK (100x per second). Each call you:\r\n * 1. Read game state using hooks (usePosition, useEnemy, etc.)\r\n * 2. Return ONE action (missile, shield, blink, move, cancel, or idle)\r\n *\r\n * The function must ALWAYS return an action. During cooldowns (GCD), return\r\n * move() to keep moving — casting spells during GCD is silently ignored.\r\n * Check useTicksUntilReady() > 0 to know when you're on cooldown.\r\n *\r\n * === GAME RULES ===\r\n * Arena: 800x800, positions clamped to [5, 795]\r\n * Health: 60 HP, wizard dies at 0\r\n * Timing: 100 ticks = 1 second, match lasts 30,000 ticks (5 min)\r\n * Movement: 1 unit/tick (100 u/s), 50% speed while casting, 0% while shielding\r\n * GCD: 100 ticks (1s) lockout after any spell completes or is canceled\r\n *\r\n * === SPELLS ===\r\n * missile(config, ai, direction)\r\n * config: { damage, speed, duration, turnRate }\r\n * - damage: HP removed on hit (1-60). Hitbox radius = 2 + 0.1 x damage.\r\n * - speed: units/tick (min 1.5, player moves at 1). Range = speed x duration.\r\n * - duration: ticks the missile lives (min 10). Longer = more range but slower cast.\r\n * - turnRate: degrees/tick of homing (0 = straight, 3 = moderate, 5+ = strong).\r\n * ai: called every tick to steer -> return { turnToward: {x,y} } or {} for straight.\r\n * direction: launch angle in degrees (0=right, 90=down, 180=left, 270=up).\r\n * Cast time scales with all stats. Repeated similar missiles cast 20% faster (warmup).\r\n * Chain .move(dx, dy) to walk at 50% speed while casting.\r\n *\r\n * shield()\r\n * Channeled. Blocks 90% initially, decays 20%/sec, minimum 30%.\r\n * 0.2s cast time. Immobile while channeling. Cancel with cancel().\r\n *\r\n * blink(x, y) — Teleport to ABSOLUTE position (not direction). Max 300 units.\r\n * move(dx, dy) — Move in DIRECTION (not position). Auto-normalized to max speed.\r\n * cancel() — Cancel current cast/channel. Chain .move() to dodge simultaneously.\r\n * idle() — Do nothing this tick.\r\n *\r\n * === KEY TYPES ===\r\n * useEnemy() returns: { position: {x, y}, velocity: {x, y}, health, state, ... }\r\n * useThreats() returns array of:\r\n * { ticksToImpact, damage, position, velocity, canDodge, bestDodgeDirection, ... }\r\n * fitMissileToBudget(budget, opts) — finds optimal missile config for a cast-time budget\r\n * getLeadPosition(pos, vel, time) — predicts where a moving target will be\r\n *\r\n * All imports have full JSDoc — hover or jump-to-definition to see docs.\r\n */\r\nexport function ${botName}()\r\n{\r\n\tconst myPos = usePosition();\r\n\tconst enemy = useEnemy();\r\n\tconst ready = useTicksUntilReady();\r\n\tconst threats = useThreats();\r\n\r\n\t// Direction toward enemy (used for movement and aiming)\r\n\tconst dx = enemy.position.x - myPos.x;\r\n\tconst dy = enemy.position.y - myPos.y;\r\n\tconst dist = Math.sqrt(dx * dx + dy * dy);\r\n\tconst angle = Math.atan2(dy, dx) * (180 / Math.PI);\r\n\r\n\t// While on cooldown, move toward the enemy\r\n\t// move() takes a direction vector, not an absolute position\r\n\tif (ready > 0) return move(dx, dy);\r\n\r\n\t// Shield if a missile is about to hit (within 30 ticks = 0.3s)\r\n\tconst closestThreat = threats[0];\r\n\tif (closestThreat && closestThreat.ticksToImpact < 30)\r\n\t{\r\n\t\treturn shield();\r\n\t}\r\n\r\n\t// Fire a homing missile at the enemy\r\n\t// Duration scales with distance so missiles always have enough range\r\n\t// Chain .move() to walk toward enemy at 50% speed while casting\r\n\treturn missile(\r\n\t\t{damage: 15, speed: 6, duration: Math.max(60, Math.ceil(dist / 6) + 20), turnRate: 3},\r\n\t\t({worldState}) =>\r\n\t\t{\r\n\t\t\t// Missile AI: called every tick to steer the missile\r\n\t\t\t// Return { turnToward: position } to home, or {} to fly straight\r\n\t\t\tconst target = worldState.enemies[0];\r\n\t\t\tif (!target) return {};\r\n\t\t\treturn {turnToward: target.position};\r\n\t\t},\r\n\t\tangle, // Launch angle in degrees toward enemy\r\n\t).move(dx, dy);\r\n}\r\n`;\r\n}\r\n\r\nexport function readmeMd(botName: string): string\r\n{\r\n\treturn `# ${botName} — Vibemancer Bot\r\n\r\nThis is a Vibemancer wizard bot project. The bot fights 1v1 against other wizard bots in an 800x800 arena.\r\n\r\n## Quick Start\r\n\r\n\\`\\`\\`bash\r\nnpm test # Verify everything works\r\nnpm run dev # Start dev server + open browser (refresh to see changes)\r\nnpm run fight # Fight against all 29 built-in bots\r\nnpm run trace # Per-tick debug trace against TargetDummy\r\nnpm run typecheck # Check for type errors (catches bugs esbuild misses)\r\nnpm run optimize # Auto-tune useParam() values via optimizer\r\nnpm run upload # Upload to vibemancer.com for rated competition\r\nnpm run pull # Download latest source from server (after MCP edits)\r\n\\`\\`\\`\r\n\r\nTo trace/fight a specific opponent:\r\n\\`\\`\\`bash\r\nnpx vibemancer trace --opponent Battlemage\r\nnpx vibemancer fight --opponent Nightblade\r\nnpx vibemancer bots # list all bots with descriptions\r\nnpx vibemancer bots Battlemage # details about a specific bot\r\n\\`\\`\\`\r\n\r\n## Project Structure\r\n\r\n- \\`src/bot.ts\\` — Bot source code (edit this!)\r\n- \\`tests/bot.test.ts\\` — Automated tests for your bot\r\n- \\`vibemancer.json\\` — Config: \\`{ \"bot\": \"src/bot.ts\", \"export\": \"${botName}\" }\\`\r\n\r\n## Development Workflow\r\n\r\n1. Edit \\`src/bot.ts\\`\r\n2. Run \\`npm run typecheck\\` to catch type errors early\r\n3. Run \\`npm test\\` to check your bot doesn't crash and beats weak bots\r\n4. Run \\`npm run fight\\` to see how you rank against all 29 built-in bots\r\n5. Run \\`npm run trace\\` to see per-tick events when something isn't working\r\n6. Run \\`npm run optimize\\` to auto-tune useParam() values\r\n\r\nFor the browser viewer: run \\`npm run dev\\`, then refresh the browser after editing your bot.\r\n\r\n## Difficulty Progression\r\n\r\nStart by beating the weakest bots and work your way up:\r\n\r\n| Milestone | Bots to Beat | What You Need |\r\n|-----------|-------------|---------------|\r\n| Beginner | TargetDummy, Critter | Basic missile firing |\r\n| Easy | Rookie, Hogger, Bonemancer | Homing missiles + movement |\r\n| Medium | Turtle, Sentinel, Flamecaller | Shielding + dodge awareness |\r\n| Hard | Battlemage (#11), Stormchaser | Cast timing + positioning |\r\n| Expert | Archmage, Stormforger | Adaptive missiles + vulnerability punish |\r\n| Master | Nightblade (#29) | Everything at once |\r\n\r\n## Debugging\r\n\r\nWhen your bot isn't working:\r\n1. \\`npm test\\` — check for runtime errors (captured in test results)\r\n2. \\`vibemancer trace --opponent TargetDummy\\` — watch exactly what happens tick by tick\r\n3. Look at the trace stats: hit rate, shield usage, idle time\r\n4. Look for ERROR and WARNING events in the trace output\r\n\r\n## Common Pitfalls\r\n\r\n- \\`move(dx, dy)\\` is a **direction vector**, NOT a target position\r\n- \\`blink(x, y)\\` is an **absolute position**, NOT a direction\r\n- Calling \\`missile()\\` during GCD is **silently ignored** — check \\`useTicksUntilReady()\\` first\r\n- Missile range = speed x duration. If range < distance, missiles expire before reaching the enemy\r\n- All angles are in **degrees** (not radians). Use: \\`Math.atan2(dy, dx) * (180 / Math.PI)\\`\r\n- All time values are in **ticks** (100 ticks = 1 second)\r\n- Your bot runs every tick — always return an action, even during cooldowns (\\`move()\\`)\r\n- \\`fitMissileToBudget()\\` and \\`getLeadPosition()\\` return **null** when no solution exists\r\n\r\n## Built-in Bots (29 total, ranked weakest -> strongest)\r\n\r\nTargetDummy, Critter, Bonemancer, Hogger, Rookie, Turtle, Sentinel, Flamecaller,\r\nGolem, Stormchaser, Battlemage, Spellspinner, Doombringer, Lich, Stormcaller,\r\nSpellbinder, Shadowblade, Pyromancer, Warmage, Spelltracer, Archmage, Spellseeker,\r\nStormforger, Spellweaver, Spellshot, Voidblade, Infernalist, Archlich, Nightblade\r\n\r\nRun \\`vibemancer bots\\` to see descriptions, or \\`vibemancer bots Battlemage\\` for details.\r\n\r\n## Strategy Tips\r\n\r\n- Shield is strongest at the start (90% block) — cancel early to minimize GCD waste\r\n- Repeated similar missiles cast 20% faster (warmup). Switching styles costs 20%\r\n- Higher damage = longer cast time, but DPS always increases with damage\r\n- Homing missiles (turnRate > 0) are harder to dodge but cost more cast time\r\n- Straight missiles (turnRate: 0) are fast to cast. Use \\`getLeadPosition()\\` to aim\r\n- Use \\`useThreats()\\` to decide: dodge (best), shield (good), or eat the hit (risky)\r\n`;\r\n}\r\n\r\nexport function botTestTemplate(botName: string): string\r\n{\r\n\treturn `import {expect, test} from 'vitest';\r\nimport {testBot} from '@vibemancer/core';\r\nimport {${botName}} from '../src/bot';\r\n\r\n// Run with: npm test\r\n// These tests are ordered by difficulty — fix them top to bottom.\r\n\r\ntest('no runtime errors', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('TargetDummy');\r\n\texpect(result.errors).toHaveLength(0);\r\n});\r\n\r\ntest('beats TargetDummy', () =>\r\n{\r\n\tconst result = testBot(${botName}).fight('TargetDummy');\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('beats Critter', () =>\r\n{\r\n\tconst result = testBot(${botName}).fight('Critter');\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('kills TargetDummy within 15 seconds', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('TargetDummy', {maxTicks: 1500});\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('lands at least 40% of missiles', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('Rookie', {maxTicks: 3000});\r\n\tif (result.stats.missilesLaunched > 0)\r\n\t{\r\n\t\texpect(result.stats.hitRate).toBeGreaterThan(0.4);\r\n\t}\r\n});\r\n`;\r\n}\r\n\r\nexport function agentsMd(botName: string): string\r\n{\r\n\treturn `# AGENTS.md — context for AI assistants\r\n\r\nThis is a [Vibemancer](https://vibemancer.com) wizard-bot project. The goal\r\nis to write a TypeScript bot that wins 1v1 fights against other wizards in\r\nan 800x800 arena.\r\n\r\n## Layout\r\n\r\n- \\`src/bot.ts\\` — the bot. Edit this. Export must be a single PascalCase\r\n function (currently \\`${botName}\\`).\r\n- \\`tests/bot.test.ts\\` — vitest suite. Add cases as you discover edge\r\n cases the bot should handle.\r\n- \\`vibemancer.json\\` — \\`{ \"bot\": \"src/bot.ts\", \"export\": \"${botName}\" }\\`.\r\n Don't move the bot without updating this.\r\n- \\`README.md\\` — a more thorough developer guide. Skim it once.\r\n\r\n## How to verify a change\r\n\r\n\\`\\`\\`bash\r\nnpm test # vitest — fast, runs every change\r\nnpm run typecheck # catches typos esbuild would silently bundle\r\nnpm run fight # round-robin against all 29 built-ins\r\nnpx vibemancer trace --opponent <Bot> # per-tick debug trace\r\n\\`\\`\\`\r\n\r\nTreat \\`npm test\\` as the smallest verifying step. Run it before claiming a\r\nchange is done.\r\n\r\n## The bot API\r\n\r\nImported from \\`@vibemancer/core\\`. The bot is called every tick (100 ticks\r\nper second). It returns an action object — typically built by helpers:\r\n\r\n- **Movement:** \\`move(dx, dy)\\` — direction vector (NOT a target). Always\r\n return *something* even on cooldown — bare \\`move(0, 0)\\` if you have\r\n nothing else to do.\r\n- **Spells (only one per cast):**\r\n - \\`missile({damage, speed, duration, turnRate}, ai, angle)\\` — fire a\r\n projectile. Range = speed × duration. Higher damage = longer cast time.\r\n - \\`shield()\\` — channel a shield. Strongest at start (90% block),\r\n decays. Cancel early to free up GCD.\r\n - \\`blink(x, y)\\` — teleport to **absolute position** (NOT a direction).\r\n Range cap is 300; further targets are clamped along the line.\r\n- **Hooks** (read state):\r\n - \\`usePosition()\\` — your current \\`{x, y}\\`.\r\n - \\`useEnemy()\\` — opponent's last-known state.\r\n - \\`useThreats()\\` — incoming missiles you might want to dodge/shield.\r\n - \\`useTicksUntilReady()\\` — GCD remaining. Cast attempts during GCD are\r\n silently ignored — gate on this.\r\n - \\`useParam(name, default, {min, max, step})\\` — declare a tunable; the\r\n optimizer's coordinate-descent will sweep it.\r\n\r\nRead the full surface: \\`packages/core/src/index-browser.ts\\` if you have\r\nthe monorepo, or jump-to-definition from any \\`@vibemancer/core\\` import.\r\n\r\n## Common pitfalls\r\n\r\n- All angles are in **degrees**, not radians. Use \\`Math.atan2(dy, dx) * (180 / Math.PI)\\`.\r\n- All time values are in **ticks**, not seconds. 100 ticks = 1 second.\r\n- \\`getLeadPosition()\\` and \\`fitMissileToBudget()\\` return **null** when no\r\n solution exists — handle that, don't assume non-null.\r\n- Returning nothing freezes the bot for that tick. Always return at least\r\n \\`move(0, 0)\\`.\r\n- The bot runs in a sandboxed Web Worker / isolated-vm — no \\`fetch\\`,\r\n no DOM, no \\`Math.random()\\` (use the seeded RNG passed via hooks if you\r\n need randomness).\r\n\r\n## Don't\r\n\r\n- Don't add new top-level files outside \\`src/\\` and \\`tests/\\` without a\r\n reason — the dev server scans \\`src/\\` for bots.\r\n- Don't add npm dependencies that pull in Node-only modules. Bots are\r\n bundled for browser/sandbox execution.\r\n- Don't mutate globals or the prototype chain — the sandbox freezes them\r\n and crashes will be silent.\r\n\r\n## Publishing\r\n\r\nOnce \\`npm run fight\\` shows acceptable wins:\r\n\r\n\\`\\`\\`bash\r\nnpx vibemancer upload\r\n\\`\\`\\`\r\n\r\nThis signs in (Google), compiles, and ships the bundle to vibemancer.com.\r\nThe matchmaker auto-pairs your wizard against other active uploads. Watch\r\nthe leaderboard / your wizard's match history for results, find a\r\nweakness, edit, re-upload.\r\n`;\r\n}\r\n\r\nexport function gitignore(): string\r\n{\r\n\treturn `node_modules/\r\ndist/\r\n.vibemancer/\r\n*.tgz\r\n`;\r\n}\r\n\r\n/**\r\n * Scaffold a new project directory with all template files.\r\n */\r\nexport function scaffoldProject(projectDir: string, projectName: string, botName: string): void\r\n{\r\n\tconst files: [string, string][] = [\r\n\t\t['package.json', packageJson(projectName)],\r\n\t\t['tsconfig.json', tsconfigJson()],\r\n\t\t['vibemancer.json', vibemancerJson(botName)],\r\n\t\t['src/bot.ts', botTemplate(botName)],\r\n\t\t['tests/bot.test.ts', botTestTemplate(botName)],\r\n\t\t['README.md', readmeMd(botName)],\r\n\t\t['AGENTS.md', agentsMd(botName)],\r\n\t\t['.gitignore', gitignore()],\r\n\t];\r\n\r\n\tfs.mkdirSync(path.join(projectDir, 'src'), {recursive: true});\r\n\tfs.mkdirSync(path.join(projectDir, 'tests'), {recursive: true});\r\n\r\n\tfor (const [filePath, content] of files)\r\n\t{\r\n\t\tconst fullPath = path.join(projectDir, filePath);\r\n\t\tfs.writeFileSync(fullPath, content);\r\n\t}\r\n}\r\n"],"mappings":";;;AAUA,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACJjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,aAAa,KAC7B;AACC,MAAI,SAAS,IACX,QAAQ,UAAU,GAAG,EACrB,QAAQ,SAAS,CAAC,MA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3,"sources":["../src/index.ts","../src/scaffolder.ts"],"sourcesContent":["/**\r\n * create-vibemancer\r\n *\r\n * Scaffolds a new Vibemancer wizard bot project.\r\n *\r\n * Usage:\r\n * npx create-vibemancer my-wizard\r\n * npx create-vibemancer my-wizard --name MyWizard\r\n */\r\n\r\nimport fs from 'node:fs';\r\nimport path from 'node:path';\r\nimport {\r\n\ttoPascalCase,\r\n\tisValidIdentifier,\r\n\tisValidProjectName,\r\n\tscaffoldProject,\r\n} from './scaffolder.js';\r\n\r\nconst args = process.argv.slice(2);\r\n\r\nfunction printHelp(): void\r\n{\r\n\tconsole.log(`\r\ncreate-vibemancer - Create a new Vibemancer wizard bot project\r\n\r\nUsage:\r\n npx create-vibemancer <project-name> [--name <BotName>]\r\n\r\nOptions:\r\n --name <name> Bot function name (also the leaderboard name; default: derived from project name)\r\n\r\nExamples:\r\n npx create-vibemancer my-wizard\r\n npx create-vibemancer fire-mage --name FireMage\r\n`);\r\n}\r\n\r\nfunction parseArgs(): {projectName: string; botName: string}\r\n{\r\n\tconst projectName = args.find((a) => !a.startsWith('-'));\r\n\tif (!projectName)\r\n\t{\r\n\t\tprintHelp();\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tif (!isValidProjectName(projectName))\r\n\t{\r\n\t\tconsole.error(`Error: \"${projectName}\" is not a valid project name.`);\r\n\t\tconsole.error('Project names must start and end with alphanumeric characters');\r\n\t\tconsole.error('and may contain letters, digits, dots, hyphens, and underscores.');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconst nameIdx = args.indexOf('--name');\r\n\tif (nameIdx !== -1 && !args[nameIdx + 1])\r\n\t{\r\n\t\tconsole.error('Error: --name requires a value.');\r\n\t\tconsole.error('Example: npx create-vibemancer my-bot --name MyBot');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconst botName = nameIdx !== -1 && args[nameIdx + 1]\r\n\t\t? args[nameIdx + 1]\r\n\t\t: toPascalCase(projectName);\r\n\r\n\tif (!isValidIdentifier(botName))\r\n\t{\r\n\t\tconsole.error(`Error: \"${botName}\" is not a valid JavaScript identifier.`);\r\n\t\tconsole.error('Bot names must start with a letter, underscore, or $');\r\n\t\tconsole.error('and contain only letters, digits, underscores, and $.');\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\treturn {projectName, botName};\r\n}\r\n\r\nfunction main(): void\r\n{\r\n\tconst {projectName, botName} = parseArgs();\r\n\tconst projectDir = path.resolve(projectName);\r\n\r\n\tif (fs.existsSync(projectDir))\r\n\t{\r\n\t\tconsole.error(`Error: Directory \"${projectName}\" already exists.`);\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconsole.log(`\\nCreating Vibemancer project: ${projectName}`);\r\n\tconsole.log(`Bot name: ${botName}\\n`);\r\n\r\n\ttry\r\n\t{\r\n\t\tscaffoldProject(projectDir, projectName, botName);\r\n\r\n\t\tconst files = ['package.json', 'tsconfig.json', 'vibemancer.json', 'src/bot.ts', 'tests/bot.test.ts', 'README.md', '.gitignore'];\r\n\t\tfor (const filePath of files)\r\n\t\t{\r\n\t\t\tconsole.log(` Created ${filePath}`);\r\n\t\t}\r\n\t}\r\n\tcatch(err)\r\n\t{\r\n\t\tconsole.error(`\\nError creating project: ${err instanceof Error ? err.message : String(err)}`);\r\n\t\ttry\r\n\t\t{\r\n\t\t\tfs.rmSync(projectDir, {recursive: true, force: true});\r\n\t\t}\r\n\t\tcatch\r\n\t\t{\r\n\t\t\t// Best-effort cleanup\r\n\t\t}\r\n\t\tprocess.exit(1);\r\n\t}\r\n\r\n\tconsole.log(`\r\nDone! To get started:\r\n\r\n cd ${projectName}\r\n npm install\r\n npm test (verify everything works)\r\n npm run dev (start dev server + open browser)\r\n\r\nOther commands:\r\n npm run fight Fight against all 29 built-in bots\r\n npm run trace Per-tick debug trace (see exactly what your bot does)\r\n npm run optimize Auto-tune bot parameters\r\n\r\nEdit src/bot.ts to change your bot. Refresh the browser to see changes.\r\n`);\r\n}\r\n\r\nmain();\r\n","/**\r\n * Scaffolder - Core logic for creating a Vibemancer project.\r\n *\r\n * Pure functions for validation, naming, and template generation.\r\n * Separated from index.ts for testability.\r\n */\r\n\r\nimport fs from 'node:fs';\r\nimport path from 'node:path';\r\n\r\nexport function toPascalCase(str: string): string\r\n{\r\n\tlet result = str\r\n\t\t.replace(/[-_]+/g, ' ')\r\n\t\t.replace(/\\b\\w/g, (c) => c.toUpperCase())\r\n\t\t.replace(/\\s+/g, '');\r\n\r\n\t// Ensure starts with a letter (prepend underscore if starts with digit)\r\n\tif (/^\\d/.test(result))\r\n\t{\r\n\t\tresult = '_' + result;\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n/**\r\n * Validate that a string is a valid JavaScript identifier.\r\n */\r\nexport function isValidIdentifier(name: string): boolean\r\n{\r\n\treturn /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);\r\n}\r\n\r\n/**\r\n * Validate that a project name is safe for use as a directory name.\r\n */\r\nexport function isValidProjectName(name: string): boolean\r\n{\r\n\treturn /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/.test(name);\r\n}\r\n\r\nexport function packageJson(projectName: string): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tname: projectName,\r\n\t\tversion: '0.1.0',\r\n\t\tprivate: true,\r\n\t\ttype: 'module',\r\n\t\tscripts: {\r\n\t\t\tdev: 'vibemancer dev',\r\n\t\t\ttest: 'vibemancer test',\r\n\t\t\ttypecheck: 'tsc --noEmit',\r\n\t\t\tfight: 'vibemancer fight',\r\n\t\t\ttrace: 'vibemancer trace',\r\n\t\t\toptimize: 'vibemancer optimize',\r\n\t\t\tupload: 'vibemancer upload',\r\n\t\t\tpull: 'vibemancer pull',\r\n\t\t\tfeedback: 'vibemancer feedback',\r\n\t\t\tbuild: 'vibemancer build --opponent Battlemage',\r\n\t\t},\r\n\t\tdependencies: {\r\n\t\t\t'@vibemancer/core': '~0.1.0',\r\n\t\t},\r\n\t\tdevDependencies: {\r\n\t\t\t'vibemancer': '~0.1.0',\r\n\t\t\t'typescript': '^5.9.0',\r\n\t\t\t'vitest': '^3.0.0',\r\n\t\t},\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function tsconfigJson(): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tcompilerOptions: {\r\n\t\t\ttarget: 'ESNext',\r\n\t\t\tmodule: 'ESNext',\r\n\t\t\tlib: ['ESNext'],\r\n\t\t\tskipLibCheck: true,\r\n\t\t\tmoduleResolution: 'Bundler',\r\n\t\t\tstrict: true,\r\n\t\t\tnoUnusedLocals: true,\r\n\t\t\tnoUnusedParameters: true,\r\n\t\t\tisolatedModules: true,\r\n\t\t\tnoEmit: true,\r\n\t\t},\r\n\t\tinclude: ['src', 'tests'],\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function vibemancerJson(botName: string): string\r\n{\r\n\treturn JSON.stringify({\r\n\t\tbot: 'src/bot.ts',\r\n\t\texport: botName,\r\n\t}, null, '\\t') + '\\n';\r\n}\r\n\r\nexport function botTemplate(botName: string): string\r\n{\r\n\treturn `import {\r\n\tusePosition, useEnemy, useTicksUntilReady, useThreats,\r\n\tmissile, shield, move,\r\n\tgetMissileContext, turnToward, flyStraight,\r\n\t// More actions (all importable from '@vibemancer/core'):\r\n\t// blink, cancel, idle, turnToAngle,\r\n\t// More hooks:\r\n\t// useHealth, useBlinkCooldown, useStatus, useVelocity,\r\n\t// useCastProgress, useMyProjectiles, useMyThreatsToEnemy,\r\n\t// useClosestThreat, useShieldStrength, useCastingSpell,\r\n\t// useTick, useArenaSize, useDamageDealt, useDamageTaken,\r\n\t// useRandom,\r\n\t// Utility functions:\r\n\t// distanceTo, angleTo, directionTo, directionAway,\r\n\t// getLeadPosition, fitMissileToBudget, getMissileCastTime,\r\n\t// predictPosition, interceptAngle, clampPositionToArena,\r\n\t// Persistence hooks (React-style, state preserved across ticks):\r\n\t// useState, useRef, useMemo, useEffect\r\n\t// Parameter tuning (for optimizer):\r\n\t// useParam\r\n} from '@vibemancer/core';\r\n\r\n/**\r\n * ${botName} - Your custom wizard bot!\r\n *\r\n * === HOW IT WORKS ===\r\n * Your function is called EVERY TICK (100x per second). Each call you:\r\n * 1. Read game state using hooks (usePosition, useEnemy, etc.)\r\n * 2. Return ONE action (missile, shield, blink, move, cancel, or idle)\r\n *\r\n * The function must ALWAYS return an action. During cooldowns (GCD), return\r\n * move() to keep moving — casting spells during GCD is silently ignored.\r\n * Check useTicksUntilReady() > 0 to know when you're on cooldown.\r\n *\r\n * === GAME RULES ===\r\n * Arena: 800x800, positions clamped to [5, 795]\r\n * Health: 60 HP, wizard dies at 0\r\n * Timing: 100 ticks = 1 second, match lasts 30,000 ticks (5 min)\r\n * Movement: 1 unit/tick (100 u/s), 50% speed while casting, 0% while shielding\r\n * GCD: 100 ticks (1s) lockout after any spell completes or is canceled\r\n *\r\n * === SPELLS ===\r\n * missile(config, ai, direction)\r\n * config: { damage, speed, duration, turnRate }\r\n * - damage: HP removed on hit (1-60). Hitbox radius = 2 + 0.1 x damage.\r\n * - speed: units/tick (min 1.5, player moves at 1). Range = speed x duration.\r\n * - duration: ticks the missile lives (min 10). Longer = more range but slower cast.\r\n * - turnRate: degrees/tick of homing (0 = straight, 3 = moderate, 5+ = strong).\r\n * ai: hooks-style function called every tick to steer. Use getMissileContext() to read state, return turnToward(x,y), turnToAngle(deg), or flyStraight().\r\n * direction: launch angle in degrees (0=right, 90=down, 180=left, 270=up).\r\n * Cast time scales with all stats. Repeated similar missiles cast 20% faster (warmup).\r\n * Chain .move(dx, dy) to walk at 50% speed while casting.\r\n *\r\n * shield()\r\n * Channeled. Blocks 90% initially, decays 20%/sec, minimum 30%.\r\n * 0.2s cast time. Immobile while channeling. Cancel with cancel().\r\n *\r\n * blink(x, y) — Teleport to ABSOLUTE position (not direction). Max 300 units.\r\n * move(dx, dy) — Move in DIRECTION (not position). Speed clamped to [-1, 1].\r\n * cancel() — Cancel current cast/channel. Chain .move() to dodge simultaneously.\r\n * idle() — Do nothing this tick.\r\n *\r\n * === KEY TYPES ===\r\n * useEnemy() returns: { position: {x, y}, velocity: {x, y}, health, state, ... }\r\n * useThreats() returns array of:\r\n * { ticksToImpact, damage, position, velocity, canDodge, bestDodgeDirection, ... }\r\n * fitMissileToBudget(budget, opts) — finds optimal missile config for a cast-time budget\r\n * getLeadPosition(pos, vel, time) — predicts where a moving target will be\r\n *\r\n * All imports have full JSDoc — hover or jump-to-definition to see docs.\r\n */\r\nexport function ${botName}()\r\n{\r\n\tconst myPos = usePosition();\r\n\tconst enemy = useEnemy();\r\n\tconst ready = useTicksUntilReady();\r\n\tconst threats = useThreats();\r\n\r\n\t// Direction toward enemy (used for movement and aiming)\r\n\tconst dx = enemy.position.x - myPos.x;\r\n\tconst dy = enemy.position.y - myPos.y;\r\n\tconst dist = Math.sqrt(dx * dx + dy * dy);\r\n\tconst angle = Math.atan2(dy, dx) * (180 / Math.PI);\r\n\r\n\t// While on cooldown, move toward the enemy\r\n\t// move() takes a direction vector, not an absolute position\r\n\tif (ready > 0) return move(dx, dy);\r\n\r\n\t// Shield if a missile is about to hit (within 30 ticks = 0.3s)\r\n\tconst closestThreat = threats[0];\r\n\tif (closestThreat && closestThreat.ticksToImpact < 30)\r\n\t{\r\n\t\treturn shield();\r\n\t}\r\n\r\n\t// Fire a homing missile at the enemy\r\n\t// Duration scales with distance so missiles always have enough range\r\n\t// Chain .move() to walk toward enemy at 50% speed while casting\r\n\treturn missile(\r\n\t\t{damage: 15, speed: 6, duration: Math.max(60, Math.ceil(dist / 6) + 20), turnRate: 3},\r\n\t\t() =>\r\n\t\t{\r\n\t\t\t// Missile AI: hooks-style function called every tick to steer the missile\r\n\t\t\t// Use getMissileContext() to read state, return turnToward/flyStraight\r\n\t\t\tconst ctx = getMissileContext();\r\n\t\t\tconst target = ctx.worldState.enemies[0];\r\n\t\t\tif (!target) return flyStraight();\r\n\t\t\treturn turnToward(target.position.x, target.position.y);\r\n\t\t},\r\n\t\tangle, // Launch angle in degrees toward enemy\r\n\t).move(dx, dy);\r\n}\r\n`;\r\n}\r\n\r\nexport function readmeMd(botName: string): string\r\n{\r\n\treturn `# ${botName} — Vibemancer Bot\r\n\r\nThis is a Vibemancer wizard bot project. The bot fights 1v1 against other wizard bots in an 800x800 arena.\r\n\r\n## Quick Start\r\n\r\n\\`\\`\\`bash\r\nnpm test # Verify everything works\r\nnpm run dev # Start dev server + open browser (refresh to see changes)\r\nnpm run fight # Fight against all 29 built-in bots\r\nnpm run trace # Per-tick debug trace against TargetDummy\r\nnpm run typecheck # Check for type errors (catches bugs esbuild misses)\r\nnpm run optimize # Auto-tune useParam() values via optimizer\r\nnpm run upload # Upload to vibemancer.com for rated competition\r\nnpm run pull # Download latest source from server (after MCP edits)\r\n\\`\\`\\`\r\n\r\nTo trace/fight a specific opponent:\r\n\\`\\`\\`bash\r\nnpx vibemancer trace --opponent Battlemage\r\nnpx vibemancer fight --opponent Nightblade\r\nnpx vibemancer bots # list all bots with descriptions\r\nnpx vibemancer bots Battlemage # details about a specific bot\r\n\\`\\`\\`\r\n\r\n## Project Structure\r\n\r\n- \\`src/bot.ts\\` — Bot source code (edit this!)\r\n- \\`tests/bot.test.ts\\` — Automated tests for your bot\r\n- \\`vibemancer.json\\` — Config: \\`{ \"bot\": \"src/bot.ts\", \"export\": \"${botName}\" }\\`\r\n\r\n## Development Workflow\r\n\r\n1. Edit \\`src/bot.ts\\`\r\n2. Run \\`npm run typecheck\\` to catch type errors early\r\n3. Run \\`npm test\\` to check your bot doesn't crash and beats weak bots\r\n4. Run \\`npm run fight\\` to see how you rank against all 29 built-in bots\r\n5. Run \\`npm run trace\\` to see per-tick events when something isn't working\r\n6. Run \\`npm run optimize\\` to auto-tune useParam() values\r\n\r\nFor the browser viewer: run \\`npm run dev\\`, then refresh the browser after editing your bot.\r\n\r\n## Difficulty Progression\r\n\r\nStart by beating the weakest bots and work your way up:\r\n\r\n| Milestone | Bots to Beat | What You Need |\r\n|-----------|-------------|---------------|\r\n| Beginner | TargetDummy, Critter | Basic missile firing |\r\n| Easy | Rookie, Hogger, Bonemancer | Homing missiles + movement |\r\n| Medium | Turtle, Sentinel, Flamecaller | Shielding + dodge awareness |\r\n| Hard | Battlemage (#11), Stormchaser | Cast timing + positioning |\r\n| Expert | Archmage, Stormforger | Adaptive missiles + vulnerability punish |\r\n| Master | Nightblade (#29) | Everything at once |\r\n\r\n## Debugging\r\n\r\nWhen your bot isn't working:\r\n1. \\`npm test\\` — check for runtime errors (captured in test results)\r\n2. \\`vibemancer trace --opponent TargetDummy\\` — watch exactly what happens tick by tick\r\n3. Look at the trace stats: hit rate, shield usage, idle time\r\n4. Look for ERROR and WARNING events in the trace output\r\n\r\n## Common Pitfalls\r\n\r\n- \\`move(dx, dy)\\` is a **direction vector**, NOT a target position\r\n- \\`blink(x, y)\\` is an **absolute position**, NOT a direction\r\n- Calling \\`missile()\\` during GCD is **silently ignored** — check \\`useTicksUntilReady()\\` first\r\n- Missile range = speed x duration. If range < distance, missiles expire before reaching the enemy\r\n- All angles are in **degrees** (not radians). Use: \\`Math.atan2(dy, dx) * (180 / Math.PI)\\`\r\n- All time values are in **ticks** (100 ticks = 1 second)\r\n- Your bot runs every tick — always return an action, even during cooldowns (\\`move()\\`)\r\n- \\`fitMissileToBudget()\\` and \\`getLeadPosition()\\` return **null** when no solution exists\r\n\r\n## Built-in Bots (29 total, ranked weakest -> strongest)\r\n\r\nTargetDummy, Critter, Bonemancer, Hogger, Rookie, Turtle, Sentinel, Flamecaller,\r\nGolem, Stormchaser, Battlemage, Spellspinner, Doombringer, Lich, Stormcaller,\r\nSpellbinder, Shadowblade, Pyromancer, Warmage, Spelltracer, Archmage, Spellseeker,\r\nStormforger, Spellweaver, Spellshot, Voidblade, Infernalist, Archlich, Nightblade\r\n\r\nRun \\`vibemancer bots\\` to see descriptions, or \\`vibemancer bots Battlemage\\` for details.\r\n\r\n## Strategy Tips\r\n\r\n- Shield is strongest at the start (90% block) — cancel early to minimize GCD waste\r\n- Repeated similar missiles cast 20% faster (warmup). Switching styles costs 20%\r\n- Higher damage = longer cast time, but DPS always increases with damage\r\n- Homing missiles (turnRate > 0) are harder to dodge but cost more cast time\r\n- Straight missiles (turnRate: 0) are fast to cast. Use \\`getLeadPosition()\\` to aim\r\n- Use \\`useThreats()\\` to decide: dodge (best), shield (good), or eat the hit (risky)\r\n`;\r\n}\r\n\r\nexport function botTestTemplate(botName: string): string\r\n{\r\n\treturn `import {expect, test} from 'vitest';\r\nimport {testBot} from '@vibemancer/core';\r\nimport {${botName}} from '../src/bot';\r\n\r\n// Run with: npm test\r\n// These tests are ordered by difficulty — fix them top to bottom.\r\n\r\ntest('no runtime errors', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('TargetDummy');\r\n\texpect(result.errors).toHaveLength(0);\r\n});\r\n\r\ntest('beats TargetDummy', () =>\r\n{\r\n\tconst result = testBot(${botName}).fight('TargetDummy');\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('beats Critter', () =>\r\n{\r\n\tconst result = testBot(${botName}).fight('Critter');\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('kills TargetDummy within 15 seconds', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('TargetDummy', {maxTicks: 1500});\r\n\texpect(result.won).toBe(true);\r\n});\r\n\r\ntest('lands at least 40% of missiles', () =>\r\n{\r\n\tconst result = testBot(${botName}).simulate('Rookie', {maxTicks: 3000});\r\n\tif (result.stats.missilesLaunched > 0)\r\n\t{\r\n\t\texpect(result.stats.hitRate).toBeGreaterThan(0.4);\r\n\t}\r\n});\r\n`;\r\n}\r\n\r\nexport function agentsMd(botName: string): string\r\n{\r\n\treturn `# AGENTS.md — context for AI assistants\r\n\r\nThis is a [Vibemancer](https://vibemancer.com) wizard-bot project. The goal\r\nis to write a TypeScript bot that wins 1v1 fights against other wizards in\r\nan 800x800 arena.\r\n\r\n## Layout\r\n\r\n- \\`src/bot.ts\\` — the bot. Edit this. Export must be a single PascalCase\r\n function (currently \\`${botName}\\`).\r\n- \\`tests/bot.test.ts\\` — vitest suite. Add cases as you discover edge\r\n cases the bot should handle.\r\n- \\`vibemancer.json\\` — \\`{ \"bot\": \"src/bot.ts\", \"export\": \"${botName}\" }\\`.\r\n Don't move the bot without updating this.\r\n- \\`README.md\\` — a more thorough developer guide. Skim it once.\r\n\r\n## How to verify a change\r\n\r\n\\`\\`\\`bash\r\nnpm test # vitest — fast, runs every change\r\nnpm run typecheck # catches typos esbuild would silently bundle\r\nnpm run fight # round-robin against all 29 built-ins\r\nnpx vibemancer trace --opponent <Bot> # per-tick debug trace\r\n\\`\\`\\`\r\n\r\nTreat \\`npm test\\` as the smallest verifying step. Run it before claiming a\r\nchange is done.\r\n\r\n## The bot API\r\n\r\nImported from \\`@vibemancer/core\\`. The bot is called every tick (100 ticks\r\nper second). It returns an action object — typically built by helpers:\r\n\r\n- **Movement:** \\`move(dx, dy)\\` — direction vector (NOT a target). Always\r\n return *something* even on cooldown — bare \\`move(0, 0)\\` if you have\r\n nothing else to do.\r\n- **Spells (only one per cast):**\r\n - \\`missile({damage, speed, duration, turnRate}, ai, angle)\\` — fire a\r\n projectile. Range = speed × duration. Higher damage = longer cast time.\r\n The \\`ai\\` is a hooks-style function \\`() => MissileAction\\` — use\r\n \\`getMissileContext()\\` to read state, return \\`turnToward(x, y)\\`,\r\n \\`turnToAngle(degrees)\\`, or \\`flyStraight()\\`.\r\n - \\`shield()\\` — channel a shield. Strongest at start (90% block),\r\n decays. Cancel early to free up GCD.\r\n - \\`blink(x, y)\\` — teleport to **absolute position** (NOT a direction).\r\n Range cap is 300; further targets are clamped along the line.\r\n- **Hooks** (read state):\r\n - \\`usePosition()\\` — your current \\`{x, y}\\`.\r\n - \\`useEnemy()\\` — opponent's last-known state.\r\n - \\`useThreats()\\` — incoming missiles you might want to dodge/shield.\r\n - \\`useTicksUntilReady()\\` — GCD remaining. Cast attempts during GCD are\r\n silently ignored — gate on this.\r\n - \\`useRandom()\\` — seeded PRNG (\\`() => number\\`). Deterministic. Use\r\n instead of \\`Math.random()\\` (blocked in sandbox).\r\n - \\`useParam(name, default, {min, max, step})\\` — declare a tunable; the\r\n optimizer's coordinate-descent will sweep it.\r\n\r\nRead the full surface: \\`packages/core/src/index-browser.ts\\` if you have\r\nthe monorepo, or jump-to-definition from any \\`@vibemancer/core\\` import.\r\n\r\n## Common pitfalls\r\n\r\n- All angles are in **degrees**, not radians. Use \\`Math.atan2(dy, dx) * (180 / Math.PI)\\`.\r\n- All time values are in **ticks**, not seconds. 100 ticks = 1 second.\r\n- \\`getLeadPosition()\\` and \\`fitMissileToBudget()\\` return **null** when no\r\n solution exists — handle that, don't assume non-null.\r\n- Returning nothing freezes the bot for that tick. Always return at least\r\n \\`move(0, 0)\\`.\r\n- The bot runs in a sandboxed Web Worker / isolated-vm — no \\`fetch\\`,\r\n no DOM, no \\`Math.random()\\` (use \\`useRandom()\\` for a seeded,\r\n deterministic PRNG).\r\n\r\n## Don't\r\n\r\n- Don't add new top-level files outside \\`src/\\` and \\`tests/\\` without a\r\n reason — the dev server scans \\`src/\\` for bots.\r\n- Don't add npm dependencies that pull in Node-only modules. Bots are\r\n bundled for browser/sandbox execution.\r\n- Don't mutate globals or the prototype chain — the sandbox freezes them\r\n and crashes will be silent.\r\n\r\n## Publishing\r\n\r\nOnce \\`npm run fight\\` shows acceptable wins:\r\n\r\n\\`\\`\\`bash\r\nnpx vibemancer upload\r\n\\`\\`\\`\r\n\r\nThis signs in (Google), compiles, and ships the bundle to vibemancer.com.\r\nThe matchmaker auto-pairs your wizard against other active uploads. Watch\r\nthe leaderboard / your wizard's match history for results, find a\r\nweakness, edit, re-upload.\r\n`;\r\n}\r\n\r\nexport function gitignore(): string\r\n{\r\n\treturn `node_modules/\r\ndist/\r\n.vibemancer/\r\n*.tgz\r\n`;\r\n}\r\n\r\n/**\r\n * Scaffold a new project directory with all template files.\r\n */\r\nexport function scaffoldProject(projectDir: string, projectName: string, botName: string): void\r\n{\r\n\tconst files: [string, string][] = [\r\n\t\t['package.json', packageJson(projectName)],\r\n\t\t['tsconfig.json', tsconfigJson()],\r\n\t\t['vibemancer.json', vibemancerJson(botName)],\r\n\t\t['src/bot.ts', botTemplate(botName)],\r\n\t\t['tests/bot.test.ts', botTestTemplate(botName)],\r\n\t\t['README.md', readmeMd(botName)],\r\n\t\t['AGENTS.md', agentsMd(botName)],\r\n\t\t['.gitignore', gitignore()],\r\n\t];\r\n\r\n\tfs.mkdirSync(path.join(projectDir, 'src'), {recursive: true});\r\n\tfs.mkdirSync(path.join(projectDir, 'tests'), {recursive: true});\r\n\r\n\tfor (const [filePath, content] of files)\r\n\t{\r\n\t\tconst fullPath = path.join(projectDir, filePath);\r\n\t\tfs.writeFileSync(fullPath, content);\r\n\t}\r\n}\r\n"],"mappings":";;;AAUA,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACJjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,aAAa,KAC7B;AACC,MAAI,SAAS,IACX,QAAQ,UAAU,GAAG,EACrB,QAAQ,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,EACvC,QAAQ,QAAQ,EAAE;AAGpB,MAAI,MAAM,KAAK,MAAM,GACrB;AACC,aAAS,MAAM;AAAA,EAChB;AAEA,SAAO;AACR;AAKO,SAAS,kBAAkB,MAClC;AACC,SAAO,6BAA6B,KAAK,IAAI;AAC9C;AAKO,SAAS,mBAAmB,MACnC;AACC,SAAO,6CAA6C,KAAK,IAAI;AAC9D;AAEO,SAAS,YAAY,aAC5B;AACC,SAAO,KAAK,UAAU;AAAA,IACrB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,MACR,KAAK;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA,MACP,OAAO;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAA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Q,KAAK,CAAC;AAAA,EACf;AAEA,UAAQ,IAAI;AAAA,+BAAkC,WAAW,EAAE;AAC3D,UAAQ,IAAI,aAAa,OAAO;AAAA,CAAI;AAEpC,MACA;AACC,oBAAgB,YAAY,aAAa,OAAO;AAEhD,UAAM,QAAQ,CAAC,gBAAgB,iBAAiB,mBAAmB,cAAc,qBAAqB,aAAa,YAAY;AAC/H,eAAW,YAAY,OACvB;AACC,cAAQ,IAAI,aAAa,QAAQ,EAAE;AAAA,IACpC;AAAA,EACD,SACM,KACN;AACC,YAAQ,MAAM;AAAA,0BAA6B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAC7F,QACA;AACC,MAAAA,IAAG,OAAO,YAAY,EAAC,WAAW,MAAM,OAAO,KAAI,CAAC;AAAA,IACrD,QAEA;AAAA,IAEA;AACA,YAAQ,KAAK,CAAC;AAAA,EACf;AAEA,UAAQ,IAAI;AAAA;AAAA;AAAA,OAGN,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAWjB;AACD;AAEA,KAAK;","names":["fs","path","path","fs"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vibemancer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Create a new Vibemancer wizard bot project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Low Entry",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"prepublishOnly": "pnpm run test && pnpm run clean && pnpm run build"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
30
|
+
"@eslint/js": "^10.0.1",
|
|
31
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
32
|
+
"@types/node": "^25.6.0",
|
|
33
|
+
"eslint": "^10.3.0",
|
|
33
34
|
"tsup": "^8.5.1",
|
|
34
|
-
"typescript": "^
|
|
35
|
-
"typescript-eslint": "^8.
|
|
36
|
-
"vitest": "^4.
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"typescript-eslint": "^8.59.1",
|
|
37
|
+
"vitest": "^4.1.5"
|
|
37
38
|
}
|
|
38
39
|
}
|