Skip to content

Commit 741ba06

Browse files
committed
update to clarify what commands to use and what they can do
1 parent 94ea4e3 commit 741ba06

File tree

2 files changed

+323
-14
lines changed

2 files changed

+323
-14
lines changed

CLAUDE.md

Lines changed: 204 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,207 @@ nix build .#logos-app-poc --override-input logos-cpp-sdk path:./repos/logos-cpp-
168168
Available directly or as `ws` subcommands (e.g. `lgx` or `ws lgx`).
169169
Auto-build on first use, auto-rebuild when source files change. Only builds the specific binary, not the full repo.
170170

171-
- `lm` (logos-module) — module inspector: `lm metadata <plugin>`, `lm methods <plugin>`
172-
- `logoscore` (logos-liblogos) — headless runtime: `logoscore -m <dir> --load-modules <name>`
173-
- `lgx` (logos-package) — package tool: `lgx create`, `lgx add-variant`, `lgx list`, `lgx verify`
174-
- `lgpm` (logos-package-manager-module) — package manager: `lgpm install`, `lgpm search`, `lgpm list`
175-
- `logos-cpp-generator` (logos-cpp-sdk) — SDK code generator from plugin metadata
171+
### `logoscore` — headless module runtime (logos-liblogos)
172+
173+
Loads modules and optionally calls their methods. Essential for testing modules without the full GUI app.
174+
175+
```bash
176+
logoscore [options]
177+
-m, --modules-dir <path> Directory to scan for module plugins (repeatable)
178+
-l, --load-modules <mod1,mod2> Comma-separated modules to load (auto-resolves deps)
179+
-c, --call <module.method(args)> Call a method after loading (repeatable, sequential)
180+
-h, --help Show help
181+
--version Show version
182+
```
183+
184+
Method call syntax for `-c`: `module_name.method(arg1, arg2)`
185+
- Type auto-detection: `true`/`false` → bool, `42` → int, `3.14` → double, else → string
186+
- `@filename` loads file content as the argument (e.g. `@config.json`)
187+
- 30-second timeout per call; exit code 1 on failure
188+
189+
```bash
190+
# Load a module (auto-resolves transitive dependencies)
191+
logoscore -m ./modules --load-modules my_module
192+
193+
# Load and call a method
194+
logoscore -m ./modules -l my_module -c "my_module.doSomething(hello)"
195+
196+
# Sequential calls with file parameter
197+
logoscore -m ./modules -l storage_module \
198+
-c "storage_module.init(@config.json)" \
199+
-c "storage_module.start()"
200+
201+
# Multiple modules (deps resolved automatically)
202+
logoscore -m ./modules -l waku_module,chat,my_module
203+
```
204+
205+
### `lm` — module inspector (logos-module)
206+
207+
Introspects compiled Qt plugin files to show metadata and method signatures.
208+
209+
```bash
210+
lm [command] <plugin-path> [options]
211+
212+
Commands:
213+
(none) Show both metadata and methods
214+
metadata Show plugin metadata only
215+
methods Show exposed Q_INVOKABLE methods only
216+
217+
Options:
218+
--json Output structured JSON (works with all commands)
219+
--debug Show Qt debug output during plugin loading
220+
-h, --help Show help
221+
-v, --version
222+
```
223+
224+
```bash
225+
# Inspect a built module
226+
lm ./result/lib/my_module_plugin.so
227+
lm metadata ./result/lib/my_module_plugin.so
228+
lm methods ./result/lib/my_module_plugin.so --json
229+
230+
# JSON metadata output includes: name, version, description, author, type, dependencies
231+
# JSON methods output includes: name, signature, returnType, isInvokable, parameters[]
232+
```
233+
234+
### `lgx` — LGX package tool (logos-package)
235+
236+
Creates and manages `.lgx` packages (gzip tar archives with platform-specific variants).
237+
238+
```bash
239+
lgx <command> [options]
240+
241+
Commands:
242+
create <name> Create empty .lgx package
243+
add <pkg> -v <variant> -f <path> Add files to a variant (replaces if exists)
244+
--variant, -v <name> Variant name (e.g. linux-x86_64, darwin-arm64)
245+
--files, -f <path> File or directory to add
246+
--main, -m <relpath> Main entry point (required if --files is a directory)
247+
--yes, -y Skip confirmation prompts
248+
remove <pkg> -v <variant> Remove a variant
249+
extract <pkg> [-v <variant>] [-o <dir>] Extract variant(s)
250+
verify <pkg> Validate against LGX spec
251+
sign <pkg> (not yet implemented)
252+
publish <pkg> (not yet implemented)
253+
```
254+
255+
```bash
256+
# Create and populate a package
257+
lgx create my_module
258+
lgx add my_module.lgx -v linux-x86_64 -f ./result/lib/my_module_plugin.so
259+
lgx add my_module.lgx -v darwin-arm64 -f ./result/lib/my_module_plugin.dylib
260+
261+
# Add a directory variant with main entry point
262+
lgx add my_module.lgx -v web -f ./dist --main index.js -y
263+
264+
# Inspect and verify
265+
lgx verify my_module.lgx
266+
lgx extract my_module.lgx -v linux-x86_64 -o ./extracted
267+
```
268+
269+
### `lgpm` — package manager (logos-package-manager-module)
270+
271+
Installs, searches, and manages module packages. Fetches from GitHub releases with automatic dependency resolution.
272+
273+
```bash
274+
lgpm [global-options] <command> [options]
275+
276+
Global options:
277+
--modules-dir <path> Target directory for core modules
278+
--ui-plugins-dir <path> Target directory for UI plugins
279+
--release <tag> GitHub release tag (default: latest)
280+
--json Output JSON format
281+
-h, --help
282+
283+
Commands:
284+
search <query> Search packages by name/description
285+
list [--category <cat>] [--installed] List packages
286+
info <package> Show package details
287+
categories List available categories
288+
install <pkg> [pkgs...] Install packages (resolves deps automatically)
289+
--file <path> Install from local .lgx file instead
290+
```
291+
292+
```bash
293+
# Search and browse
294+
lgpm search waku
295+
lgpm list --installed
296+
lgpm list --category networking
297+
lgpm info my_module
298+
299+
# Install from registry (with automatic dep resolution)
300+
lgpm --modules-dir ./modules install my_module
301+
302+
# Install from local .lgx file
303+
lgpm --modules-dir ./modules install --file ./my_module.lgx
304+
305+
# Install specific release
306+
lgpm --modules-dir ./modules --release v2.0.0 install my_module
307+
```
308+
309+
## Creating a new module
310+
311+
Scaffold, build, test, package — the full lifecycle:
312+
313+
```bash
314+
# 1. Scaffold
315+
mkdir logos-my-module && cd logos-my-module
316+
nix flake init -t github:logos-co/logos-module-builder
317+
# Edit module.yaml (name, version, deps) and src/ files
318+
# For modules wrapping external C/C++ libs, use the #with-external-lib template instead
319+
320+
# 2. Build
321+
git init && git add -A # nix needs files tracked by git
322+
nix build # outputs: result/lib/<name>_plugin.so, result/include/
323+
324+
# 3. Inspect
325+
lm ./result/lib/my_module_plugin.so # metadata + methods
326+
lm methods ./result/lib/my_module_plugin.so --json # method signatures as JSON
327+
328+
# 4. Test with logoscore
329+
logoscore -m ./result/lib -l my_module -c "my_module.someMethod(arg)"
330+
331+
# 5. Package
332+
lgx create my_module
333+
lgx add my_module.lgx -v linux-x86_64 -f ./result/lib/my_module_plugin.so
334+
lgx verify my_module.lgx
335+
336+
# 6. Install locally
337+
lgpm --modules-dir ./test-modules install --file ./my_module.lgx
338+
339+
# 7. Run with other modules
340+
logoscore -m ./test-modules -l my_module -c "my_module.someMethod(test)"
341+
```
342+
343+
Key files in a module:
344+
- `module.yaml` — name, version, type, category, dependencies, nix_packages, external_libraries, cmake settings
345+
- `flake.nix`~15 lines, calls `logos-module-builder.lib.mkLogosModule`
346+
- `src/<name>_interface.h` — pure virtual interface (inherits `PluginInterface`)
347+
- `src/<name>_plugin.h``Q_OBJECT` + `Q_INVOKABLE` methods = public API
348+
- `src/<name>_plugin.cpp` — implementation
349+
- `CMakeLists.txt` — uses `logos_module()` macro from LogosModule.cmake
350+
351+
Every `Q_INVOKABLE` method is automatically discoverable by `lm`, callable by `logoscore -c`, and accessible from other modules via `LogosAPI`.
352+
353+
## Inter-module communication
354+
355+
Modules receive a `LogosAPI*` pointer via `initLogos()`. Use it to call other modules:
356+
357+
```cpp
358+
// Raw call
359+
LogosAPIClient* client = logosAPI->getClient("other_module");
360+
QVariant result = client->invokeRemoteMethod("other_module", "method", arg1, arg2);
361+
362+
// Or use generated type-safe wrappers (from logos-cpp-generator):
363+
LogosModules* logos = new LogosModules(logosAPI);
364+
QString result = logos->other_module.doSomething("hello");
365+
```
366+
367+
Return structured results with `LogosResult`:
368+
```cpp
369+
Q_INVOKABLE LogosResult fetchData(const QString& id) {
370+
if (id.isEmpty()) return {false, QVariant(), "ID cannot be empty"};
371+
QVariantMap data; data["id"] = id; data["count"] = 42;
372+
return {true, data};
373+
}
374+
```

README.md

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,127 @@ ws test --all --quiet
104104

105105
### CLI Tools
106106

107-
These are also in `scripts/` and auto-build from the local repo on first use. They rebuild automatically when source files change.
107+
These are also in `scripts/` and auto-build from the local repo on first use. They rebuild automatically when source files change. All are also available as `ws` subcommands (e.g. `ws lgx`, `ws lm`, `ws logoscore`).
108108

109-
| Command | Repo | Description |
110-
|---------|------|-------------|
111-
| `lm` | logos-module | Module inspector (`lm metadata <plugin>`, `lm methods <plugin>`) |
112-
| `logoscore` | logos-liblogos | Headless runtime (`logoscore -m <dir> --load-modules <name>`) |
113-
| `lgx` | logos-package | Package tool (`lgx create`, `lgx add-variant`, `lgx list`, `lgx verify`) |
114-
| `lgpm` | logos-package-manager-module | Package manager (`lgpm install`, `lgpm search`, `lgpm list`) |
115-
| `logos-cpp-generator` | logos-cpp-sdk | SDK code generator from plugin metadata |
109+
#### `logoscore` — headless module runtime (logos-liblogos)
110+
111+
Loads modules and calls their methods without the full GUI. Essential for testing.
112+
113+
```
114+
logoscore [options]
115+
-m, --modules-dir <path> Directory to scan for plugins (repeatable)
116+
-l, --load-modules <mod1,mod2> Comma-separated modules to load (auto-resolves deps)
117+
-c, --call <module.method(args)> Call a method after loading (repeatable, sequential)
118+
-h, --help Show help
119+
--version Show version
120+
```
121+
122+
Method call syntax for `-c`: `module_name.method(arg1, arg2)`
123+
- Type auto-detection: `true`/`false` → bool, `42` → int, `3.14` → double, else → string
124+
- `@filename` reads file content as the argument (e.g. `@config.json` for JSON configs)
125+
- 30-second timeout per call; exit code 1 on any failure
126+
127+
```bash
128+
# Load a module (auto-resolves transitive dependencies)
129+
logoscore -m ./modules --load-modules my_module
130+
131+
# Load and call a method
132+
logoscore -m ./modules -l my_module -c "my_module.doSomething(hello)"
133+
134+
# Sequential calls with a file parameter
135+
logoscore -m ./modules -l storage_module \
136+
-c "storage_module.init(@config.json)" \
137+
-c "storage_module.start()"
138+
139+
# Multiple modules — dependencies resolved automatically
140+
logoscore -m ./modules -l waku_module,chat,my_module
141+
```
142+
143+
#### `lm` — module inspector (logos-module)
144+
145+
Introspects compiled Qt plugin files to show metadata and method signatures.
146+
147+
```
148+
lm [command] <plugin-path> [options]
149+
150+
Commands:
151+
(default) Show both metadata and methods
152+
metadata Show plugin metadata only (name, version, description, author, type, deps)
153+
methods Show exposed Q_INVOKABLE methods only (name, signature, return type, params)
154+
155+
Options:
156+
--json Output structured JSON
157+
--debug Show Qt debug output during plugin loading
158+
-h, --help
159+
-v, --version
160+
```
161+
162+
```bash
163+
lm ./result/lib/my_module_plugin.so # everything
164+
lm metadata ./result/lib/my_module_plugin.so # metadata only
165+
lm methods ./result/lib/my_module_plugin.so --json # methods as JSON
166+
```
167+
168+
#### `lgx` — LGX package tool (logos-package)
169+
170+
Creates and manages `.lgx` packages (gzip tar archives with platform-specific variants).
171+
172+
```
173+
lgx <command> [options]
174+
175+
Commands:
176+
create <name> Create empty .lgx package
177+
add <pkg> -v <variant> -f <path> Add files to a variant (replaces if exists)
178+
--variant, -v <name> e.g. linux-x86_64, darwin-arm64
179+
--files, -f <path> File or directory to add
180+
--main, -m <relpath> Main entry point (required if --files is a dir)
181+
--yes, -y Skip confirmation prompts
182+
remove <pkg> -v <variant> Remove a variant
183+
extract <pkg> [-v <variant>] [-o <dir>] Extract variant(s)
184+
verify <pkg> Validate against LGX spec
185+
sign <pkg> (not yet implemented)
186+
publish <pkg> (not yet implemented)
187+
```
188+
189+
```bash
190+
lgx create my_module
191+
lgx add my_module.lgx -v linux-x86_64 -f ./result/lib/my_module_plugin.so
192+
lgx add my_module.lgx -v darwin-arm64 -f ./result/lib/my_module_plugin.dylib
193+
lgx verify my_module.lgx
194+
lgx extract my_module.lgx -v linux-x86_64 -o ./extracted
195+
```
196+
197+
#### `lgpm` — package manager (logos-package-manager-module)
198+
199+
Installs, searches, and manages module packages. Fetches from GitHub releases with automatic dependency resolution.
200+
201+
```
202+
lgpm [global-options] <command> [options]
116203
117-
All CLI tools are also available as `ws` subcommands (e.g. `ws lgx`, `ws lm`, `ws logoscore`).
204+
Global options:
205+
--modules-dir <path> Target directory for core modules
206+
--ui-plugins-dir <path> Target directory for UI plugins
207+
--release <tag> GitHub release tag (default: latest)
208+
--json Output JSON format
209+
-h, --help
210+
211+
Commands:
212+
search <query> Search packages by name/description
213+
list [--category <cat>] [--installed] List packages
214+
info <package> Show package details
215+
categories List available categories
216+
install <pkg> [pkgs...] Install packages (auto-resolves deps)
217+
--file <path> Install from local .lgx file instead
218+
```
219+
220+
```bash
221+
lgpm search waku
222+
lgpm list --installed
223+
lgpm info my_module
224+
lgpm --modules-dir ./modules install my_module # from registry
225+
lgpm --modules-dir ./modules install --file ./my_module.lgx # from local file
226+
lgpm --modules-dir ./modules --release v2.0.0 install my_module
227+
```
118228

119229
### Build/Run Options
120230

0 commit comments

Comments
 (0)