Skip to content

Conversation

@LunaStev
Copy link
Member

This PR introduces the foundational infrastructure for the Wave Standard Library (std). It includes a dedicated management system for installing and updating the library via the CLI, a revamped import resolution mechanism for namespaced modules, and a lightweight custom JSON parser to handle metadata without adding external dependencies.

Key Changes

1. Standard Library Management CLI

  • New Commands: Added wavec install std and wavec update std.
  • Installation Logic:
    • Utilizes Git's sparse-checkout feature to efficiently pull only the /std directory from the official repository.
    • Automatically manages the library path at ~/.wave/lib/wave/std.
  • Environment Validation: Checks for the existence of git and ensures the HOME environment variable is correctly set before proceeding.

2. Namespaced Import System

  • std:: Prefix Support: Refactored the import resolver to recognize the std:: namespace (e.g., import("std::io::format")).
  • Resolution Strategy:
    • Standard library paths are resolved against the local ~/.wave installation directory.
    • Relative imports (e.g., import("./local_file")) remain unchanged, maintaining backward compatibility.
  • Code Hygiene: Centralized file parsing into parse_wave_file to eliminate redundant logic across the parser.

3. Lightweight Internal JSON Parser

  • Dependency-Free: Introduced utils::json, a custom-built JSON parser designed to read standard library manifests.
  • Feature Set: Supports standard JSON primitives: Objects, Arrays, Strings, Numbers, Booleans, and Null. This avoids bringing in heavy crates like serde_json for simple configuration tasks.

4. CLI & Error Handling

  • Robust Diagnostics: Added CliError variants for specific failures, such as installation errors, missing Git binaries, and manifest validation failures.
  • UI/UX: Updated the CLI help menu to guide users through the new standard library commands.

5. Initial Std Content & Testing

  • Boilerplate: Added the initial std/manifest.json and a placeholder std/io/format.wave module.
  • Verification: Added test/test75.wave to verify complex string manipulation logic and struct usage within the context of the new import system.

This commit introduces a formal standard library system for the Wave
language. It includes CLI commands to install and update the library
from the source repository, a revamped import resolution mechanism for
namespaced std modules, and a custom JSON parser for manifest handling.

Changes:
- **Standard Library Management**:
  - Added `wavec install std` and `wavec update std` commands.
  - Implemented sparse-checkout logic using Git to pull only the `std`
    directory from the remote repository to `~/.wave/lib/wave/std`.
  - Added manifest validation to ensure library integrity during installation.
- **Import System Enhancements**:
  - Refactored `import.rs` to support the `std::` prefix (e.g., `import("std::io::format")`).
  - Standard library imports are automatically resolved to the local
    installation directory, while relative imports continue to work as usual.
  - Centralized file parsing logic into `parse_wave_file` to reduce redundancy.
- **Lightweight JSON Parser**:
  - Introduced a custom JSON parser in `utils::json` to handle manifest
    files without external dependencies.
  - Supports basic JSON types: Objects, Arrays, Strings, Numbers, Booleans, and Null.
- **CLI & Error Handling**:
  - Added specific error variants in `CliError` for installation failures,
    missing external tools (Git), and environment issues (HOME not set).
  - Updated the CLI help menu to include the new standard library commands.
- **Initial Std Content**:
  - Added `std/manifest.json` and a boilerplate `std/io/format.wave` module.
- **Testing**:
  - Added `test/test75.wave` to verify complex string manipulation logic
    and struct usage.

This infrastructure allows the language to distribute common utilities
independently of the compiler while maintaining a clean, namespaced
import syntax.

Signed-off-by: LunaStev <luna@lunastev.org>
@LunaStev LunaStev merged commit 773d7d9 into wavefnd:master Jan 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant