@josfox/jos 0.2.1

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 ADDED
@@ -0,0 +1 @@
1
+ MIT
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # @josfox/jos v0.2.1
2
+ Short-name CLI. Supports --version/--help and .jos export.
package/bin/jos.js ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { DEFAULT_SPEC, asConsole } = require('../lib/spec');
5
+ const VERSION = "0.2.1";
6
+ function printBanner(){ console.log(`JOSFOX CLI v${VERSION}`); }
7
+ function printHelp(){ printBanner(); console.log(`
8
+ Usage:
9
+ jos [command] [options]
10
+
11
+ Commands:
12
+ help Show help
13
+ version Print version
14
+ init <name> Scaffold a starter folder with spec.jos.json
15
+ export --format FMT Export current spec (FMT: jos|console)
16
+ run [--mode value] Example
17
+
18
+ Flags:
19
+ -h, --help Show help
20
+ -v, --version Print version
21
+ `); }
22
+ function main(){
23
+ const argv = process.argv.slice(2);
24
+ if (argv.includes('--version') || argv.includes('-v')) { console.log(VERSION); return; }
25
+ if (argv.includes('--help') || argv.includes('-h')) { printHelp(); return; }
26
+ const cmd = (argv[0] || 'help').toLowerCase(); const rest = argv.slice(1);
27
+ if (cmd === 'help' || cmd === '?') return printHelp();
28
+ if (cmd === 'version') return console.log(VERSION);
29
+ if (cmd === 'init') {
30
+ const name = rest[0]; if (!name) return (console.error('Provide a name: jos init <name>'), process.exit(1));
31
+ const dir = path.resolve(process.cwd(), name); if (!fs.existsSync(dir)) fs.mkdirSync(dir,{recursive:true});
32
+ fs.writeFileSync(path.join(dir,'spec.jos.json'), JSON.stringify(DEFAULT_SPEC,null,2));
33
+ console.log(`Initialized ${dir} with spec.jos.json`); return;
34
+ }
35
+ if (cmd === 'export') {
36
+ const idx = rest.indexOf('--format'); let fmt = 'jos';
37
+ if (idx >= 0 && rest[idx+1]) fmt = String(rest[idx+1]).toLowerCase();
38
+ if (fmt === 'console') console.log(asConsole(DEFAULT_SPEC)); else console.log(JSON.stringify(DEFAULT_SPEC,null,2));
39
+ return;
40
+ }
41
+ if (cmd === 'run') {
42
+ const m = rest.indexOf('--mode'); const mode = (m>=0 && rest[m+1]) ? rest[m+1] : 'default';
43
+ console.log(`Running in mode: ${mode}`); return;
44
+ }
45
+ printHelp();
46
+ }
47
+ main();
package/lib/spec.js ADDED
@@ -0,0 +1,25 @@
1
+ const DEFAULT_SPEC = {"version":"v2","kind":"Pack","name":"example-pack","description":"Example JOS Pack with prompts and an agent.","imports":[{"kind":"Prompt","ref":"./prompts/greet","as":"greet"},{"kind":"Prompt","ref":"./prompts/farewell","as":"bye"}],"prompts":{"greet":{"kind":"Prompt","id":"greet","template":"Hello, {{name}}!"},"farewell":{"kind":"Prompt","id":"farewell","template":"Bye, {{name}}."}},"agents":{"support":{"kind":"Agent","uses":["greet","farewell"],"vars":{"tone":"friendly"},"routes":[{"when":"start","do":"greet"},{"when":"end","do":"farewell"}]}},"meta":{"createdBy":"jos","kinds":["Prompt","Pack","Agent","App"],"hierarchy":{"Prompt":{"role":"leaf","canImport":[],"canContain":[]},"Pack":{"role":"library","canImport":["Prompt","Pack"],"canContain":["Prompt","Agent"]},"Agent":{"role":"runtime","canImport":["Prompt","Pack"],"canContain":[]},"App":{"role":"product","canImport":["Agent","Pack"],"canContain":["Agent"]}}}};
2
+ function asConsole(spec = DEFAULT_SPEC) {
3
+ const lines = [];
4
+ const meta = spec.meta || {}
5
+ const kinds = meta.kinds || [];
6
+ const hierarchy = meta.hierarchy || {}
7
+ lines.push('JOS Spec');
8
+ lines.push(`version: ${spec.version}`);
9
+ lines.push(`kind: ${spec.kind}`);
10
+ lines.push('kinds:');
11
+ kinds.forEach(kind => lines.push(` - ${kind}`));
12
+ lines.push('hierarchy:');
13
+ Object.keys(hierarchy).forEach(key => {
14
+ const h = hierarchy[key];
15
+ const imp = (h.canImport || []).join(',');
16
+ const cont = (h.canContain || []).join(',');
17
+ lines.push(` ${key}: role=${h.role || ''}, canImport=${imp}, canContain=${cont}`);
18
+ });
19
+ const prompts = Object.keys(spec.prompts || {});
20
+ const agents = Object.keys(spec.agents || {});
21
+ lines.push('prompts:' + (prompts.length ? ' ' + prompts.join(', ') : ' (none)'));
22
+ lines.push('agents:' + (agents.length ? ' ' + agents.join(', ') : ' (none)'));
23
+ return lines.join('\n');
24
+ }
25
+ module.exports = { DEFAULT_SPEC, asConsole };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@josfox/jos",
3
+ "version": "0.2.1",
4
+ "description": "JOSFOX CLI \u2014 exposes `jos` command with .jos export & kinds/hierarchy",
5
+ "bin": {
6
+ "jos": "bin/jos.js"
7
+ },
8
+ "type": "commonjs",
9
+ "keywords": [
10
+ "jos",
11
+ "josfox",
12
+ "cli",
13
+ ".jos",
14
+ "spec",
15
+ "export"
16
+ ],
17
+ "author": "JOSFOX",
18
+ "license": "MIT",
19
+ "homepage": "https://github.com/josfox/jos",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/josfox/jos.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/josfox/jos/issues"
26
+ },
27
+ "engines": {
28
+ "node": ">=16"
29
+ },
30
+ "files": [
31
+ "bin",
32
+ "lib",
33
+ "README.md",
34
+ "LICENSE"
35
+ ]
36
+ }