plainscript-lang 1.0.362 → 1.1.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.
Files changed (99) hide show
  1. package/README.md +394 -54
  2. package/compiler/bundler.js +78 -3
  3. package/compiler/cli.js +239 -30
  4. package/compiler/formatter.js +21 -1
  5. package/compiler/generator.js +453 -107
  6. package/compiler/ir.js +62 -0
  7. package/compiler/lexer.js +42 -7
  8. package/compiler/lsp.js +290 -0
  9. package/compiler/parser.js +820 -113
  10. package/compiler/type-checker.js +440 -0
  11. package/compiler/version.js +1 -1
  12. package/docs/CAPABILITY_GAP_AUDIT.md +19 -3
  13. package/docs/GAME-PROMPT.md +3 -3
  14. package/docs/PLAINSCRIPT-GRAMMAR.md +317 -0
  15. package/docs/PLAINSCRIPT-SPEC.md +264 -5
  16. package/docs/V1.1-TYPED-COLLECTIONS-DESIGN.md +220 -0
  17. package/docs/index.html +5 -5
  18. package/docs/website/script.js +1 -1
  19. package/examples/ai-memory-cli.pln +221 -0
  20. package/examples/ai-memory.json +1 -0
  21. package/examples/ai-providers.pln +1 -1
  22. package/examples/arrays.pln +1 -1
  23. package/examples/async-errors.pln +1 -1
  24. package/examples/auth-api.pln +1 -1
  25. package/examples/auth-sessions.pln +1 -1
  26. package/examples/basics.pln +1 -1
  27. package/examples/bots.pln +1 -1
  28. package/examples/browser-interactive/README.md +1 -1
  29. package/examples/browser-interactive/src/interactive.pln +1 -1
  30. package/examples/cache-and-jobs.pln +1 -1
  31. package/examples/cache-schedule.pln +1 -1
  32. package/examples/canvas-game/README.md +1 -1
  33. package/examples/canvas-game/src/game.pln +1 -1
  34. package/examples/collections.pln +1 -1
  35. package/examples/compound-assignments.pln +24 -0
  36. package/examples/concurrency.pln +2 -2
  37. package/examples/conditions.pln +1 -1
  38. package/examples/database.pln +1 -1
  39. package/examples/day2.pln +1 -1
  40. package/examples/day3.pln +1 -1
  41. package/examples/deployment.pln +1 -1
  42. package/examples/email-send.pln +1 -1
  43. package/examples/error-handling.pln +1 -1
  44. package/examples/expressions.pln +1 -1
  45. package/examples/file-manager-cli.pln +51 -0
  46. package/examples/file-uploads.pln +1 -1
  47. package/examples/files-and-config.pln +1 -1
  48. package/examples/files.pln +1 -1
  49. package/examples/football-backend/app.pln +1 -1
  50. package/examples/functions.pln +1 -1
  51. package/examples/hello.pln +1 -1
  52. package/examples/http-client.pln +1 -1
  53. package/examples/http.pln +1 -1
  54. package/examples/id-verification/app.pln +1 -1
  55. package/examples/interactive-cli.pln +34 -0
  56. package/examples/javascript-library/README.md +1 -1
  57. package/examples/javascript-library/src/interop.pln +1 -1
  58. package/examples/json.pln +1 -1
  59. package/examples/loops.pln +1 -1
  60. package/examples/memoize-demo.pln +31 -0
  61. package/examples/modules/app.pln +1 -1
  62. package/examples/modules/main.pln +1 -1
  63. package/examples/modules/math.pln +1 -1
  64. package/examples/mongo.pln +1 -1
  65. package/examples/normalization-forms.pln +22 -0
  66. package/examples/objects.pln +1 -1
  67. package/examples/ocr.pln +1 -1
  68. package/examples/packages.pln +1 -1
  69. package/examples/random-cli.pln +32 -0
  70. package/examples/record-kinds.pln +1 -1
  71. package/examples/records.pln +1 -1
  72. package/examples/rest-api-fetch.pln +1 -1
  73. package/examples/rest-api.pln +1 -1
  74. package/examples/run-in-parallel.pln +25 -0
  75. package/examples/scheduled-tasks.pln +1 -1
  76. package/examples/search-and-filter.pln +1 -1
  77. package/examples/server.pln +1 -1
  78. package/examples/sessions-and-cookies.pln +1 -1
  79. package/examples/sqlite.pln +1 -1
  80. package/examples/start.pln +1 -1
  81. package/examples/stats-cli.pln +29 -0
  82. package/examples/stdlib.pln +1 -1
  83. package/examples/string-helpers.pln +23 -0
  84. package/examples/string-verbs.pln +1 -1
  85. package/examples/telegram-ai-bot.pln +1 -1
  86. package/examples/telegram-bot.pln +1 -1
  87. package/examples/terminal-cli.pln +11 -0
  88. package/examples/testing.pln +1 -1
  89. package/examples/three-dimensional/README.md +1 -1
  90. package/examples/three-dimensional/src/scene.pln +1 -1
  91. package/examples/todo-cli.pln +98 -0
  92. package/examples/typed-collections.pln +21 -0
  93. package/examples/web-api.pln +1 -1
  94. package/examples/web-app.pln +1 -1
  95. package/examples/websocket-server.pln +1 -1
  96. package/examples/websocket.pln +1 -1
  97. package/examples/whatsapp-bot/pairing.pln +1 -1
  98. package/examples/whatsapp-bot/qr.pln +1 -1
  99. package/package.json +13 -4
@@ -0,0 +1,98 @@
1
+ // PlainScript 1.0.363 — a persistent to-do CLI.
2
+ // State lives in todos.json next to where you run the script.
3
+ //
4
+ // Usage:
5
+ // plainscript run examples/todo-cli.pln add "Write the release notes"
6
+ // plainscript run examples/todo-cli.pln list
7
+ // plainscript run examples/todo-cli.pln done 0
8
+ // plainscript run examples/todo-cli.pln remove 0
9
+
10
+ remember storeFile as "todos.json"
11
+
12
+ make loadTodos()
13
+ if fileExists(storeFile) is true
14
+ give jsonDecode(readFile(storeFile))
15
+ otherwise
16
+ give []
17
+ done
18
+ done
19
+
20
+ make saveTodos(todos)
21
+ writeFile(storeFile, jsonEncode(todos))
22
+ done
23
+
24
+ make label(todo)
25
+ if completed of todo is true
26
+ give "[x] " + text of todo
27
+ otherwise
28
+ give "[ ] " + text of todo
29
+ done
30
+ done
31
+
32
+ make showList(todos)
33
+ if count of todos is 0
34
+ show "nothing to do"
35
+ otherwise
36
+ remember i as 0
37
+ for each todo in todos
38
+ show i + ": " + label(todo)
39
+ i += 1
40
+ done
41
+ done
42
+ done
43
+
44
+ make main()
45
+ remember argv as args()
46
+ remember todos as loadTodos()
47
+ if count of argv is 0
48
+ show "usage: todo-cli.pln <add|list|done|remove> [text|index]"
49
+ exit(0)
50
+ done
51
+ remember command as argv at position 0
52
+ if command is "add"
53
+ if count of argv is at least 2
54
+ push(todos, { text: argv at position 1, completed: false })
55
+ saveTodos(todos)
56
+ show "added: " + argv at position 1
57
+ otherwise
58
+ show "usage: ... add <text>"
59
+ done
60
+ otherwise if command is "list"
61
+ showList(todos)
62
+ otherwise if command is "done"
63
+ if count of argv is at least 2
64
+ remember target as parseInt(argv at position 1, 10)
65
+ remember i as 0
66
+ for each todo in todos
67
+ if i is target
68
+ completed of todo becomes true
69
+ done
70
+ i += 1
71
+ done
72
+ saveTodos(todos)
73
+ show "completed item " + target
74
+ otherwise
75
+ show "usage: ... done <index>"
76
+ done
77
+ otherwise if command is "remove"
78
+ if count of argv is at least 2
79
+ remember target as parseInt(argv at position 1, 10)
80
+ remember kept as []
81
+ remember i as 0
82
+ for each todo in todos
83
+ if i different from target
84
+ push(kept, todo)
85
+ done
86
+ i += 1
87
+ done
88
+ saveTodos(kept)
89
+ show "removed item " + target
90
+ otherwise
91
+ show "usage: ... remove <index>"
92
+ done
93
+ otherwise
94
+ show "unknown command: " + command
95
+ done
96
+ done
97
+
98
+ main()
@@ -0,0 +1,21 @@
1
+ type User
2
+ id is number
3
+ name is text
4
+ done
5
+
6
+ let users as list of User is [
7
+ { id: 1, name: "Ada" },
8
+ { id: 2, name: "Grace" }
9
+ ]
10
+
11
+ let usersById as dictionary of User is {
12
+ first: { id: 1, name: "Ada" },
13
+ second: { id: 2, name: "Grace" }
14
+ }
15
+
16
+ make firstUser() returns User
17
+ give users[0]
18
+ done
19
+
20
+ show firstUser().name
21
+ show usersById.first.name
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: web apps, routes, JSON, and status codes.
1
+ // PlainScript 1.0.363: web apps, routes, JSON, and status codes.
2
2
 
3
3
  web app
4
4
  allow cors
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: web application.
1
+ // PlainScript 1.0.363: web application.
2
2
  web app
3
3
  route get "/health"
4
4
  reply json
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: WebSocket server.
1
+ // PlainScript 1.0.363: WebSocket server.
2
2
  websocket server on 8080
3
3
  when socket connects
4
4
  send socket "connected"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: WebSocket server handlers.
1
+ // PlainScript 1.0.363: WebSocket server handlers.
2
2
 
3
3
  websocket server on 8080
4
4
  when socket connects
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: WhatsApp pairing login.
1
+ // PlainScript 1.0.363: WhatsApp pairing login.
2
2
  // Showcases `use baileys`, message.type branching, media downloads,
3
3
  // and button/list reply handling.
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.362: WhatsApp QR login.
1
+ // PlainScript 1.0.363: WhatsApp QR login.
2
2
  // Showcases `use baileys`, message.type branching, media downloads,
3
3
  // and button handling.
4
4
 
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "plainscript-lang",
3
- "version": "1.0.362",
3
+ "version": "1.1.0",
4
4
  "description": "PlainScript - an Intent-Oriented Programming Language. When even a simple sentence can be code.",
5
5
  "main": "compiler/cli.js",
6
6
  "bin": {
7
- "plainscript": "./compiler/cli.js"
7
+ "plainscript": "./compiler/cli.js",
8
+ "plainscript-lsp": "./compiler/lsp.js"
8
9
  },
9
10
  "scripts": {
10
- "test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/docs.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js && node tests/packaging.test.js"
11
+ "test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/assignment.test.js && node tests/primitives.test.js && node tests/concurrency.test.js && node tests/terminal.test.js && node tests/cli.test.js && node tests/docs.test.js && node tests/types.test.js && node tests/ir.test.js && node tests/lsp.test.js && node tests/parser-robustness.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js && node tests/torture.test.js && node tests/packaging.test.js && node tools/verify-all-docs.js",
12
+ "docs:check": "node tools/verify-all-docs.js"
11
13
  },
12
14
  "files": [
13
15
  "compiler",
@@ -39,7 +41,14 @@
39
41
  "sql.js": "^1.13.0",
40
42
  "ws": "^8.21.3"
41
43
  },
42
- "dependencies": {},
44
+ "dependencies": {
45
+ "@whiskeysockets/baileys": "^7.0.0-rc14",
46
+ "axios": "^1.20.0",
47
+ "mrz": "^5.0.2",
48
+ "pg": "^8.23.0",
49
+ "qrcode-terminal": "^0.12.0",
50
+ "three": "^0.186.0"
51
+ },
43
52
  "optionalDependencies": {
44
53
  "better-sqlite3": "^11.10.0",
45
54
  "mongodb": "^6.20.0",