@lukeguo12210/canvas-cli 0.0.3 → 0.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukeguo12210/canvas-cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Connect Canvas courses to AI agents: pull modules, files, assignments, pages, folders, and review packs without manual downloads.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,6 +3,10 @@ Canvas CLI installed.
3
3
 
4
4
  To enable agent skills, run:
5
5
 
6
+ canvas skills install
7
+
8
+ Or run the installer command directly:
9
+
6
10
  npx skills add lukeguo12210/canvas-cli -g --skill "*" -y
7
11
 
8
12
  Then authenticate:
@@ -14,30 +14,39 @@ Read this skill before using any other Canvas skill.
14
14
 
15
15
  ## CLI Availability
16
16
 
17
- First try:
17
+ Resolve the CLI command once per session:
18
18
 
19
19
  ```bash
20
- canvas auth status --format json
20
+ command -v canvas
21
21
  ```
22
22
 
23
- If the shell returns `command not found: canvas`, the CLI is not on `PATH`.
23
+ If this succeeds, use plain `canvas ...` commands for the rest of the session.
24
24
 
25
- Use this non-global fallback inside an agent session:
25
+ If this fails, use this non-global fallback prefix for the rest of the session:
26
26
 
27
27
  ```bash
28
- npm exec --yes --package @lukeguo12210/canvas-cli -- canvas auth status --format json
28
+ npm exec --yes --package @lukeguo12210/canvas-cli -- canvas
29
29
  ```
30
30
 
31
- When using the fallback, replace the leading `canvas` in any command with:
31
+ Do not wrap every command in `canvas ... || npm exec ...`; it is noisy and can make agents wait on npm repeatedly. Pick one command prefix, then run the requested Canvas command once.
32
+
33
+ Check auth after the command prefix is resolved:
32
34
 
33
35
  ```bash
34
- npm exec --yes --package @lukeguo12210/canvas-cli -- canvas
36
+ canvas auth status --format json
37
+ ```
38
+
39
+ or:
40
+
41
+ ```bash
42
+ npm exec --yes --package @lukeguo12210/canvas-cli -- canvas auth status --format json
35
43
  ```
36
44
 
37
45
  For permanent install, tell the user:
38
46
 
39
47
  ```bash
40
48
  npm install -g @lukeguo12210/canvas-cli
49
+ canvas skills install
41
50
  ```
42
51
 
43
52
  If global install fails with `EACCES` under `/usr/local`, do not use `sudo` or create symlinks in `/usr/local`. Ask the user to configure a user-level npm prefix, use a Node version manager, or continue with the `npm exec` fallback for this session.
@@ -48,6 +57,7 @@ Implemented now:
48
57
 
49
58
  - `canvas auth login`
50
59
  - `canvas auth status`
60
+ - `canvas auth schools search <query>`
51
61
  - `canvas auth logout`
52
62
  - `canvas config show`
53
63
  - `canvas me`
@@ -63,6 +73,7 @@ Implemented now:
63
73
  - `canvas pages list/show/export`
64
74
  - `canvas files list/show/download/download-linked`
65
75
  - `canvas folders list/path`
76
+ - `canvas skills install/command/status`
66
77
 
67
78
  Planned but not implemented yet:
68
79
 
@@ -72,8 +83,8 @@ Planned but not implemented yet:
72
83
  ## Core Rules
73
84
 
74
85
  - Use `canvas auth status` first if auth state is uncertain.
75
- - If no auth config exists, ask the user to run `canvas auth login`.
76
- - Never print, paste, summarize, or expose a Canvas personal access token.
86
+ - If no auth config exists, use `canvas auth schools search <query>` and then `canvas auth login --school <query> --token-env <env>` or `canvas auth login --school <query> --token <token>` when the user explicitly provides a PAT.
87
+ - Never print, paste, summarize, or expose a Canvas personal access token after receiving it.
77
88
  - Default output is JSON and should be preferred for agents.
78
89
  - Use `--format pretty` only when presenting a compact human-facing result.
79
90
  - Use `--page-all` when completeness matters.
@@ -112,6 +123,8 @@ Do not include those in review packs unless the user explicitly asks.
112
123
 
113
124
  ```bash
114
125
  canvas auth status --format json
126
+ canvas auth schools search "Columbia" --format json
127
+ canvas skills install
115
128
  canvas courses list --active --page-all --format json
116
129
  canvas courses search "course name" --format json
117
130
  canvas courses overview <course-id> --format json
@@ -4,22 +4,71 @@ Implemented auth commands:
4
4
 
5
5
  ```bash
6
6
  canvas auth login
7
+ canvas auth login --school "Columbia" --token-env CANVAS_TOKEN
8
+ canvas auth login --school-url https://courseworks2.columbia.edu --school-name "Columbia University (CourseWorks)" --token "paste-token-here"
9
+ canvas auth schools search "Columbia" --format json
7
10
  canvas auth status --format json
8
11
  canvas auth logout
9
12
  canvas config show --format json
10
13
  canvas me --format json
11
14
  ```
12
15
 
13
- If `canvas` is not on `PATH`, use the npm exec fallback:
16
+ Resolve the CLI command once per session:
17
+
18
+ ```bash
19
+ command -v canvas
20
+ ```
21
+
22
+ If `canvas` is not on `PATH`, use the npm exec fallback prefix for the rest of the session:
14
23
 
15
24
  ```bash
16
25
  npm exec --yes --package @lukeguo12210/canvas-cli -- canvas auth status --format json
17
26
  npm exec --yes --package @lukeguo12210/canvas-cli -- canvas auth login
27
+ npm exec --yes --package @lukeguo12210/canvas-cli -- canvas auth login --school "Columbia" --token-env CANVAS_TOKEN
18
28
  ```
19
29
 
30
+ Do not run repeated compound commands like `canvas ... || npm exec ...`. Pick either `canvas` or the npm exec prefix and use it consistently.
31
+
20
32
  Do not attempt `sudo npm install -g` from inside an agent session. Prefer the fallback above or ask the user to fix their npm global prefix.
21
33
 
22
- ## Login Flow
34
+ ## Agent Login Flow
35
+
36
+ Agents can complete login non-interactively when the user explicitly provides a Canvas PAT.
37
+
38
+ 1. Search schools:
39
+
40
+ ```bash
41
+ canvas auth schools search "Columbia" --format json
42
+ ```
43
+
44
+ 2. Login with a known school match:
45
+
46
+ ```bash
47
+ canvas auth login --school "Columbia" --token-env CANVAS_TOKEN
48
+ ```
49
+
50
+ or, if the user provides the token directly in chat:
51
+
52
+ ```bash
53
+ canvas auth login --school "Columbia" --token "paste-token-here"
54
+ ```
55
+
56
+ 3. For a custom Canvas URL:
57
+
58
+ ```bash
59
+ canvas auth login --school-url https://courseworks2.columbia.edu --school-name "Columbia University (CourseWorks)" --token-env CANVAS_TOKEN
60
+ ```
61
+
62
+ 4. Verify:
63
+
64
+ ```bash
65
+ canvas auth status --format json
66
+ canvas courses list --active --page-all --format json
67
+ ```
68
+
69
+ If `--school` matches multiple schools, run `canvas auth schools search <query>` and retry with a more specific value or use `--school-url`.
70
+
71
+ ## Interactive Login Flow
23
72
 
24
73
  `canvas auth login` is interactive.
25
74
 
@@ -40,9 +89,15 @@ Is this your school: Columbia University (CourseWorks) (https://courseworks2.col
40
89
  8. Validate token.
41
90
  9. Store local config.
42
91
 
43
- ## Token Safety
92
+ ## Token Handling
93
+
94
+ The CLI supports agent-provided PATs for initial setup:
95
+
96
+ - `--token <PAT>`: direct token argument.
97
+ - `--token-env <ENV_NAME>`: read token from an environment variable.
98
+ - `--token-stdin`: read token from stdin.
44
99
 
45
- Never ask the user to paste a token into chat. The token should be pasted into the local terminal prompt from `canvas auth login`.
100
+ Prefer `--token-env` or `--token-stdin` when possible. If the user pastes a PAT into chat, use it only for `canvas auth login`, then do not repeat, print, summarize, or store it anywhere except the Canvas config written by the CLI.
46
101
 
47
102
  Never print:
48
103