SNU Canvas CLI
Use this skill to operate lx-agent exclusively through its CLI bridge. Do NOT bypass the CLI by calling Canvas API endpoints directly with curl, fetch, or any HTTP client.
Critical Rules
- 1. CLI-only access — Always use the bridge script below. Never curl/fetch Canvas API endpoints directly. The CLI handles authentication, XSRF tokens, and error handling internally.
- Never ask for tokens in chat — Tokens are secrets. Never ask the user to paste or send API tokens via Telegram, Slack, or any chat. Instead, guide them to update
config.yaml or set CANVAS_TOKEN env var on the server. - Never expose token values — Do not print, log, or display token values (even partially masked) in responses.
- Follow verification flow — Always run
config command first before diagnosing issues.
Command Bridge
Run commands through the bundled bridge script:
CODEBLOCK0
Set LX_AGENT_ROOT when running outside the repository root.
Domain Guardrails (Important)
- - Treat
canvas.url in config.yaml (or CANVAS_URL) as source of truth unless the user explicitly changes it. - Never replace the LMS domain with other university domains by inference.
- Do not claim a domain is invalid from one resolver or one server network.
- If DNS check fails in current environment, report it as environment-scoped and ask for the user-confirmed LMS URL before changing config.
- Keep "Learning X" as product naming and
learningx as technical identifier.
Error Handling: 401 Unauthorized / Token Errors
When the CLI returns 401 or token-related errors:
- 1. Run
skills/learningx-cli/scripts/run-lx-agent-cli.sh config to confirm which token/URL is configured. - Tell the user: "Canvas API 토큰이 만료되었거나 유효하지 않습니다. LMS 웹사이트의 Settings → New Access Token에서 새 토큰을 발급한 뒤, 서버의 config.yaml 파일에서 canvas.token 값을 직접 업데이트해주세요."
- Do NOT ask them to send the token in chat.
- Do NOT attempt to curl the API yourself to "test" the token.
- After the user confirms they updated the config, re-run the CLI command to verify.
Required URL Verification Flow
Run this sequence before concluding URL problems:
CODEBLOCK1
If these checks fail from the current runtime:
- - say "cannot verify from this server/runtime"
- do not claim global NXDOMAIN unless confirmed by multiple independent resolvers
- ask user to confirm LMS URL they use in browser
Common Commands
CODEBLOCK2
Notes
- - The bridge runs
go run ./cmd/lx-agent .... - Keep outputs concise and include command results directly in your response.
- For bot/serve runs, surface startup errors and required env/config clearly.
- For URL issues, follow
Domain Guardrails and never auto-substitute a different domain. - When something fails, use the CLI to diagnose — do not fall back to raw HTTP calls.
SNU Canvas CLI
使用此技能时,请仅通过其CLI桥接器操作lx-agent。切勿使用curl、fetch或任何HTTP客户端直接调用Canvas API端点来绕过CLI。
关键规则
- 1. 仅限CLI访问 — 始终使用下方的桥接脚本。切勿直接curl/fetch Canvas API端点。CLI内部处理认证、XSRF令牌和错误处理。
- 切勿在聊天中索要令牌 — 令牌是机密信息。切勿要求用户通过Telegram、Slack或任何聊天工具粘贴或发送API令牌。应引导他们在服务器上更新config.yaml或设置CANVAS_TOKEN环境变量。
- 切勿暴露令牌值 — 不要在回复中打印、记录或显示令牌值(即使是部分遮盖的)。
- 遵循验证流程 — 在诊断问题前,始终先运行config命令。
命令桥接
通过捆绑的桥接脚本运行命令:
bash
skills/learningx-cli/scripts/run-lx-agent-cli.sh [args...]
在仓库根目录外运行时,需设置LXAGENTROOT。
域名护栏(重要)
- - 除非用户明确更改,否则以config.yaml中的canvas.url(或CANVAS_URL)为准。
- 切勿通过推断将LMS域名替换为其他大学域名。
- 不要仅凭一个解析器或一个服务器网络就声称域名无效。
- 如果当前环境的DNS检查失败,应将其报告为环境范围的问题,并在更改配置前询问用户确认的LMS URL。
- 产品命名保持为Learning X,技术标识符保持为learningx。
错误处理:401未授权/令牌错误
当CLI返回401或令牌相关错误时:
- 1. 运行skills/learningx-cli/scripts/run-lx-agent-cli.sh config确认配置的令牌/URL。
- 告知用户:Canvas API令牌已过期或无效。请在LMS网站的Settings → New Access Token中生成新令牌,然后直接在服务器的config.yaml文件中更新canvas.token值。
- 切勿要求他们在聊天中发送令牌。
- 切勿自行curl API来测试令牌。
- 用户确认更新配置后,重新运行CLI命令进行验证。
必需的URL验证流程
在得出URL问题结论前,按此顺序运行:
bash
skills/learningx-cli/scripts/run-lx-agent-cli.sh config
getent hosts || nslookup || dig +short
curl -I --max-time 10 https://
如果这些检查在当前运行环境中失败:
- - 说明无法从此服务器/运行环境验证
- 除非经多个独立解析器确认,否则不要声称全局NXDOMAIN
- 询问用户在浏览器中使用的LMS URL
常用命令
bash
skills/learningx-cli/scripts/run-lx-agent-cli.sh config
skills/learningx-cli/scripts/run-lx-agent-cli.sh courses
skills/learningx-cli/scripts/run-lx-agent-cli.sh assignments
skills/learningx-cli/scripts/run-lx-agent-cli.sh files
skills/learningx-cli/scripts/run-lx-agent-cli.sh announcements
skills/learningx-cli/scripts/run-lx-agent-cli.sh bot
skills/learningx-cli/scripts/run-lx-agent-cli.sh serve
备注
- - 桥接器运行go run ./cmd/lx-agent ...。
- 保持输出简洁,直接在回复中包含命令结果。
- 对于bot/serve运行,清晰显示启动错误及所需的环境/配置。
- 对于URL问题,遵循域名护栏规则,切勿自动替换为其他域名。
- 出现故障时,使用CLI进行诊断——不要回退到原始HTTP调用。