onenote-cli 0.2.0 → 0.2.1-darwin-arm64
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/bin/onenote-cli +0 -0
- package/package.json +12 -44
- package/.env.example +0 -10
- package/.github/workflows/release.yml +0 -43
- package/.husky/pre-commit +0 -1
- package/.releaserc.json +0 -13
- package/.secretlintrc.json +0 -3
- package/CLAUDE.md +0 -42
- package/README.md +0 -254
- package/SKILL.md +0 -77
- package/bun.lock +0 -1427
- package/docs/azure-app-registration.md +0 -80
- package/docs/development-notes.md +0 -84
- package/docs/graph-api-endpoints.md +0 -131
- package/docs/local-search-architecture.md +0 -132
- package/docs/onen0te-cli-analysis.md +0 -130
- package/docs/setup.md +0 -141
- package/docs/zhihu-intro.md +0 -92
- package/src/auth.ts +0 -359
- package/src/cache.ts +0 -1709
- package/src/debug-tags.ts +0 -207
- package/src/export.ts +0 -367
- package/src/graph.ts +0 -1480
- package/src/index.ts +0 -1176
- package/src/markdown.ts +0 -134
- package/src/read-render.ts +0 -621
- package/src/sync-ui.tsx +0 -220
- package/tsconfig.json +0 -16
package/bin/onenote-cli
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,51 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onenote-cli",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1-darwin-arm64",
|
|
4
|
+
"description": "onenote-cli native binaries for darwin-arm64",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/snomiao/onenote-cli.git"
|
|
8
9
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"typecheck": "bunx tsgo --noEmit",
|
|
19
|
-
"prepare": "husky"
|
|
20
|
-
},
|
|
21
|
-
"lint-staged": {
|
|
22
|
-
"**/*.{ts,tsx,js,jsx,mjs,cjs}": [
|
|
23
|
-
"oxlint --fix"
|
|
24
|
-
],
|
|
25
|
-
"**/*": "secretlint"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@azure/msal-node": "^2.16.0",
|
|
29
|
-
"@types/react": "^19.2.14",
|
|
30
|
-
"clipboardy": "^5.3.1",
|
|
31
|
-
"ink": "^7.0.1",
|
|
32
|
-
"pretty-bytes": "^7.1.0",
|
|
33
|
-
"react": "^19.2.5",
|
|
34
|
-
"yargs": "^17.7.2"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@secretlint/secretlint-rule-preset-recommend": "^11.6.0",
|
|
38
|
-
"@semantic-release/git": "^10.0.1",
|
|
39
|
-
"@semantic-release/github": "^12.0.6",
|
|
40
|
-
"@types/bun": "^1.3.12",
|
|
41
|
-
"@types/yargs": "^17.0.33",
|
|
42
|
-
"@typescript/native-preview": "^7.0.0-dev.20260412.1",
|
|
43
|
-
"husky": "^9.1.7",
|
|
44
|
-
"lint-staged": "^16.4.0",
|
|
45
|
-
"oxlint": "^1.59.0",
|
|
46
|
-
"secretlint": "^11.6.0",
|
|
47
|
-
"semantic-release": "^25.0.3",
|
|
48
|
-
"typescript": "^5.7.0"
|
|
49
|
-
},
|
|
50
|
-
"license": "MIT"
|
|
10
|
+
"os": [
|
|
11
|
+
"darwin"
|
|
12
|
+
],
|
|
13
|
+
"cpu": [
|
|
14
|
+
"arm64"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"bin"
|
|
18
|
+
]
|
|
51
19
|
}
|
package/.env.example
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Azure AD App Registration
|
|
2
|
-
# Register at: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps
|
|
3
|
-
# 1. New registration -> Name: onenote-cli
|
|
4
|
-
# 2. Supported account types: Personal Microsoft accounts + Organizational
|
|
5
|
-
# 3. Platform: Mobile and desktop applications
|
|
6
|
-
# 4. Copy Application (client) ID here:
|
|
7
|
-
ONENOTE_CLIENT_ID=YOUR_CLIENT_ID
|
|
8
|
-
|
|
9
|
-
# Authority URL (default: common for multi-tenant + personal accounts)
|
|
10
|
-
ONENOTE_AUTHORITY=https://login.microsoftonline.com/common
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write # push release commit + tag
|
|
10
|
-
issues: write # semantic-release/github comments
|
|
11
|
-
pull-requests: write
|
|
12
|
-
id-token: write # npm trusted publishing (OIDC) + provenance
|
|
13
|
-
|
|
14
|
-
concurrency:
|
|
15
|
-
group: release
|
|
16
|
-
cancel-in-progress: false
|
|
17
|
-
|
|
18
|
-
jobs:
|
|
19
|
-
release:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v4
|
|
23
|
-
with:
|
|
24
|
-
fetch-depth: 0
|
|
25
|
-
persist-credentials: false
|
|
26
|
-
|
|
27
|
-
- uses: oven-sh/setup-bun@v2
|
|
28
|
-
|
|
29
|
-
- uses: actions/setup-node@v4
|
|
30
|
-
with:
|
|
31
|
-
node-version: 24
|
|
32
|
-
registry-url: https://registry.npmjs.org
|
|
33
|
-
|
|
34
|
-
# Trusted publishing requires npm >= 11.5.1
|
|
35
|
-
- run: npm install -g npm@latest
|
|
36
|
-
|
|
37
|
-
- run: bun install --frozen-lockfile
|
|
38
|
-
|
|
39
|
-
- run: bun run typecheck
|
|
40
|
-
|
|
41
|
-
- run: npx semantic-release
|
|
42
|
-
env:
|
|
43
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bunx lint-staged
|
package/.releaserc.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": ["main"],
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@semantic-release/commit-analyzer",
|
|
5
|
-
"@semantic-release/release-notes-generator",
|
|
6
|
-
"@semantic-release/npm",
|
|
7
|
-
["@semantic-release/git", {
|
|
8
|
-
"assets": ["package.json"],
|
|
9
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
10
|
-
}],
|
|
11
|
-
"@semantic-release/github"
|
|
12
|
-
]
|
|
13
|
-
}
|
package/.secretlintrc.json
DELETED
package/CLAUDE.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
## Build & Run
|
|
4
|
-
- `bun install` — install deps
|
|
5
|
-
- `bun run start` — run CLI
|
|
6
|
-
- `bun run lint` — lint with oxlint
|
|
7
|
-
- `bun run lint:fix` — auto-fix lint issues
|
|
8
|
-
- `bun run typecheck` — type check with tsgo
|
|
9
|
-
|
|
10
|
-
## Commands
|
|
11
|
-
- `onenote auth login/logout/whoami/setup` — authentication
|
|
12
|
-
- `onenote notebooks list/get/create` — notebook management
|
|
13
|
-
- `onenote sections list/get/create` — section management
|
|
14
|
-
- `onenote pages list/get/content/create/delete` — page management
|
|
15
|
-
- `onenote export <ref> <output>` — export a page (→ `.md`/`.html` file) or a section/section group/notebook (→ directory tree, one file per page named by sanitized title). Markdown gets YAML frontmatter (`title`/`source`/`notebook`/`section`/`exported`); HTML gets `<meta name="onenote-*">`. Media default to `./assets` next to each file (content-addressed, safe to share), override with `--assets-dir`; `--format md|html`; `[date]` token expands to today. Format for a page is inferred from extension, for directories defaults to md. Notebook/section-group enumeration uses the OneNote API, falling back to OneDrive drive-walking (`.one`→section via sourcedoc GUID, subfolder→section group) when the library exceeds the Graph 5,000-item limit.
|
|
16
|
-
- `onenote sync` — download and cache all sections for local search
|
|
17
|
-
- `onenote search <query>` — full-text page-level search (local cache)
|
|
18
|
-
- `onenote search <query> --online` — online section-level search (Graph API)
|
|
19
|
-
|
|
20
|
-
## Conventions
|
|
21
|
-
- Use `import.meta.main` for script entry points
|
|
22
|
-
- Use `import.meta.dir` for package-relative paths (env, cache)
|
|
23
|
-
- Conventional commits for all commit messages
|
|
24
|
-
- `.env.local` at package root for credentials (auto-loaded)
|
|
25
|
-
|
|
26
|
-
## Safe by default
|
|
27
|
-
Destructive operations (anything that deletes or overwrites user content in OneNote) must be opt-in, not default. Without an explicit confirmation flag, they dry-run: show what would be affected + a short content sha, then exit.
|
|
28
|
-
|
|
29
|
-
- `rm` / `pages delete` / `pages update --action=replace` require `--sha=<4-char>` (sha256 of page HTML, first 4 hex chars). Mismatch → refuse.
|
|
30
|
-
- `read` prints the same sha to stderr so users can copy it straight from a prior read.
|
|
31
|
-
- Non-destructive ops (`cp`, `append`, additive `update` actions, `rename`, `create`) don't need confirmation.
|
|
32
|
-
- When in doubt between atomic-but-risky and two-step-but-safe (e.g. section move), ship the safe version first and leave the destructive step manual.
|
|
33
|
-
|
|
34
|
-
## Cache paths
|
|
35
|
-
All CLI caches live at **package root** (`<pkg>/.onenote/`), NOT cwd. The CLI is project-agnostic — caches must survive across `cd` and not pollute user directories. Resolve via `dirname(import.meta.dir)` in `src/*.ts`.
|
|
36
|
-
|
|
37
|
-
- `<pkg>/.onenote/cache/<notebook>/<section>.{json,one}` — full section sync (`onenote sync`)
|
|
38
|
-
- `<pkg>/.onenote/notebooks.json` — notebook metadata list (24h TTL), used for name→id resolution
|
|
39
|
-
- `<pkg>/.onenote/assets/` — downloaded resource files (images/PDFs) referenced by `onenote read`
|
|
40
|
-
- `~/.onenote-cli/` — user-level state (MSAL token cache, config)
|
|
41
|
-
|
|
42
|
-
Never use `process.cwd()` for cache paths. Override via env: `ONENOTE_CACHE_DIR`, `ONENOTE_READ_ASSET_DIR`.
|
package/README.md
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
# onenote-cli
|
|
2
|
-
|
|
3
|
-
**Your OneNote, in a terminal. Fluent with AI.**
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
onenote ls # browse your notebooks
|
|
7
|
-
onenote read NotebookA/SectionB/PageC # read a page, rendered as markdown
|
|
8
|
-
onenote search "visa interview" # find any word, anywhere
|
|
9
|
-
onenote open NotebookA/SectionB # jump back into OneNote Online
|
|
10
|
-
onenote append NotebookA/SectionB/today -c "- met with alex" --md
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Every page, every section, every word — addressable by path, openable from a prompt, pipe-able into anything.
|
|
14
|
-
|
|
15
|
-
## Install
|
|
16
|
-
|
|
17
|
-
### As an AI Agent Skill
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Claude Code / OpenClaw / Codex / Cursor / any SKILL.md-compatible agent
|
|
21
|
-
npx skills add snomiao/onenote-cli
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Manual
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
git clone https://github.com/snomiao/onenote-cli.git
|
|
28
|
-
cd onenote-cli
|
|
29
|
-
bun install
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Setup
|
|
33
|
-
|
|
34
|
-
1. Register an Azure AD app at [entra.microsoft.com](https://entra.microsoft.com) (see [docs/setup.md](docs/setup.md) for full walkthrough)
|
|
35
|
-
2. Copy `.env.example` to `.env.local` and set your Client ID:
|
|
36
|
-
```bash
|
|
37
|
-
cp .env.example .env.local
|
|
38
|
-
# Edit .env.local with your Application (client) ID
|
|
39
|
-
```
|
|
40
|
-
3. Login:
|
|
41
|
-
```bash
|
|
42
|
-
bun run src/index.ts auth login
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Usage
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# Auth
|
|
49
|
-
onenote auth login # Browser sign-in; on a remote host, paste the redirect URL back into the terminal
|
|
50
|
-
onenote auth whoami # Show current user
|
|
51
|
-
onenote auth setup # Print setup instructions
|
|
52
|
-
onenote auth logout # Clear tokens
|
|
53
|
-
|
|
54
|
-
# Notebooks (<ref> = name, path, Graph ID, or URL)
|
|
55
|
-
onenote notebooks list
|
|
56
|
-
onenote notebooks get <ref>
|
|
57
|
-
onenote notebooks create <name>
|
|
58
|
-
|
|
59
|
-
# Sections
|
|
60
|
-
onenote sections list [<ref>] # e.g. "NotebookA"
|
|
61
|
-
onenote sections create -n <ref> --name <name>
|
|
62
|
-
|
|
63
|
-
# Pages (<ref> = "nb/sec/page", page ID, or OneNote URL)
|
|
64
|
-
onenote pages list [<ref>] # e.g. "NotebookA/SectionB"
|
|
65
|
-
onenote pages get <ref>
|
|
66
|
-
onenote pages create -s <ref> -t <title> --body "# Heading" --md
|
|
67
|
-
onenote pages append <ref> -c "- bullet" --md # ⚠ may reformat existing content (Graph API limitation)
|
|
68
|
-
onenote pages update <ref> --target "#element-id" --action replace -c "<p>new</p>" --sha <4-char>
|
|
69
|
-
onenote pages delete <ref> --sha <4-char>
|
|
70
|
-
|
|
71
|
-
# Top-level shortcuts
|
|
72
|
-
onenote ls [<path>] # auto: notebooks / sections / pages
|
|
73
|
-
onenote read <ref> # render page (or list section/notebook)
|
|
74
|
-
onenote export <page-ref> <out.md> # export a page to Markdown + downloaded media
|
|
75
|
-
onenote export <page-ref> <out.html> # export as HTML (format inferred from extension)
|
|
76
|
-
onenote export <section-ref> <dir> # dump a section to a folder (one .md per page)
|
|
77
|
-
onenote export <notebook-ref> <dir> # dump a whole notebook as a directory tree
|
|
78
|
-
onenote open <ref> # open in browser
|
|
79
|
-
onenote rename <ref> <new-name> # rename (depth inferred)
|
|
80
|
-
onenote rm <ref> # dry-run: prints content + sha
|
|
81
|
-
onenote rm <ref> --sha=<4-char> # confirm deletion with content sha
|
|
82
|
-
onenote init # first-run setup
|
|
83
|
-
|
|
84
|
-
# Search
|
|
85
|
-
onenote sync # Download and cache all sections
|
|
86
|
-
onenote search <query> # Full-text page-level search (local)
|
|
87
|
-
onenote search <query> -o # Online section-level search (Graph API)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Append caveat
|
|
91
|
-
|
|
92
|
-
`pages append` uses the Microsoft Graph OneNote PATCH API (`action: "append"`). This is safe — it never deletes existing content — but the Graph API re-parses the entire page on the server side, which can normalize or strip custom fonts, indentation, and other formatting from **existing** content. New content is added correctly.
|
|
93
|
-
|
|
94
|
-
If preserving exact formatting matters, edit the page directly in OneNote Online or the desktop app.
|
|
95
|
-
|
|
96
|
-
### Export
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
onenote export <ref> <output>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Exports a **page**, **section**, **section group**, or **whole notebook** to local files plus their media. What `<ref>` resolves to decides the shape:
|
|
103
|
-
|
|
104
|
-
| `<ref>` resolves to | `<output>` | Result |
|
|
105
|
-
| --- | --- | --- |
|
|
106
|
-
| page | a file (`.md`/`.html`) | one file |
|
|
107
|
-
| page | a directory | `<dir>/<page-title>.md` |
|
|
108
|
-
| section | a directory | one file per page |
|
|
109
|
-
| section group / notebook | a directory | a directory tree mirroring the structure, one file per page |
|
|
110
|
-
|
|
111
|
-
Details:
|
|
112
|
-
|
|
113
|
-
- **Format** — for a single page it's inferred from the output extension (`.html`/`.htm` → HTML, else Markdown). For directory exports it defaults to Markdown; use `--format md|html`.
|
|
114
|
-
- **Filenames** — pages are named by their sanitized title (Unicode preserved; only filesystem-illegal characters are stripped). Collisions get ` (2)`, ` (3)`… suffixes.
|
|
115
|
-
- **Frontmatter** — every Markdown file gets YAML frontmatter with `title`, `source` (the original OneNote URL), `notebook`/`section` (when known), and `exported` date. HTML exports get the same as `<meta name="onenote-*">` tags.
|
|
116
|
-
- **Media** — downloaded next to each file, into `./assets` by default (safe to share across pages — assets are content-addressed, so no clashes). Override with `--assets-dir <dir>`. Links are rewritten to local relative paths, so folders are portable.
|
|
117
|
-
- **`[date]`** in the output path expands to today's date (`YYYY-MM-DD`).
|
|
118
|
-
- **Large libraries** — notebook/section-group exports normally enumerate via the OneNote API. When a OneDrive library exceeds the Graph API's 5,000-item limit, export automatically falls back to walking the OneDrive file tree (`.one` files → sections, subfolders → section groups), so even huge accounts export fully.
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
# One page → Markdown + ./assets next to it
|
|
122
|
-
onenote export "<page-url>" './[date]-my-page/page.md'
|
|
123
|
-
|
|
124
|
-
# One page → HTML
|
|
125
|
-
onenote export NotebookA/SectionB/PageC ./out/page.html
|
|
126
|
-
|
|
127
|
-
# A whole section → a folder of Markdown files (one per page)
|
|
128
|
-
onenote export "<section-url>" ./out/my-section
|
|
129
|
-
|
|
130
|
-
# A whole notebook → a directory tree of sections/section groups
|
|
131
|
-
onenote export NotebookA ./backup/NotebookA
|
|
132
|
-
|
|
133
|
-
# Shared media directory + HTML
|
|
134
|
-
onenote export NotebookA ./backup --format html --assets-dir ./backup/media
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Search Example
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
$ onenote search project plan
|
|
141
|
-
|
|
142
|
-
# (2024-11-03) Meeting notes
|
|
143
|
-
Section: Work | Notebook: MyNotebook
|
|
144
|
-
**project plan** ...
|
|
145
|
-
https://contoso.sharepoint.com/.../Notebooks/MyNotebook?wd=target(...)
|
|
146
|
-
|
|
147
|
-
2 page-level results found.
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Clicking the URL opens OneNote Online directly on the matching page.
|
|
151
|
-
|
|
152
|
-
For architecture, permissions, and internals see [docs/](docs/).
|
|
153
|
-
|
|
154
|
-
## Roadmap
|
|
155
|
-
|
|
156
|
-
### ✅ v0.1 — Foundation (shipped)
|
|
157
|
-
|
|
158
|
-
- Browse, read, edit, create, delete — notebooks, sections, pages
|
|
159
|
-
- Path refs (`Notebook/Section/Page`) across every command
|
|
160
|
-
- Full-text page-level search with context snippets
|
|
161
|
-
- Incremental local cache, works on huge libraries
|
|
162
|
-
- Markdown-in / markdown-out for reads and writes
|
|
163
|
-
- Export a page to Markdown or HTML with all media downloaded locally
|
|
164
|
-
- Clickable links in the terminal
|
|
165
|
-
- Installable as an AI agent skill
|
|
166
|
-
|
|
167
|
-
### 🚀 v0.2 — AI Native
|
|
168
|
-
|
|
169
|
-
Make onenote-cli the standard way AI accesses OneNote.
|
|
170
|
-
|
|
171
|
-
- **MCP server mode** — `onenote mcp` starts an MCP server on stdio. Unlocks Claude Desktop, Cursor, Continue, and any MCP client.
|
|
172
|
-
- **`onenote ask <question>`** — RAG over your notebook. Searches locally, fetches top N pages, feeds to LLM for answer.
|
|
173
|
-
- **`onenote summarize <url>`** — LLM summary of any page.
|
|
174
|
-
- **Semantic search** — local embeddings via `@xenova/transformers`.
|
|
175
|
-
|
|
176
|
-
### 📦 v0.3 — Portability
|
|
177
|
-
|
|
178
|
-
Own your data. Never locked in.
|
|
179
|
-
|
|
180
|
-
- ✅ **`onenote export`** — convert a page to Markdown or HTML with media downloaded to a local assets folder. _(shipped)_
|
|
181
|
-
- **`onenote import <dir>`** — ingest Markdown directory tree as notebook.
|
|
182
|
-
- **`onenote backup --incremental`** — daily diff-based snapshots.
|
|
183
|
-
- **Obsidian / Notion bridges** — `--format obsidian` preserves `[[wiki-links]]`.
|
|
184
|
-
|
|
185
|
-
### 🎨 v0.4 — Terminal UI
|
|
186
|
-
|
|
187
|
-
- **`onenote browse`** — interactive TUI with react-ink (tree view, arrow keys, `/` search, split-pane preview).
|
|
188
|
-
- **`onenote fzf`** — pipe all page titles to fuzzy finder.
|
|
189
|
-
- **Progress bars for sync** — real-time KB/s, ETA, spinner.
|
|
190
|
-
- **`onenote stats`** — total pages, size, word count, oldest note, etc.
|
|
191
|
-
|
|
192
|
-
### 🔧 v0.5 — Power User
|
|
193
|
-
|
|
194
|
-
Unix composition, scripting, automation.
|
|
195
|
-
|
|
196
|
-
- **Stdin piping** — `echo "note" | onenote append <id>`.
|
|
197
|
-
- **`--json` flag everywhere** — structured output for `jq` / scripts.
|
|
198
|
-
- **`onenote watch <file> --to-page <id>`** — live sync file → page.
|
|
199
|
-
- **`onenote new --daily`** — auto-create dated journal page with template.
|
|
200
|
-
- **Clipboard capture** — `onenote clip <id>` reads clipboard → page.
|
|
201
|
-
- **Screenshot + OCR** — `onenote snap <id>` captures screen → OCR → page.
|
|
202
|
-
|
|
203
|
-
### 🤝 v0.6 — Collaboration
|
|
204
|
-
|
|
205
|
-
- **Group notebooks** — `/groups/{id}/onenote/` support.
|
|
206
|
-
- **SharePoint site notebooks** — `/sites/{id}/onenote/`.
|
|
207
|
-
- **`onenote share <id> --user <email>`** — permissions management.
|
|
208
|
-
- **`onenote diff <url>`** — show changes since last sync.
|
|
209
|
-
- **`onenote subscribe <url>`** — webhooks on page changes.
|
|
210
|
-
|
|
211
|
-
### 🧠 v0.7 — Insights
|
|
212
|
-
|
|
213
|
-
- **`onenote graph --out graph.html`** — d3.js interactive page graph (nodes = pages, edges = cross-references).
|
|
214
|
-
- **`onenote duplicates`** — find and merge similar pages.
|
|
215
|
-
- **`onenote timeline`** — activity heatmap by date.
|
|
216
|
-
- **`onenote links <id>`** — incoming/outgoing references for a page.
|
|
217
|
-
|
|
218
|
-
### 🔐 v0.8 — Privacy & Local-First
|
|
219
|
-
|
|
220
|
-
- **Offline-only mode** — `--offline` flag uses only local cache.
|
|
221
|
-
- **SQLite FTS5 index** — sub-millisecond full-text search.
|
|
222
|
-
- **End-to-end encryption** — encrypt pages with `age` before sync.
|
|
223
|
-
- **Self-hosted relay** — optional proxy for air-gapped environments.
|
|
224
|
-
|
|
225
|
-
### 🛠 v1.0 — Platform
|
|
226
|
-
|
|
227
|
-
- **SDK** — `import { OneNote } from "onenote-cli"`.
|
|
228
|
-
- **HTTP API** — `onenote serve --port 3000` exposes OpenAPI 3.1.
|
|
229
|
-
- **Plugin system** — `onenote plugin install @company/jira-sync`.
|
|
230
|
-
- **Raycast / Alfred extensions** — native launcher integration.
|
|
231
|
-
- **Browser extension** — right-click → save to OneNote.
|
|
232
|
-
- **Proper MS-ONESTORE parser** — 100% accurate page attribution (replaces heuristic).
|
|
233
|
-
|
|
234
|
-
### Not planned
|
|
235
|
-
|
|
236
|
-
- GUI / Electron app (OneNote Online exists)
|
|
237
|
-
- Mobile apps (use Microsoft OneNote app)
|
|
238
|
-
- Rich text editor (keep it CLI-first)
|
|
239
|
-
- User management (stay delegated auth only)
|
|
240
|
-
|
|
241
|
-
## Contributing
|
|
242
|
-
|
|
243
|
-
Pick any unchecked roadmap item. Open an issue to claim it, or just ship a PR.
|
|
244
|
-
|
|
245
|
-
## Support
|
|
246
|
-
|
|
247
|
-
Love this tool? Help keep it moving:
|
|
248
|
-
|
|
249
|
-
- 💛 [Sponsor / donate](https://github.com/snomiao) — options on my homepage
|
|
250
|
-
- 🤖 Gift AI credits (Claude / OpenAI / etc.) — this project is built with AI and every token goes straight back into shipping features
|
|
251
|
-
|
|
252
|
-
## License
|
|
253
|
-
|
|
254
|
-
MIT
|
package/SKILL.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: onenote-cli
|
|
3
|
-
description: Make your OneNote notebooks survive in the age of AI. Search and operate OneNote from CLI via Microsoft Graph API. Use when the user wants to search OneNote notes, list notebooks, read pages, or manage OneNote content.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# onenote-cli
|
|
7
|
-
|
|
8
|
-
CLI for Microsoft OneNote via Microsoft Graph. Built with Bun + yargs + MSAL.
|
|
9
|
-
|
|
10
|
-
## Quick Reference
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
onenote auth login # Browser sign-in (on a VPS: paste the localhost redirect URL back into the terminal)
|
|
14
|
-
onenote auth logout # Clear cached tokens
|
|
15
|
-
onenote auth whoami # Show current user
|
|
16
|
-
onenote auth setup # Show OAuth setup instructions
|
|
17
|
-
|
|
18
|
-
onenote notebooks list # List notebooks
|
|
19
|
-
onenote notebooks get <id> # Get notebook by ID
|
|
20
|
-
onenote notebooks create <name> # Create notebook
|
|
21
|
-
|
|
22
|
-
onenote sections list -n <nb-id> # List sections in a notebook
|
|
23
|
-
onenote sections create -n <nb> --name <name>
|
|
24
|
-
|
|
25
|
-
onenote pages list -s <sec-id> # List pages in a section
|
|
26
|
-
onenote pages content <id> # Get page HTML content
|
|
27
|
-
onenote pages create -s <sec> -t <title> -b <html>
|
|
28
|
-
onenote pages delete <id>
|
|
29
|
-
|
|
30
|
-
onenote sync # Build local cache (.one binary + page index)
|
|
31
|
-
onenote search <query> # Full-text search across cached pages
|
|
32
|
-
onenote search <query> --online # Online section-level search via Graph
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Setup
|
|
36
|
-
|
|
37
|
-
See [docs/setup.md](docs/setup.md) for full Azure AD app registration walkthrough.
|
|
38
|
-
|
|
39
|
-
Quick setup:
|
|
40
|
-
1. Register app at https://entra.microsoft.com → App registrations → New
|
|
41
|
-
2. Supported account types: "Accounts in any organizational directory and personal Microsoft accounts"
|
|
42
|
-
3. Add platform: Mobile and desktop applications, redirect URI `https://login.microsoftonline.com/common/oauth2/nativeclient`
|
|
43
|
-
4. Settings → Allow public client flows: **Yes**
|
|
44
|
-
5. API permissions → Microsoft Graph → Delegated: `Notes.Read`, `Notes.ReadWrite`, `Notes.ReadWrite.All`, `Files.Read`, `Files.Read.All`, `Sites.Read.All`
|
|
45
|
-
6. Copy Application (client) ID into `.env.local`:
|
|
46
|
-
```env
|
|
47
|
-
ONENOTE_CLIENT_ID=your-client-id-here
|
|
48
|
-
ONENOTE_AUTHORITY=https://login.microsoftonline.com/common
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## How Search Works
|
|
52
|
-
|
|
53
|
-
`onenote search <query>` returns page-level results with **official OneNote URLs** that navigate directly to the matching page (bypassing OneNote Online's session caching).
|
|
54
|
-
|
|
55
|
-
The search:
|
|
56
|
-
1. Downloads `.one` files via OneDrive (cached locally in `<package>/.onenote/cache/`)
|
|
57
|
-
2. Extracts page GUIDs from the binary
|
|
58
|
-
3. Resolves official `oneNoteWebUrl` via `/me/onenote/sections/0-{guid}/pages` (works around the 5,000-item document library limit)
|
|
59
|
-
4. Searches the binary for the query (UTF-8 + UTF-16LE) and attributes matches to the correct page using context-based lookup
|
|
60
|
-
|
|
61
|
-
See [docs/local-search-architecture.md](docs/local-search-architecture.md) for details.
|
|
62
|
-
|
|
63
|
-
## File Locations
|
|
64
|
-
|
|
65
|
-
- `.env.local` — at the package root (auto-loaded via `import.meta.dir`)
|
|
66
|
-
- Token cache — `~/.onenote-cli/msal-cache.json`
|
|
67
|
-
- Config fallback — `~/.onenote-cli/config.json`
|
|
68
|
-
- Page cache — `<package>/.onenote/cache/` (override with `ONENOTE_CACHE_DIR`)
|
|
69
|
-
|
|
70
|
-
## Common Issues
|
|
71
|
-
|
|
72
|
-
| Error | Fix |
|
|
73
|
-
|---|---|
|
|
74
|
-
| `AADSTS7000218` | Enable "Allow public client flows" in app Authentication settings |
|
|
75
|
-
| `AADSTS65001` | Admin consent required for API permissions, or accept consent during login |
|
|
76
|
-
| `Graph API 403: error 10008` | Document library has > 5,000 OneNote items; use `onenote sync` and local search instead |
|
|
77
|
-
| Cache empty | Run `onenote sync` (auto-runs on first search) |
|