@cognivia/cli 0.1.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 CHANGED
@@ -9,8 +9,15 @@ npm i -g @cognivia/cli
9
9
  cognivia diagnose --demo # bundled sample data, no key
10
10
  cognivia diagnose --input answers.json # your export
11
11
  cognivia memory-state <learnerId> # hosted API (needs COGNIVIA_API_KEY)
12
+ cognivia report <learnerId> # a learner's stored state as a readable report
13
+ cognivia content items --input items.json # item -> misconception maps
14
+ cognivia content prerequisites --input pre.json # concept -> prerequisite maps
12
15
  ```
13
16
 
17
+ `content` maps sharpen `diagnose` on your own items and concepts; they need a
18
+ self-serve live key. `items.json`: `[{ item_ref, distractors: { "wrong option": "misconception" } }]`.
19
+ `pre.json`: `[{ concept, requires: ["prerequisite concept"] }]`.
20
+
14
21
  With `COGNIVIA_API_KEY` set it calls the hosted API; otherwise it computes locally.
15
22
 
16
23
  MIT · Manik Maurya
package/bin/cognivia.mjs CHANGED
@@ -49,16 +49,37 @@ Usage:
49
49
  cognivia diagnose --demo
50
50
  cognivia diagnose --input answers.json [--json] [--out file]
51
51
  cognivia report --input answers.json [--out report.txt]
52
+ cognivia report <learnerId> (hosted; needs a live key)
52
53
  cognivia memory-state --input answers.json
54
+ cognivia memory-state <learnerId> (hosted; needs a live key)
55
+ cognivia content items --input items.json (upload item -> misconception maps)
56
+ cognivia content prerequisites --input pre.json (upload concept -> prerequisite maps)
57
+ cognivia content items | prerequisites (list what is stored)
53
58
  cognivia --version
54
59
 
55
60
  answers.json: JSON array of { subject, question, answer, correct, latencyMs, confidence(1-5) }
61
+ items.json: JSON array of { item_ref, distractors: { "wrong option": "misconception" } }
62
+ pre.json: JSON array of { concept, requires: ["prerequisite concept", ...] }
56
63
  Diagnostics are computed by @cognivia/core, the same engine behind the API, MCP server, and site.`);
57
64
  }
58
65
 
59
66
  switch (cmd) {
60
- case "diagnose":
61
67
  case "report": {
68
+ // `cognivia report <learnerId>` renders a learner's stored memory state
69
+ // (hosted, needs a live key). Falls through to the attempts-based report.
70
+ const rid = args[1] && !args[1].startsWith("-") ? args[1] : null;
71
+ if (rid) {
72
+ if (!client.hasKey()) fail("report <learnerId> needs COGNIVIA_API_KEY (a live key).");
73
+ try {
74
+ const st = await client.memoryStateRemote(rid);
75
+ out(has("--json") ? JSON.stringify(st, null, 2) : client.renderMemoryState(st));
76
+ } catch (e) { fail("report: " + e.message); }
77
+ break;
78
+ }
79
+ // no id → fall through to the attempts-based report below.
80
+ }
81
+ // eslint-disable-next-line no-fallthrough
82
+ case "diagnose": {
62
83
  const attempts = loadAttempts();
63
84
  // Use the hosted API when a key is set (unless --demo or --local); else compute locally.
64
85
  const useRemote = !has("--demo") && (has("--remote") || (client.hasKey() && !has("--local")));
@@ -86,9 +107,39 @@ switch (cmd) {
86
107
  out(lines.join("\n"));
87
108
  break;
88
109
  }
110
+ case "content": {
111
+ // Owner-scoped content maps that sharpen /v1/diagnose on your own items.
112
+ // cognivia content items --input items.json upload item -> misconception maps
113
+ // cognivia content prerequisites --input pre.json upload concept -> prerequisite maps
114
+ // cognivia content items | prerequisites (no --input) list what is stored
115
+ if (!client.hasKey()) fail("content needs COGNIVIA_API_KEY (a self-serve live key).");
116
+ const kind = args[1];
117
+ const f = opt("--input");
118
+ const isUpload = f && f !== true;
119
+ const readArr = (key) => {
120
+ const data = JSON.parse(readFileSync(f, "utf8"));
121
+ const arr = Array.isArray(data) ? data : data[key];
122
+ if (!Array.isArray(arr) || !arr.length) fail("input must be a non-empty JSON array");
123
+ return arr;
124
+ };
125
+ try {
126
+ if (kind === "items") {
127
+ out(JSON.stringify(isUpload
128
+ ? await client.setItemMisconceptions(readArr("items"))
129
+ : await client.getItemMisconceptions(), null, 2));
130
+ } else if (kind === "prerequisites" || kind === "prereqs") {
131
+ out(JSON.stringify(isUpload
132
+ ? await client.setConceptPrerequisites(readArr("prerequisites"))
133
+ : await client.getConceptPrerequisites(), null, 2));
134
+ } else {
135
+ fail("content <items|prerequisites> [--input file.json]");
136
+ }
137
+ } catch (e) { fail("content: " + e.message); }
138
+ break;
139
+ }
89
140
  case "--version":
90
141
  case "-v":
91
- console.log("cognivia/0.1.0 (core " + "0.1.0" + ")");
142
+ console.log("cognivia/0.3.0 (core " + "0.3.0" + ")");
92
143
  break;
93
144
  case undefined:
94
145
  case "help":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognivia/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
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
5
  "type": "module",
6
6
  "bin": { "cognivia": "bin/cognivia.mjs" },
@@ -9,7 +9,7 @@
9
9
  "homepage": "https://cognivia-platform.vercel.app/intelligence",
10
10
  "repository": { "type": "git", "url": "git+https://github.com/Manik-Maurya/cognivia-platform.git", "directory": "packages/cli" },
11
11
  "engines": { "node": ">=18" },
12
- "dependencies": { "@cognivia/core": "^0.1.0" },
12
+ "dependencies": { "@cognivia/core": "^0.3.0" },
13
13
  "publishConfig": { "access": "public" },
14
14
  "license": "MIT",
15
15
  "author": "Manik Maurya"