Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Kimi SharePoint Plugin

A Kimi plugin to manage SharePoint and OneDrive through the Microsoft Graph API. Connect your Microsoft 365 account with OAuth2, explore sites and document libraries, upload and download files, and search documents โ€” all in natural language from Kimi.


Features

  • ๐Ÿ” OAuth2 Authentication โ€” Device code flow with MSAL; token is stored locally and silently auto-refreshed.
  • ๐Ÿข Site Exploration โ€” List your followed SharePoint sites and search sites by keyword.
  • ๐Ÿ“ Library Navigation โ€” List drives (document libraries) and explore folders in OneDrive or any site.
  • โฌ‡๏ธ Downloads โ€” Bring files from SharePoint/OneDrive to your local workspace.
  • โฌ†๏ธ Uploads โ€” Upload local files to any remote folder, with conflict handling (rename / replace / fail).
  • ๐Ÿ” Search โ€” Search files by keyword in your OneDrive and accessible sites.
  • ๐Ÿ•˜ Recent โ€” List files you have used recently.

Current Development Status

Version: 0.1.0 โ€” Functional MVP โœ…

Completed:

  • Plugin scaffold (manifest + skill)
  • OAuth2 authentication (MSAL device flow, token cache with auto-refresh)
  • List followed sites and search sites
  • List libraries (drives) and navigate folders
  • Download and upload files
  • File search by keyword
  • Status commands: auth-check, whoami, recent

Pending (Phase 2 โ€” see Roadmap):

  • Sharing links and version management
  • SharePoint lists (read/write)
  • Folder change monitoring + automations (cron jobs)
  • Dashboard widget (recent files / site modifications)
  • Document content extraction for analysis with Kimi
  • Multi-account / multi-site support
  • Large file upload sessions (> 250 MB)

Prerequisites

Before installing you need:

  1. Kimi Desktop installed on your machine.
  2. A Microsoft 365 account with access to SharePoint/OneDrive.
  3. Graph permissions in the tenant app registration: Files.ReadWrite.All and Sites.ReadWrite.All.

About the app registration

The plugin uses by default the CLIENT_ID / TENANT_ID defined at the beginning of skills/sharepoint/scripts/sp_cli.py. If the tenant requires admin consent, an admin must grant the above permissions in Azure Portal โ†’ Entra ID โ†’ App registrations โ†’ (the app) โ†’ API permissions.

You can use your own app registration without touching the code, using environment variables:

  • SP_CLIENT_ID โ€” your Application (client) ID
  • SP_TENANT_ID โ€” your Directory (tenant) ID
  • SP_AUTH_DIR โ€” directory where to store tokens (default ~/.kimi-sharepoint)

Installation

Step 1: Clone the repository

git clone https://github.com/FlacH7/kimi-sharepoint-plugin.git

Step 2: Register the plugin in your personal marketplace

Option A (recommended):

In a Kimi conversation, ask:

"Register this local plugin in my personal marketplace: <absolute path to repo>"

The agent validates and registers it. Then open Kimi's Plugins page โ†’ ใ€Œไธชไบบใ€ (Personal) tab โ†’ click ๏ผ‹ on "SharePoint Manager". No restart needed.

Option B (manual, terminal):

Windows (PowerShell):

& "$env:APPDATA\kimi-desktop\daimon-bundle\bin\kimi-daimon.cmd" kimi-plugin register-personal "C:\full\path\to\kimi-sharepoint-plugin" --share-dir "$env:APPDATA\kimi-desktop\daimon-share"

macOS:

kimi-daimon kimi-plugin register-personal ~/path/to/kimi-sharepoint-plugin \
  --share-dir ~/Library/Application\ Support/kimi-desktop/daimon-share

Linux:

kimi-daimon kimi-plugin register-personal ~/path/to/kimi-sharepoint-plugin \
  --share-dir ~/.kimi/daimon-share

Step 3: Install from Kimi Desktop

  1. Open Kimi Desktop
  2. Go to the Plugins panel (ๆ’ไปถ)
  3. Switch to the ใ€Œไธชไบบใ€ (Personal) tab
  4. Search for "SharePoint Manager"
  5. Click ๏ผ‹ or ใ€Œๅฎ‰่ฃ…ใ€ (Install)
  6. Done! The plugin activates immediately โ€” no restart

Configuration (authentication)

The first time you use it, ask Kimi: "Connect to my SharePoint". The agent will run the device code flow:

  1. It shows you a URL (https://login.microsoft.com/device) and a code.
  2. You open the URL, enter the code and sign in with your Microsoft 365 account.
  3. You accept the permissions. The token is saved to ~/.kimi-sharepoint and renews automatically.

Security: Never upload the contents of ~/.kimi-sharepoint (contains the token) to the repo. It lives outside the plugin directory, and .gitignore covers it just in case.


Usage

Once installed and authenticated, ask Kimi in natural language:

Request Action
"List my SharePoint sites" Show your followed sites
"What folders are in the team site?" Explore libraries and folders
"Search OneDrive for report documents" Search by keyword
"Download the presentation from the Shared folder" Download to your workspace
"Upload this PDF to the Documents folder of site X" Upload a local file
"What files have I used recently?" Recent files list
"Which account am I connected to?" Session status

Architecture

kimi-sharepoint-plugin/
โ”œโ”€โ”€ kimi.plugin.json                 # Plugin manifest
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ skills/
    โ””โ”€โ”€ sharepoint/
        โ”œโ”€โ”€ SKILL.md                 # Agent instructions + command reference
        โ””โ”€โ”€ scripts/
            โ””โ”€โ”€ sp_cli.py            # CLI: auth + Graph API (browse / up / down / search)

sp_cli.py โ€” Command Reference

Drive identifiers: me = user's OneDrive; <drive-id> = specific library; site:<site-id> = default drive of a site.

# Authentication
python3 scripts/sp_cli.py auth-check        # read-only preflight (is there a saved session?)
python3 scripts/sp_cli.py auth-start        # start device flow (shows URL + code)
python3 scripts/sp_cli.py auth-complete     # complete login and save token
python3 scripts/sp_cli.py whoami            # authenticated account

# Navigation
python3 scripts/sp_cli.py sites [keyword] [--limit N]   # followed sites / site search
python3 scripts/sp_cli.py drives [--site <id>]          # libraries (drives)
python3 scripts/sp_cli.py ls <drive> [path] [--limit N] # list folder (root if no path)

# Files
python3 scripts/sp_cli.py download <drive> <remote-path> [local-destination]
python3 scripts/sp_cli.py upload <local> <drive> <remote-folder> [--name X] [--conflict rename|replace|fail]

# Search and recent
python3 scripts/sp_cli.py search <keyword> [--drive <drive>] [--limit N]
python3 scripts/sp_cli.py recent [--limit N]

Typical exploration pattern: sites โ†’ drives --site <id> โ†’ ls <drive> <path> โ†’ download / search.


Roadmap

Development continues in phases. The suggested order to complete 100% of the scope:

  1. Sharing links and versioning โ€” create links with expiration/permissions (/createLink), list file versions and restore.
  2. SharePoint lists โ€” read and write list items (/sites/{id}/lists), useful for inventories, tasks and records.
  3. Change monitoring โ€” folder polling with delta query (/delta) to detect new/modified files and trigger automations (Kimi cron jobs).
  4. Widget โ€” Dashboard/็œ‹ๆฟ panel with recent files and site modifications linked to an automation.
  5. Content extraction โ€” download and convert documents (Word/Excel/PDF) to analyze them with Kimi without manual steps.
  6. Multi-account / multi-site โ€” multiple Microsoft 365 accounts and favorite sites configurable.
  7. Large files โ€” upload sessions for files over 250 MB.

Each phase should end with: changes to sp_cli.py + update SKILL.md + cachebuster.py (bump version) + test + commit.


Troubleshooting

"AADSTS65001 / consent required"

The app registration has not been granted Graph permissions. A tenant admin must add Files.ReadWrite.All and Sites.ReadWrite.All in Azure Portal โ†’ App registrations โ†’ API permissions โ†’ Grant admin consent.

"You cannot use any scope value that is reserved" (offline_access)

Bug fixed in 0.1.0+local.20260907-150122. MSAL adds offline_access by itself; it must not be declared in SCOPES. Update the plugin from the ใ€Œไธชไบบใ€ tab.

"kimi-daimon is not recognized as a command"

Locate the executable in your Kimi Desktop installation:

  • Windows: C:\Users\<USER>\AppData\Roaming\kimi-desktop\daimon-bundle\bin\kimi-daimon.cmd
  • macOS: ~/Library/Application Support/kimi-desktop/daimon-bundle/bin/kimi-daimon
  • Linux: ~/.kimi/daimon-bundle/bin/kimi-daimon

The plugin does not appear in the ใ€Œไธชไบบใ€ tab

Check that:

  1. The register-personal command finished without errors.
  2. The repo folder contains kimi.plugin.json.
  3. Refresh the Plugins page (close and reopen).

404 error when listing or downloading

Verify the drive id and remote path. Use sites and drives to get the correct identifiers before navigating.

Token expired and not renewing

Run auth-start / auth-complete again. If it persists, delete ~/.kimi-sharepoint/msal_cache.json and repeat login.


Changelog

v0.1.0 (MVP)

  • OAuth2 authentication with device flow (MSAL) and auto-refresh token
  • List followed sites and site search
  • List drives and navigate folders
  • Download and upload files (with conflict handling)
  • File search and recent files list
  • Fix: removed offline_access from SCOPES (reserved by MSAL)

License

MIT โ€” see LICENSE.


Compatible with: Microsoft Graph API v1.0 Requires: Kimi Desktop, Python 3 with msal and requests

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages