@chalksurf/cli 0.1.0 → 0.2.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/docs/manual.md ADDED
@@ -0,0 +1,152 @@
1
+ # Manual Operator Guide
2
+
3
+ Use this flow when a person is driving the CLI directly from a terminal.
4
+
5
+ ## Authentication
6
+
7
+ Interactive login stores the token and base URL in the local CLI config:
8
+
9
+ ```bash
10
+ chalksurf auth login --base-url https://api.chalksurf.com
11
+ ```
12
+
13
+ The same command also works with piped stdin:
14
+
15
+ ```bash
16
+ printf '%s' "$CHALKSURF_TOKEN" | chalksurf auth login --base-url https://api.chalksurf.com
17
+ ```
18
+
19
+ Check what the CLI will use for the current session:
20
+
21
+ ```bash
22
+ chalksurf auth status
23
+ ```
24
+
25
+ Config resolution rules:
26
+
27
+ - `--base-url` overrides `CHALKSURF_BASE_URL`, which overrides the stored config.
28
+ - `CHALKSURF_TOKEN` overrides the stored config token.
29
+ - `--organization` overrides manifest `organizationId`, which overrides `CHALKSURF_ORGANIZATION_ID`, which overrides the stored config.
30
+
31
+ ## Organization Selection
32
+
33
+ List organizations visible to the current token:
34
+
35
+ ```bash
36
+ chalksurf org list
37
+ ```
38
+
39
+ Store a default organization for future commands:
40
+
41
+ ```bash
42
+ chalksurf org use org_123
43
+ ```
44
+
45
+ Override it for one command:
46
+
47
+ ```bash
48
+ chalksurf sheet import ./fixtures/algebra.pdf --organization org_456
49
+ ```
50
+
51
+ ## Common Import Flows
52
+
53
+ Import one sheet and wait for the background job to finish:
54
+
55
+ ```bash
56
+ chalksurf sheet import ./fixtures/algebra.pdf --wait
57
+ ```
58
+
59
+ Import one sheet, override its title, and request an English translation during import:
60
+
61
+ ```bash
62
+ chalksurf sheet import ./fixtures/algebra.pdf \
63
+ --title "OKTV 2014 Round 1" \
64
+ --translate-to english \
65
+ --wait
66
+ ```
67
+
68
+ Import one sheet assembled from multiple source files:
69
+
70
+ ```bash
71
+ chalksurf sheet import ./fixtures/round-1-a.pdf ./fixtures/round-1-b.pdf \
72
+ --single-sheet \
73
+ --target-folder "OKTV/2014" \
74
+ --wait
75
+ ```
76
+
77
+ Import exercises into an existing sheet:
78
+
79
+ ```bash
80
+ chalksurf exercise import ./fixtures/problem-set.pdf \
81
+ --sheet-id 00000000-0000-4000-8000-000000000001 \
82
+ --wait
83
+ ```
84
+
85
+ Import a solution into an existing exercise:
86
+
87
+ ```bash
88
+ chalksurf exercise import-solution \
89
+ 00000000-0000-4000-8000-000000000001 \
90
+ ./fixtures/solution.pdf \
91
+ --wait
92
+ ```
93
+
94
+ Import from a remote URL:
95
+
96
+ ```bash
97
+ chalksurf sheet import https://example.com/trig.docx \
98
+ --single-sheet \
99
+ --target-folder Imported \
100
+ --wait
101
+ ```
102
+
103
+ Use a manifest for multi-source imports or when each resulting sheet needs explicit metadata:
104
+
105
+ ```bash
106
+ chalksurf sheet import --manifest ./import.json --wait
107
+ ```
108
+
109
+ Sheet import manifests use top-level `sheets[]`. Each sheet has one destination `targetFolderPath`, optional `title` and `translateTo`, and one or more ordered `sources[]`.
110
+
111
+ ## Working With Jobs
112
+
113
+ Read one job:
114
+
115
+ ```bash
116
+ chalksurf job get job_123
117
+ ```
118
+
119
+ Wait on one or more jobs later:
120
+
121
+ ```bash
122
+ chalksurf job wait job_123 job_124
123
+ ```
124
+
125
+ `--wait` on an import command means the requested import work is complete before the command exits. For sheet imports, that includes requested translations.
126
+
127
+ ## Troubleshooting
128
+
129
+ Missing auth:
130
+
131
+ ```bash
132
+ chalksurf auth status
133
+ ```
134
+
135
+ Use a separate config file when switching between local, staging, and production:
136
+
137
+ ```bash
138
+ export CHALKSURF_CONFIG_PATH=/tmp/chalksurf-staging.json
139
+ chalksurf auth login --base-url https://staging-api.chalksurf.com
140
+ ```
141
+
142
+ Use JSON mode when you need exact machine-readable output:
143
+
144
+ ```bash
145
+ chalksurf job wait job_123 --json
146
+ ```
147
+
148
+ Further reference:
149
+
150
+ - [Agent and Codex guide](./agents.md)
151
+ - [Manifest reference](./manifest.md)
152
+ - [Exit codes and JSON errors](./exit-codes.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chalksurf/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
- "README.md"
11
+ "README.md",
12
+ "docs",
13
+ "schemas"
12
14
  ],
13
15
  "bin": {
14
16
  "chalksurf": "dist/bin/chalksurf.js"
@@ -26,12 +28,14 @@
26
28
  "build": "tsc --project ./tsconfig.build.json",
27
29
  "lint": "eslint .",
28
30
  "type-check": "tsc --noEmit --project ./tsconfig.json",
29
- "test": "vitest --config ./vitest.config.ts --run",
31
+ "test": "vitest --config ./vitest.config.ts --run --maxWorkers=1",
32
+ "test:watch": "vitest --config ./vitest.config.ts --watch --maxWorkers=1",
30
33
  "smoke-pack": "node --import tsx ./scripts/smoke-pack.ts"
31
34
  },
32
35
  "dependencies": {
33
36
  "p-limit": "^6.2.0",
34
- "yargs": "^17.7.2"
37
+ "yargs": "^17.7.2",
38
+ "zod": "^4.1.12"
35
39
  },
36
40
  "devDependencies": {
37
41
  "@types/node": "^24.10.1",
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/knowledge-maps/chalksurf/blob/main/packages/cli/schemas/exercise-import-manifest.schema.json",
4
+ "title": "ChalkSurf Exercise Import Manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["sources"],
8
+ "properties": {
9
+ "organizationId": {
10
+ "type": "string",
11
+ "minLength": 1
12
+ },
13
+ "exerciseSheetId": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "wait": {
18
+ "type": "boolean"
19
+ },
20
+ "sources": {
21
+ "type": "array",
22
+ "minItems": 1,
23
+ "items": {
24
+ "$ref": "#/$defs/source"
25
+ }
26
+ }
27
+ },
28
+ "$defs": {
29
+ "nonEmptyString": {
30
+ "type": "string",
31
+ "minLength": 1
32
+ },
33
+ "localSource": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["kind", "path"],
37
+ "properties": {
38
+ "sourceId": {
39
+ "$ref": "#/$defs/nonEmptyString"
40
+ },
41
+ "kind": {
42
+ "const": "local"
43
+ },
44
+ "path": {
45
+ "$ref": "#/$defs/nonEmptyString"
46
+ },
47
+ "relativePath": {
48
+ "$ref": "#/$defs/nonEmptyString"
49
+ }
50
+ }
51
+ },
52
+ "directorySource": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": ["kind", "path"],
56
+ "properties": {
57
+ "sourceId": {
58
+ "$ref": "#/$defs/nonEmptyString"
59
+ },
60
+ "kind": {
61
+ "const": "directory"
62
+ },
63
+ "path": {
64
+ "$ref": "#/$defs/nonEmptyString"
65
+ },
66
+ "relativeRoot": {
67
+ "$ref": "#/$defs/nonEmptyString"
68
+ }
69
+ }
70
+ },
71
+ "urlSource": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["kind", "url"],
75
+ "properties": {
76
+ "sourceId": {
77
+ "$ref": "#/$defs/nonEmptyString"
78
+ },
79
+ "kind": {
80
+ "const": "url"
81
+ },
82
+ "url": {
83
+ "$ref": "#/$defs/nonEmptyString"
84
+ },
85
+ "relativePath": {
86
+ "$ref": "#/$defs/nonEmptyString"
87
+ }
88
+ }
89
+ },
90
+ "source": {
91
+ "oneOf": [
92
+ {
93
+ "$ref": "#/$defs/localSource"
94
+ },
95
+ {
96
+ "$ref": "#/$defs/directorySource"
97
+ },
98
+ {
99
+ "$ref": "#/$defs/urlSource"
100
+ }
101
+ ]
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/knowledge-maps/chalksurf/blob/main/packages/cli/schemas/exercise-solution-import-manifest.schema.json",
4
+ "title": "ChalkSurf Exercise Solution Import Manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["sources"],
8
+ "properties": {
9
+ "organizationId": {
10
+ "type": "string",
11
+ "minLength": 1
12
+ },
13
+ "exerciseId": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "wait": {
18
+ "type": "boolean"
19
+ },
20
+ "sources": {
21
+ "type": "array",
22
+ "minItems": 1,
23
+ "items": {
24
+ "$ref": "#/$defs/source"
25
+ }
26
+ }
27
+ },
28
+ "$defs": {
29
+ "nonEmptyString": {
30
+ "type": "string",
31
+ "minLength": 1
32
+ },
33
+ "localSource": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["kind", "path"],
37
+ "properties": {
38
+ "sourceId": {
39
+ "$ref": "#/$defs/nonEmptyString"
40
+ },
41
+ "kind": {
42
+ "const": "local"
43
+ },
44
+ "path": {
45
+ "$ref": "#/$defs/nonEmptyString"
46
+ },
47
+ "relativePath": {
48
+ "$ref": "#/$defs/nonEmptyString"
49
+ }
50
+ }
51
+ },
52
+ "directorySource": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": ["kind", "path"],
56
+ "properties": {
57
+ "sourceId": {
58
+ "$ref": "#/$defs/nonEmptyString"
59
+ },
60
+ "kind": {
61
+ "const": "directory"
62
+ },
63
+ "path": {
64
+ "$ref": "#/$defs/nonEmptyString"
65
+ },
66
+ "relativeRoot": {
67
+ "$ref": "#/$defs/nonEmptyString"
68
+ }
69
+ }
70
+ },
71
+ "urlSource": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": ["kind", "url"],
75
+ "properties": {
76
+ "sourceId": {
77
+ "$ref": "#/$defs/nonEmptyString"
78
+ },
79
+ "kind": {
80
+ "const": "url"
81
+ },
82
+ "url": {
83
+ "$ref": "#/$defs/nonEmptyString"
84
+ },
85
+ "relativePath": {
86
+ "$ref": "#/$defs/nonEmptyString"
87
+ }
88
+ }
89
+ },
90
+ "source": {
91
+ "oneOf": [
92
+ {
93
+ "$ref": "#/$defs/localSource"
94
+ },
95
+ {
96
+ "$ref": "#/$defs/directorySource"
97
+ },
98
+ {
99
+ "$ref": "#/$defs/urlSource"
100
+ }
101
+ ]
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,142 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/knowledge-maps/chalksurf/blob/main/packages/cli/schemas/sheet-import-manifest.schema.json",
4
+ "title": "ChalkSurf Sheet Import Manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["sheets"],
8
+ "properties": {
9
+ "organizationId": {
10
+ "type": "string",
11
+ "minLength": 1
12
+ },
13
+ "wait": {
14
+ "type": "boolean"
15
+ },
16
+ "sheets": {
17
+ "type": "array",
18
+ "minItems": 1,
19
+ "items": {
20
+ "$ref": "#/$defs/sheet"
21
+ }
22
+ }
23
+ },
24
+ "$defs": {
25
+ "nonEmptyString": {
26
+ "type": "string",
27
+ "minLength": 1
28
+ },
29
+ "targetFolderPath": {
30
+ "oneOf": [
31
+ {
32
+ "type": "null"
33
+ },
34
+ {
35
+ "$ref": "#/$defs/nonEmptyString"
36
+ }
37
+ ]
38
+ },
39
+ "translateLanguage": {
40
+ "type": "string",
41
+ "enum": ["english", "hungarian", "german", "french", "spanish", "italian"]
42
+ },
43
+ "localSource": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "required": ["kind", "path"],
47
+ "properties": {
48
+ "sourceId": {
49
+ "$ref": "#/$defs/nonEmptyString"
50
+ },
51
+ "kind": {
52
+ "const": "local"
53
+ },
54
+ "path": {
55
+ "$ref": "#/$defs/nonEmptyString"
56
+ },
57
+ "relativePath": {
58
+ "$ref": "#/$defs/nonEmptyString"
59
+ }
60
+ }
61
+ },
62
+ "directorySource": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "required": ["kind", "path"],
66
+ "properties": {
67
+ "sourceId": {
68
+ "$ref": "#/$defs/nonEmptyString"
69
+ },
70
+ "kind": {
71
+ "const": "directory"
72
+ },
73
+ "path": {
74
+ "$ref": "#/$defs/nonEmptyString"
75
+ },
76
+ "relativeRoot": {
77
+ "$ref": "#/$defs/nonEmptyString"
78
+ }
79
+ }
80
+ },
81
+ "urlSource": {
82
+ "type": "object",
83
+ "additionalProperties": false,
84
+ "required": ["kind", "url"],
85
+ "properties": {
86
+ "sourceId": {
87
+ "$ref": "#/$defs/nonEmptyString"
88
+ },
89
+ "kind": {
90
+ "const": "url"
91
+ },
92
+ "url": {
93
+ "$ref": "#/$defs/nonEmptyString"
94
+ },
95
+ "relativePath": {
96
+ "$ref": "#/$defs/nonEmptyString"
97
+ }
98
+ }
99
+ },
100
+ "source": {
101
+ "oneOf": [
102
+ {
103
+ "$ref": "#/$defs/localSource"
104
+ },
105
+ {
106
+ "$ref": "#/$defs/directorySource"
107
+ },
108
+ {
109
+ "$ref": "#/$defs/urlSource"
110
+ }
111
+ ]
112
+ },
113
+ "sheet": {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": ["targetFolderPath", "sources"],
117
+ "properties": {
118
+ "targetFolderPath": {
119
+ "$ref": "#/$defs/targetFolderPath"
120
+ },
121
+ "title": {
122
+ "$ref": "#/$defs/nonEmptyString"
123
+ },
124
+ "translateTo": {
125
+ "type": "array",
126
+ "minItems": 1,
127
+ "uniqueItems": true,
128
+ "items": {
129
+ "$ref": "#/$defs/translateLanguage"
130
+ }
131
+ },
132
+ "sources": {
133
+ "type": "array",
134
+ "minItems": 1,
135
+ "items": {
136
+ "$ref": "#/$defs/source"
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }