naider 1.14.0 → 1.16.0

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
@@ -1,8 +1,28 @@
1
1
  # NAIDE
2
2
 
3
- **Node AI Development Environment** — A programming language designed for AI-speed code generation that transpiles to Node.js.
4
-
5
- NAIDE is built on three principles: one way to write everything (zero ambiguity), keyword-driven intent (the first token decides meaning), and minimal token count (fewer tokens = faster AI generation). It includes built-in declarations for servers, databases, authentication, file uploads, WebSockets, bots (Discord/Slack/Telegram/LINE), CLI apps, HTML pages, email, GraphQL, desktop apps, mobile screens, cron jobs, job queues, testing, and more — all with zero external dependencies.
3
+ **Node AI Development Environment** — A programming language simpler than Python, designed for AI-speed code generation, that transpiles to **15 languages**.
4
+
5
+ NAIDE is built on four principles: simpler than Python (built-in functions, syntax sugar, zero boilerplate), one way to write everything (zero ambiguity), keyword-driven intent (the first token decides meaning), and minimal token count (fewer tokens = faster AI generation). Write once, compile to any target. 35+ built-in functions, syntax sugar (`unless`, `until`, `repeat`, `swap`, `is`/`isnt`, one-line functions), and 47 built-in features including servers, databases, authentication, bots, GraphQL, gRPC, WebRTC, blockchain, and more.
6
+
7
+ ### Compilation Targets
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 |
6
26
 
7
27
  Two syntax modes:
8
28
 
@@ -756,6 +776,104 @@ image "photo.jpg" -> "output.jpg":
756
776
 
757
777
  Operations: `resize`, `crop`, `rotate`, `blur`, `grayscale`, `flip`, `watermark`, `format`. Compiles to sharp (Node.js) or Pillow (Python).
758
778
 
779
+ ## CSV/Excel Export
780
+
781
+ ```python
782
+ csv "users" format "csv":
783
+ columns "name" "email" "age"
784
+ from data
785
+
786
+ csv "report" format "xlsx":
787
+ columns "id" "value" "date"
788
+ from items
789
+ output "monthly_report.xlsx"
790
+ ```
791
+
792
+ | Target | CSV Library | Excel Library |
793
+ |--------|-----------|-------------|
794
+ | Node.js | csv-stringify | ExcelJS |
795
+ | Python | csv (stdlib) | openpyxl |
796
+
797
+ ## Logging
798
+
799
+ ```python
800
+ logging "app":
801
+ level "info"
802
+ file "app.log"
803
+ format "json"
804
+ rotate "14d"
805
+ ```
806
+
807
+ Usage: `logger.info("message")`, `logger.error("fail")`, `logger.warn("caution")`.
808
+
809
+ | Target | Library |
810
+ |--------|---------|
811
+ | Node.js | winston + winston-daily-rotate-file |
812
+ | Python | logging (stdlib) |
813
+
814
+ ## DB Migrations
815
+
816
+ ```python
817
+ migrate "create_users":
818
+ up:
819
+ log "Creating users table"
820
+ down:
821
+ log "Dropping users table"
822
+ ```
823
+
824
+ Generates migration files with `up()` and `down()` methods for reversible schema changes.
825
+
826
+ ## gRPC
827
+
828
+ ```python
829
+ grpc "users" port 50051:
830
+ rpc getUser(id) -> user
831
+ rpc createUser(data) -> user
832
+ rpc deleteUser(id) -> result
833
+ ```
834
+
835
+ | Target | Library |
836
+ |--------|---------|
837
+ | Node.js | @grpc/grpc-js + @grpc/proto-loader |
838
+ | Python | grpcio |
839
+
840
+ ## WebRTC
841
+
842
+ ```python
843
+ webrtc "video-chat":
844
+ stun "stun:stun.l.google.com:19302"
845
+ on offer(data):
846
+ log "Received offer"
847
+ on answer(data):
848
+ log "Received answer"
849
+ on candidate(data):
850
+ log "ICE candidate"
851
+ ```
852
+
853
+ Generates a WebSocket-based signaling server with ICE configuration.
854
+
855
+ | Target | Library |
856
+ |--------|---------|
857
+ | Node.js | ws (WebSocketServer) |
858
+ | Python | websockets + asyncio |
859
+
860
+ ## Blockchain / Web3
861
+
862
+ ```python
863
+ blockchain "eth":
864
+ network "ethereum"
865
+ provider env.ETH_RPC
866
+ contract "0x1234abcd..."
867
+ abi "contract-abi.json"
868
+ ```
869
+
870
+ Usage: `eth.getBalance("0x...")`, `eth.getBlock()`, `eth.sendTx(wallet, to, "0.1")`.
871
+
872
+ | Target | Library |
873
+ |--------|---------|
874
+ | Node.js | ethers.js v6 |
875
+ | Python | web3.py |
876
+
759
877
  ## Environment Variables
760
878
 
761
879
  ```python
@@ -767,14 +885,97 @@ env:
767
885
 
768
886
  Variables become constants. Missing `required` vars exit with an error.
769
887
 
888
+ ## Syntax Sugar (Simpler than Python)
889
+
890
+ ```python
891
+ # unless — negated if
892
+ unless x > 10:
893
+ log "small"
894
+
895
+ # until — negated while
896
+ until done:
897
+ process()
898
+
899
+ # repeat — simple counted loop
900
+ repeat 5:
901
+ log "hi"
902
+ repeat 10 as i:
903
+ log i
904
+
905
+ # enum
906
+ enum Color:
907
+ RED
908
+ GREEN
909
+ BLUE
910
+
911
+ # swap
912
+ swap a, b
913
+
914
+ # is / isnt — readable equality
915
+ if x is 5: log "five"
916
+ if y isnt null: log "exists"
917
+
918
+ # one-line functions
919
+ fn double(int x) -> int = x * 2
920
+
921
+ # print alias
922
+ print "hello world"
923
+ ```
924
+
770
925
  ## Built-in Functions
771
926
 
772
927
  ```python
773
- str id = uuid() # UUID
774
- str hashed = hash("password") # scrypt hash
775
- bool ok = verify("password", hashed) # timing-safe verify
776
- str token = sign({id: 1}) # JWT (uses auth secret)
777
- str token = sign({id: 1}, "my-secret") # JWT (explicit secret)
928
+ # Security
929
+ str id = uuid()
930
+ str hashed = hash("password")
931
+ bool ok = verify("password", hashed)
932
+ str token = sign({id: 1})
933
+
934
+ # Type conversions
935
+ str s = str(42)
936
+ int n = int("42")
937
+ num f = float("3.14")
938
+
939
+ # String ops
940
+ str u = upper("hello")
941
+ str l = lower("HELLO")
942
+ str t = trim(" hi ")
943
+ list parts = split("a,b,c", ",")
944
+ str joined = join(parts, "-")
945
+ bool has = contains("hello", "ell")
946
+
947
+ # Collection ops
948
+ int length = len(items)
949
+ list sorted = sort(items)
950
+ list r = range(10)
951
+ list k = keys(obj)
952
+ list v = values(obj)
953
+ list uniq = unique(items)
954
+ list flat_list = flat(nested)
955
+ list zipped = zip(a, b)
956
+ list chunks = chunk(items, 3)
957
+
958
+ # Math
959
+ num a = abs(-5)
960
+ num r = round(3.7)
961
+ num s = sqrt(16)
962
+ num p = pow(2, 10)
963
+ num total = sum(nums)
964
+
965
+ # JSON
966
+ any data = json_parse('{"a":1}')
967
+ str json = json_str(data)
968
+
969
+ # I/O
970
+ str answer = ask("Name?")
971
+ str content = read("file.txt")
972
+ write("out.txt", content)
973
+
974
+ # Time & misc
975
+ int ts = now()
976
+ str t = time()
977
+ sleep(1000)
978
+ exit(0)
778
979
  ```
779
980
 
780
981
  Auto-imported from the runtime when used.
package/SPEC.naide CHANGED
@@ -584,3 +584,155 @@ image "photo.jpg" -> "output.jpg":
584
584
  resize 800 600
585
585
  grayscale
586
586
  watermark "logo.png"
587
+
588
+
589
+ # ---- CSV/Excelエクスポート ----
590
+ csv "users" format "csv":
591
+ columns "name" "email" "age"
592
+ from data
593
+ # Excel形式
594
+ csv "report" format "xlsx":
595
+ columns "id" "value" "date"
596
+ from items
597
+ output "monthly_report.xlsx"
598
+
599
+ # ---- ロギング ----
600
+ logging "app":
601
+ level "info"
602
+ file "app.log"
603
+ format "json"
604
+ rotate "14d"
605
+ # usage: logger.info("message"), logger.error("fail")
606
+
607
+ # ---- DBマイグレーション ----
608
+ migrate "create_users":
609
+ up:
610
+ log "Creating users table"
611
+ down:
612
+ log "Dropping users table"
613
+
614
+ # ---- gRPC ----
615
+ grpc "users" port 50051:
616
+ rpc getUser(id) -> user
617
+ rpc createUser(data) -> user
618
+ rpc deleteUser(id) -> result
619
+
620
+ # ---- WebRTC ----
621
+ webrtc "video-chat":
622
+ stun "stun:stun.l.google.com:19302"
623
+ on offer(data):
624
+ log "Received offer"
625
+ on answer(data):
626
+ log "Received answer"
627
+ on candidate(data):
628
+ log "ICE candidate"
629
+
630
+ # ---- ブロックチェーン ----
631
+ blockchain "eth":
632
+ network "ethereum"
633
+ provider env.ETH_RPC
634
+ contract "0x1234abcd..."
635
+ abi "contract-abi.json"
636
+ # usage: eth.getBalance("0x..."), eth.getBlock(), eth.sendTx(wallet, to, "0.1")
637
+
638
+
639
+ # ============================================
640
+ # シンプルシンタックス (Pythonより簡単)
641
+ # ============================================
642
+
643
+ # ---- unless (ifの逆) ----
644
+ unless x > 10:
645
+ log "xは10以下"
646
+
647
+ # ---- until (whileの逆) ----
648
+ mut int i = 0
649
+ until i > 10:
650
+ i = i + 1
651
+
652
+ # ---- repeat (簡単ループ) ----
653
+ repeat 5:
654
+ log "hello"
655
+
656
+ repeat 10 as i:
657
+ log i
658
+
659
+ # ---- enum (列挙型) ----
660
+ enum Color:
661
+ RED
662
+ GREEN
663
+ BLUE
664
+
665
+ # インライン形式
666
+ enum Status: ACTIVE, INACTIVE, PENDING
667
+
668
+ # ---- swap (値の交換) ----
669
+ mut int a = 1
670
+ mut int b = 2
671
+ swap a, b
672
+
673
+ # ---- is / isnt (比較演算子) ----
674
+ if x is 5:
675
+ log "xは5"
676
+ if y isnt null:
677
+ log "yはnullじゃない"
678
+
679
+ # ---- 一行関数 ----
680
+ fn double(int x) -> int = x * 2
681
+ fn greet(str name) -> str = "Hello, {name}!"
682
+
683
+ # ---- print (logのエイリアス) ----
684
+ print "hello world"
685
+
686
+ # ---- ビルトイン関数 ----
687
+ # 型変換
688
+ str s = str(42)
689
+ int n = int("42")
690
+ num f = float("3.14")
691
+
692
+ # 文字列操作
693
+ str u = upper("hello") # "HELLO"
694
+ str l = lower("HELLO") # "hello"
695
+ str t = trim(" hi ") # "hi"
696
+ list parts = split("a,b,c", ",") # ["a","b","c"]
697
+ str joined = join(parts, "-") # "a-b-c"
698
+ str replaced = replace("hello", "l", "r") # "herro"
699
+ bool has = contains("hello", "ell") # true
700
+
701
+ # コレクション操作
702
+ int length = len(items)
703
+ list sorted = sort(items)
704
+ list reversed = reverse(items)
705
+ list uniq = unique([1,1,2,3]) # [1,2,3]
706
+ list k = keys(obj)
707
+ list v = values(obj)
708
+ list e = entries(obj)
709
+ list r = range(10) # [0,1,...,9]
710
+ list chunks = chunk([1,2,3,4], 2) # [[1,2],[3,4]]
711
+ list zipped = zip([1,2], ["a","b"])
712
+ list flattened = flat([[1,2],[3,4]])
713
+
714
+ # 数学
715
+ num a2 = abs(-5)
716
+ num r2 = round(3.7)
717
+ num c = ceil(3.1)
718
+ num fl = floor(3.9)
719
+ num sq = sqrt(16)
720
+ num p = pow(2, 10)
721
+ num total = sum([1,2,3])
722
+
723
+ # JSON
724
+ any data2 = json_parse('{"a":1}')
725
+ str json = json_str(data2)
726
+
727
+ # 時間
728
+ int timestamp = now()
729
+ str timestr = time()
730
+
731
+ # I/O
732
+ str content = read("file.txt")
733
+ write("out.txt", content)
734
+ str answer = ask("名前は?")
735
+
736
+ # その他
737
+ sleep(1000)
738
+ exit(0)
package/lsp/server.js CHANGED
@@ -290,6 +290,8 @@ function getCompletions() {
290
290
  'cache', 'view', 'upload', 'group', 'validate', 'openapi', 'error', 'mid', 'prompt',
291
291
  'page', 'cli', 'mail', 'graphql', 'desktop', 'screen',
292
292
  'oauth', 'pay', 'storage', 'pdf', 'i18n', 'push', 'search', 'image',
293
+ 'csv', 'logging', 'migrate', 'grpc', 'webrtc', 'blockchain',
294
+ 'unless', 'until', 'repeat', 'enum', 'swap', 'is', 'isnt', 'print',
293
295
  ];
294
296
  const builtins = [
295
297
  { label: 'uuid()', detail: 'Generate UUID v4', insertText: 'uuid()' },
@@ -314,6 +316,45 @@ function getCompletions() {
314
316
  { label: 'graphql "/path"', detail: 'GraphQL endpoint', insertText: 'graphql ' },
315
317
  { label: 'desktop name:', detail: 'Desktop app', insertText: 'desktop ' },
316
318
  { label: 'screen Name:', detail: 'Mobile screen', insertText: 'screen ' },
319
+ { label: 'len(list)', detail: 'Get length', insertText: 'len(' },
320
+ { label: 'sort(list)', detail: 'Sort a list', insertText: 'sort(' },
321
+ { label: 'reverse(list)', detail: 'Reverse a list', insertText: 'reverse(' },
322
+ { label: 'unique(list)', detail: 'Remove duplicates', insertText: 'unique(' },
323
+ { label: 'upper(str)', detail: 'Uppercase string', insertText: 'upper(' },
324
+ { label: 'lower(str)', detail: 'Lowercase string', insertText: 'lower(' },
325
+ { label: 'trim(str)', detail: 'Trim whitespace', insertText: 'trim(' },
326
+ { label: 'split(str, sep)', detail: 'Split string', insertText: 'split(' },
327
+ { label: 'join(list, sep)', detail: 'Join list to string', insertText: 'join(' },
328
+ { label: 'contains(list, item)', detail: 'Check if contains', insertText: 'contains(' },
329
+ { label: 'replace(str, old, new)', detail: 'Replace in string', insertText: 'replace(' },
330
+ { label: 'keys(map)', detail: 'Get map keys', insertText: 'keys(' },
331
+ { label: 'values(map)', detail: 'Get map values', insertText: 'values(' },
332
+ { label: 'entries(map)', detail: 'Get key-value pairs', insertText: 'entries(' },
333
+ { label: 'range(n)', detail: 'Generate 0..n-1', insertText: 'range(' },
334
+ { label: 'abs(num)', detail: 'Absolute value', insertText: 'abs(' },
335
+ { label: 'round(num)', detail: 'Round number', insertText: 'round(' },
336
+ { label: 'ceil(num)', detail: 'Round up', insertText: 'ceil(' },
337
+ { label: 'floor(num)', detail: 'Round down', insertText: 'floor(' },
338
+ { label: 'sqrt(num)', detail: 'Square root', insertText: 'sqrt(' },
339
+ { label: 'pow(base, exp)', detail: 'Power', insertText: 'pow(' },
340
+ { label: 'sum(list)', detail: 'Sum of list', insertText: 'sum(' },
341
+ { label: 'flat(list)', detail: 'Flatten nested list', insertText: 'flat(' },
342
+ { label: 'zip(a, b)', detail: 'Zip two lists', insertText: 'zip(' },
343
+ { label: 'chunk(list, n)', detail: 'Split into chunks', insertText: 'chunk(' },
344
+ { label: 'str(val)', detail: 'Convert to string', insertText: 'str(' },
345
+ { label: 'int(val)', detail: 'Convert to integer', insertText: 'int(' },
346
+ { label: 'float(val)', detail: 'Convert to float', insertText: 'float(' },
347
+ { label: 'json_parse(str)', detail: 'Parse JSON string', insertText: 'json_parse(' },
348
+ { label: 'json_str(val)', detail: 'Stringify to JSON', insertText: 'json_str(' },
349
+ { label: 'now()', detail: 'Current timestamp ms', insertText: 'now()' },
350
+ { label: 'time()', detail: 'Current ISO time', insertText: 'time()' },
351
+ { label: 'ask(prompt)', detail: 'Read user input', insertText: 'ask(' },
352
+ { label: 'sleep(ms)', detail: 'Wait milliseconds', insertText: 'sleep(' },
353
+ { label: 'exit(code)', detail: 'Exit process', insertText: 'exit(' },
354
+ { label: 'read(path)', detail: 'Read file contents', insertText: 'read(' },
355
+ { label: 'write(path, data)', detail: 'Write to file', insertText: 'write(' },
356
+ { label: 'fetch_json(url)', detail: 'Fetch JSON from URL', insertText: 'fetch_json(' },
357
+ { label: 'random(min, max)', detail: 'Random number', insertText: 'random(' },
317
358
  ];
318
359
 
319
360
  return [
@@ -354,6 +395,20 @@ const HOVER_DOCS = {
354
395
  'push': '**push** — Push notifications\n```naide\npush env.VAPID_PUBLIC env.VAPID_PRIVATE:\n endpoint "/subscribe"\n```\nUsage: `push.send(subscription, title, body)`',
355
396
  'search': '**search** — Full-text search\n```naide\nsearch "meilisearch" "http://localhost:7700" env.KEY:\n index "products"\n```\nUsage: `search.query("keyword")`, `search.add(docs)`',
356
397
  'image': '**image** — Image processing\n```naide\nimage "input.jpg" -> "output.jpg":\n resize 800 600\n grayscale\n watermark "logo.png"\n```',
398
+ 'csv': '**csv** — CSV/Excel export\n```naide\ncsv "users" format "xlsx":\n columns "name" "email"\n from data\n```\nSupports csv and xlsx formats',
399
+ 'logging': '**logging** — Structured logging\n```naide\nlogging "app":\n level "info"\n file "app.log"\n format "json"\n rotate "14d"\n```\nUsage: `logger.info("msg")`, `logger.error("fail")`',
400
+ 'migrate': '**migrate** — DB migrations\n```naide\nmigrate "create_users":\n up:\n log "creating"\n down:\n log "dropping"\n```',
401
+ 'grpc': '**grpc** — gRPC service\n```naide\ngrpc "users" port 50051:\n rpc getUser(id) -> user\n rpc createUser(data) -> user\n```',
402
+ 'webrtc': '**webrtc** — WebRTC signaling\n```naide\nwebrtc "video":\n stun "stun:stun.l.google.com:19302"\n on offer(data):\n log "offer received"\n```',
403
+ 'blockchain': '**blockchain** — Blockchain/Web3\n```naide\nblockchain "eth":\n network "ethereum"\n provider env.ETH_RPC\n contract "0x..."\n```\nUsage: `eth.getBalance(addr)`, `eth.getBlock()`',
404
+ 'unless': '**unless** — Negated if (do X unless condition)\n```naide\nunless x > 10:\n log "small"\n```',
405
+ 'until': '**until** — Negated while (loop until condition)\n```naide\nuntil done:\n process()\n```',
406
+ 'repeat': '**repeat** — Simple counted loop\n```naide\nrepeat 5:\n log "hi"\nrepeat 10 as i:\n log i\n```',
407
+ 'enum': '**enum** — Enumeration type\n```naide\nenum Color:\n RED\n GREEN\n BLUE\n```\nInline: `enum Status: ACTIVE, INACTIVE`',
408
+ 'swap': '**swap** — Swap two variables\n```naide\nswap a, b\n```',
409
+ 'is': '**is** — Equality comparison (===)\n```naide\nif x is 5: log "five"\n```',
410
+ 'isnt': '**isnt** — Inequality comparison (!==)\n```naide\nif x isnt null: log "exists"\n```',
411
+ 'print': '**print** — Alias for log\n```naide\nprint "hello world"\n```',
357
412
  };
358
413
 
359
414
  function getHover(params) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "naider",
3
- "version": "1.14.0",
4
- "description": "NAIDE - Node AI Development Environment. AI-specialized language with built-in server, auth, DB, SQL, AI/LLM, WebSocket, bots (Discord/Slack/Telegram/LINE), CLI, HTML, email, GraphQL, desktop, mobile, and more — transpiles to Node.js/Python/Bun.",
3
+ "version": "1.16.0",
4
+ "description": "NAIDE - Simpler than Python, compiles to 15 targets. AI-specialized language with 35+ built-in functions, syntax sugar (unless/until/repeat/swap/is/isnt), and 47 features. Targets: Node.js, Python, TypeScript, C, C++, Java, Go, Rust, PHP, Ruby, Kotlin, Swift, Dart, C#, Bun.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
7
7
  ".": "./src/index.js",
@@ -56,7 +56,26 @@
56
56
  "react-native",
57
57
  "cron",
58
58
  "python",
59
- "bun"
59
+ "bun",
60
+ "csv",
61
+ "excel",
62
+ "logging",
63
+ "migration",
64
+ "grpc",
65
+ "webrtc",
66
+ "blockchain",
67
+ "web3",
68
+ "typescript",
69
+ "java",
70
+ "go",
71
+ "rust",
72
+ "swift",
73
+ "kotlin",
74
+ "dart",
75
+ "csharp",
76
+ "cpp",
77
+ "ruby",
78
+ "php"
60
79
  ],
61
80
  "author": "pirikari.sena@gmail.com",
62
81
  "license": "MIT",