onlyhuman 0.2.0 → 0.3.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/README.md +19 -1
- package/dist/cli.js +36 -1
- package/package.json +24 -7
package/README.md
CHANGED
|
@@ -84,13 +84,28 @@ The full rules, including how the robot behaves, are in [SKILL.md](SKILL.md). Th
|
|
|
84
84
|
|
|
85
85
|
## Tools
|
|
86
86
|
|
|
87
|
-
The parser, linter, go-to-definition and highlighter work on both `.human` and `.bot` files.
|
|
87
|
+
The parser, linter, go-to-definition and highlighter work on both `.human` and `.bot` files. Development requires Node 22.18 or newer; the published CLI bundle targets Node 20 or newer.
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
90
|
npm install
|
|
91
91
|
npm test
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
For the published CLI:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install --global onlyhuman
|
|
98
|
+
onlyhuman lint spec/spec.human
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Initialize a project skill:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
onlyhuman skill init
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This copies the project's `SKILL.md` into `.onlyhuman/SKILL.md`; add `--force` to overwrite an existing file.
|
|
108
|
+
|
|
94
109
|
Lint a file. This prints `file:line:col severity rule message` and exits 1 on errors:
|
|
95
110
|
|
|
96
111
|
```bash
|
|
@@ -128,6 +143,9 @@ code --extensionDevelopmentPath=/path/to/onlyhuman/vscode /path/to/onlyhuman/spe
|
|
|
128
143
|
| `src/definition.ts` | go-to-definition and `[path][line]` pointers |
|
|
129
144
|
| `src/files.ts` | the only file-system access: sibling file and project root |
|
|
130
145
|
| `src/cli.ts`, `src/lsp/server.ts` | command line and language server |
|
|
146
|
+
| `src/skill.ts` | copies `SKILL.md` into `.onlyhuman/SKILL.md` |
|
|
147
|
+
| `npm.sh` | build, verify and publish the CLI package |
|
|
148
|
+
| `LICENSE` | MIT license |
|
|
131
149
|
| `vscode/` | editor client and highlighting grammars |
|
|
132
150
|
| `tests/` | unit tests |
|
|
133
151
|
| `spec/` | the project's own `spec.human` and `spec.bot` |
|
package/dist/cli.js
CHANGED
|
@@ -338,16 +338,51 @@ function checkOperators(node, add) {
|
|
|
338
338
|
});
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
// src/skill.ts
|
|
342
|
+
import { copyFileSync, existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
343
|
+
import { dirname as dirname2, join as join2, resolve as resolve2 } from "node:path";
|
|
344
|
+
function initSkill(directory = ".", options = {}) {
|
|
345
|
+
const root = resolve2(directory);
|
|
346
|
+
const source = join2(root, "SKILL.md");
|
|
347
|
+
const target = join2(root, ".onlyhuman", "SKILL.md");
|
|
348
|
+
if (!existsSync2(source)) {
|
|
349
|
+
throw new Error(`${source} does not exist; create the project SKILL.md first`);
|
|
350
|
+
}
|
|
351
|
+
if (existsSync2(target) && !options.force) {
|
|
352
|
+
throw new Error(`${target} already exists; use --force to overwrite`);
|
|
353
|
+
}
|
|
354
|
+
mkdirSync(dirname2(target), { recursive: true });
|
|
355
|
+
copyFileSync(source, target);
|
|
356
|
+
return target;
|
|
357
|
+
}
|
|
358
|
+
|
|
341
359
|
// src/cli.ts
|
|
342
360
|
var USAGE = `usage:
|
|
343
361
|
onlyhuman lint <file> *.human or *.bot
|
|
344
362
|
onlyhuman def <name> <file> e.g. onlyhuman def @Token spec.human
|
|
345
|
-
onlyhuman def <file>:<line>:<col> 1-based line and col
|
|
363
|
+
onlyhuman def <file>:<line>:<col> 1-based line and col
|
|
364
|
+
onlyhuman skill init [directory] [--force] write .onlyhuman/SKILL.md`;
|
|
346
365
|
function load(file) {
|
|
347
366
|
return parseText(readFileSync2(file, "utf8"));
|
|
348
367
|
}
|
|
349
368
|
function main(argv) {
|
|
350
369
|
const [cmd, ...rest] = argv;
|
|
370
|
+
if (cmd === "skill" && rest[0] === "init") {
|
|
371
|
+
const args = rest.slice(1);
|
|
372
|
+
const paths = args.filter((a) => a !== "--force");
|
|
373
|
+
if (paths.length > 1) {
|
|
374
|
+
console.error(USAGE);
|
|
375
|
+
return 2;
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const target = initSkill(paths[0] ?? ".", { force: args.includes("--force") });
|
|
379
|
+
console.log(`created ${target}`);
|
|
380
|
+
return 0;
|
|
381
|
+
} catch (e) {
|
|
382
|
+
console.error(e.message);
|
|
383
|
+
return 1;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
351
386
|
if (cmd === "lint" && rest.length === 1) {
|
|
352
387
|
const file = rest[0];
|
|
353
388
|
const diags = lint(load(file), {
|
package/package.json
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onlyhuman",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A descriptive language for writing specs in plain bullets, with a CLI linter and go-to-definition.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
|
|
7
|
+
"bin": {
|
|
8
|
+
"onlyhuman": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
9
15
|
"repository": {
|
|
10
16
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Benjit87/onlyhuman.git"
|
|
17
|
+
"url": "git+https://github.com/Benjit87/onlyhuman.git"
|
|
12
18
|
},
|
|
13
19
|
"homepage": "https://github.com/Benjit87/onlyhuman#readme",
|
|
14
|
-
"bugs": {
|
|
15
|
-
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Benjit87/onlyhuman/issues"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"onlyhuman",
|
|
25
|
+
"spec",
|
|
26
|
+
"specification",
|
|
27
|
+
"language",
|
|
28
|
+
"linter",
|
|
29
|
+
"cli"
|
|
30
|
+
],
|
|
16
31
|
"author": "Benjit87",
|
|
17
32
|
"scripts": {
|
|
18
33
|
"test": "node --test \"tests/*.test.ts\"",
|
|
@@ -22,7 +37,9 @@
|
|
|
22
37
|
"build:cli": "esbuild src/cli.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/cli.js",
|
|
23
38
|
"prepublishOnly": "npm test && npm run typecheck && npm run build:cli"
|
|
24
39
|
},
|
|
25
|
-
"engines": {
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
},
|
|
26
43
|
"devEngines": {
|
|
27
44
|
"runtime": {
|
|
28
45
|
"name": "node",
|