feat: enforce @scope/name format for all variable names #30

Merged
xiaomo merged 1 commits from feat/29-scoped-variable-names into main 2026-06-01 16:15:26 +00:00
Owner

What

All variable names must now follow @scope/name format.

Why

  • Visually distinct from hashes (13-char Base32)
  • Scoped namespace prevents collisions
  • Consistent with @ocas/* builtin convention

Changes

  • packages/core/src/variable-store.ts — rewrite validateName() to enforce @scope/name pattern
  • packages/cli/src/index.ts — update error messages to suggest @scope/name format
  • 11 test files — all bare variable names → @test/name or @myapp/name; added new validation cases

Valid / Invalid

  • @myapp/config, @todo/schema, @ocas/schema (builtin)
  • config (no scope), foo/bar (no @), @/foo (empty scope), @123/foo (digit scope)

594 tests pass.

Fixes #29

小橘 🍊(NEKO Team)

## What All variable names must now follow `@scope/name` format. ## Why - Visually distinct from hashes (13-char Base32) - Scoped namespace prevents collisions - Consistent with `@ocas/*` builtin convention ## Changes - **`packages/core/src/variable-store.ts`** — rewrite `validateName()` to enforce `@scope/name` pattern - **`packages/cli/src/index.ts`** — update error messages to suggest `@scope/name` format - **11 test files** — all bare variable names → `@test/name` or `@myapp/name`; added new validation cases ## Valid / Invalid - ✅ `@myapp/config`, `@todo/schema`, `@ocas/schema` (builtin) - ❌ `config` (no scope), `foo/bar` (no @), `@/foo` (empty scope), `@123/foo` (digit scope) 594 tests pass. Fixes #29 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-06-01 16:12:40 +00:00
All variable names must now follow @scope/name pattern:
- scope: @[a-zA-Z][a-zA-Z0-9]* (e.g. @myapp, @todo)
- name: one or more segments of [a-zA-Z0-9._-]+
- @ocas/* reserved for internal use

Examples: @myapp/config, @todo/schema, @ocas/schema (builtin)
Rejected: config (no scope), foo/bar (no @), @/foo (empty scope)

Updated validateName() in core, CLI error messages, and all tests.
594 tests pass.

Fixes #29
xiaomo approved these changes 2026-06-01 16:15:20 +00:00
xiaomo left a comment
Owner

LGTM 命名规范化做得干净。

  • @scope/name 格式清晰,scope 必须字母开头,与 hash 格式天然区分
  • 验证逻辑简洁:一个正则匹配 scope,剩余段复用原有的 segment 校验
  • 测试全面适配,error message 引导用户用正确格式

合!

LGTM ✅ 命名规范化做得干净。 - `@scope/name` 格式清晰,scope 必须字母开头,与 hash 格式天然区分 - 验证逻辑简洁:一个正则匹配 scope,剩余段复用原有的 segment 校验 - 测试全面适配,error message 引导用户用正确格式 合!
xiaomo merged commit b99d74093c into main 2026-06-01 16:15:26 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/ocas#30