|
| 1 | +Toolbox Aid |
| 2 | +David Quesenberry |
| 3 | +04/05/2026 |
| 4 | +BUILD_PR_DEV_CONSOLE_COMMAND_PACKS.md |
| 5 | + |
| 6 | +# BUILD PR |
| 7 | +Dev Console Command Packs |
| 8 | + |
| 9 | +## Source Of Truth |
| 10 | +- Plan input: `docs/pr/PLAN_PR_DEV_CONSOLE_COMMAND_PACKS.md` |
| 11 | +- Workflow: `PLAN_PR -> BUILD_PR -> APPLY_PR` |
| 12 | +- This BUILD is docs-only and defines implementation-ready contracts without shipping runtime code. |
| 13 | + |
| 14 | +## Objective |
| 15 | +Define a namespaced command-pack model for the existing dev console so command registration, help output, validation, and output formatting are consistent and scalable. |
| 16 | + |
| 17 | +## Scope |
| 18 | +- Define command-pack and command registry shape |
| 19 | +- Define built-in help behavior for pack and command discovery |
| 20 | +- Define output contract for command execution results |
| 21 | +- Define validation conventions and error surface |
| 22 | +- Keep future implementation scope limited to `tools/dev` and optional tests |
| 23 | + |
| 24 | +## Out Of Scope |
| 25 | +- No engine core changes |
| 26 | +- No runtime refactor beyond command-registry adoption path |
| 27 | +- No autocomplete feature requirement in this slice |
| 28 | +- No multi-sample rollout in this slice |
| 29 | + |
| 30 | +## Implementation Boundaries (Future Apply Scope) |
| 31 | +- Allowed implementation folders: |
| 32 | + - `tools/dev/` |
| 33 | + - optional `tests/tools/` |
| 34 | +- Not allowed: |
| 35 | + - `engine/` |
| 36 | + - runtime core rewrites |
| 37 | + - unrelated tools/samples/games |
| 38 | + |
| 39 | +## Command Registry Shape |
| 40 | +Use a registry composed of command packs. |
| 41 | + |
| 42 | +### Command Pack Contract |
| 43 | +- `packId`: string (namespace token, example: `scene`) |
| 44 | +- `label`: string (human-readable title) |
| 45 | +- `description`: string |
| 46 | +- `commands`: array of command definitions |
| 47 | +- `contextRequirements` (optional): array of required context keys |
| 48 | + |
| 49 | +### Command Contract |
| 50 | +- `name`: full namespaced command, example `scene.info` |
| 51 | +- `summary`: short command description |
| 52 | +- `usage`: usage string |
| 53 | +- `arguments` (optional): argument spec array |
| 54 | +- `handler(context, args)`: execution handler |
| 55 | +- `outputHint` (optional): formatting hint (`text`, `table`, `json`) |
| 56 | +- `validate(args, context)` (optional): pre-execution validator |
| 57 | + |
| 58 | +## Help Behavior Contract |
| 59 | +Support these forms: |
| 60 | +- `help` |
| 61 | + - lists command packs and basic usage |
| 62 | +- `help <pack>` |
| 63 | + - lists commands inside that pack |
| 64 | +- `help <full.command>` |
| 65 | + - shows command summary, usage, args, validation notes |
| 66 | + |
| 67 | +Behavior rules: |
| 68 | +- Unknown pack/command returns structured error output (not silent fail) |
| 69 | +- Help output is stable and deterministic (sorted by pack then command name) |
| 70 | + |
| 71 | +## Command Output Contract |
| 72 | +All command executions should normalize to: |
| 73 | +- `status`: `ready | failed` |
| 74 | +- `title`: string |
| 75 | +- `lines`: string array |
| 76 | +- `details` (optional): structured payload object |
| 77 | +- `code` (optional): machine-readable error/result code |
| 78 | + |
| 79 | +Output conventions: |
| 80 | +- Success uses `status=ready` |
| 81 | +- Validation/lookup failures use `status=failed` with explicit `code` |
| 82 | +- Empty output should still return at least one user-facing line |
| 83 | + |
| 84 | +## Validation Conventions |
| 85 | +Normalize these cases: |
| 86 | +- Unknown command |
| 87 | + - `code=COMMAND_NOT_FOUND` |
| 88 | +- Unknown pack in help |
| 89 | + - `code=COMMAND_PACK_NOT_FOUND` |
| 90 | +- Invalid arguments |
| 91 | + - `code=INVALID_COMMAND_ARGS` |
| 92 | +- Missing context dependencies |
| 93 | + - `code=MISSING_COMMAND_CONTEXT` |
| 94 | +- Handler failure |
| 95 | + - `code=COMMAND_EXECUTION_FAILED` |
| 96 | + |
| 97 | +Validation behavior: |
| 98 | +- Reject invalid command execution before handler call when possible |
| 99 | +- Return structured non-silent failure with actionable message |
| 100 | + |
| 101 | +## Suggested Pack Coverage |
| 102 | +- `scene.*` |
| 103 | +- `render.*` |
| 104 | +- `entity.*` |
| 105 | +- `debug.*` |
| 106 | +- `input.*` |
| 107 | +- `hotreload.*` |
| 108 | +- `validation.*` |
| 109 | + |
| 110 | +## Future Candidate Files (Implementation Phase) |
| 111 | +- `tools/dev/commandPacks/sceneCommandPack.js` |
| 112 | +- `tools/dev/commandPacks/renderCommandPack.js` |
| 113 | +- `tools/dev/commandPacks/entityCommandPack.js` |
| 114 | +- `tools/dev/commandPacks/debugCommandPack.js` |
| 115 | +- `tools/dev/commandPacks/inputCommandPack.js` |
| 116 | +- `tools/dev/commandPacks/hotReloadCommandPack.js` |
| 117 | +- `tools/dev/commandPacks/validationCommandPack.js` |
| 118 | +- `tools/dev/devConsoleCommandRegistry.js` |
| 119 | +- `tools/dev/devConsoleIntegration.js` |
| 120 | +- Optional tests under `tests/tools/` |
| 121 | + |
| 122 | +## Acceptance Criteria |
| 123 | +- Namespaced command pack model documented |
| 124 | +- Registry and command definition shape documented |
| 125 | +- Help behavior documented for global/pack/command modes |
| 126 | +- Output contract documented and standardized |
| 127 | +- Validation conventions documented with explicit error codes |
| 128 | +- Future scope constrained to `tools/dev` and optional tests |
| 129 | +- No engine-core change requirements introduced |
| 130 | + |
| 131 | +## Manual Validation Checklist |
| 132 | +- Confirm pack and command schema is complete enough to implement directly |
| 133 | +- Confirm help behavior covers global, pack, and command views |
| 134 | +- Confirm output contract supports both human and structured tooling usage |
| 135 | +- Confirm validation conventions avoid silent failures |
| 136 | +- Confirm no implementation scope leaks outside `tools/dev` and optional tests |
| 137 | + |
| 138 | +## Packaging |
| 139 | +Expected BUILD delta ZIP: |
| 140 | +- `<project folder>/tmp/BUILD_PR_DEV_CONSOLE_COMMAND_PACKS_delta.zip` |
0 commit comments