Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

### Added
- **Turn pushed edits into tracked changes** - `suggestChanges(projectId, path, edits)` makes edits that reached Overleaf as plain text, through git, `olcli push` or a sync, show up as tracked changes, as if they had been typed in Reviewing mode. Each edit is given as the old and new text with some text around it; olcli finds the new text, undoes the edit without tracking and redoes it with tracking (`meta.tc` on the update, as the editor sends it). The text ends up as it was, so a git clone that pushed the edit has nothing new to pull. An edit whose new text is not on Overleaf yet is reported as `not-pushed` and left alone. sharejs-text-ot docs only; history-ot docs are refused
- **Turn pushed edits into tracked changes** ([#66](https://github.com/aloth/olcli/pull/66)) - `suggestChanges(projectId, path, edits)` makes edits that reached Overleaf as plain text, through git, `olcli push` or a sync, show up as tracked changes, as if they had been typed in Reviewing mode. Each edit is given as the old and new text with some text around it; olcli finds the new text, undoes the edit without tracking and redoes it with tracking (`meta.tc` on the update, as the editor sends it). The text ends up as it was, so a git clone that pushed the edit has nothing new to pull. An edit whose new text is not on Overleaf yet is reported as `not-pushed` and left alone. sharejs-text-ot docs only; history-ot docs are refused. Thanks to @fredericosantos
- **MCP tool `suggest_changes` (experimental)** - turns edits that are already on Overleaf as plain text into suggestions collaborators can accept or reject, for projects with track changes, by calling `suggestChanges`. Like the other write tools it asks the user first: the dialog lists each edit with its location and the suggested deletion and insertion, or why it is left alone. If no edit can become a suggestion it asks nothing and writes nothing, and it refuses to write when the document changed after the preview. Clients without elicitation get the preview only, since there is no olcli command for this yet. sharejs-text-ot documents only; returns one result per edit

### Fixed
- **`suggestChanges` no longer hangs on an edit with nothing to search for** - an edit whose `before`, `inserted` and `after` were all empty, such as a pure deletion given without surrounding text, made the search loop forever. Such an edit is now reported as `invalid` and nothing is sent
- **`suggestChanges` no longer tracks the same edit twice** - running it again for an edit that is already a tracked change added a second tracked change, and the tracked deletion held the old text twice. An edit whose new or old text is already tracked at that place is now reported as `already-tracked` and nothing is sent, also when the same edit appears twice in one call
- **`suggestChanges` checks its result** - after writing, the document is read again, and an edit without a tracked change at the expected place is reported as `not-tracked` instead of `done`
- **`suggestChanges` names the missing permission** - with review-only access the untracked undo is refused, and the call failed with "applyOtUpdate did not return an acknowledgement". It now throws `SuggestionPermissionError`, which says that the account needs edit access to the project, and nothing is written. When Overleaf reports the access level up front, the check happens before anything is sent
- **`suggestChanges` sends a tracked-change id seed in Overleaf's format** - the seed in `meta.tc` was 18 random hex digits; it now starts with the current time in seconds like the seeds the Overleaf editor generates, so the ids of the new tracked changes carry a meaningful timestamp

### Changed
- **`suggestChanges` reports `unchanged`** for an edit whose `inserted` equals `deleted`, instead of `not-pushed`. `SuggestionResult` gains `already-tracked`, `unchanged`, `invalid` and `not-tracked`; existing values keep their meaning. `hint` is now optional
- **`suggestChanges` is marked experimental** - sharejs-text-ot documents only (history-ot documents are refused), and collaborators who have the document open see the old text for about 0.2 seconds while an edit is undone and redone. `planSuggestions` reports what it would do without writing, and an `expectedVersion` option refuses to write when the document changed since. Documented in docs/LIBRARY.md

## [0.17.0] - 2026-11-15

Expand Down
2 changes: 1 addition & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ olcli-mcp
npx -y --package @aloth/olcli olcli-mcp
```

Available MCP tools: `list_projects`, `get_project_info`, `pull_project`, `push_file`, `compile`, `download_pdf`, `list_comments`, `get_entities`, `download_file`, `add_comment`, `reply_to_comment`, `resolve_comment`, `delete_entity`, `rename_entity`, `rename_project`, `plan_project_renames`, `compile_with_outputs`, `diff_project`, `create_project`, `accept_tracked_changes`, `reject_tracked_changes`.
Available MCP tools: `list_projects`, `get_project_info`, `pull_project`, `push_file`, `compile`, `download_pdf`, `list_comments`, `get_entities`, `download_file`, `add_comment`, `reply_to_comment`, `resolve_comment`, `delete_entity`, `rename_entity`, `rename_project`, `plan_project_renames`, `compile_with_outputs`, `diff_project`, `create_project`, `accept_tracked_changes`, `reject_tracked_changes`, `suggest_changes` (experimental).

`compile`, `download_pdf` and `compile_with_outputs` accept an optional `resource_path` to compile a specific root document.

Expand Down
32 changes: 32 additions & 0 deletions docs/LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import {
FolderEntry, DocEntry, FileEntry,
CommentMessage, ProjectComment, CommentContext, CommentStatus,
ListCommentsOptions, AddCommentOptions, Credentials, SessionCookiePair,
// Tracked changes and suggestions
TrackedChange, ListTrackedChangesOptions, ProjectReview, RejectConflictError,
SuggestionEdit, SuggestionResult, SuggestionOutcome, SuggestionPlan, SuggestionPermissionError,
// Config utilities
getBaseUrl, setBaseUrl, getSessionCookie, setSessionCookie,
getSessionCookieName, setSessionCookieName, getCsrf, setCsrf,
Expand All @@ -48,3 +51,32 @@ import {
IgnoreContext, LoadIgnoreOptions,
} from '@aloth/olcli';
```

## Turning pushed edits into suggestions (experimental)

`client.suggestChanges(projectId, path, edits)` turns edits that are already on Overleaf as plain text, for example pushed through git, `olcli push` or a sync, into tracked changes that collaborators can accept or reject. Each edit is `{ before, deleted, inserted, after, hint? }`: the old and the new text with some unchanged text around it, and optionally the approximate offset of the edit; the nearest match wins. `client.planSuggestions(projectId, path, edits)` reports what would happen without writing.

```ts
const results = await client.suggestChanges(projectId, 'main.tex', [
{ before: 'The ', deleted: 'quick', inserted: 'slow', after: ' fox', hint: 120 },
]);
// ['done']
```

This method is experimental:

- Only documents in the `sharejs-text-ot` format are supported; `history-ot` documents are refused with an error.
- Each edit is undone without tracking and redone with tracking. The text ends up the same, but collaborators who have the document open see the old text for a short moment, about 0.2 seconds.
- The account needs edit access to the project. Review-only access cannot send the untracked undo, so the call throws `SuggestionPermissionError` before writing anything.

One result per edit, in order:

| Result | Meaning |
|--------|---------|
| `done` | Now a tracked change, checked by reading the document again |
| `already-tracked` | The edit is already a tracked change, for example from an earlier call; nothing was sent |
| `not-pushed` | Overleaf still has the old text; nothing was sent |
| `not-found` | Neither the old nor the new text is there; nothing was sent |
| `unchanged` | `inserted` equals `deleted`; nothing was sent |
| `invalid` | `before`, `inserted` and `after` are all empty, so the edit cannot be found; nothing was sent |
| `not-tracked` | The edit was sent, but no tracked change showed up when the document was read again. The text is as before the call |
6 changes: 5 additions & 1 deletion docs/MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Tools marked "asks first" change the Overleaf project. Before writing, the serve
| `resolve_comment` | Mark a comment thread as resolved; asks first |
| `accept_tracked_changes` | Accept tracked changes by id; sends nothing if any id is unknown; asks first |
| `reject_tracked_changes` | Reject tracked changes by id; returns a diff preview and writes only with `apply: true`, after asking |
| `suggest_changes` | Experimental. Turn edits that are already on Overleaf as plain text (pushed through git, `push_file` or a sync) into tracked changes collaborators can accept or reject, for projects with track changes; sharejs-text-ot documents only; returns one result per edit; asks first |
| `delete_entity` | Delete a file or document by path; asks first |
| `rename_entity` | Rename a file, document, or folder, or move it into another folder (`new_name` as a path, see below); asks first |
| `rename_project` | Rename the project itself (not a file inside it); asks first |
Expand All @@ -32,6 +33,8 @@ Tools marked "asks first" change the Overleaf project. Before writing, the serve

> **Tracked changes need a premium project.** Track changes is an Overleaf premium feature: it is only available in projects whose owner has a premium plan, and invited collaborators can then use it regardless of their own plan. In other projects `list_comments` with `include_changes` returns no changes and `accept_tracked_changes`/`reject_tracked_changes` report the ids as not found. See the [Overleaf documentation](https://docs.overleaf.com/collaborating/track-changes).

> **`suggest_changes` is experimental.** Each edit is undone without tracking and redone with tracking, so the text ends up the same, but collaborators who have the document open see the old text for a short moment (about 0.2 seconds). It needs edit access to the project: review-only access cannot send the untracked undo, and the tool then fails with an error that says so before writing anything. Only documents in the `sharejs-text-ot` format are supported; `history-ot` documents are refused. Results per edit: `done` (checked by reading the document again), `already-tracked`, `not-pushed`, `not-found`, `unchanged`, `invalid`, and `not-tracked` (sent, but no tracked change showed up afterwards).

> **What `diff_project` compares.** The remote side is fetched fresh on every call, so the result describes the project as it is right now, which is what a later push would overwrite. It is not a comparison against the last pull: the manifest records remote paths, never remote contents, so there is no stored snapshot. Every response carries `remote_fetched_at` for that reason — a collaborator editing between the call and a push can still change the outcome. Patches are oriented `a/` = remote, `b/` = local, so a `+` line is content a push would upload. Pass `name_only` to get statuses without patch text.

> **What `new_name` of `rename_entity` accepts.** The same destinations as `olcli mv`: a bare name renames in place and the entity keeps its folder; `chapters/intro.tex` moves the entity into `chapters/` (created if missing) and renames it; `chapters/` moves it and keeps the name; `/` is the project root. The result returns `old_path`, `new_path` and `created_folders`.
Expand All @@ -58,12 +61,13 @@ The server also tells the client, in its MCP `instructions` and in the descripti
| `resolve_comment` | The thread |
| `accept_tracked_changes` | Each change as `path:line:column`, kind, author, and text, plus a diff of what becomes final: the text without the selected suggestions against the text after accepting them. Other tracked changes in the same document stay pending and are shown as not applied on both sides |
| `reject_tracked_changes` with `apply: true` | Each change and the rejection diff. With `apply: false` (the default) it returns the preview and asks nothing |
| `suggest_changes` | Per edit its location as `path:line:column` and the suggested deletion and insertion with the text around them, or why the edit is left alone (already tracked, not pushed, not found, unchanged, invalid). If no edit can become a suggestion, nothing is asked and nothing is written. Clients without elicitation get the preview only, since there is no olcli command for this yet |

The dialog has one checkbox, "Confirm", which starts unchecked. Only accepting with the box checked writes. Declining, dismissing the dialog, submitting it unchecked, no answer within 10 minutes (or the client canceling the call sooner), or an error all write nothing, and the tool result tells the assistant that the change was not made and why.

Long content is cut with an explicit note such as `... 12 more lines not shown`. Control characters, zero-width characters, and bidirectional formatting characters are shown as `\u{...}`, so text cannot look different from what it is.

What you confirm is what gets written: `delete_entity` and `rename_entity` act on the entity shown in the dialog, `reject_tracked_changes` refuses to write if a document changed after the preview, and `accept_tracked_changes` refuses if a selected change no longer has the text shown.
What you confirm is what gets written: `delete_entity` and `rename_entity` act on the entity shown in the dialog, `reject_tracked_changes` and `suggest_changes` refuse to write if a document changed after the preview, and `accept_tracked_changes` refuses if a selected change no longer has the text shown.

Tools that only read never ask. `pull_project`, `download_file`, and `download_pdf` write local files but do not change the Overleaf project, and do not ask either. `plan_project_renames` never applies anything.

Expand Down
Loading
Loading