naider 2.0.0 → 2.0.1

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 CHANGED
@@ -6,26 +6,32 @@ NAIDE is designed around one canonical syntax shared by people, AI tools, the co
6
6
 
7
7
  ### Compilation Targets
8
8
 
9
- | Target | Flag | Language | Server Framework |
10
- |--------|------|----------|-----------------|
11
- | `node` | default | JavaScript (ES Modules) | Express |
12
- | `python` / `py` | `--target python` | Python | Flask |
13
- | `bun` | `--target bun` | JavaScript (Bun) | Bun.serve |
14
- | `typescript` / `ts` | `--target ts` | TypeScript | Express |
15
- | `go` | `--target go` | Go | net/http |
16
- | `java` | `--target java` | Java | HttpServer |
17
- | `rust` / `rs` | `--target rust` | Rust | actix-web |
18
- | `cpp` / `c++` | `--target cpp` | C++ | cpp-httplib |
19
- | `c` | `--target c` | C | libmicrohttpd |
20
- | `csharp` / `cs` | `--target csharp` | C# | ASP.NET |
21
- | `kotlin` / `kt` | `--target kotlin` | Kotlin | Ktor |
22
- | `swift` | `--target swift` | Swift | Vapor |
23
- | `dart` | `--target dart` | Dart | shelf |
24
- | `php` | `--target php` | PHP | Built-in / Laravel |
25
- | `ruby` / `rb` | `--target ruby` | Ruby | Sinatra |
9
+ | Target | Flag | Language | Server Framework | CI validation |
10
+ |--------|------|----------|-----------------|---------------|
11
+ | `node` | default | JavaScript (ES Modules) | Express | Code generation + basic runtime smoke |
12
+ | `python` / `py` | `--target python` | Python | Flask | Code generation + basic runtime smoke |
13
+ | `bun` | `--target bun` | JavaScript (Bun) | Bun.serve | Code generation + basic runtime smoke |
14
+ | `typescript` / `ts` | `--target ts` | TypeScript | Express | Code generation smoke test |
15
+ | `go` | `--target go` | Go | net/http | Code generation + basic runtime smoke |
16
+ | `java` | `--target java` | Java | HttpServer | Code generation smoke test |
17
+ | `rust` / `rs` | `--target rust` | Rust | actix-web | Code generation smoke test |
18
+ | `cpp` / `c++` | `--target cpp` | C++ | cpp-httplib | Code generation + basic runtime smoke |
19
+ | `c` | `--target c` | C | libmicrohttpd | Code generation + basic runtime smoke |
20
+ | `csharp` / `cs` | `--target csharp` | C# | ASP.NET | Code generation smoke test |
21
+ | `kotlin` / `kt` | `--target kotlin` | Kotlin | Ktor | Code generation smoke test |
22
+ | `swift` | `--target swift` | Swift | Vapor | Code generation smoke test |
23
+ | `dart` | `--target dart` | Dart | shelf | Code generation smoke test |
24
+ | `php` | `--target php` | PHP | Built-in / Laravel | Code generation smoke test |
25
+ | `ruby` / `rb` | `--target ruby` | Ruby | Sinatra | Code generation smoke test |
26
26
 
27
27
  NAIDE source files use the `.naide` extension. There is one language syntax; no separate compressed or AI-only dialect.
28
28
 
29
+ #### What "supported target" means
30
+
31
+ The table describes exactly what CI currently verifies: all 15 targets have automated code-generation smoke tests; Node.js, Python, Bun, Go, C, and C++ also run a minimal output program (C/C++ are compiled first). This does **not** guarantee that every generated program compiles or runs, or that every built-in feature has equivalent behavior. Backend feature coverage varies; review generated code and target-specific requirements before relying on it in production.
32
+
33
+ The server-framework column identifies the backend's intended framework; it is not a promise that every NAIDE server feature is implemented for that target. Some backends emit TODO comments instead of working behavior—for example, the C backend's CRUD, authentication, and WebSocket paths, and the Rust backend's CRUD and WebSocket paths. Treat those generated sections as unsupported until the backend emits executable implementations and the corresponding integration tests pass.
34
+
29
35
  ## Install
30
36
 
31
37
  ```bash
@@ -39,6 +45,7 @@ npm install -g naider
39
45
  naide init my-app
40
46
  cd my-app
41
47
  npm install
48
+ npm run check
42
49
  npm run dev
43
50
  ```
44
51
 
@@ -55,6 +62,27 @@ server app port 3000:
55
62
  naide app.naide
56
63
  ```
57
64
 
65
+ ### Japanese Learning Path
66
+
67
+ 1. **Values and variables** — `str` / `int` / `bool` declare values; add `mut` only when a value must change.
68
+ 2. **Decisions and repetition** — use `if` / `elif` / `else` and `each`.
69
+ 3. **Functions** — declare reusable behavior with `fn` and return with `ret`.
70
+ 4. **Applications** — start with a route, then add validation, authentication, and storage deliberately.
71
+
72
+ ```naide
73
+ str name = "NAIDE"
74
+ mut int visits = 0
75
+
76
+ fn greet(str who) -> str:
77
+ ret "こんにちは、{who}さん"
78
+
79
+ if visits == 0:
80
+ log greet(name)
81
+ visits += 1
82
+ ```
83
+
84
+ Save as `lesson.naide`, then run `naide lesson.naide`. To inspect a project's local setup, use `naide doctor`; use `naide verify` to check its manifests without executing code. Each lesson should introduce one concept at a time—read the generated behavior and test your own small variation before adding features.
85
+
58
86
  ## CLI
59
87
 
60
88
  ```bash
@@ -68,8 +96,13 @@ naide fmt <files...> # Format NAIDE files
68
96
  naide lsp # Start Language Server (LSP)
69
97
  naide vscode # Install VS Code extension
70
98
  naide deploy [dir] # Generate Dockerfile for deployment
99
+ naide doctor [dir] # Diagnose local tools and project setup
100
+ naide verify [dir] # Validate manifests and type-check NAIDE sources
101
+ naide test [dir] # Run detected native test suites
71
102
  naide pkg init # Create naide.pkg.json manifest
72
103
  naide pkg install <name> # Install a NAIDE package
104
+ naide pkg add <manager> <spec> # Install with a native package manager
105
+ naide pkg managers # List supported package ecosystems
73
106
  naide pkg publish # Publish package to npm
74
107
  naide -w <file> # Watch mode (auto-restart on changes)
75
108
  naide -d <file> # Debug mode (Node.js inspector)
@@ -155,7 +188,7 @@ project.files.forEach(f => console.log(f.path));
155
188
 
156
189
  ```
157
190
  $ naide
158
- NAIDE REPL v1.21.0 — type NAIDE code, see JavaScript output
191
+ NAIDE REPL v2.0.1 — type NAIDE code, see JavaScript output
159
192
  Type .exit to quit, .eval to toggle eval mode
160
193
 
161
194
  >>> str name = "hello"
@@ -1269,7 +1302,7 @@ db.sql "postgres" "postgresql://localhost/mydb"
1269
1302
 
1270
1303
  ## Language Server (LSP)
1271
1304
 
1272
- Built-in LSP for editor integration — diagnostics, completions, and hover docs:
1305
+ Built-in LSP for editor integration — live syntax/type diagnostics, prefix-filtered completions, hover docs, document symbols, and definition/reference navigation across open `.naide` files:
1273
1306
 
1274
1307
  ```bash
1275
1308
  naide lsp
@@ -1281,7 +1314,7 @@ naide lsp
1281
1314
  naide vscode
1282
1315
  ```
1283
1316
 
1284
- One command installs the extension — syntax highlighting, LSP diagnostics, autocomplete, and hover docs for `.naide` files. Restart VS Code after install.
1317
+ One command installs the extension — syntax highlighting, LSP diagnostics, autocomplete, hover docs, symbols, and definition/reference navigation for `.naide` files. Restart VS Code after install.
1285
1318
 
1286
1319
  ## Deploy
1287
1320
 
@@ -1408,7 +1441,7 @@ every "30m":
1408
1441
  log "cleanup"
1409
1442
  ```
1410
1443
 
1411
- This generates a complete production API — SQLite database, AI/LLM integration, auth, password hashing, CORS, sessions, rate limiting, CRUD with pagination/search, WebSocket, SSE, file caching, request validation, background jobs, auto-generated API docs, route middleware, file downloads, redirects with status codes, type checking, error handling with ensure/finally, and event-driven hooks — from ~75 lines.
1444
+ This generates a broad API starter demonstrating SQLite, AI/LLM integration, auth, CORS, CRUD, WebSocket, SSE, file caching, request validation, background jobs, and more from ~75 lines. Treat it as a starting point: install the generated dependencies, inspect the emitted code, and perform your own security, load, and deployment reviews before production use.
1412
1445
 
1413
1446
  ## One syntax, end to end
1414
1447
 
@@ -1479,7 +1512,7 @@ Catches type mismatches at compile time:
1479
1512
  app.naide:7 WARN: Type warning: reassigning int variable 'count' with str
1480
1513
  ```
1481
1514
 
1482
- The type checker understands NAIDE's type annotations (`str`, `int`, `num`, `bool`, `list`, `map`), infers types from expressions and function return values, and checks assignments for compatibility. `num` accepts `int` values. `any` and `json` accept all types.
1515
+ The type checker checks supported annotations (`str`, `int`, `num`, `bool`, `list`, `map`), known function argument counts and types, return expressions against explicit annotations, and straightforward assignments. `num` accepts `int` values. `any` and `json` accept all types. Expressions whose types cannot be determined (including many dynamic member accesses) are treated as `any`, so passing `naide check` is useful feedback, **not a proof of program correctness or runtime safety**.
1483
1516
 
1484
1517
  Also available as a flag: `naide --check app.naide` or programmatically via `compile(source, { typeCheck: true })`.
1485
1518
 
@@ -1508,18 +1541,61 @@ naide -d app.naide # starts with --inspect-brk
1508
1541
 
1509
1542
  Then open `chrome://inspect` in Chrome to connect. The program pauses at the first line so you can set breakpoints before execution.
1510
1543
 
1511
- ## Package Ecosystem
1544
+ ## Project Diagnostics
1512
1545
 
1513
- Manage NAIDE packages via npm:
1546
+ ```bash
1547
+ naide doctor # inspect Node.js and installed language tools
1548
+ naide doctor . --json # machine-readable report
1549
+ naide verify # validate package manifests and find setup gaps
1550
+ ```
1551
+
1552
+ `doctor` checks the local Node.js requirement, available ecosystem tools, package manifests, and NAIDE source files. `verify` parses `package.json`, checks its dependency and script sections, and compiles and type-checks `.naide` files recursively, excluding `.git`, `dist`, `node_modules`, and the root `SPEC.naide` language reference. It is read-only and does not execute package scripts or source code; it is a setup/type-check aid, not a security audit or a guarantee that dependencies resolve or the application behaves correctly. Other ecosystem manifests are detected but are not fully validated. `test` is a separate, explicit command: it detects common native test setups (npm, Cargo, Go, .NET, Maven/Gradle, SwiftPM, Dart, Composer, Bundler, and pytest) and runs their configured test commands. Since project tests are executable code, run this only in a project you trust.
1553
+
1554
+ ## Native Package Ecosystems
1555
+
1556
+ NAIDE can ask the native package manager to install dependencies from several registries:
1514
1557
 
1515
1558
  ```bash
1516
- naide pkg init # create naide.pkg.json manifest
1517
- naide pkg install my-plugin # install from npm + add to manifest
1518
- naide pkg publish # publish to npm with naide-plugin keyword
1519
- naide pkg list # list installed NAIDE packages
1559
+ naide pkg managers
1560
+ naide pkg add npm zod@3.24.0
1561
+ python -m venv .venv
1562
+ # Activate .venv before installing Python packages
1563
+ naide pkg add pip requests==2.32.0
1564
+ naide pkg add cargo serde@1.0.0
1565
+ naide pkg add go github.com/google/uuid@v1.6.0
1566
+ naide pkg add dotnet Newtonsoft.Json@13.0.1
1567
+ naide pkg add composer symfony/console:^7.0
1568
+ naide pkg add gem rails@7.1.0
1569
+ naide pkg add dart 'http:^1.2.0'
1570
+ naide pkg add maven org.slf4j:slf4j-api:2.0.16
1571
+ naide pkg add conan fmt/11.0.2
1572
+ ```
1573
+
1574
+ Supported adapters are npm, PyPI/pip, Cargo, Go modules, NuGet/.NET, Packagist/Composer, RubyGems via Bundler, pub.dev, Maven Central, and Conan. Arguments are passed separately; on Windows, script-based manager shims use a quoted `cmd.exe` wrapper, and arguments containing quotes, percent signs, or line breaks are rejected. npm, pip, Cargo, Go, .NET, Composer, Bundler, and Dart delegate dependency declaration and lockfile updates to their native tools (where that ecosystem supports lockfiles). pip installs into an active/project `.venv`, records its requirement in `requirements.txt`, and records the ecosystem dependency in `naide.pkg.json`; activate a virtual environment before installing. Metadata files are staged before replacement, and failed multi-file updates are rolled back where possible. Every successful `naide pkg add` creates or updates `naide.pkg.json` as NAIDE's cross-ecosystem index, while native project manifests remain authoritative.
1575
+
1576
+ This is package-manager interoperability, **not** automatic cross-language linking. A Python, Rust, Java, or other native library cannot be called directly from NAIDE just because it is installed. To use one from a Node.js NAIDE program, expose a deliberate boundary such as a subprocess protocol, HTTP service, or a maintained FFI/WASM adapter. The Ruby adapter uses `bundle add`, so a Gemfile must already exist. Maven downloads to the local cache, and Conan resolves/generates dependency metadata; both still require their respective build-file/toolchain integration before the dependency is usable by an application. SwiftPM, Gradle, and other ecosystems without a tested adapter can still be used through their normal native tools.
1577
+
1578
+ `naide.pkg.json` stores NAIDE package metadata and records non-npm additions under `languageDependencies`; the native manager's manifest and lockfile remain authoritative. `naide pkg install` remains the npm convenience command for NAIDE plugins.
1579
+
1580
+ ## MCP Server
1581
+
1582
+ `naide-mcp` communicates over stdio and provides tools for compilation/generation, non-executing `naide_check` diagnostics, project verification and tests, package ecosystem guidance, and the language specification. The `verify_changes` prompt (also available in Japanese) guides agents to check changed source and the project without running code. It also exposes read-only resources (`naide://spec`, `naide://package-ecosystems`, `naide://project`).
1583
+
1584
+ For VS Code, after installing `naider` in a location on `PATH`, add this to `.vscode/mcp.json`:
1585
+
1586
+ ```json
1587
+ {
1588
+ "servers": {
1589
+ "naide": {
1590
+ "type": "stdio",
1591
+ "command": "naide-mcp",
1592
+ "args": []
1593
+ }
1594
+ }
1595
+ }
1520
1596
  ```
1521
1597
 
1522
- The `naide.pkg.json` manifest tracks NAIDE-specific metadata (main entry, exports, dependencies) while using npm as the underlying registry.
1598
+ The MCP server's `naide_run` and `naide_test` tools execute code with the server process's operating-system permissions. Connect it only to clients and workspaces whose code you trust.
1523
1599
 
1524
1600
  ## NAIDE vs Python — Side by Side
1525
1601