@vizualmodel/vmblu-cli 0.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.
- package/LICENSE.txt +201 -0
- package/README.md +59 -0
- package/bin/vmblu.js +47 -0
- package/commands/init/index.js +45 -0
- package/commands/init/init-project.js +288 -0
- package/commands/init/make-package-json.js +59 -0
- package/package.json +8 -0
- package/templates/0.8.2/seed.md +17 -0
- package/templates/0.8.2/srcdoc.schema.json +74 -0
- package/templates/0.8.2/vmblu.annex.md +93 -0
- package/templates/0.8.2/vmblu.schema.json +268 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Sam Verstraete, vizualmodel organization
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# CLI for vmblu
|
|
2
|
+
This folder contains the CLI commands that are available for vmblu. Currently there is only the 'init' and 'help' command, but others will follow.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Folder layout
|
|
6
|
+
|
|
7
|
+
```txt
|
|
8
|
+
vmblu/
|
|
9
|
+
cli/ # your CLI source
|
|
10
|
+
commands/
|
|
11
|
+
init/
|
|
12
|
+
migrate/
|
|
13
|
+
templates/
|
|
14
|
+
0.8.2/
|
|
15
|
+
vmblu.schema.json
|
|
16
|
+
vmblu.annex.md
|
|
17
|
+
seed.md
|
|
18
|
+
srcdoc.schema.json
|
|
19
|
+
bin/
|
|
20
|
+
vmblu.js # the executable (router)
|
|
21
|
+
package.json
|
|
22
|
+
README.md
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Add more commands
|
|
26
|
+
|
|
27
|
+
Create commands/migrate/index.js with the same export shape { command, describe, builder, handler }. The router auto-discovers it, so users can run vmblu migrate ….
|
|
28
|
+
|
|
29
|
+
## Dev/test workflow
|
|
30
|
+
|
|
31
|
+
### from vmblu/cli
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm link # exposes "vmblu" globally
|
|
35
|
+
vmblu init my-app --schema 0.8.2
|
|
36
|
+
vmblu --help
|
|
37
|
+
vmblu init --help
|
|
38
|
+
```
|
|
39
|
+
### Publish & use
|
|
40
|
+
```bash
|
|
41
|
+
npm publish --access public
|
|
42
|
+
```
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx @vizualmodel/vmblu-cli init my-app --schema 0.8.2
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**or, after global install:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
vmblu init my-app
|
|
53
|
+
```
|
|
54
|
+
## Tips
|
|
55
|
+
|
|
56
|
+
* Keep templates inside the package and list them in "files" so npx works offline.
|
|
57
|
+
* If you later prefer a richer UX, you can swap the router to commander/yargs without changing your command folders.
|
|
58
|
+
* If your main repo houses both runtime and CLI, publish the CLI from vmblu/cli (separate package.json). This keeps runtime installs lean.
|
|
59
|
+
* This gives you one tidy package for all current and future commands, with zero drift and easy discoverability.
|
package/bin/vmblu.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* Minimal subcommand router: vmblu <command> [args] */
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const root = path.join(__dirname, '..');
|
|
7
|
+
const commandsDir = path.join(root, 'commands');
|
|
8
|
+
|
|
9
|
+
function printGlobalHelp() {
|
|
10
|
+
const cmds = fs.readdirSync(commandsDir)
|
|
11
|
+
.filter(n => fs.existsSync(path.join(commandsDir, n, 'index.js')));
|
|
12
|
+
console.log(`vmblu <command> [options]
|
|
13
|
+
|
|
14
|
+
Commands:
|
|
15
|
+
${cmds.map(c => `- ${c}`).join('\n ')}
|
|
16
|
+
|
|
17
|
+
Run "vmblu <command> --help" for details.`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function run() {
|
|
21
|
+
const [,, cmd, ...rest] = process.argv;
|
|
22
|
+
|
|
23
|
+
if (!cmd || ['-h','--help','help'].includes(cmd)) {
|
|
24
|
+
printGlobalHelp(); process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
if (['-v','--version','version'].includes(cmd)) {
|
|
27
|
+
console.log(require(path.join(root, 'package.json')).version); process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const entry = path.join(commandsDir, cmd, 'index.js');
|
|
31
|
+
if (!fs.existsSync(entry)) {
|
|
32
|
+
console.error(`Unknown command: ${cmd}\n`); printGlobalHelp(); process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const mod = require(entry);
|
|
36
|
+
// Optional per-command help
|
|
37
|
+
if (rest.includes('--help') || rest.includes('-h')) {
|
|
38
|
+
console.log(`vmblu ${mod.command}\n\n${mod.describe}\n\nOptions:\n${(mod.builder || []).map(o => ` ${o.flag}\t${o.desc}`).join('\n')}`);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
await mod.handler(rest);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
run().catch(err => {
|
|
45
|
+
console.error(err?.stack || String(err));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// vmblu init [targetDir] --name <project> --schema <ver> --force --dry-run
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { initProject } = require('./init-project');
|
|
4
|
+
|
|
5
|
+
exports.command = 'init';
|
|
6
|
+
exports.describe = 'Scaffold an empty vmblu project';
|
|
7
|
+
exports.builder = [
|
|
8
|
+
{ flag: '--name <project>', desc: 'Project name (default: folder name)' },
|
|
9
|
+
{ flag: '--schema <ver>', desc: 'Schema version (default: 0.8.2)' },
|
|
10
|
+
{ flag: '--force', desc: 'Overwrite existing files' },
|
|
11
|
+
{ flag: '--dry-run', desc: 'Show actions without writing' }
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
exports.handler = async (argv) => {
|
|
15
|
+
// tiny arg parse (no deps)
|
|
16
|
+
const args = { _: [] };
|
|
17
|
+
for (let i=0;i<argv.length;i++) {
|
|
18
|
+
const a = argv[i];
|
|
19
|
+
if (a === '--force') args.force = true;
|
|
20
|
+
else if (a === '--dry-run') args.dryRun = true;
|
|
21
|
+
else if (a === '--name') args.name = argv[++i];
|
|
22
|
+
else if (a === '--schema') args.schema = argv[++i];
|
|
23
|
+
else if (!a.startsWith('-')) args._.push(a);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const targetDir = path.resolve(args._[0] || '.');
|
|
27
|
+
const projectName = args.name || path.basename(targetDir);
|
|
28
|
+
const schemaVersion = args.schema || '0.8.2';
|
|
29
|
+
|
|
30
|
+
await initProject({
|
|
31
|
+
targetDir,
|
|
32
|
+
projectName,
|
|
33
|
+
schemaVersion,
|
|
34
|
+
force: !!args.force,
|
|
35
|
+
dryRun: !!args.dryRun,
|
|
36
|
+
templatesDir: path.join(__dirname, '..', '..', 'templates'),
|
|
37
|
+
ui: {
|
|
38
|
+
info: (m) => console.log(m),
|
|
39
|
+
warn: (m) => console.warn(m),
|
|
40
|
+
error: (m) => console.error(m)
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
console.log(`✔ vmblu project scaffolded in ${targetDir}`);
|
|
45
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// core/initProject.js
|
|
2
|
+
// Node 18+ (fs/promises, crypto). No external deps.
|
|
3
|
+
const fs = require('fs/promises');
|
|
4
|
+
const fssync = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
//const crypto = require('crypto');
|
|
7
|
+
const pckg = require('./make-package-json');
|
|
8
|
+
|
|
9
|
+
function rel(from, to) {
|
|
10
|
+
return path.posix.join(...path.relative(from, to).split(path.sep));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function exists(p) {
|
|
14
|
+
try { await fs.access(p); return true; } catch { return false; }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function ensureDir(dir, dry) {
|
|
18
|
+
if (dry) return;
|
|
19
|
+
await fs.mkdir(dir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function writeFileSafe(file, contents, { force = false, dry = false } = {}) {
|
|
23
|
+
const already = await exists(file);
|
|
24
|
+
if (already && !force) return false;
|
|
25
|
+
if (dry) return true;
|
|
26
|
+
await fs.writeFile(file, contents);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function copyOrWriteFallback(src, dst, fallback, { force = false, dry = false } = {}) {
|
|
31
|
+
const already = await exists(dst);
|
|
32
|
+
if (already && !force) return false;
|
|
33
|
+
|
|
34
|
+
if (dry) return true;
|
|
35
|
+
|
|
36
|
+
if (src && fssync.existsSync(src)) {
|
|
37
|
+
await fs.copyFile(src, dst);
|
|
38
|
+
} else {
|
|
39
|
+
await fs.writeFile(dst, fallback);
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// async function sha256(file) {
|
|
45
|
+
// const buf = await fs.readFile(file);
|
|
46
|
+
// return crypto.createHash('sha256').update(buf).digest('hex');
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
function defaultModel(projectName) {
|
|
50
|
+
const now = new Date().toISOString();
|
|
51
|
+
return JSON.stringify({
|
|
52
|
+
header: {
|
|
53
|
+
version: "0.8.2",
|
|
54
|
+
created: now,
|
|
55
|
+
saved: now,
|
|
56
|
+
utc: now,
|
|
57
|
+
style: "#2c7be5",
|
|
58
|
+
runtime: "@vizualmodel/vmblu/runtime",
|
|
59
|
+
description: `${projectName} — vmblu model (scaffolded)`
|
|
60
|
+
},
|
|
61
|
+
models: [],
|
|
62
|
+
factories: [],
|
|
63
|
+
root: {
|
|
64
|
+
group: "Root",
|
|
65
|
+
pins: [],
|
|
66
|
+
nodes: [],
|
|
67
|
+
routes: [],
|
|
68
|
+
prompt: "Root group for the application."
|
|
69
|
+
}
|
|
70
|
+
}, null, 2);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function defaultDoc(projectName) {
|
|
74
|
+
const now = new Date().toISOString();
|
|
75
|
+
return JSON.stringify({
|
|
76
|
+
project: projectName,
|
|
77
|
+
generator: "vmblu-docgen",
|
|
78
|
+
generatorVersion: "0.0.0",
|
|
79
|
+
created: now,
|
|
80
|
+
files: [],
|
|
81
|
+
nodes: [],
|
|
82
|
+
pins: [],
|
|
83
|
+
handlers: []
|
|
84
|
+
}, null, 2);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fallbackAnnex() {
|
|
88
|
+
return `# vmblu Annex (placeholder)
|
|
89
|
+
This is a minimal scaffold. Replace with the official annex matching your pinned schema version.
|
|
90
|
+
|
|
91
|
+
- Nodes: Source, Group, Dock
|
|
92
|
+
- Pins: input/output/channel, 'profile' describes payloads
|
|
93
|
+
- Routes: "output@NodeA" -> "input@NodeB" (or via group pads)
|
|
94
|
+
- Keep names normalized; avoid ambiguous magic.
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function fallbackSchema() {
|
|
99
|
+
return `{
|
|
100
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
101
|
+
"title": "vmblu.schema (placeholder)",
|
|
102
|
+
"type": "object",
|
|
103
|
+
"description": "Placeholder schema. Replace with official version."
|
|
104
|
+
}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function fallbackSrcdocSchema() {
|
|
108
|
+
return `{
|
|
109
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
110
|
+
"title": "srcdoc.schema (placeholder)",
|
|
111
|
+
"type": "object",
|
|
112
|
+
"description": "Placeholder schema. Replace with official version."
|
|
113
|
+
}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function fallbackSeed() {
|
|
117
|
+
return `# Session Seed (System Prompt)
|
|
118
|
+
|
|
119
|
+
vmblu (Vizual Model Blueprint) is a graphical editor that maintains a visual, runnable model of a software system.
|
|
120
|
+
vmblu models software as interconnected nodes that pass messages via pins.
|
|
121
|
+
The model has a well defined format described by a schema. An additional annex gives semantic background information about the schema.
|
|
122
|
+
The parameter profiles of messages and where in the actual source code messages are received and sent, is stored in a second file, the srcdoc file.
|
|
123
|
+
The srcdoc file is generated automatically by vmblu and is only to be consulted, not written.
|
|
124
|
+
|
|
125
|
+
You are an expert **architecture + code copilot** for **vmblu** .
|
|
126
|
+
You can find the location of the model file, the model schema, the model annex, the srcdoc file and the srcdoc schema in the 'manifest.json' file of this project.
|
|
127
|
+
The location of all other files in the project can be found via the model file.
|
|
128
|
+
|
|
129
|
+
Your job is to co-design the architecture and the software for the system.
|
|
130
|
+
For modifications of the model, always follow the schema.
|
|
131
|
+
If the srcdoc does not contain profile information it could be that the code for a message has not been written yet, this should not stop you from continuing
|
|
132
|
+
`}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Initialize a vmblu project directory.
|
|
136
|
+
*
|
|
137
|
+
* @param {Object} opts
|
|
138
|
+
* @param {string} opts.targetDir Absolute path to project dir (created if missing)
|
|
139
|
+
* @param {string} [opts.projectName] Defaults to basename(targetDir)
|
|
140
|
+
* @param {string} [opts.schemaVersion] e.g. "0.8.2"
|
|
141
|
+
* @param {boolean}[opts.force] Overwrite existing files
|
|
142
|
+
* @param {boolean}[opts.dryRun] Print actions, do not write
|
|
143
|
+
* @param {string} [opts.templatesDir] Root where templates live (defaults to package templates)
|
|
144
|
+
* expects:
|
|
145
|
+
* templates/schemas/<ver>/vmblu.schema.json
|
|
146
|
+
* templates/annex/<ver>/vmblu.annex.md
|
|
147
|
+
* @param {Object} [opts.ui] { info, warn, error } callbacks (optional)
|
|
148
|
+
*/
|
|
149
|
+
async function initProject(opts) {
|
|
150
|
+
const {
|
|
151
|
+
targetDir,
|
|
152
|
+
projectName = path.basename(opts.targetDir),
|
|
153
|
+
schemaVersion = "0.8.2",
|
|
154
|
+
force = false,
|
|
155
|
+
dryRun = false,
|
|
156
|
+
templatesDir = path.join(__dirname, '..', 'templates'),
|
|
157
|
+
ui = {
|
|
158
|
+
info: console.log,
|
|
159
|
+
warn: console.warn,
|
|
160
|
+
error: console.error
|
|
161
|
+
}
|
|
162
|
+
} = opts || {};
|
|
163
|
+
|
|
164
|
+
if (!targetDir) throw new Error("initProject: targetDir is required");
|
|
165
|
+
|
|
166
|
+
const absTarget = path.resolve(targetDir);
|
|
167
|
+
const modelFile = path.join(absTarget, `${projectName}.vmblu`);
|
|
168
|
+
const docFile = path.join(absTarget, `${projectName}-doc.json`);
|
|
169
|
+
|
|
170
|
+
const llmDir = path.join(absTarget, 'llm');
|
|
171
|
+
const sessionDir = path.join(llmDir, 'session');
|
|
172
|
+
const nodesDir = path.join(absTarget, 'nodes');
|
|
173
|
+
|
|
174
|
+
// Template sources
|
|
175
|
+
// const schemaSrc = path.join(templatesDir, 'schemas', schemaVersion, 'vmblu.schema.json');
|
|
176
|
+
// const annexSrc = path.join(templatesDir, 'annex', schemaVersion, 'vmblu.annex.md');
|
|
177
|
+
|
|
178
|
+
// Template sources
|
|
179
|
+
const schemaSrc = path.join(templatesDir, schemaVersion, 'vmblu.schema.json');
|
|
180
|
+
const annexSrc = path.join(templatesDir, schemaVersion, 'vmblu.annex.md');
|
|
181
|
+
const srcdocSchemaSrc = path.join(templatesDir, schemaVersion, 'srcdoc.schema.json');
|
|
182
|
+
const seedSrc = path.join(templatesDir, schemaVersion, 'seed.md');
|
|
183
|
+
|
|
184
|
+
// 1) Create folders
|
|
185
|
+
for (const dir of [absTarget, llmDir, sessionDir, nodesDir]) {
|
|
186
|
+
ui.info(`mkdir -p ${dir}`);
|
|
187
|
+
await ensureDir(dir, dryRun);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 2) Create root files
|
|
191
|
+
ui.info(`create ${modelFile}${force ? ' (force)' : ''}`);
|
|
192
|
+
await writeFileSafe(modelFile, defaultModel(projectName), { force, dry: dryRun });
|
|
193
|
+
|
|
194
|
+
ui.info(`create ${docFile}${force ? ' (force)' : ''}`);
|
|
195
|
+
await writeFileSafe(docFile, defaultDoc(projectName), { force, dry: dryRun });
|
|
196
|
+
|
|
197
|
+
// 3) Copy schema + annex into llm/
|
|
198
|
+
const schemaDst = path.join(llmDir, 'vmblu.schema.json');
|
|
199
|
+
const annexDst = path.join(llmDir, 'vmblu.annex.md');
|
|
200
|
+
const srcdocSchemaDst = path.join(llmDir, 'srcdoc.schema.json');
|
|
201
|
+
const seedDst = path.join(llmDir, 'seed.md');
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
ui.info(`copy ${schemaSrc} -> ${schemaDst}${force ? ' (force)' : ''}`);
|
|
205
|
+
await copyOrWriteFallback(schemaSrc, schemaDst, fallbackSchema(), { force, dry: dryRun });
|
|
206
|
+
|
|
207
|
+
ui.info(`copy ${annexSrc} -> ${annexDst}${force ? ' (force)' : ''}`);
|
|
208
|
+
await copyOrWriteFallback(annexSrc, annexDst, fallbackAnnex(), { force, dry: dryRun });
|
|
209
|
+
|
|
210
|
+
ui.info(`copy ${srcdocSchemaSrc} -> ${srcdocSchemaDst}${force ? ' (force)' : ''}`);
|
|
211
|
+
await copyOrWriteFallback(srcdocSchemaSrc, srcdocSchemaDst, fallbackSrcdocSchema(), { force, dry: dryRun });
|
|
212
|
+
|
|
213
|
+
ui.info(`copy ${seedSrc} -> ${seedDst}${force ? ' (force)' : ''}`);
|
|
214
|
+
await copyOrWriteFallback(seedSrc, seedDst, fallbackSeed(), { force, dry: dryRun });
|
|
215
|
+
|
|
216
|
+
// 4) Build manifest with hashes
|
|
217
|
+
const willWriteManifest = !(await exists(path.join(llmDir, 'manifest.json'))) || force;
|
|
218
|
+
let manifest = null;
|
|
219
|
+
|
|
220
|
+
if (dryRun) {
|
|
221
|
+
ui.info(`would write manifest.json in ${llmDir}`);
|
|
222
|
+
} else {
|
|
223
|
+
|
|
224
|
+
// I don't need the hashes
|
|
225
|
+
// const [schemaHash, annexHash, modelHash, docHash] = await Promise.all([
|
|
226
|
+
// sha256(schemaDst), sha256(annexDst), sha256(modelFile), sha256(docFile)
|
|
227
|
+
// ]);
|
|
228
|
+
|
|
229
|
+
// Paths in manifest should be relative to /llm to keep it portable
|
|
230
|
+
const llmPosix = llmDir; // absolute
|
|
231
|
+
manifest = {
|
|
232
|
+
version: schemaVersion,
|
|
233
|
+
model: {
|
|
234
|
+
path: rel(llmPosix, modelFile),
|
|
235
|
+
schema: 'vmblu.schema.json',
|
|
236
|
+
annex: 'vmblu.annex.md',
|
|
237
|
+
},
|
|
238
|
+
srcdoc: {
|
|
239
|
+
path: rel(llmPosix, docFile),
|
|
240
|
+
schema: 'srcdoc.schema.json',
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
if (willWriteManifest) {
|
|
245
|
+
const manifestPath = path.join(llmDir, 'manifest.json');
|
|
246
|
+
ui.info(`create ${manifestPath}${force ? ' (force)' : ''}`);
|
|
247
|
+
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
|
|
248
|
+
} else {
|
|
249
|
+
ui.warn(`manifest.json exists and --force not set. Skipped.`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// 5) Make the package file
|
|
254
|
+
pckg.makePackageJson( {absTarget, projectName, force, dryRun, addCliDep: true, cliVersion: "^0.1.0"}, ui);
|
|
255
|
+
|
|
256
|
+
// 6) Final tree hint
|
|
257
|
+
ui.info(`\nScaffold complete${dryRun ? ' (dry run)' : ''}:\n` +
|
|
258
|
+
` ${absTarget}/
|
|
259
|
+
${path.basename(modelFile)}
|
|
260
|
+
${path.basename(docFile)}
|
|
261
|
+
package.json
|
|
262
|
+
llm/
|
|
263
|
+
seed.md
|
|
264
|
+
manifest.json
|
|
265
|
+
vmblu.schema.json
|
|
266
|
+
vmblu.annex.md
|
|
267
|
+
srcdoc.schema.json
|
|
268
|
+
session/
|
|
269
|
+
nodes/\n`);
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
targetDir: absTarget,
|
|
273
|
+
projectName,
|
|
274
|
+
schemaVersion,
|
|
275
|
+
files: {
|
|
276
|
+
model: modelFile,
|
|
277
|
+
doc: docFile,
|
|
278
|
+
schema: schemaDst,
|
|
279
|
+
annex: annexDst,
|
|
280
|
+
srdocSchema: srcdocSchemaDst,
|
|
281
|
+
manifest: path.join(llmDir, 'manifest.json')
|
|
282
|
+
},
|
|
283
|
+
dryRun,
|
|
284
|
+
manifest
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
module.exports = { initProject };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const fs = require('fs/promises');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
async function readJsonIfExists(file) {
|
|
5
|
+
try { return JSON.parse(await fs.readFile(file, 'utf8')); } catch { return null; }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function sortKeys(obj) {
|
|
9
|
+
return Object.fromEntries(Object.entries(obj).sort(([a],[b]) => a.localeCompare(b)));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function makePackageJson({
|
|
13
|
+
absTarget, projectName, force, dryRun,
|
|
14
|
+
addCliDep = true, cliVersion = "^0.1.0"
|
|
15
|
+
}, ui) {
|
|
16
|
+
const pkgPath = path.join(absTarget, 'package.json');
|
|
17
|
+
const existing = await readJsonIfExists(pkgPath);
|
|
18
|
+
|
|
19
|
+
// Base skeleton (created if missing)
|
|
20
|
+
const basePkg = existing || {
|
|
21
|
+
name: projectName,
|
|
22
|
+
private: true,
|
|
23
|
+
version: "0.0.0",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Add/merge scripts (idempotent)
|
|
27
|
+
basePkg.scripts = Object.assign({}, basePkg.scripts, {
|
|
28
|
+
"vm:init": "vmblu init ."
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Optionally add the CLI as a devDependency
|
|
32
|
+
if (addCliDep) {
|
|
33
|
+
basePkg.devDependencies = Object.assign({}, basePkg.devDependencies, {
|
|
34
|
+
"@vizualmodel/vmblu-cli": basePkg.devDependencies?.["@vizualmodel/vmblu-cli"] || cliVersion
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Nice-to-have: keep deterministic key order
|
|
39
|
+
const ordered = {
|
|
40
|
+
...sortKeys(basePkg),
|
|
41
|
+
scripts: sortKeys(basePkg.scripts || {}),
|
|
42
|
+
devDependencies: basePkg.devDependencies ? sortKeys(basePkg.devDependencies) : undefined
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (existing && !force) {
|
|
46
|
+
ui.info(`update package.json (merge scripts${addCliDep ? " + devDependency" : ""})`);
|
|
47
|
+
} else if (!existing) {
|
|
48
|
+
ui.info(`create ${pkgPath}`);
|
|
49
|
+
} else {
|
|
50
|
+
ui.info(`overwrite ${pkgPath} (force)`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!dryRun) {
|
|
54
|
+
await fs.writeFile(pkgPath, JSON.stringify(ordered, null, 2) + '\n', 'utf8');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return pkgPath;
|
|
58
|
+
}
|
|
59
|
+
module.exports = { makePackageJson };
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Session Seed (System Prompt)
|
|
2
|
+
|
|
3
|
+
vmblu (Vizual Model Blueprint) is a graphical editor that maintains a visual, runnable model of a software system.
|
|
4
|
+
vmblu models software as interconnected nodes that pass messages via pins.
|
|
5
|
+
|
|
6
|
+
The model has a well defined format described by a schema. An additional annex gives semantic background information about the schema.
|
|
7
|
+
The parameter profiles of messages and where messages are received and sent in the actual source code, are stored in a second file, the srcdoc file.
|
|
8
|
+
The srcdoc file is generated automatically by vmblu and is only to be consulted, not written, at the start of a project it does not yet exist
|
|
9
|
+
|
|
10
|
+
You are an expert **architecture + code copilot** for **vmblu** .
|
|
11
|
+
You can find the location of the model file, the model schema, the model annex, the srcdoc file and the srcdoc schema in the 'manifest.json' file of this project. Read these files.
|
|
12
|
+
|
|
13
|
+
The location of all other files in the project can be found via the model file.
|
|
14
|
+
|
|
15
|
+
Your job is to co-design the architecture and the software for the system.
|
|
16
|
+
For modifications of the model, always follow the schema.
|
|
17
|
+
If the srcdoc does not exist yet or does notcontain profile information it could be that the code for the node has not been written yet, this should not stop you from continuing.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://vmblu.dev/schema/srcdoc/0.2/srcdoc.schema.json",
|
|
4
|
+
"title": "vmblu Source Documentation (grouped by node)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["version", "generatedAt", "entries"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"version": { "type": "string" },
|
|
9
|
+
"generatedAt": { "type": "string", "format": "date-time" },
|
|
10
|
+
"entries": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": { "$ref": "#/$defs/Entry" }
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"$defs": {
|
|
16
|
+
"Param": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"required": ["name", "type", "description"],
|
|
20
|
+
"properties": {
|
|
21
|
+
"name": { "type": "string" },
|
|
22
|
+
"type": { "type": "string" },
|
|
23
|
+
"description": { "type": "string" }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"Handle": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": ["pin", "handler", "file", "line", "summary", "returns", "examples", "params"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"pin": { "type": "string" },
|
|
32
|
+
"handler": { "type": "string" },
|
|
33
|
+
"file": { "type": "string" },
|
|
34
|
+
"line": { "type": "integer", "minimum": 1 },
|
|
35
|
+
"summary": { "type": "string" },
|
|
36
|
+
"returns": { "type": "string" },
|
|
37
|
+
"examples": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": { "type": "string" }
|
|
40
|
+
},
|
|
41
|
+
"params": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": { "$ref": "#/$defs/Param" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"Transmit": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"required": ["pin", "file", "line"],
|
|
51
|
+
"properties": {
|
|
52
|
+
"pin": { "type": "string" },
|
|
53
|
+
"file": { "type": "string" },
|
|
54
|
+
"line": { "type": "integer", "minimum": 1 }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"Entry": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"additionalProperties": false,
|
|
60
|
+
"required": ["node", "handles", "transmits"],
|
|
61
|
+
"properties": {
|
|
62
|
+
"node": { "type": "string" },
|
|
63
|
+
"handles": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": { "$ref": "#/$defs/Handle" }
|
|
66
|
+
},
|
|
67
|
+
"transmits": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"items": { "$ref": "#/$defs/Transmit" }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Annex A: Semantic Clarifications for vmblu v0.8
|
|
2
|
+
|
|
3
|
+
This annex captures subtle semantic points that are not fully enforceable in the JSON Schema but are critical for correct usage of the vmblu format by both humans and LLMs.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## A.1 Request / Reply Semantics
|
|
8
|
+
|
|
9
|
+
- A **request pin** is an **output pin**.
|
|
10
|
+
- It is used by the requester node to initiate a request with `tx.request('pinName', payload)`.
|
|
11
|
+
- This function returns a **Promise** which resolves when the callee replies.
|
|
12
|
+
|
|
13
|
+
- A **reply pin** is an **input pin** on the callee.
|
|
14
|
+
- It receives the request payload and has a handler like any input pin.
|
|
15
|
+
- Inside this handler, the callee must call `tx.reply(payload)` to respond to the requester.
|
|
16
|
+
- The runtime delivers this reply on the backchannel and resolves the requester’s Promise.
|
|
17
|
+
|
|
18
|
+
- **Connections**:
|
|
19
|
+
- Normally, `request` pins connect to `reply` pins.
|
|
20
|
+
- It is also valid to connect a `request` pin to an `input` pin (e.g. for logging or monitoring), but in that case no reply is sent.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## A.2 Handler Naming
|
|
25
|
+
|
|
26
|
+
Every **input** or **reply** pin corresponds to a message handler in the node implementation.
|
|
27
|
+
|
|
28
|
+
- Handler name is `on<PinNameInCamelCase>`.
|
|
29
|
+
- Example:
|
|
30
|
+
- Pin: `"name": "saveMessage", "kind": "input"`
|
|
31
|
+
- Handler: `onSaveMessage(payload)`
|
|
32
|
+
|
|
33
|
+
This uniform convention ensures LLMs and the editor can always map pins to their corresponding handler.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## A.3 Factory Function Signature
|
|
38
|
+
|
|
39
|
+
A source node references its implementation via a **factory** object (`path` + `function`).
|
|
40
|
+
The factory function is called by the runtime to create the node instance.
|
|
41
|
+
|
|
42
|
+
In order to let documentation tools find the factory function add a *node* JSdoc tag before the function.
|
|
43
|
+
|
|
44
|
+
- Signature:
|
|
45
|
+
```js
|
|
46
|
+
/**
|
|
47
|
+
* @node node name
|
|
48
|
+
*/
|
|
49
|
+
export function createMyNode( tx, sx ) { ... }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- tx: object exposing runtime message functions (send, request, reply).
|
|
53
|
+
- sx: arbitrary initialization data supplied by the model.
|
|
54
|
+
- rx: not passed to the node. Runtime-only directives; used by the runtime to decide how/where to host the node (e.g. worker thread, debug flags).
|
|
55
|
+
|
|
56
|
+
## A.4 Dock Nodes and Drift
|
|
57
|
+
|
|
58
|
+
- A dock node references another node defined in a different file via a link.
|
|
59
|
+
- Pins and connections of the dock node are kept in the importing file.
|
|
60
|
+
- If the external node definition changes, the editor highlights differences (“drift”) between the dock node and its linked definition.
|
|
61
|
+
|
|
62
|
+
## A.5 Buses and Pads
|
|
63
|
+
|
|
64
|
+
A bus simplifies routing:
|
|
65
|
+
|
|
66
|
+
- Outputs connected to a bus are forwarded to inputs of the same name.
|
|
67
|
+
- Buses do not introduce new message names; they only group routes.
|
|
68
|
+
|
|
69
|
+
Pads are how group nodes expose their internal pins externally.
|
|
70
|
+
- If a connection omits the node in its address, it refers to a pad on the group itself.
|
|
71
|
+
|
|
72
|
+
## A.6 Connections
|
|
73
|
+
|
|
74
|
+
A connection is between pins or interfaces.
|
|
75
|
+
|
|
76
|
+
For a connection between pins, the message flow is from 'src' to 'dst'. So 'src is either an ouput pin of a node or an input pin of the containing group node (a pad in the editor) and 'dst' is either an input pin of a node or an ouput pin of the containing group node.
|
|
77
|
+
|
|
78
|
+
When connecting interfaces the *ouput pins* of the interface are connected the *input pins* with the same name, of the interface on the other node, and in the same way the *input pins* of the interface are connected to the *output pins* with the same name of the interface connected to on the other node. Not all pins have to be present in both interfaces.
|
|
79
|
+
|
|
80
|
+
## A.7 AI Generation Guidelines
|
|
81
|
+
|
|
82
|
+
For LLMs working with vmblu files:
|
|
83
|
+
|
|
84
|
+
- Respect node and pin names — do not rename unless explicitly asked.
|
|
85
|
+
- Connection rules — only connect compatible pins:
|
|
86
|
+
|
|
87
|
+
- output → input
|
|
88
|
+
- request → reply
|
|
89
|
+
|
|
90
|
+
- Reply requirement — every new request pin should be connected to at least one reply pin.
|
|
91
|
+
- Do not edit editor fields — they are for the graphical editor only.
|
|
92
|
+
|
|
93
|
+
When generating source code for the nodes in the vmblu file, only generate code for the nodes, the *main* function and node setup is generated directly from the vmblu file itself.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "@vizual_model/cli/templates/0.8.2/vmblu.schema.json",
|
|
4
|
+
"title": "vmblu Model (v0.8.2 draft)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["header", "root"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"header": { "$ref": "#/$defs/Header" },
|
|
10
|
+
"imports": {
|
|
11
|
+
"description": "List of vmblu files that are referenced in the model. Allows for faster loading.",
|
|
12
|
+
"type": "array",
|
|
13
|
+
"items": { "type": "string", "minLength": 1 },
|
|
14
|
+
"uniqueItems": true
|
|
15
|
+
},
|
|
16
|
+
"factories": {
|
|
17
|
+
"description": "List of files where the source code of the source nodes can be found. Used by the docgen tool.",
|
|
18
|
+
"type": "array",
|
|
19
|
+
"items": { "type": "string", "minLength": 1 },
|
|
20
|
+
"uniqueItems": true
|
|
21
|
+
},
|
|
22
|
+
"libraries": {
|
|
23
|
+
"description": "List of vmblu files from which the editor allows the user to select nodes in an easy way.",
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": { "type": "string", "minLength": 1 },
|
|
26
|
+
"uniqueItems": true
|
|
27
|
+
},
|
|
28
|
+
"root": {
|
|
29
|
+
"description": "The starting point of the vmblu model. Every field named 'editor' is there only to let the editor display the model for the user.",
|
|
30
|
+
"$ref": "#/$defs/Node"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"$defs": {
|
|
34
|
+
"Header": {
|
|
35
|
+
"description": "Contains meta information about the model. Used by the editor.",
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"version": { "type": "string" },
|
|
39
|
+
"created": { "type": "string", "format": "date-time" },
|
|
40
|
+
"saved": { "type": "string", "format": "date-time" },
|
|
41
|
+
"utc": { "type": "string", "format": "date-time" },
|
|
42
|
+
"style": { "type": "string" },
|
|
43
|
+
"runtime": { "type": "string" }
|
|
44
|
+
},
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"required": ["version", "created", "saved", "utc"]
|
|
47
|
+
},
|
|
48
|
+
"Node" : {
|
|
49
|
+
"description": "A node describes a component of a software system. Nodes communicate via messages. There are three types of nodes.",
|
|
50
|
+
"type": "object",
|
|
51
|
+
"properties": {
|
|
52
|
+
"kind": {"enum": ["source", "group", "dock"]},
|
|
53
|
+
"name": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" },
|
|
54
|
+
"label": { "type": "string"},
|
|
55
|
+
"interfaces":{
|
|
56
|
+
"type": "array",
|
|
57
|
+
"items": { "$ref": "#/$defs/Interface" }
|
|
58
|
+
},
|
|
59
|
+
"prompt": {"type": "string"},
|
|
60
|
+
"sx": { "$ref": "#/$defs/NodeInitialization" },
|
|
61
|
+
"rx": { "$ref": "#/$defs/RuntimeDirectives" }
|
|
62
|
+
},
|
|
63
|
+
"oneOf": [
|
|
64
|
+
{ "$ref": "#/$defs/SourceNode" },
|
|
65
|
+
{ "$ref": "#/$defs/GroupNode" },
|
|
66
|
+
{ "$ref": "#/$defs/DockNode" }
|
|
67
|
+
],
|
|
68
|
+
"required": ["kind", "name"],
|
|
69
|
+
"unevaluatedProperties": false
|
|
70
|
+
},
|
|
71
|
+
"SourceNode": {
|
|
72
|
+
"description": "A source node has an implementation in source code.",
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"kind": {"const": "source"},
|
|
76
|
+
"factory": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {
|
|
79
|
+
"path": { "type": "string", "minLength": 1 },
|
|
80
|
+
"function": { "type": "string", "minLength": 1 }
|
|
81
|
+
},
|
|
82
|
+
"required": ["name"]
|
|
83
|
+
},
|
|
84
|
+
"editor": { "$ref": "#/$defs/EditorNode" }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"GroupNode": {
|
|
88
|
+
"description": "A group node consists of other connected nodes. It allows to build modular models.",
|
|
89
|
+
"type": "object",
|
|
90
|
+
"properties": {
|
|
91
|
+
"kind": {"const": "group"},
|
|
92
|
+
"nodes": {
|
|
93
|
+
"type": "array",
|
|
94
|
+
"items": { "$ref": "#/$defs/Node" }
|
|
95
|
+
},
|
|
96
|
+
"connections": {
|
|
97
|
+
"type": "array",
|
|
98
|
+
"items": { "$ref": "#/$defs/Connection" }
|
|
99
|
+
},
|
|
100
|
+
"editor": { "$ref": "#/$defs/EditorGroupNode" }
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"DockNode": {
|
|
104
|
+
"description": "A dock node is a placeholder for a node that is defined in another file, specified in the link field.",
|
|
105
|
+
"type": "object",
|
|
106
|
+
"properties": {
|
|
107
|
+
"kind": {"const": "dock"},
|
|
108
|
+
"link": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"required": ["name"],
|
|
111
|
+
"properties": {
|
|
112
|
+
"path": { "type": "string", "minLength": 1 },
|
|
113
|
+
"node": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"editor": { "$ref": "#/$defs/EditorNode" }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"Interface": {
|
|
120
|
+
"description": "An interface groups a number of pins of a node.",
|
|
121
|
+
"type": "object",
|
|
122
|
+
"required": ["name"],
|
|
123
|
+
"properties": {
|
|
124
|
+
"name": { "type": "string", "pattern": "^[^@]+$" },
|
|
125
|
+
"pins": {
|
|
126
|
+
"type": "array",
|
|
127
|
+
"items": { "$ref": "#/$defs/Pin" }
|
|
128
|
+
},
|
|
129
|
+
"editor" : {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"required": ["id"],
|
|
132
|
+
"properties": {
|
|
133
|
+
"id": {"type": "integer"}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"Pin": {
|
|
139
|
+
"description": "A node can receive or send a message via a pin. Inputs connect to outputs and requests connect to replies.",
|
|
140
|
+
"type": "object",
|
|
141
|
+
"required": ["name", "kind"],
|
|
142
|
+
"properties": {
|
|
143
|
+
"name": { "type": "string", "minLength": 1, "pattern": "^[^@]+$"},
|
|
144
|
+
"kind": { "enum": ["input", "output", "request", "reply"] },
|
|
145
|
+
"editor": {"$ref": "#/$defs/EditorPin"}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"Connection": {
|
|
149
|
+
"description": "A connection can be made between two pins or between two interfaces. For pins the message flow is from 'src' to 'dst', so 'src' is either an output pin of a node or an input pin of the containing group node and 'dst' is either an input pin of a node or an output pin of the containing group node.",
|
|
150
|
+
"type": "object",
|
|
151
|
+
"additionalProperties": false,
|
|
152
|
+
"required": ["from", "to"],
|
|
153
|
+
"properties": {
|
|
154
|
+
"src": { "$ref": "#/$defs/Address" },
|
|
155
|
+
"dst": { "$ref": "#/$defs/Address" }
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"Address": {
|
|
159
|
+
"description": "The format for the address of a pin or interface. If node is omitted the node is the containing group node, and the pin or interface are represented as pads.",
|
|
160
|
+
"type": "object",
|
|
161
|
+
"additionalProperties": false,
|
|
162
|
+
"properties": {
|
|
163
|
+
"node": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" },
|
|
164
|
+
"pin": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" },
|
|
165
|
+
"interface": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" }
|
|
166
|
+
},
|
|
167
|
+
"oneOf": [
|
|
168
|
+
{ "required": ["pin"] },
|
|
169
|
+
{ "required": ["interface"] }
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
"NodeInitialization": {
|
|
173
|
+
"description": "Node-defined initialization data passed to the node at creation time. Shape is entirely up to the node designer.",
|
|
174
|
+
"type": "object"
|
|
175
|
+
},
|
|
176
|
+
"RuntimeDirectives": {
|
|
177
|
+
"description": "Runtime-defined creation/hosting directives. Shape is determined by the runtime (e.g., host=worker, debug=true).",
|
|
178
|
+
"type": "object",
|
|
179
|
+
"properties": {
|
|
180
|
+
"$contract": {
|
|
181
|
+
"type": "string",
|
|
182
|
+
"description": "Optional contract/version tag or URI (e.g., 'vmblu.rx/v1'). Lets tools know which directive dialect to expect."
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"examples": [
|
|
186
|
+
{ "$contract": "vmblu.rx/v1", "host": "worker", "debug": true, "logLevel": "info" }
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
"EditorNode": {
|
|
190
|
+
"description": "Allows the editor to position and draw the node.",
|
|
191
|
+
"type": "object",
|
|
192
|
+
"properties": {
|
|
193
|
+
"rect": { "type": "string" }
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"EditorGroupNode": {
|
|
197
|
+
"description": "Allows the editor to position and draw the content of a group node in a dedicated view.",
|
|
198
|
+
"type": "object",
|
|
199
|
+
"properties": {
|
|
200
|
+
"rect": { "type": "string" },
|
|
201
|
+
"view": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"required": ["rect"],
|
|
204
|
+
"properties": {
|
|
205
|
+
"state": {"enum": ["open", "closed"]},
|
|
206
|
+
"rect": { "type": "string" },
|
|
207
|
+
"transform": { "type": "string" }
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"buses": {
|
|
211
|
+
"type": "array",
|
|
212
|
+
"items": {"$ref": "#/$defs/EditorBus"}
|
|
213
|
+
},
|
|
214
|
+
"routes": {
|
|
215
|
+
"type": "array",
|
|
216
|
+
"items": {"$ref": "#/$defs/EditorRoute"}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"EditorPin" : {
|
|
221
|
+
"description": "Allows the editor to draw the pin in the node it belongs to.",
|
|
222
|
+
"type": "object",
|
|
223
|
+
"properties": {
|
|
224
|
+
"id": { "type": "integer" },
|
|
225
|
+
"align": { "enum": ["left", "right"]},
|
|
226
|
+
"pad": {
|
|
227
|
+
"type": "object",
|
|
228
|
+
"required": ["rect"],
|
|
229
|
+
"properties": {
|
|
230
|
+
"rect": { "type": "string" },
|
|
231
|
+
"align": { "enum": ["left", "right"]}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"EditorBus": {
|
|
237
|
+
"description": "A bus is an easy way to route multiple connections between nodes. A bus can also do some routing via a filter.",
|
|
238
|
+
"type": "object",
|
|
239
|
+
"required": ["kind","name"],
|
|
240
|
+
"properties": {
|
|
241
|
+
"kind": { "enum": ["busbar", "cable"]},
|
|
242
|
+
"name": { "type": "string", "minLength": 1, "pattern": "^[^@]+$" },
|
|
243
|
+
"filter": { "$ref": "#/$defs/Filter" },
|
|
244
|
+
"start" : { "type": "string"},
|
|
245
|
+
"wire": { "type": "string" }
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"Filter": {
|
|
249
|
+
"description": "A bus uses a filter to route messages based on message parameters. A filter is a software routine.",
|
|
250
|
+
"type": "object",
|
|
251
|
+
"required": ["path", "function"],
|
|
252
|
+
"properties": {
|
|
253
|
+
"path": { "type": "string", "minLength": 1 },
|
|
254
|
+
"function": { "type": "string", "minLength": 1 }
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"EditorRoute": {
|
|
258
|
+
"description": "A route is how the editor shows the connections between pins or interfaces.The from-string and to-string start with either pin, bus, pad or itf",
|
|
259
|
+
"type": "object",
|
|
260
|
+
"properties": {
|
|
261
|
+
"from":{ "type": "string" },
|
|
262
|
+
"to":{ "type": "string" },
|
|
263
|
+
"wire": { "type": "string" }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|