@cognivia/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 +21 -0
- package/README.md +16 -0
- package/bin/cognivia.mjs +101 -0
- package/package.json +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Manik Maurya
|
|
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 whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @cognivia/cli
|
|
2
|
+
|
|
3
|
+
Run Cognivia's learning diagnostics from a terminal or a data pipeline. Point it
|
|
4
|
+
at any learning or quiz app's answer export and get back the Learning Genome and
|
|
5
|
+
a session report.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g @cognivia/cli
|
|
9
|
+
cognivia diagnose --demo # bundled sample data, no key
|
|
10
|
+
cognivia diagnose --input answers.json # your export
|
|
11
|
+
cognivia memory-state <learnerId> # hosted API (needs COGNIVIA_API_KEY)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With `COGNIVIA_API_KEY` set it calls the hosted API; otherwise it computes locally.
|
|
15
|
+
|
|
16
|
+
MIT · Manik Maurya
|
package/bin/cognivia.mjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @cognivia/cli - run Cognivia's diagnostics from a terminal or a data pipeline.
|
|
3
|
+
//
|
|
4
|
+
// cognivia diagnose --demo run on bundled sample data (no key)
|
|
5
|
+
// cognivia diagnose --input answers.json diagnose your own attempts
|
|
6
|
+
// cognivia report --input answers.json --out report.txt
|
|
7
|
+
// cognivia memory-state --input answers.json
|
|
8
|
+
//
|
|
9
|
+
// answers.json is a JSON array of attempts:
|
|
10
|
+
// [{ "subject":"Physics", "question":"...", "answer":"...",
|
|
11
|
+
// "correct":true, "latencyMs":4200, "confidence":5 }]
|
|
12
|
+
//
|
|
13
|
+
// The diagnosis comes from @cognivia/core - the exact engine the site,
|
|
14
|
+
// console, and MCP server use, so results match everywhere.
|
|
15
|
+
|
|
16
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import * as core from "@cognivia/core";
|
|
18
|
+
import * as client from "@cognivia/core/client";
|
|
19
|
+
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const cmd = args[0];
|
|
22
|
+
const opt = (name) => { const i = args.indexOf(name); return i >= 0 ? (args[i + 1] || true) : undefined; };
|
|
23
|
+
const has = (name) => args.includes(name);
|
|
24
|
+
|
|
25
|
+
function loadAttempts() {
|
|
26
|
+
if (has("--demo")) return core.DEMO_ATTEMPTS;
|
|
27
|
+
const f = opt("--input");
|
|
28
|
+
if (!f || f === true) fail("provide --input <file.json> or --demo");
|
|
29
|
+
let data;
|
|
30
|
+
try { data = JSON.parse(readFileSync(f, "utf8")); }
|
|
31
|
+
catch (e) { fail("could not read/parse " + f + ": " + e.message); }
|
|
32
|
+
const arr = Array.isArray(data) ? data : data.attempts;
|
|
33
|
+
if (!Array.isArray(arr) || !arr.length) fail("input must be a non-empty JSON array of attempts");
|
|
34
|
+
return arr;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function fail(msg) { console.error("cognivia: " + msg); process.exit(1); }
|
|
38
|
+
|
|
39
|
+
function out(text) {
|
|
40
|
+
const o = opt("--out");
|
|
41
|
+
if (o && o !== true) { writeFileSync(o, text); console.error("→ wrote " + o); }
|
|
42
|
+
else console.log(text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function help() {
|
|
46
|
+
console.log(`cognivia - learning diagnostics on the command line
|
|
47
|
+
|
|
48
|
+
Usage:
|
|
49
|
+
cognivia diagnose --demo
|
|
50
|
+
cognivia diagnose --input answers.json [--json] [--out file]
|
|
51
|
+
cognivia report --input answers.json [--out report.txt]
|
|
52
|
+
cognivia memory-state --input answers.json
|
|
53
|
+
cognivia --version
|
|
54
|
+
|
|
55
|
+
answers.json: JSON array of { subject, question, answer, correct, latencyMs, confidence(1-5) }
|
|
56
|
+
Diagnostics are computed by @cognivia/core, the same engine behind the API, MCP server, and site.`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
switch (cmd) {
|
|
60
|
+
case "diagnose":
|
|
61
|
+
case "report": {
|
|
62
|
+
const attempts = loadAttempts();
|
|
63
|
+
// Use the hosted API when a key is set (unless --demo or --local); else compute locally.
|
|
64
|
+
const useRemote = !has("--demo") && (has("--remote") || (client.hasKey() && !has("--local")));
|
|
65
|
+
let rep;
|
|
66
|
+
if (useRemote) {
|
|
67
|
+
try { rep = await client.reportRemote(attempts); }
|
|
68
|
+
catch (e) { console.error("cognivia: API call failed (" + e.message + "), computing locally."); }
|
|
69
|
+
}
|
|
70
|
+
if (!rep) rep = core.buildReport(attempts, { idPrefix: has("--demo") ? "CGV-DEMO" : "CGV-CLI" });
|
|
71
|
+
out(has("--json") ? JSON.stringify(rep, null, 2) : core.renderText(rep));
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case "memory-state": {
|
|
75
|
+
// `cognivia memory-state <learnerId>` hits the hosted API (needs a live key).
|
|
76
|
+
const id = args[1] && !args[1].startsWith("-") ? args[1] : null;
|
|
77
|
+
if (id) {
|
|
78
|
+
if (!client.hasKey()) fail("memory-state <id> needs COGNIVIA_API_KEY (a live key).");
|
|
79
|
+
try { out(JSON.stringify(await client.memoryStateRemote(id), null, 2)); }
|
|
80
|
+
catch (e) { fail("memory-state: " + e.message); }
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const atts = loadAttempts();
|
|
84
|
+
const lines = atts.map((a, i) =>
|
|
85
|
+
`${i + 1}. ${(a.subject || a.topic || "item").padEnd(24)} ${core.memoryState(a).padEnd(16)} ${core.diagnosis(a)}`);
|
|
86
|
+
out(lines.join("\n"));
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "--version":
|
|
90
|
+
case "-v":
|
|
91
|
+
console.log("cognivia/0.1.0 (core " + "0.1.0" + ")");
|
|
92
|
+
break;
|
|
93
|
+
case undefined:
|
|
94
|
+
case "help":
|
|
95
|
+
case "--help":
|
|
96
|
+
case "-h":
|
|
97
|
+
help();
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
fail("unknown command '" + cmd + "'. Try: cognivia --help");
|
|
101
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cognivia/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Run Cognivia's learning diagnostics from the terminal. Point it at any learning or quiz app's answer export and get back the Learning Genome, per-item diagnosis, and a session report.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "cognivia": "bin/cognivia.mjs" },
|
|
7
|
+
"files": ["bin", "README.md", "LICENSE"],
|
|
8
|
+
"keywords": ["cognivia", "learning", "diagnostics", "cli", "edtech", "spaced-repetition"],
|
|
9
|
+
"homepage": "https://cognivia-platform.vercel.app/intelligence",
|
|
10
|
+
"repository": { "type": "git", "url": "git+https://github.com/Manik-Maurya/cognivia-platform.git", "directory": "packages/cli" },
|
|
11
|
+
"engines": { "node": ">=18" },
|
|
12
|
+
"dependencies": { "@cognivia/core": "^0.1.0" },
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Manik Maurya"
|
|
16
|
+
}
|