onenote-cli 0.2.1-win32-arm64 → 0.2.1

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/.env.example ADDED
@@ -0,0 +1,10 @@
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
package/.gitattributes ADDED
@@ -0,0 +1,7 @@
1
+ # The Rust port's files stay LF in every checkout, also on Windows with
2
+ # core.autocrlf (as GitHub's Windows runners have it):
3
+ # `node rs/parity.gen.mjs --check` compares rs/parity.json and the fixtures
4
+ # byte for byte, the parity job runs rs/parity/*.sh in Git Bash, and the
5
+ # binary compiles rs/src/auth_setup.txt in, so a CR LF checkout would print
6
+ # `onenote auth setup` with CR LF where the TypeScript prints LF.
7
+ rs/** text=auto eol=lf
@@ -0,0 +1,170 @@
1
+ name: Release
2
+
3
+ # A release is decided by semantic-release from the commits on main, built for
4
+ # every platform, install-tested, and only then tagged and published:
5
+ #
6
+ # plan the type-check the release always ran, then: which version would
7
+ # this commit release? (nothing is written)
8
+ # build rust-npm-release.yml at that version: Rust `onenote-cli` for six
9
+ # platforms, the parity proof against the TypeScript, packed with
10
+ # the TypeScript and installed with bun and npm on Linux, macOS,
11
+ # Windows
12
+ # release semantic-release: the version in package.json and the release
13
+ # commit, git tag, GitHub release. It does not publish to npm
14
+ # (npmPublish is false in .releaserc.json).
15
+ # publish npm: the platform builds, then onenote-cli, as packed by build
16
+ # verify install onenote-cli from npm on every OS and run it
17
+ #
18
+ # Nothing is tagged or published unless build passed. `rehearse` runs plan and
19
+ # build only. If publish or verify fails, "Re-run failed jobs" finishes the
20
+ # same version; publishing a version twice is harmless.
21
+ #
22
+ # The build pipeline lives in https://github.com/snomiao/rustify. npm trusted
23
+ # publishing is configured for this file; the platform builds are versions of
24
+ # onenote-cli, so they need no setup of their own.
25
+
26
+ on:
27
+ push:
28
+ branches: [main]
29
+ workflow_dispatch:
30
+ inputs:
31
+ rehearse:
32
+ description: "Build, pack and install-test on every platform, but tag and publish nothing"
33
+ type: boolean
34
+ default: false
35
+
36
+ permissions:
37
+ contents: read
38
+
39
+ concurrency:
40
+ group: release
41
+ cancel-in-progress: false
42
+
43
+ jobs:
44
+ plan:
45
+ runs-on: ubuntu-latest
46
+ timeout-minutes: 15
47
+ permissions:
48
+ contents: write # semantic-release checks that it could push
49
+ outputs:
50
+ version: ${{ steps.next.outputs.version }}
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ with:
54
+ fetch-depth: 0
55
+ persist-credentials: false
56
+
57
+ - uses: oven-sh/setup-bun@v2
58
+
59
+ - uses: actions/setup-node@v4
60
+ with:
61
+ node-version: 24
62
+
63
+ - run: bun install --frozen-lockfile
64
+
65
+ - run: bun run typecheck
66
+
67
+ # semantic-release logs "The next release version is 1.2.3" (or "There
68
+ # is no previous release, the next release version is 1.0.0") on a line
69
+ # of its own scope; with nothing to release it logs neither. Its
70
+ # plugins' lines ("[semantic-release] [@semantic-release/commit-analyzer]
71
+ # › ℹ Analyzing commit: ...") and the release notes after it repeat
72
+ # commit messages, so only that line, the last of its kind, is taken.
73
+ - name: Next version (dry run)
74
+ id: next
75
+ shell: bash
76
+ env:
77
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78
+ run: |
79
+ npx semantic-release --dry-run | tee semantic-release.log
80
+ version="$(sed -E 's/\x1b\[[0-9;]*m//g' semantic-release.log \
81
+ | sed -nE 's/^\[[^]]*\] \[semantic-release\] [^[]*(The|There is no previous release, the) next release version is ([0-9]+\.[0-9]+\.[0-9]+[0-9A-Za-z.+-]*)$/\2/p' \
82
+ | tail -n 1)"
83
+ echo "version=$version" >> "$GITHUB_OUTPUT"
84
+ echo "Next version: ${version:-none, nothing to release}"
85
+
86
+ build:
87
+ needs: plan
88
+ if: needs.plan.outputs.version != '' || inputs.rehearse
89
+ uses: ./.github/workflows/rust-npm-release.yml
90
+ with:
91
+ version: ${{ needs.plan.outputs.version || format('0.0.0-rehearsal.{0}', github.run_number) }}
92
+
93
+ release:
94
+ needs: [plan, build]
95
+ if: needs.plan.outputs.version != '' && !inputs.rehearse
96
+ runs-on: ubuntu-latest
97
+ timeout-minutes: 15
98
+ permissions:
99
+ contents: write # push release commit + tag, GitHub release
100
+ issues: write # semantic-release/github comments
101
+ pull-requests: write
102
+ outputs:
103
+ version: ${{ steps.released.outputs.version }}
104
+ steps:
105
+ - uses: actions/checkout@v4
106
+ with:
107
+ fetch-depth: 0
108
+ persist-credentials: false
109
+
110
+ - uses: oven-sh/setup-bun@v2
111
+
112
+ - uses: actions/setup-node@v4
113
+ with:
114
+ node-version: 24
115
+
116
+ - run: bun install --frozen-lockfile
117
+
118
+ # Writes the version to package.json, commits it, tags, writes the
119
+ # GitHub release. Publishing is the publish job's.
120
+ - run: npx semantic-release
121
+ env:
122
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123
+
124
+ # The tag is on the release commit @semantic-release/git made on top of
125
+ # the commit that was built. On a re-run of this job semantic-release
126
+ # finds main ahead and does nothing, and the tag from the first run
127
+ # still says what was released.
128
+ - name: Confirm the release
129
+ id: released
130
+ shell: bash
131
+ env:
132
+ PLANNED: ${{ needs.plan.outputs.version }}
133
+ run: |
134
+ tagged="$(git rev-parse -q --verify "refs/tags/v$PLANNED^{commit}" || true)"
135
+ parent="$(if [ -n "$tagged" ]; then git rev-parse -q --verify "$tagged^" || true; fi)"
136
+ if [ -n "$tagged" ] && { [ "$tagged" = "$GITHUB_SHA" ] || [ "$parent" = "$GITHUB_SHA" ]; }; then
137
+ echo "version=$PLANNED" >> "$GITHUB_OUTPUT"
138
+ echo "Released v$PLANNED"
139
+ elif [ -n "$tagged" ] || [ -n "$(git tag --points-at HEAD)" ]; then
140
+ echo "::error::built v$PLANNED from $GITHUB_SHA, but v$PLANNED is ${tagged:-not a tag} and HEAD is tagged '$(git tag --points-at HEAD | paste -sd' ' -)'"
141
+ exit 1
142
+ else
143
+ # main moved on while this run was building; the newer run releases.
144
+ echo "::notice::no release from this commit"
145
+ fi
146
+
147
+ publish:
148
+ needs: [build, release]
149
+ if: needs.release.outputs.version != ''
150
+ runs-on: ubuntu-latest
151
+ timeout-minutes: 20
152
+ permissions:
153
+ contents: read
154
+ id-token: write # npm trusted publishing (OIDC) + provenance
155
+ steps:
156
+ # The platform builds first, the package users install last.
157
+ - uses: snomiao/rustify/actions/publish@releases/v1
158
+
159
+ # The same commands as the smoke test in rust-npm-release.yml; keep the two
160
+ # in step.
161
+ verify:
162
+ needs: [build, publish]
163
+ uses: snomiao/rustify/.github/workflows/rust-npm-verify.yml@releases/v1
164
+ with:
165
+ smoke: onenote --help
166
+ smoke-expect: List notebooks, sections, or pages
167
+ smoke-extra: |
168
+ [handback] onenote-cli --help => List notebooks, sections, or pages
169
+ [native] onenote auth setup => === onenote-cli OAuth Setup ===
170
+ [native] onenote-cli auth setup => onenote auth login
@@ -0,0 +1,109 @@
1
+ # Builds the Rust `onenote-cli` binary for every platform, compares it with
2
+ # the TypeScript on Linux, macOS and Windows, packs it together with the
3
+ # TypeScript the package ships, and checks on Linux, macOS and Windows (x64
4
+ # and arm64) that `bun i -g` / `npm i -g` gives working `onenote` and
5
+ # `onenote-cli` commands.
6
+ #
7
+ # It does not publish: there is no publish job. release.yml calls it
8
+ # (workflow_call) to build a release at the version semantic-release decided,
9
+ # so a release is packed and proven with the inputs below, and then publishes
10
+ # from a job of its own: npm's trusted publisher is set up for release.yml,
11
+ # the workflow a release starts from.
12
+ #
13
+ # The pipeline lives in https://github.com/snomiao/rustify.
14
+
15
+ name: rust-npm-release
16
+
17
+ on:
18
+ pull_request:
19
+ paths:
20
+ - "rs/**"
21
+ # The parity cases compare the binary with the TypeScript, so a change
22
+ # to either side has to run them.
23
+ - "src/**"
24
+ - "package.json"
25
+ - "bun.lock"
26
+ - ".github/workflows/rust-npm-release.yml"
27
+ workflow_dispatch:
28
+ inputs:
29
+ version:
30
+ description: "Version to build, without a leading v (default: the version in rs/Cargo.toml)"
31
+ required: false
32
+ type: string
33
+ workflow_call:
34
+ inputs:
35
+ version:
36
+ description: "Version to build, without a leading v (default: the version in rs/Cargo.toml)"
37
+ required: false
38
+ type: string
39
+ npm_tag:
40
+ description: "npm dist-tag the release is packed for"
41
+ required: false
42
+ default: latest
43
+ type: string
44
+ publish:
45
+ description: "Kept for the shape of rustify's release template; this workflow has no publish job and publishes nothing either way. release.yml publishes."
46
+ required: false
47
+ default: false
48
+ type: boolean
49
+
50
+ jobs:
51
+ build:
52
+ uses: snomiao/rustify/.github/workflows/rust-npm-build.yml@releases/v1
53
+ with:
54
+ manifest: rs/Cargo.toml
55
+ bins: onenote-cli
56
+ version: ${{ inputs.version }}
57
+ npm-tag: ${{ inputs.npm_tag || 'latest' }}
58
+ # Both commands are the same binary. --help is yargs's, so these go
59
+ # through the hand-back to src/index.ts on every machine.
60
+ # (--version is no use as the check: installed with bun, yargs cannot
61
+ # find the package and prints "unknown".)
62
+ smoke: onenote --help
63
+ smoke-expect: List notebooks, sections, or pages
64
+ # Rust against TypeScript, on the binaries that were just built, on
65
+ # Linux, macOS and Windows (rs/parity.gen.mjs says what the cases are;
66
+ # nothing in them reaches Microsoft, and every case that would sync
67
+ # runs with an empty home, without a token). rs/parity/proof.sh runs,
68
+ # side by side, in bash (Git Bash on Windows):
69
+ # - every case, TypeScript against the binary;
70
+ # - the binary alone against a stand-in package, which fails unless
71
+ # exactly the cases marked "handback" for this system reach the
72
+ # JavaScript (the search is answered on Linux and macOS and handed
73
+ # back on Windows; `auth setup` is answered everywhere);
74
+ # - the same two with a pseudo-terminal as standard output, where the
75
+ # search prints colours and clickable titles (not on Windows, which
76
+ # has no pseudo-terminal for python's pty, and where the binary
77
+ # hands a search on a console back anyway);
78
+ # - `cargo test` in rs/, for the test that compares every time zone
79
+ # the binary reads with the time zone database of the bun that is
80
+ # installed here (inside bun on Linux; on macOS bun takes the
81
+ # system's, so this compares with the runner's macOS). That one
82
+ # builds the crate once more with the runner's own Rust, from the
83
+ # same sources and Cargo.lock. It fails when that database or the
84
+ # crate's has moved and the two no longer agree where the binary
85
+ # answers, and prints the lines to add to rs/src/time.rs. With it
86
+ # runs the test that holds the binary's lower case of every code
87
+ # point against this bun's toLowerCase (rs/src/js.rs), whatever
88
+ # Unicode the runner's Rust has: the binary answers from
89
+ # rs/src/unicode.rs, which proof.sh first checks to be what this
90
+ # bun says (rs/unicode.gen.mjs --check). On Windows, where nothing
91
+ # the binary answers reads a time zone or lower-cases, it runs the
92
+ # unit tests of what is compiled there.
93
+ parity: >-
94
+ bun install --frozen-lockfile
95
+ && sh rs/parity/proof.sh "$RUSTIFY_PARITY" "$RUSTIFY_BIN_DIR/onenote-cli"
96
+ parity-platforms: '["linux-x64", "darwin-arm64", "win32-x64"]'
97
+ # Run once on every platform after installing, each line marked with
98
+ # who has to answer it. `auth setup` is answered by the binary itself
99
+ # on every system (it prints the setup guide and needs nothing); it is
100
+ # the one ported command that can run on a machine with no index.
101
+ # --help is yargs's, so the binary hands it to the JavaScript.
102
+ # `onenote search` is not run here on purpose: without an index the
103
+ # TypeScript starts a sync, and on a machine that is signed in that is
104
+ # a real one. (It is native on Linux and macOS and handed back on
105
+ # Windows; the parity job shows that on each.)
106
+ smoke-extra: |
107
+ [handback] onenote-cli --help => List notebooks, sections, or pages
108
+ [native] onenote auth setup => === onenote-cli OAuth Setup ===
109
+ [native] onenote-cli auth setup => onenote auth login
@@ -0,0 +1 @@
1
+ bunx lint-staged
@@ -0,0 +1,15 @@
1
+ {
2
+ "branches": ["main"],
3
+ "plugins": [
4
+ "@semantic-release/commit-analyzer",
5
+ "@semantic-release/release-notes-generator",
6
+ ["@semantic-release/npm", {
7
+ "npmPublish": false
8
+ }],
9
+ ["@semantic-release/git", {
10
+ "assets": ["package.json"],
11
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
12
+ }],
13
+ "@semantic-release/github"
14
+ ]
15
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "rules": [{ "id": "@secretlint/secretlint-rule-preset-recommend" }]
3
+ }
package/CLAUDE.md ADDED
@@ -0,0 +1,42 @@
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 ADDED
@@ -0,0 +1,267 @@
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
+ ### As a command
25
+
26
+ ```bash
27
+ bun i -g onenote-cli # or: npm i -g onenote-cli
28
+ onenote search "visa interview"
29
+ ```
30
+
31
+ `onenote` is a native binary on Linux, macOS and Windows, x64 and arm64; the
32
+ install picks the right one. It answers `onenote search` from the local index
33
+ (Linux and macOS) and `onenote auth setup` itself, in a few milliseconds.
34
+ Every other command still runs the TypeScript, exactly as before, so
35
+ [bun](https://bun.sh) has to be installed.
36
+
37
+ ### Manual
38
+
39
+ ```bash
40
+ git clone https://github.com/snomiao/onenote-cli.git
41
+ cd onenote-cli
42
+ bun install
43
+ ```
44
+
45
+ ## Setup
46
+
47
+ 1. Register an Azure AD app at [entra.microsoft.com](https://entra.microsoft.com) (see [docs/setup.md](docs/setup.md) for full walkthrough)
48
+ 2. Copy `.env.example` to `.env.local` and set your Client ID:
49
+ ```bash
50
+ cp .env.example .env.local
51
+ # Edit .env.local with your Application (client) ID
52
+ ```
53
+ 3. Login:
54
+ ```bash
55
+ bun run src/index.ts auth login
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ```bash
61
+ # Auth
62
+ onenote auth login # Browser sign-in; on a remote host, paste the redirect URL back into the terminal
63
+ onenote auth whoami # Show current user
64
+ onenote auth setup # Print setup instructions
65
+ onenote auth logout # Clear tokens
66
+
67
+ # Notebooks (<ref> = name, path, Graph ID, or URL)
68
+ onenote notebooks list
69
+ onenote notebooks get <ref>
70
+ onenote notebooks create <name>
71
+
72
+ # Sections
73
+ onenote sections list [<ref>] # e.g. "NotebookA"
74
+ onenote sections create -n <ref> --name <name>
75
+
76
+ # Pages (<ref> = "nb/sec/page", page ID, or OneNote URL)
77
+ onenote pages list [<ref>] # e.g. "NotebookA/SectionB"
78
+ onenote pages get <ref>
79
+ onenote pages create -s <ref> -t <title> --body "# Heading" --md
80
+ onenote pages append <ref> -c "- bullet" --md # ⚠ may reformat existing content (Graph API limitation)
81
+ onenote pages update <ref> --target "#element-id" --action replace -c "<p>new</p>" --sha <4-char>
82
+ onenote pages delete <ref> --sha <4-char>
83
+
84
+ # Top-level shortcuts
85
+ onenote ls [<path>] # auto: notebooks / sections / pages
86
+ onenote read <ref> # render page (or list section/notebook)
87
+ onenote export <page-ref> <out.md> # export a page to Markdown + downloaded media
88
+ onenote export <page-ref> <out.html> # export as HTML (format inferred from extension)
89
+ onenote export <section-ref> <dir> # dump a section to a folder (one .md per page)
90
+ onenote export <notebook-ref> <dir> # dump a whole notebook as a directory tree
91
+ onenote open <ref> # open in browser
92
+ onenote rename <ref> <new-name> # rename (depth inferred)
93
+ onenote rm <ref> # dry-run: prints content + sha
94
+ onenote rm <ref> --sha=<4-char> # confirm deletion with content sha
95
+ onenote init # first-run setup
96
+
97
+ # Search
98
+ onenote sync # Download and cache all sections
99
+ onenote search <query> # Full-text page-level search (local)
100
+ onenote search <query> -o # Online section-level search (Graph API)
101
+ ```
102
+
103
+ ### Append caveat
104
+
105
+ `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.
106
+
107
+ If preserving exact formatting matters, edit the page directly in OneNote Online or the desktop app.
108
+
109
+ ### Export
110
+
111
+ ```
112
+ onenote export <ref> <output>
113
+ ```
114
+
115
+ Exports a **page**, **section**, **section group**, or **whole notebook** to local files plus their media. What `<ref>` resolves to decides the shape:
116
+
117
+ | `<ref>` resolves to | `<output>` | Result |
118
+ | --- | --- | --- |
119
+ | page | a file (`.md`/`.html`) | one file |
120
+ | page | a directory | `<dir>/<page-title>.md` |
121
+ | section | a directory | one file per page |
122
+ | section group / notebook | a directory | a directory tree mirroring the structure, one file per page |
123
+
124
+ Details:
125
+
126
+ - **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`.
127
+ - **Filenames** — pages are named by their sanitized title (Unicode preserved; only filesystem-illegal characters are stripped). Collisions get ` (2)`, ` (3)`… suffixes.
128
+ - **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.
129
+ - **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.
130
+ - **`[date]`** in the output path expands to today's date (`YYYY-MM-DD`).
131
+ - **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.
132
+
133
+ ```
134
+ # One page → Markdown + ./assets next to it
135
+ onenote export "<page-url>" './[date]-my-page/page.md'
136
+
137
+ # One page → HTML
138
+ onenote export NotebookA/SectionB/PageC ./out/page.html
139
+
140
+ # A whole section → a folder of Markdown files (one per page)
141
+ onenote export "<section-url>" ./out/my-section
142
+
143
+ # A whole notebook → a directory tree of sections/section groups
144
+ onenote export NotebookA ./backup/NotebookA
145
+
146
+ # Shared media directory + HTML
147
+ onenote export NotebookA ./backup --format html --assets-dir ./backup/media
148
+ ```
149
+
150
+ ### Search Example
151
+
152
+ ```
153
+ $ onenote search project plan
154
+
155
+ # (2024-11-03) Meeting notes
156
+ Section: Work | Notebook: MyNotebook
157
+ **project plan** ...
158
+ https://contoso.sharepoint.com/.../Notebooks/MyNotebook?wd=target(...)
159
+
160
+ 2 page-level results found.
161
+ ```
162
+
163
+ Clicking the URL opens OneNote Online directly on the matching page.
164
+
165
+ For architecture, permissions, and internals see [docs/](docs/).
166
+
167
+ ## Roadmap
168
+
169
+ ### ✅ v0.1 — Foundation (shipped)
170
+
171
+ - Browse, read, edit, create, delete — notebooks, sections, pages
172
+ - Path refs (`Notebook/Section/Page`) across every command
173
+ - Full-text page-level search with context snippets
174
+ - Incremental local cache, works on huge libraries
175
+ - Markdown-in / markdown-out for reads and writes
176
+ - Export a page to Markdown or HTML with all media downloaded locally
177
+ - Clickable links in the terminal
178
+ - Installable as an AI agent skill
179
+
180
+ ### 🚀 v0.2 — AI Native
181
+
182
+ Make onenote-cli the standard way AI accesses OneNote.
183
+
184
+ - **MCP server mode** — `onenote mcp` starts an MCP server on stdio. Unlocks Claude Desktop, Cursor, Continue, and any MCP client.
185
+ - **`onenote ask <question>`** — RAG over your notebook. Searches locally, fetches top N pages, feeds to LLM for answer.
186
+ - **`onenote summarize <url>`** — LLM summary of any page.
187
+ - **Semantic search** — local embeddings via `@xenova/transformers`.
188
+
189
+ ### 📦 v0.3 — Portability
190
+
191
+ Own your data. Never locked in.
192
+
193
+ - ✅ **`onenote export`** — convert a page to Markdown or HTML with media downloaded to a local assets folder. _(shipped)_
194
+ - **`onenote import <dir>`** — ingest Markdown directory tree as notebook.
195
+ - **`onenote backup --incremental`** — daily diff-based snapshots.
196
+ - **Obsidian / Notion bridges** — `--format obsidian` preserves `[[wiki-links]]`.
197
+
198
+ ### 🎨 v0.4 — Terminal UI
199
+
200
+ - **`onenote browse`** — interactive TUI with react-ink (tree view, arrow keys, `/` search, split-pane preview).
201
+ - **`onenote fzf`** — pipe all page titles to fuzzy finder.
202
+ - **Progress bars for sync** — real-time KB/s, ETA, spinner.
203
+ - **`onenote stats`** — total pages, size, word count, oldest note, etc.
204
+
205
+ ### 🔧 v0.5 — Power User
206
+
207
+ Unix composition, scripting, automation.
208
+
209
+ - **Stdin piping** — `echo "note" | onenote append <id>`.
210
+ - **`--json` flag everywhere** — structured output for `jq` / scripts.
211
+ - **`onenote watch <file> --to-page <id>`** — live sync file → page.
212
+ - **`onenote new --daily`** — auto-create dated journal page with template.
213
+ - **Clipboard capture** — `onenote clip <id>` reads clipboard → page.
214
+ - **Screenshot + OCR** — `onenote snap <id>` captures screen → OCR → page.
215
+
216
+ ### 🤝 v0.6 — Collaboration
217
+
218
+ - **Group notebooks** — `/groups/{id}/onenote/` support.
219
+ - **SharePoint site notebooks** — `/sites/{id}/onenote/`.
220
+ - **`onenote share <id> --user <email>`** — permissions management.
221
+ - **`onenote diff <url>`** — show changes since last sync.
222
+ - **`onenote subscribe <url>`** — webhooks on page changes.
223
+
224
+ ### 🧠 v0.7 — Insights
225
+
226
+ - **`onenote graph --out graph.html`** — d3.js interactive page graph (nodes = pages, edges = cross-references).
227
+ - **`onenote duplicates`** — find and merge similar pages.
228
+ - **`onenote timeline`** — activity heatmap by date.
229
+ - **`onenote links <id>`** — incoming/outgoing references for a page.
230
+
231
+ ### 🔐 v0.8 — Privacy & Local-First
232
+
233
+ - **Offline-only mode** — `--offline` flag uses only local cache.
234
+ - **SQLite FTS5 index** — sub-millisecond full-text search.
235
+ - **End-to-end encryption** — encrypt pages with `age` before sync.
236
+ - **Self-hosted relay** — optional proxy for air-gapped environments.
237
+
238
+ ### 🛠 v1.0 — Platform
239
+
240
+ - **SDK** — `import { OneNote } from "onenote-cli"`.
241
+ - **HTTP API** — `onenote serve --port 3000` exposes OpenAPI 3.1.
242
+ - **Plugin system** — `onenote plugin install @company/jira-sync`.
243
+ - **Raycast / Alfred extensions** — native launcher integration.
244
+ - **Browser extension** — right-click → save to OneNote.
245
+ - **Proper MS-ONESTORE parser** — 100% accurate page attribution (replaces heuristic).
246
+
247
+ ### Not planned
248
+
249
+ - GUI / Electron app (OneNote Online exists)
250
+ - Mobile apps (use Microsoft OneNote app)
251
+ - Rich text editor (keep it CLI-first)
252
+ - User management (stay delegated auth only)
253
+
254
+ ## Contributing
255
+
256
+ Pick any unchecked roadmap item. Open an issue to claim it, or just ship a PR.
257
+
258
+ ## Support
259
+
260
+ Love this tool? Help keep it moving:
261
+
262
+ - 💛 [Sponsor / donate](https://github.com/snomiao) — options on my homepage
263
+ - 🤖 Gift AI credits (Claude / OpenAI / etc.) — this project is built with AI and every token goes straight back into shipping features
264
+
265
+ ## License
266
+
267
+ MIT