@josfox/jos 3.1.1 → 4.0.2

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 DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- JOSFOX `.jos` Specification v0.3.1 — Community Edition
2
- Spec: CC BY 4.0 (attribution required). Implementation code: MIT.
3
- NO WARRANTY. Users must implement their own security and operational safeguards.
4
- Repo (spec): https://github.com/josfox-ai/jos-format-spec
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,71 +0,0 @@
1
- #!/usr/bin/env node
2
- import { hideBin } from 'yargs/helpers';
3
- import yargs from 'yargs';
4
- import fs from 'node:fs';
5
-
6
- import { validate } from '../lib/validate.js';
7
- import { resolveJos } from '../lib/resolve.js';
8
- import { run } from '../lib/run.js';
9
- import { serve } from '../lib/serve.js';
10
-
11
- function writeJSON(p, data){ fs.writeFileSync(p, JSON.stringify(data, null, 2), 'utf8'); }
12
-
13
- yargs(hideBin(process.argv))
14
- .scriptName('jos')
15
-
16
- // 1) VALIDATE: igual que antes
17
- .command('validate <file>', 'Validate .jos file', y => y.positional('file', { type: 'string' }), argv => {
18
- const res = validate(argv.file);
19
- if (!res.ok) { console.error('Schema errors:', res.errors); process.exit(1); }
20
- console.log('OK ✅');
21
- })
22
-
23
- // 2) RUN: usar resolveJos para tolerar versiones legacy
24
- .command('run <file>', 'Run task/pipeline', y => y.positional('file', { type: 'string' }), async argv => {
25
- const doc = resolveJos(argv.file); // <-- antes usaba validate(...)
26
- const flags = {};
27
- for (const [k, v] of Object.entries(argv)) if (k.startsWith('eval.')) flags[k] = v;
28
- const code = await run(doc, flags);
29
- process.exit(code);
30
- })
31
-
32
- // 3) SERVE: también resolver primero
33
- .command('serve <file>', 'Run dev server', y => y.positional('file', { type: 'string' }), async argv => {
34
- const doc = resolveJos(argv.file);
35
- await serve(doc);
36
- })
37
-
38
- // 4) DOC: se mantiene (usa validate estricto)
39
- .command('doc <file> --out <out>', 'Generate docs', y => y
40
- .positional('file', { type: 'string' })
41
- .option('out', { type: 'string', demandOption: true }),
42
- argv => {
43
- const { doc } = validate(argv.file);
44
- const tasks = (doc.tasks || []).map(t => `- **${t.id}** \`${t.runner}${t.action ? ':' + t.action : ''}\``).join('\n');
45
- const md = `# ${doc.name}\n\nSchema: ${doc.schema}\n\n## Tasks\n${tasks}\n`;
46
- fs.writeFileSync(argv.out, md, 'utf8');
47
- console.log(`Doc written to ${argv.out}`);
48
- })
49
-
50
- // 5) PACK: corregir el log
51
- .command('pack <file> --out <out>', 'Pack resolved JSON', y => y
52
- .positional('file', { type: 'string' })
53
- .option('out', { type: 'string', demandOption: true }),
54
- argv => {
55
- const doc = resolveJos(argv.file);
56
- writeJSON(argv.out, doc);
57
- console.log(`Packed to ${argv.out}`); // <-- antes usaba ${out}
58
- })
59
-
60
- .command('publish <file>', 'Publish (stub)', y => y.positional('file', { type: 'string' }), () => {
61
- console.warn('[stub] Forge publish not implemented in community build');
62
- })
63
- .command('test <file>', 'Run basic checks (stub)', y => y.positional('file', { type: 'string' }), () => {
64
- console.warn('[stub] checks TBD');
65
- })
66
- .command('lint <path>', 'Lint (stub)', y => y.positional('path', { type: 'string' }), () => {
67
- console.warn('[stub] lint TBD');
68
- })
69
- .demandCommand(1)
70
- .help()
71
- .parse();
@@ -1,39 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
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 DELETED
@@ -1,43 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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
- }
@@ -1,64 +0,0 @@
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
- }