kampus 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/README.md ADDED
@@ -0,0 +1,420 @@
1
+ <div align="center">
2
+
3
+ <br>
4
+
5
+ # Kampus
6
+
7
+ **The Korean School Information Toolkit**<br>
8
+ <sub>한국 학교 정보 통합 도구</sub>
9
+
10
+ <br>
11
+
12
+ *One engine, three surfaces — interactive shell · raw CLI · MCP server*
13
+
14
+ <br>
15
+
16
+ [![License: MIT](https://img.shields.io/badge/license-MIT-2563eb?style=flat-square)](LICENSE)
17
+ [![Node.js ≥ 20](https://img.shields.io/badge/node-%E2%89%A5%2020-16a34a?style=flat-square)](https://nodejs.org/)
18
+ [![TypeScript](https://img.shields.io/badge/typescript-strict-3178c6?style=flat-square)](https://www.typescriptlang.org/)
19
+ [![pnpm](https://img.shields.io/badge/pnpm-monorepo-f69220?style=flat-square)](https://pnpm.io/)
20
+ [![Platform](https://img.shields.io/badge/platform-windows%20%7C%20macos%20%7C%20linux-64748b?style=flat-square)](#)
21
+ [![AI Agent Ready](https://img.shields.io/badge/AI%20agent-ready-8b5cf6?style=flat-square)](#-ai-agent-onboarding)
22
+
23
+ </div>
24
+
25
+ <br>
26
+
27
+ ---
28
+
29
+ **Kampus** merges two Korean school data providers — **Comcigan** (practical timetables) and **NEIS Open API** (official government data) — into one unified engine. Use it as an interactive terminal app, pipe it through scripts with `--json`, or connect it as an MCP server for AI agents and integrations.
30
+
31
+ Every response carries transparent **data status** — `official-full`, `official-limited`, or `unofficial` — so you always know where your data came from and how complete it is.
32
+
33
+ ---
34
+
35
+ <br>
36
+
37
+ ## Three Surfaces
38
+
39
+ <table>
40
+ <tr>
41
+ <td width="33%" valign="top">
42
+
43
+ ### 🖥️ Human Shell
44
+
45
+ Full interactive terminal experience.
46
+
47
+ - Mission-control dashboard
48
+ - School search with quick picks
49
+ - Timetable & meal panels
50
+ - Profile & settings management
51
+ - IME-safe Korean text input
52
+ - Guided `easy` onboarding mode
53
+ - Live provider state badges
54
+
55
+ **Launch:**
56
+
57
+ `kps` · `kps human` · `kps easy`
58
+
59
+ </td>
60
+ <td width="33%" valign="top">
61
+
62
+ ### ⚡ Raw CLI
63
+
64
+ Scriptable commands, structured output.
65
+
66
+ - Complete school, timetable, meal commands
67
+ - 6 structured output formats
68
+ - Auth, config & profile management
69
+ - Built-in diagnostics & debugging
70
+ - Structured JSON error responses
71
+ - Default school & profile support
72
+
73
+ **Example:**
74
+
75
+ `kps class week --json`
76
+
77
+ </td>
78
+ <td width="33%" valign="top">
79
+
80
+ ### 🔌 MCP Server
81
+
82
+ Typed tools for agents & integrations.
83
+
84
+ - 13 structured MCP tools
85
+ - School, timetable, meals, NEIS
86
+ - Timetable snapshot diffing
87
+ - Full `structuredContent` output
88
+ - `dataStatus` on every response
89
+
90
+ **Build & run:**
91
+
92
+ `pnpm --filter @kampus/mcp build`<br>
93
+ `node packages/mcp/dist/server.js`
94
+
95
+ </td>
96
+ </tr>
97
+ </table>
98
+
99
+ <br>
100
+
101
+ ## 🚀 Quick Start
102
+
103
+ **Install from npm:**
104
+
105
+ ```bash
106
+ npm install -g kampus
107
+ kps --version
108
+ ```
109
+
110
+ **Install & verify:**
111
+
112
+ ```bash
113
+ pnpm install
114
+ pnpm verify # lint + typecheck + build + test
115
+ pnpm smoke:live # live provider health check
116
+ pnpm smoke:pack:cli # packaged CLI smoke test
117
+ ```
118
+
119
+ **Launch the interactive shell:**
120
+
121
+ ```bash
122
+ pnpm --filter @kampus/cli dev # auto-detects TTY → human shell
123
+ pnpm --filter @kampus/cli dev human # explicit human shell
124
+ pnpm --filter @kampus/cli dev easy # guided onboarding flow
125
+ ```
126
+
127
+ **Run raw commands:**
128
+
129
+ ```bash
130
+ kps school search "<keyword>"
131
+ kps class week --school "<school>" --region "<region>" --grade 3 --class 5 --json
132
+ kps meals today --school "<school>" --region "<region>" --json
133
+ kps neis schedule --school "<school>" --region "<region>" --from 2026-03-01 --to 2026-03-31 --json
134
+ kps doctor --live --json
135
+ ```
136
+
137
+ **Save a NEIS API key** (optional, unlocks full official mode):
138
+
139
+ ```bash
140
+ kps auth login --api-key "<your-neis-key>"
141
+ kps auth status --json
142
+ ```
143
+
144
+ > [!TIP]
145
+ > A NEIS key is **optional**. Without one, you get merged school search, all Comcigan timetable features, and limited official NEIS data. A real key unlocks complete official results and broader dataset queries.
146
+
147
+ <br>
148
+
149
+ ## 📋 Feature Overview
150
+
151
+ | Domain | Commands | Provider | Data Status |
152
+ |:-------|:---------|:---------|:------------|
153
+ | **School Search** | `school search` · `school resolve` · `school info` | Comcigan + NEIS | merged |
154
+ | **Student Timetable** | `class today` · `class day` · `class week` · `next` · `class-times` | Comcigan | `unofficial` |
155
+ | **Teacher** | `teacher info` · `teacher timetable` | Comcigan | `unofficial` |
156
+ | **Meals** | `meals today` · `meals week` · `meals range` · `meals month` | NEIS | `official` |
157
+ | **Official Datasets** | `neis classes` · `majors` · `tracks` · `schedule` · `timetable` · `classrooms` · `academies` | NEIS | `official` |
158
+ | **Auth & Config** | `auth login` · `status` · `validate` · `export` · `logout` | — | — |
159
+ | **Profiles** | `profile save` · `list` · `show` · `use` · `remove` | — | — |
160
+ | **Diagnostics** | `doctor` · `doctor --live` · `debug provider` · `debug school` · `debug neis-dataset` | Both | — |
161
+ | **Utilities** | `export` · `diff` | — | — |
162
+
163
+ <details>
164
+ <summary><strong>Output Formats</strong></summary>
165
+
166
+ <br>
167
+
168
+ All structured commands support multiple output formats:
169
+
170
+ | Flag | Format |
171
+ |:-----|:-------|
172
+ | `--json` | JSON |
173
+ | `--format yaml` | YAML |
174
+ | `--format csv` | CSV |
175
+ | `--format table` | Table |
176
+ | `--format markdown` | Markdown |
177
+ | `--format ndjson` | Newline-delimited JSON |
178
+
179
+ Default output is `human` (formatted for terminal reading).
180
+
181
+ </details>
182
+
183
+ <details>
184
+ <summary><strong>MCP Tools</strong></summary>
185
+
186
+ <br>
187
+
188
+ | Tool | Description |
189
+ |:-----|:-----------|
190
+ | `search_schools` | Merged school search |
191
+ | `get_school_info` | Normalized school info |
192
+ | `get_student_timetable_today` | Today's class schedule |
193
+ | `get_student_timetable_day` | Specific day schedule |
194
+ | `get_student_timetable_week` | Full weekly timetable |
195
+ | `get_teacher_timetable` | Teacher's schedule |
196
+ | `get_teacher_info` | Teacher info |
197
+ | `get_next_class` | Next upcoming class |
198
+ | `get_class_times` | Period start/end times |
199
+ | `get_meals_today` | Today's meals |
200
+ | `get_meals_week` | Weekly meal plan |
201
+ | `get_neis_dataset` | Official NEIS dataset query |
202
+ | `diff_timetable_snapshots` | Compare timetable snapshots |
203
+
204
+ </details>
205
+
206
+ <details>
207
+ <summary><strong>Human Shell Pages</strong></summary>
208
+
209
+ <br>
210
+
211
+ | Key | Page | What it shows |
212
+ |:---:|:-----|:-------------|
213
+ | <kbd>h</kbd> | Home | Dashboard: next class, timetable preview, meals, alerts |
214
+ | <kbd>s</kbd> | Schools | Search with result cards + recent quick picks (<kbd>1</kbd>–<kbd>9</kbd>) |
215
+ | <kbd>t</kbd> | Timetable | Weekly student timetable with status summary |
216
+ | <kbd>m</kbd> | Meals | Weekly meal view with notes |
217
+ | <kbd>y</kbd> | Teacher | Teacher info & timetable summary |
218
+ | <kbd>g</kbd> | Diagnostics | Key state, provider access modes, warning ledger |
219
+ | <kbd>p</kbd> | Settings | Profiles, default school, cache, destructive actions with confirmation |
220
+ | <kbd>?</kbd> | Help | Keyboard hints and design notes |
221
+
222
+ Navigation: <kbd>←</kbd> <kbd>→</kbd> arrows, <kbd>i</kbd> IME input, <kbd>r</kbd> refresh, <kbd>e</kbd> easy mode, <kbd>q</kbd> quit.
223
+
224
+ </details>
225
+
226
+ <br>
227
+
228
+ ## 🔐 Access Model
229
+
230
+ Every Kampus response includes transparent provenance via `dataStatus`:
231
+
232
+ | Status | Meaning | Requires |
233
+ |:-------|:--------|:---------|
234
+ | **`official-full`** | Authoritative NEIS data, complete results | Real `NEIS_API_KEY` |
235
+ | **`official-limited`** | Official NEIS data, may be truncated by sample cap | No key needed |
236
+ | **`unofficial`** | Comcigan data — practical but upstream-fragile | No key needed |
237
+
238
+ <table>
239
+ <tr>
240
+ <td width="50%" valign="top">
241
+
242
+ **Without a NEIS key**
243
+
244
+ - ✅ Merged school search & resolve
245
+ - ✅ Comcigan student / teacher timetables
246
+ - ✅ Limited NEIS school info, meals, datasets
247
+ - ⚠️ Broader queries may be truncated
248
+
249
+ </td>
250
+ <td width="50%" valign="top">
251
+
252
+ **With a real NEIS key**
253
+
254
+ - ✅ Everything from keyless mode
255
+ - ✅ Full official results, no truncation
256
+ - ✅ Broader schedule and dataset queries
257
+ - ✅ Full month meal queries
258
+
259
+ </td>
260
+ </tr>
261
+ </table>
262
+
263
+ > [!NOTE]
264
+ > `KEY=SAMPLE` is no longer valid for NEIS and returns `ERROR-290`. Omitting the key still works for some endpoints in limited sample mode. See [Upstream Verification](./docs/UPSTREAM_VERIFICATION.md) for full details.
265
+
266
+ <br>
267
+
268
+ ## 🤖 AI Agent Onboarding
269
+
270
+ > [!IMPORTANT]
271
+ > **This repository is agent-ready.** It ships with guardrails, task routing, and structured workflows for coding agents like Claude Code, Codex, and Cursor.
272
+
273
+ ### Quick start for agents
274
+
275
+ Point your agent at this repo and paste this prompt:
276
+
277
+ ```text
278
+ This repository has agent instructions and task-specific skills.
279
+ Start with AGENTS.md, then read docs/AGENT_GUIDE.md and docs/SKILLS_INDEX.md.
280
+ Use the appropriate Kampus skill from skills/ for school, timetable, meals, NEIS, or ops work.
281
+ Preserve raw CLI and MCP contracts unless the task explicitly changes them.
282
+ ```
283
+
284
+ ### What the agent gets
285
+
286
+ | File | Purpose |
287
+ |:-----|:--------|
288
+ | [`AGENTS.md`](./AGENTS.md) | Repo-wide guardrails and product boundaries |
289
+ | [`docs/AGENT_GUIDE.md`](./docs/AGENT_GUIDE.md) | Surface selection, provider model, verification matrix |
290
+ | [`docs/SKILLS_INDEX.md`](./docs/SKILLS_INDEX.md) | Task → domain skill routing map |
291
+ | [`docs/AGENT_RECIPES.md`](./docs/AGENT_RECIPES.md) | Copy-paste agent workflows (onboarding, daily brief, diagnosis, release) |
292
+ | [`skills/`](./skills/) | Domain-specific skill documents |
293
+
294
+ ### Skill routing
295
+
296
+ ```
297
+ skills/kampus/SKILL.md ← start here (umbrella router)
298
+ ├── kampus-school/SKILL.md school search, resolve, info
299
+ ├── kampus-timetable/SKILL.md student & teacher timetable
300
+ ├── kampus-meals/SKILL.md meal queries & metadata
301
+ ├── kampus-neis/SKILL.md official NEIS datasets
302
+ └── kampus-ops/SKILL.md verification, diagnostics, release
303
+ ```
304
+
305
+ ### Agent guardrails
306
+
307
+ - Preserve `dataStatus`, `providerMetadata`, `warnings`, `accessMode`, `complete`
308
+ - Preserve the Comcigan / NEIS provider split
309
+ - Use `--json` for scripted work; MCP for tool-calling clients
310
+ - Do not hide warning metadata to make output look cleaner
311
+ - Project and developer identity is **read-only** build metadata
312
+
313
+ <br>
314
+
315
+ ## 📦 Architecture
316
+
317
+ ```
318
+ kampus/
319
+ ├── packages/
320
+ │ ├── core/ @kampus/core
321
+ │ │ └── src/ Shared types, config, cache, routing, normalization
322
+ │ ├── providers/
323
+ │ │ ├── comcigan/ @kampus/provider-comcigan
324
+ │ │ │ └── src/ Unofficial timetable provider (dynamic route parsing)
325
+ │ │ └── neis/ @kampus/provider-neis
326
+ │ │ └── src/ Official NEIS Open API provider (key/keyless modes)
327
+ │ ├── cli/ @kampus/cli
328
+ │ │ └── src/ CLI commands, human shell, easy mode, TUI components
329
+ │ └── mcp/ @kampus/mcp
330
+ │ └── src/ MCP server with 13 typed tools
331
+ ├── skills/ Agent skill documents (6 domain skills)
332
+ ├── docs/ Reference documentation
333
+ ├── scripts/ Build, pack, and release scripts
334
+ └── .github/workflows/ CI, live smoke, release pipelines
335
+ ```
336
+
337
+ | Package | Role |
338
+ |:--------|:-----|
339
+ | **`@kampus/core`** | Normalized types, config, cache, provider routing, snapshot diff |
340
+ | **`@kampus/provider-comcigan`** | Unofficial Comcigan provider — dynamic `/st` route parsing, EUC-KR search, split-factor decode |
341
+ | **`@kampus/provider-neis`** | Official NEIS provider — keyed/keyless modes, truncation detection, dataset pagination |
342
+ | **`@kampus/cli`** | Internal workspace package for `kps`. Published to npm as **`kampus`** |
343
+ | **`@kampus/mcp`** | MCP server — 13 tools, `structuredContent`, transparent `dataStatus` |
344
+
345
+ <details>
346
+ <summary><strong>Core design decisions</strong></summary>
347
+
348
+ <br>
349
+
350
+ - **Merged school identity** — Schools are a `providerRefs` object holding both Comcigan and NEIS identifiers, enabling operation-based routing instead of provider-locked resolution.
351
+
352
+ - **Shared result model** — CLI JSON output and MCP `structuredContent` use the same `dataStatus` + `providerMetadata` model. No separate output abstractions.
353
+
354
+ - **Transparent warnings** — Provider warning codes (`NEIS_TIMETABLE_YEAR_LAG`, `NEIS_STALE_CACHE`, `NEIS_PAGE_LIMIT`, etc.) flow through to consumers instead of being swallowed.
355
+
356
+ - **Structured errors** — JSON mode returns typed error objects with semantic exit codes (2–10) for script consumption.
357
+
358
+ </details>
359
+
360
+ <br>
361
+
362
+ ## 📚 Documentation
363
+
364
+ | Document | Covers |
365
+ |:---------|:-------|
366
+ | [**CLI Reference**](./docs/CLI_REFERENCE.md) | Complete command reference — modes, flags, output formats, exit codes |
367
+ | [**Operator Runbook**](./docs/OPERATOR_RUNBOOK.md) | Setup, smoke checks, key rotation, release flow, incident playbooks |
368
+ | [**Agent Guide**](./docs/AGENT_GUIDE.md) | Surface selection, provider model, metadata contracts, verification |
369
+ | [**Agent Recipes**](./docs/AGENT_RECIPES.md) | Compact repeatable workflows — onboarding, daily brief, diagnosis, release |
370
+ | [**Skills Index**](./docs/SKILLS_INDEX.md) | Task → skill routing map for agents |
371
+ | [**TUI Handoff**](./docs/TUI_HANDOFF.md) | Human shell design contracts, UX boundaries, suggested improvements |
372
+ | [**Upstream Verification**](./docs/UPSTREAM_VERIFICATION.md) | Live upstream checks, implementation rules, repo inspections |
373
+ | [**Architecture Deep Dive**](./REPO_DEEPDIVE_REPORT.md) | Full architecture review, packaging, remaining risks |
374
+
375
+ <br>
376
+
377
+ ## ✅ Validation & Quality Gates
378
+
379
+ ```bash
380
+ pnpm verify # lint + typecheck + build + test
381
+ pnpm smoke:live # live provider health (no key required)
382
+ pnpm smoke:pack:cli # packed CLI tarball install + startup
383
+ NEIS_API_KEY=<key> pnpm smoke:keyed # full official NEIS validation
384
+ ```
385
+
386
+ | CI Workflow | Trigger | What it does |
387
+ |:------------|:--------|:-------------|
388
+ | **`ci.yml`** | Push / PR | Verify on Ubuntu, Windows, macOS · Packed CLI smoke |
389
+ | **`live-smoke.yml`** | Every 6 hours | Live provider smoke · Auto-opens/closes GitHub issues on failure |
390
+ | **`release.yml`** | `v*` tag | Verify → pack → smoke-install → upload artifact → npm publish |
391
+
392
+ <br>
393
+
394
+ ## ⚠️ Limitations
395
+
396
+ > [!WARNING]
397
+ > **Comcigan is unofficial.** It provides practical timetable data but can break without notice if the upstream changes its payload format or endpoints.
398
+
399
+ > [!CAUTION]
400
+ > **No-key NEIS is useful but limited.** Sample-mode queries may be truncated at 5 rows. A real `NEIS_API_KEY` is required for production-grade completeness.
401
+
402
+ - Official NEIS timetable data can lag behind other datasets for the same school and academic year.
403
+ - Windows uses DPAPI for local secret storage. Non-Windows environments fall back to plain-text config unless environment variables are used.
404
+ - Project and developer identity metadata is embedded in the build and is **read-only** for users.
405
+
406
+ <br>
407
+
408
+ ---
409
+
410
+ <div align="center">
411
+
412
+ <sub>
413
+
414
+ **Kampus** · [`github.com/4ndrxxs/Kampus`](https://github.com/4ndrxxs/Kampus) · MIT License
415
+
416
+ Built by **Juwon Seo** · `contact@seojuwon.com`
417
+
418
+ </sub>
419
+
420
+ </div>