libmodulor 0.2.0 → 0.4.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 (57) hide show
  1. package/.github/ISSUE_TEMPLATE/generic-issue.md +16 -0
  2. package/CHANGELOG.md +31 -0
  3. package/README.md +7 -182
  4. package/dist/esm/index.react-native-pure.d.ts +10 -0
  5. package/dist/esm/index.react-native-pure.js +10 -0
  6. package/dist/esm/target/lib/react/entrypoint.d.ts +2 -0
  7. package/dist/esm/target/lib/rn/input.d.ts +8 -0
  8. package/dist/esm/target/lib/rn/input.js +26 -0
  9. package/dist/esm/target/node-express-server/NodeExpressServerManager.js +4 -1
  10. package/dist/esm/target/react-native-pure/UCAutoExecLoader.d.ts +2 -0
  11. package/dist/esm/target/react-native-pure/UCAutoExecLoader.js +5 -0
  12. package/dist/esm/target/react-native-pure/UCEntrypointTouchable.d.ts +4 -0
  13. package/dist/esm/target/react-native-pure/UCEntrypointTouchable.js +6 -0
  14. package/dist/esm/target/react-native-pure/UCExecTouchable.d.ts +4 -0
  15. package/dist/esm/target/react-native-pure/UCExecTouchable.js +9 -0
  16. package/dist/esm/target/react-native-pure/UCForm.d.ts +4 -0
  17. package/dist/esm/target/react-native-pure/UCForm.js +13 -0
  18. package/dist/esm/target/react-native-pure/UCFormField.d.ts +11 -0
  19. package/dist/esm/target/react-native-pure/UCFormField.js +32 -0
  20. package/dist/esm/target/react-native-pure/UCFormFieldControl.d.ts +11 -0
  21. package/dist/esm/target/react-native-pure/UCFormFieldControl.js +36 -0
  22. package/dist/esm/target/react-native-pure/UCFormFieldDesc.d.ts +7 -0
  23. package/dist/esm/target/react-native-pure/UCFormFieldDesc.js +11 -0
  24. package/dist/esm/target/react-native-pure/UCFormFieldErr.d.ts +7 -0
  25. package/dist/esm/target/react-native-pure/UCFormFieldErr.js +5 -0
  26. package/dist/esm/target/react-native-pure/UCFormFieldLabel.d.ts +7 -0
  27. package/dist/esm/target/react-native-pure/UCFormFieldLabel.js +8 -0
  28. package/dist/esm/target/react-native-pure/UCFormSubmitControl.d.ts +9 -0
  29. package/dist/esm/target/react-native-pure/UCFormSubmitControl.js +8 -0
  30. package/dist/esm/target/react-web-pure/UCEntrypointTouchable.d.ts +1 -1
  31. package/dist/esm/target/react-web-pure/UCExecTouchable.d.ts +1 -1
  32. package/dist/esm/target/react-web-pure/UCExecTouchable.js +1 -1
  33. package/dist/esm/target/react-web-pure/UCFormFieldControl.d.ts +1 -1
  34. package/dist/esm/target/react-web-pure/UCFormFieldControl.js +3 -3
  35. package/dist/esm/uc/ext.d.ts +3 -1
  36. package/dist/esm/uc/helpers/UCOutputReader.d.ts +1 -1
  37. package/dist/esm/uc/helpers/UCOutputReader.js +4 -2
  38. package/dist/esm/uc/output-part.d.ts +2 -1
  39. package/dist/esm/uc/utils/ucHTTPContract.d.ts +1 -0
  40. package/dist/esm/uc/utils/ucHTTPContract.js +5 -0
  41. package/package.json +12 -5
  42. package/docs/assets/trading-buy-asset-sequence-diagram.png +0 -0
  43. package/docs/assets/trading-target-mcp-server.png +0 -0
  44. package/docs/assets/trading-target-web-human.png +0 -0
  45. package/docs/assets/trading-target-web.png +0 -0
  46. package/docs/getting-started/001_Create_the_project.md +0 -168
  47. package/docs/getting-started/002_Create_the_App.md +0 -49
  48. package/docs/getting-started/003_Create_the_UseCase.md +0 -205
  49. package/docs/getting-started/004_Test_the_App.md +0 -114
  50. package/docs/getting-started/005_Create_the_Product.md +0 -46
  51. package/docs/getting-started/006_Create_the_server_Target.md +0 -130
  52. package/docs/getting-started/007_Create_the_web_Target.md +0 -262
  53. package/docs/getting-started/008_Switch_to_a_persistent_data_storage.md +0 -52
  54. package/docs/getting-started/009_Define_wording_for_humans.md +0 -42
  55. package/docs/getting-started/010_Create_the_cli_Target.md +0 -102
  56. package/docs/getting-started/011_Create_the_mcp_server_Target.md +0 -157
  57. package/docs/getting-started/012_Summary.md +0 -29
@@ -1,102 +0,0 @@
1
- # Create the cli Target
2
-
3
- We'll use the pre-built [Node.js parseArgs](https://nodejs.org/api/util.html#utilparseargsconfig) CLI program.
4
-
5
- ```sh
6
- mkdir src/products/SuperTrader/cli
7
- touch src/products/SuperTrader/cli/{container.ts,index.ts}
8
- ```
9
-
10
- ## container.ts
11
-
12
- ```typescript
13
- import {
14
- CONTAINER_OPTS,
15
- type ServerClientManagerSettings,
16
- TARGET_DEFAULT_SERVER_CLIENT_MANAGER_SETTINGS,
17
- bindCommon,
18
- bindProduct,
19
- } from 'libmodulor';
20
- import { bindNodeCLI, bindNodeCore } from 'libmodulor/node';
21
- import { Container } from 'inversify';
22
-
23
- import { I18n } from '../i18n.js';
24
- import { Manifest } from '../manifest.js';
25
-
26
- const container = new Container(CONTAINER_OPTS);
27
-
28
- bindCommon<ServerClientManagerSettings>(container, () => ({
29
- ...TARGET_DEFAULT_SERVER_CLIENT_MANAGER_SETTINGS,
30
- }));
31
- bindNodeCore(container);
32
- bindNodeCLI(container);
33
- bindProduct(container, Manifest, I18n);
34
-
35
- export default container;
36
- ```
37
-
38
- ## index.ts
39
-
40
- ```typescript
41
- import {
42
- APPS_ROOT_DIR_NAME,
43
- type FSManager,
44
- type I18nManager,
45
- } from 'libmodulor';
46
- import { NodeCoreCLIManager } from 'libmodulor/node';
47
-
48
- import container from './container.js';
49
-
50
- await container.get<I18nManager>('I18nManager').init();
51
-
52
- await container.resolve(NodeCoreCLIManager).handleCommand({
53
- appsRootPath: container
54
- .get<FSManager>('FSManager')
55
- .path('..', '..', '..', APPS_ROOT_DIR_NAME),
56
- srcImporter: (path) => import(path),
57
- });
58
- ```
59
-
60
- ## Build & Run
61
-
62
- Update `package.json` to add a new entry to the `scripts`.
63
-
64
- ```json
65
- "run:cli": "cd dist/products/SuperTrader/cli && node index.js",
66
- ```
67
-
68
- ```sh
69
- yarn build && yarn run:cli
70
- ```
71
-
72
- You can see the CLI help appearing with the available commands.
73
-
74
- > [!TIP]
75
- > Update the app's `i18n.ts` to add `uc_BuyAsset_desc` and `ucif_isin_desc` to have a more detailed help section.
76
-
77
- Start the server if it's not running.
78
-
79
- ```sh
80
- yarn run:server
81
- ```
82
-
83
- Execute the CLI in another terminal or tab.
84
-
85
- ```sh
86
- yarn run:cli BuyAsset
87
- # ❌ ISIN must be filled
88
- yarn run:cli BuyAsset --isin US02079K3059 --limit 123.5 --qty 150
89
- # ✅ {"parts":{"_0":{"items":[{"executedDirectly":false,"id":"da3dc295-6d7c-41b1-a00a-62683f3e6ab9"}],"total":1}}}
90
- ```
91
-
92
- Open the SQLite database with you with your favorite DB editor (e.g. TablePlus, DBeaver...).
93
-
94
- ```sh
95
- open dist/products/SuperTrader/server/uc-data-store.sqlite
96
- ```
97
-
98
- ```sh
99
- yarn lint && git add . && git commit -m "feat: add the cli target"
100
- ```
101
-
102
- Now that's done, let's [Create the mcp-server Target](./011_Create_the_mcp_server_Target.md).
@@ -1,157 +0,0 @@
1
- # Create the mcp-server Target
2
-
3
- We'll use the pre-built local [stdio transport](https://modelcontextprotocol.io/docs/concepts/transports#standard-input-output-stdio) server.
4
-
5
- ```sh
6
- yarn add "@modelcontextprotocol/sdk@^1.1.1"
7
- ```
8
-
9
- ```sh
10
- mkdir src/products/SuperTrader/mcp-server
11
- touch src/products/SuperTrader/mcp-server/{container.ts,index.ts}
12
- ```
13
-
14
- ## container.ts
15
-
16
- ```typescript
17
- import {
18
- CONTAINER_OPTS,
19
- type ServerClientManagerSettings,
20
- type ServerManager,
21
- TARGET_DEFAULT_SERVER_CLIENT_MANAGER_SETTINGS,
22
- bindCommon,
23
- bindProduct,
24
- } from 'libmodulor';
25
- import { bindNodeCore, bindServer } from 'libmodulor/node';
26
- import { NodeLocalStdioMCPServerManager } from 'libmodulor/node-mcp';
27
- import { Container } from 'inversify';
28
-
29
- import { I18n } from '../i18n.js';
30
- import { Manifest } from '../manifest.js';
31
-
32
- type S = ServerClientManagerSettings;
33
-
34
- const container = new Container(CONTAINER_OPTS);
35
-
36
- bindCommon<S>(container, () => ({
37
- ...TARGET_DEFAULT_SERVER_CLIENT_MANAGER_SETTINGS,
38
- logger_level: 'error',
39
- }));
40
- bindNodeCore(container);
41
- bindServer(container);
42
- bindProduct(container, Manifest, I18n);
43
-
44
- container
45
- .bind<ServerManager>('ServerManager')
46
- .to(NodeLocalStdioMCPServerManager);
47
-
48
- export default container;
49
- ```
50
-
51
- ## index.ts
52
-
53
- ```typescript
54
- import {
55
- APPS_ROOT_DIR_NAME,
56
- type FSManager,
57
- type I18nManager,
58
- } from 'libmodulor';
59
- import { MCPServerBooter } from 'libmodulor/node-mcp';
60
-
61
- import container from './container.js';
62
-
63
- await container.get<I18nManager>('I18nManager').init();
64
-
65
- await container.resolve(MCPServerBooter).exec({
66
- appsRootPath: container
67
- .get<FSManager>('FSManager')
68
- .path('..', '..', '..', APPS_ROOT_DIR_NAME),
69
- srcImporter: (path) => import(path),
70
- });
71
- ```
72
-
73
- > [!NOTE]
74
- > Note how we increase the level of logs to `error` because logging on stdout [messes with the stdio transport](https://modelcontextprotocol.io/docs/tools/debugging#server-side-logging).
75
-
76
- ## Claude Desktop
77
-
78
- If you don't have [Claude Desktop](https://claude.ai/download) on your machine, install it.
79
-
80
- The following instructions are for macOS. You might need to adapt the paths if you are using another OS.
81
-
82
- Register the mcp server in Claude (make sure you adapt the absolute path to your `libmodulor-tuto` directory).
83
-
84
- ```sh
85
- nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
86
- ```
87
-
88
- ```json
89
- {
90
- "mcpServers": {
91
- "libmodulor-tuto": {
92
- "command": "node",
93
- "args": [
94
- "/Users/toto/libmodulor-tuto/dist/products/SuperTrader/mcp-server/index.js"
95
- ]
96
- }
97
- }
98
- }
99
- ```
100
-
101
- If you want to enable debugging within Claude Desktop :
102
-
103
- ```sh
104
- nano ~/Library/Application\ Support/Claude/developer_settings.json
105
- ```
106
-
107
- ```json
108
- {
109
- "allowDevTools": true
110
- }
111
- ```
112
-
113
- To vizualize the logs :
114
-
115
- ```sh
116
- ls -la ~/Library/Logs/Claude
117
- tail -f ~/Library/Logs/Claude/mcp.log
118
- tail -f ~/Library/Logs/Claude/mcp-server-libmodulor-tuto.log
119
- ```
120
-
121
- To open the Chrome Developer Tools wihtin Claude, press <kbd>cmd</kbd> + <kbd>option</kbd> + <kbd>shift</kbd> + <kbd>I</kbd> (should be easy if you're an emacs user).
122
-
123
- ## Build & Run
124
-
125
- Press <kbd>ctrl</kbd> + <kbd>C</kbd> to stop the server.
126
-
127
- ```sh
128
- yarn build && yarn run:server
129
- ```
130
-
131
- Launch Claude Desktop.
132
-
133
- At the bottom right of the prompt you should see a little hammer 🔨 indicating `1 MCP Tool available`.
134
-
135
- Click on it. You should see the `BuyAsset` use case registered.
136
-
137
- Now just write a prompt like below :
138
-
139
- ```txt
140
- Dear Claude. Please buy 150 shares of Google.
141
- ```
142
-
143
- And let the magic happens.
144
-
145
- <img src="/docs/assets/trading-target-mcp-server.png" width="600px">
146
-
147
- Open the SQLite database with you with your favorite DB editor (e.g. TablePlus, DBeaver...).
148
-
149
- ```sh
150
- open dist/products/SuperTrader/server/uc-data-store.sqlite
151
- ```
152
-
153
- ```sh
154
- yarn lint && git add . && git commit -m "feat: add the mcp-server target"
155
- ```
156
-
157
- For now, we're done. Let's review what we've built : [Summary](./012_Summary.md).
@@ -1,29 +0,0 @@
1
- # Summary
2
-
3
- ```sh
4
- git log --oneline
5
- ```
6
-
7
- ```sh
8
- 7be4e06 (HEAD -> master) feat: add the mcp-server target
9
- 0fb3d57 feat: add the cli target
10
- e8a52a6 feat: define wording for humans
11
- 3d41f82 feat: persist data in SQLite
12
- d55bc42 feat: add the web target
13
- 1af90ea feat: add the server target
14
- dffa202 feat: add the product
15
- 8b83e1f test: init app tests
16
- 0f99382 feat: add the use case
17
- 33ac247 feat: add the app
18
- 09909aa chore: init source code
19
- ```
20
-
21
- That was cool ! In a couple of minutes we have created the foundations of a multi-platform application.
22
-
23
- And we have only touched the surface as `libmodulor` has much more to offer.
24
-
25
- We have used the "pre-built" targets, but it's totally possible to do the same with a Hono server, a stricli CLI, a Vue.js SPA and so on. All the targets implement generic interfaces provided by `libmodulor`, making the whole thing fully modular.
26
-
27
- Coming soon : the Advanced Guide.
28
-
29
- If you appreciated this Guide or have any feedback, of all kinds, please feel free to send me a message. I'll be happy to discuss and help.