@josfox/jos 0.2.1 → 3.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 +20 -1
- package/NOTICE +4 -0
- package/README.md +50 -2
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/bin/jos.js +33 -44
- package/examples/env-check.json +39 -0
- package/lib/resolve.js +32 -0
- package/lib/run.js +43 -0
- package/lib/serve.js +6 -0
- package/lib/validate.js +11 -0
- package/package.json +45 -19
- package/schemas/jos.v0.3.1.schema.json +64 -0
- package/lib/spec.js +0 -25
package/LICENSE
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
MIT
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 JOSFOX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
# @josfox/jos
|
|
2
|
-
|
|
1
|
+
# @josfox/jos — v3.1 (Community Runtime)
|
|
2
|
+
|
|
3
|
+
**Spec-aligned**: tied to **JOSFOX `.jos` v0.3.1** (Experimental, Community Edition).
|
|
4
|
+
Implements: **validate · run · serve · pack · publish · doc · test · lint** (community scope).
|
|
5
|
+
|
|
6
|
+
> **License**: MIT (code). The **spec** is **CC BY 4.0** — *attribution required*.
|
|
7
|
+
> **No Warranty**: This software is provided **AS IS**. Users must implement their own safeguards.
|
|
8
|
+
|
|
9
|
+
**Repo (spec):** https://github.com/josfox-ai/jos-format-spec
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
```bash
|
|
13
|
+
npm i -g @josfox/jos
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
- `jos validate <file>` — validate against v0.3.1 schema and resolve `$extends/$imports`.
|
|
18
|
+
- `jos run <file>` — execute a `task` or `pipeline` (shell/node; http/forge/ai are community stubs).
|
|
19
|
+
- `jos serve <file>` — run the declared `devServer` for local testing.
|
|
20
|
+
- `jos pack <file> --out dist.json` — package resolved artifact (JSON).
|
|
21
|
+
- `jos publish <file>` — placeholder for JOSFOX.cloud Forge.
|
|
22
|
+
- `jos doc <file> --out README.md` — generate quick docs from `.jos`.
|
|
23
|
+
- `jos test <file>` — run `checks[]` (basic assertions).
|
|
24
|
+
- `jos lint <path>` — basic spec lint.
|
|
25
|
+
|
|
26
|
+
## Eval hooks (fight evaluation blindness)
|
|
27
|
+
Declare in `.jos`:
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"evaluation": {
|
|
31
|
+
"contract": "stars_1_5",
|
|
32
|
+
"feedbackEndpoint": "https://example.com/eval",
|
|
33
|
+
"authToken": "REPLACE_ME",
|
|
34
|
+
"context": {"project": "landing"}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
Then call:
|
|
39
|
+
```bash
|
|
40
|
+
jos run file.jos --eval.stars 5 --eval.notes "LGTM" --eval.context '{"actor":"human"}'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Email privacy
|
|
44
|
+
- Use org-level maintainer (e.g., `oss@josfox.mx`) and hide personal email in npm profile.
|
|
45
|
+
- Use GitHub noreply for commits (Settings → Emails → “Keep my email addresses private”).
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
- Code: **MIT**
|
|
49
|
+
- Spec: **CC BY 4.0** (attribution required)
|
|
50
|
+
- See `LICENSE`, `NOTICE`, and `THIRD_PARTY_NOTICES.md`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Third-Party Notices for @josfox/jos
|
|
2
|
+
|
|
3
|
+
This project uses open-source components. We thank the open-source community.
|
|
4
|
+
|
|
5
|
+
## ajv (MIT)
|
|
6
|
+
https://github.com/ajv-validator/ajv
|
|
7
|
+
|
|
8
|
+
## yargs (MIT)
|
|
9
|
+
https://github.com/yargs/yargs
|
|
10
|
+
|
|
11
|
+
> Include full license texts if your distribution bundles these libraries.
|
package/bin/jos.js
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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]
|
|
2
|
+
import { hideBin } from 'yargs/helpers'; import yargs from 'yargs'; import fs from 'node:fs';
|
|
3
|
+
import { validate } from '../lib/validate.js'; import { resolveJos } from '../lib/resolve.js';
|
|
4
|
+
import { run } from '../lib/run.js'; import { serve } from '../lib/serve.js';
|
|
10
5
|
|
|
11
|
-
|
|
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
|
|
6
|
+
function writeJSON(p, data){ fs.writeFileSync(p, JSON.stringify(data, null, 2), 'utf8'); }
|
|
17
7
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
fs.writeFileSync(
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
main();
|
|
8
|
+
yargs(hideBin(process.argv))
|
|
9
|
+
.scriptName('jos')
|
|
10
|
+
.command('validate <file>', 'Validate .jos v0.3.1', y=> y.positional('file',{type:'string'}), argv=>{
|
|
11
|
+
const res = validate(argv.file); if (!res.ok) { console.error('Schema errors:', res.errors); process.exit(1); } console.log('OK ✅');
|
|
12
|
+
})
|
|
13
|
+
.command('run <file>', 'Run task/pipeline', y=> y.positional('file',{type:'string'}), async argv=>{
|
|
14
|
+
const { doc } = validate(argv.file); const flags={}; for (const [k,v] of Object.entries(argv)) if (k.startsWith('eval.')) flags[k]=v;
|
|
15
|
+
const code = await run(doc, flags); process.exit(code);
|
|
16
|
+
})
|
|
17
|
+
.command('serve <file>', 'Run dev server', y=> y.positional('file',{type:'string'}), async argv=>{
|
|
18
|
+
const doc = resolveJos(argv.file); await serve(doc);
|
|
19
|
+
})
|
|
20
|
+
.command('doc <file> --out <out>', 'Generate docs', y=> y.positional('file',{type:'string'}).option('out',{type:'string', demandOption:true}), argv=>{
|
|
21
|
+
const { doc } = validate(argv.file); const tasks=(doc.tasks||[]).map(t=>`- **${t.id}** \`${t.runner}${t.action?':'+t.action:''}\``).join('\n');
|
|
22
|
+
const md = `# ${doc.name}\n\nSchema: ${doc.schema}\n\n## Tasks\n${tasks}\n`; fs.writeFileSync(argv.out, md, 'utf8'); console.log(`Doc written to ${argv.out}`);
|
|
23
|
+
})
|
|
24
|
+
.command('pack <file> --out <out>', 'Pack resolved JSON', y=> y.positional('file',{type:'string'}).option('out',{type:'string', demandOption:true}), argv=>{
|
|
25
|
+
const doc = resolveJos(argv.file); writeJSON(argv.out, doc); console.log(`Packed to ${out}`);
|
|
26
|
+
})
|
|
27
|
+
.command('publish <file>', 'Publish (stub)', y=> y.positional('file',{type:'string'}), argv=>{
|
|
28
|
+
console.warn('[stub] Forge publish not implemented in community build');
|
|
29
|
+
})
|
|
30
|
+
.command('test <file>', 'Run basic checks (stub)', y=> y.positional('file',{type:'string'}), argv=>{
|
|
31
|
+
console.warn('[stub] checks TBD');
|
|
32
|
+
})
|
|
33
|
+
.command('lint <path>', 'Lint (stub)', y=> y.positional('path',{type:'string'}), argv=>{
|
|
34
|
+
console.warn('[stub] lint TBD');
|
|
35
|
+
})
|
|
36
|
+
.demandCommand(1).help().parse();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "jos.v0.3.1",
|
|
3
|
+
"id": "tools/envCheck",
|
|
4
|
+
"name": "Env Check (masked)",
|
|
5
|
+
"version": "0.3.1",
|
|
6
|
+
"kind": "task",
|
|
7
|
+
"inputs": {
|
|
8
|
+
"vars": [
|
|
9
|
+
"NODE_ENV",
|
|
10
|
+
"PORT"
|
|
11
|
+
],
|
|
12
|
+
"mask": [
|
|
13
|
+
"API_KEY",
|
|
14
|
+
"TOKEN"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"envMap": {
|
|
18
|
+
"VARS": "inputs.vars",
|
|
19
|
+
"MASK": "inputs.mask"
|
|
20
|
+
},
|
|
21
|
+
"tasks": [
|
|
22
|
+
{
|
|
23
|
+
"id": "echo",
|
|
24
|
+
"runner": "shell",
|
|
25
|
+
"script": {
|
|
26
|
+
"shell": "bash",
|
|
27
|
+
"body": "missing=0; echo '\ud83d\udd0e Checking\u2026'; for v in $VARS; do val=$(printenv \"$v\"); if [ -z \"$val\" ]; then echo \"\u274c $v\"; missing=1; else if echo \"$MASK\" | tr ' ' '\\n' | grep -qx \"$v\"; then masked=$(printf '%s' \"$val\" | sed -E 's/.(?=.{4})/*/g'); echo \"\u2705 $v=$masked\"; else echo \"\u2705 $v=$val\"; fi; fi; done; [ $missing -eq 0 ] || exit 2"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"evaluation": {
|
|
32
|
+
"contract": "stars_1_5",
|
|
33
|
+
"feedbackEndpoint": "https://example.com/eval",
|
|
34
|
+
"authToken": "REPLACE_ME",
|
|
35
|
+
"context": {
|
|
36
|
+
"task": "env-check"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/lib/resolve.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export function loadJSON(p) { return JSON.parse(fs.readFileSync(p, 'utf8')); }
|
|
5
|
+
function isAbs(p){ return path.isAbsolute(p) || p.startsWith('http://') || p.startsWith('https://'); }
|
|
6
|
+
export function resolvePath(base, rel) { return isAbs(rel) ? rel : path.join(path.dirname(base), rel); }
|
|
7
|
+
export function deepMerge(a, b) {
|
|
8
|
+
if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
|
|
9
|
+
if (a && typeof a === 'object' && b && typeof b === 'object') {
|
|
10
|
+
const out = { ...a };
|
|
11
|
+
for (const k of Object.keys(b)) out[k] = deepMerge(a[k], b[k]);
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
return b === undefined ? a : b;
|
|
15
|
+
}
|
|
16
|
+
export function resolveJos(entry) {
|
|
17
|
+
function _res(file) {
|
|
18
|
+
const doc = loadJSON(file);
|
|
19
|
+
let acc = { ...doc };
|
|
20
|
+
if (doc.$extends) {
|
|
21
|
+
const base = resolvePath(file, doc.$extends);
|
|
22
|
+
acc = deepMerge(_res(base), acc);
|
|
23
|
+
delete acc.$extends;
|
|
24
|
+
}
|
|
25
|
+
if (doc.$imports) {
|
|
26
|
+
for (const imp of doc.$imports) acc = deepMerge(_res(resolvePath(file, imp)), acc);
|
|
27
|
+
delete acc.$imports;
|
|
28
|
+
}
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
return _res(entry);
|
|
32
|
+
}
|
package/lib/run.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import http from 'node:http'; import https from 'node:https';
|
|
3
|
+
|
|
4
|
+
function postJSON(url, token, payload) {
|
|
5
|
+
const u = new URL(url);
|
|
6
|
+
const data = Buffer.from(JSON.stringify(payload));
|
|
7
|
+
const isHttps = u.protocol === 'https:';
|
|
8
|
+
const opts = { hostname: u.hostname, port: u.port || (isHttps ? 443 : 80),
|
|
9
|
+
path: u.pathname + (u.search || ''), method: 'POST',
|
|
10
|
+
headers: { 'content-type': 'application/json', 'content-length': data.length, ...(token ? {'authorization': `Bearer ${token}`} : {}) } };
|
|
11
|
+
const agent = isHttps ? https : http;
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const req = agent.request(opts, res => { let body=''; res.on('data', c=> body+=c); res.on('end', ()=> resolve({ status: res.statusCode, body })); });
|
|
14
|
+
req.on('error', reject); req.write(data); req.end();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function run(doc, flags={}) {
|
|
19
|
+
const env = { ...process.env };
|
|
20
|
+
if (doc.envMap) for (const [k,v] of Object.entries(doc.envMap)) {
|
|
21
|
+
let val = v; if (typeof v === 'string' && v.startsWith('inputs.')) { const key = v.split('.').slice(1).join('.'); val = doc.inputs?.[key]; }
|
|
22
|
+
if (Array.isArray(val)) val = val.join(' '); env[k] = val;
|
|
23
|
+
}
|
|
24
|
+
let code = 0;
|
|
25
|
+
for (const t of (doc.tasks||[])) {
|
|
26
|
+
if (t.runner === 'shell') {
|
|
27
|
+
const sh = t.script?.shell || 'bash'; const body = t.script?.body || '';
|
|
28
|
+
const child = spawn(sh, ['-lc', body], { stdio: 'inherit', env });
|
|
29
|
+
code = await new Promise(r => child.on('close', r)); if (code !== 0) break;
|
|
30
|
+
} else if (t.runner === 'node') {
|
|
31
|
+
if (t.action) { const mod = await import(new URL('../' + t.action, import.meta.url)); if (typeof mod.default === 'function') { const r = await mod.default({ doc, task: t, env, flags }); if (r?.exitCode) code = r.exitCode; } }
|
|
32
|
+
} else if (t.runner === 'http') {
|
|
33
|
+
console.warn('[stub] http runner not implemented');
|
|
34
|
+
} else if (t.runner === 'forge' || t.runner === 'ai') {
|
|
35
|
+
console.warn(`[stub] runner "${t.runner}" not implemented in community build`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const e = doc.evaluation; const stars = Number(flags['eval.stars'] ?? 0);
|
|
39
|
+
if (e?.feedbackEndpoint && e?.contract==='stars_1_5' && stars>=1 && stars<=5) {
|
|
40
|
+
try { const res = await postJSON(e.feedbackEndpoint, e.authToken, { runId: flags.runId || Date.now().toString(36), taskId: flags.taskId || doc.id, stars, notes: flags['eval.notes']||'', context: e.context||{}, ts: new Date().toISOString() }); console.log(`[eval] posted: ${res.status}`); } catch(err){ console.warn('[eval] failed:', err.message); }
|
|
41
|
+
}
|
|
42
|
+
return code;
|
|
43
|
+
}
|
package/lib/serve.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export async function serve(doc) {
|
|
3
|
+
const cmd = doc.devServer?.command; if (!cmd) throw new Error('devServer.command not defined');
|
|
4
|
+
const [exe, ...args] = cmd.split(' '); const child = spawn(exe, args, { stdio: 'inherit', env: process.env });
|
|
5
|
+
await new Promise((r)=> child.on('close', r));
|
|
6
|
+
}
|
package/lib/validate.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { resolveJos } from './resolve.js';
|
|
4
|
+
const schema = JSON.parse(fs.readFileSync(new URL('../schemas/jos.v0.3.1.schema.json', import.meta.url)));
|
|
5
|
+
export function validate(file) {
|
|
6
|
+
const doc = resolveJos(file);
|
|
7
|
+
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
8
|
+
const check = ajv.compile(schema);
|
|
9
|
+
const ok = check(doc);
|
|
10
|
+
return { ok, errors: check.errors || [], doc };
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josfox/jos",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "JOSFOX CLI \u2014
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "JOSFOX CLI \u2014 .jos v3.1 community runtime (validate/run/serve/pack/publish/doc/test/lint)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
5
7
|
"bin": {
|
|
6
8
|
"jos": "bin/jos.js"
|
|
7
9
|
},
|
|
8
|
-
"
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"lib",
|
|
13
|
+
"schemas",
|
|
14
|
+
"examples",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"NOTICE",
|
|
18
|
+
"THIRD_PARTY_NOTICES.md"
|
|
19
|
+
],
|
|
9
20
|
"keywords": [
|
|
10
21
|
"jos",
|
|
11
22
|
"josfox",
|
|
12
|
-
"cli",
|
|
13
23
|
".jos",
|
|
14
24
|
"spec",
|
|
15
|
-
"
|
|
25
|
+
"ai",
|
|
26
|
+
"agents",
|
|
27
|
+
"forge",
|
|
28
|
+
"pipeline",
|
|
29
|
+
"task",
|
|
30
|
+
"bundle",
|
|
31
|
+
"marketplace",
|
|
32
|
+
"prompt-engineering",
|
|
33
|
+
"evaluation",
|
|
34
|
+
"cache",
|
|
35
|
+
"lineage",
|
|
36
|
+
"devserver",
|
|
37
|
+
"cloud",
|
|
38
|
+
"embeddable"
|
|
16
39
|
],
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
40
|
+
"homepage": "https://github.com/josfox-ai/jos-format-spec",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/josfox-ai/jos-format-spec/issues"
|
|
43
|
+
},
|
|
20
44
|
"repository": {
|
|
21
45
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/josfox/jos.git"
|
|
23
|
-
},
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/josfox/jos/issues"
|
|
46
|
+
"url": "git+https://github.com/josfox-ai/jos-format-spec.git"
|
|
26
47
|
},
|
|
48
|
+
"author": "JOSFOX Team",
|
|
49
|
+
"maintainers": [
|
|
50
|
+
{
|
|
51
|
+
"name": "JOSFOX",
|
|
52
|
+
"email": "oss@josfox.mx"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
27
55
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
56
|
+
"node": ">=18.17"
|
|
29
57
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
"LICENSE"
|
|
35
|
-
]
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"ajv": "^8.17.1",
|
|
60
|
+
"yargs": "^17.7.2"
|
|
61
|
+
}
|
|
36
62
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://josfox.ai/spec/jos.v0.3.1.schema.json",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"schema",
|
|
7
|
+
"id",
|
|
8
|
+
"name",
|
|
9
|
+
"version",
|
|
10
|
+
"kind"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"schema": {
|
|
14
|
+
"const": "jos.v0.3.1"
|
|
15
|
+
},
|
|
16
|
+
"id": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"version": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"kind": {
|
|
26
|
+
"enum": [
|
|
27
|
+
"task",
|
|
28
|
+
"pipeline",
|
|
29
|
+
"bundle"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"$extends": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"$imports": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"items": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"inputs": {
|
|
42
|
+
"type": "object"
|
|
43
|
+
},
|
|
44
|
+
"secrets": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"envMap": {
|
|
51
|
+
"type": "object"
|
|
52
|
+
},
|
|
53
|
+
"tasks": {
|
|
54
|
+
"type": "array"
|
|
55
|
+
},
|
|
56
|
+
"devServer": {
|
|
57
|
+
"type": "object"
|
|
58
|
+
},
|
|
59
|
+
"evaluation": {
|
|
60
|
+
"type": "object"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"additionalProperties": true
|
|
64
|
+
}
|
package/lib/spec.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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 };
|