@wirecat/cli-core 0.720.0 → 0.722.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/CHANGELOG.md +106 -0
- package/dist/cli/config-command.js +8 -2
- package/dist/cli/config-issues.d.ts +3 -1
- package/dist/cli/config-issues.js +9 -2
- package/dist/cli/documents/file-conflicts.d.ts +25 -0
- package/dist/cli/documents/file-conflicts.js +102 -0
- package/dist/cli/documents/file-edit.d.ts +29 -0
- package/dist/cli/documents/file-edit.js +352 -0
- package/dist/cli/documents/file-update.d.ts +43 -0
- package/dist/cli/documents/file-update.js +95 -0
- package/dist/cli/documents/history.d.ts +34 -0
- package/dist/cli/documents/history.js +89 -0
- package/dist/cli/documents/index.d.ts +9 -2
- package/dist/cli/documents/index.js +9 -2
- package/dist/cli/documents/library.js +10 -0
- package/dist/cli/messenger/lacks.d.ts +2 -1
- package/dist/cli/messenger/lacks.js +14 -1
- package/dist/cli/permission-keys.d.ts +6 -0
- package/dist/cli/permission-keys.js +15 -3
- package/dist/cli/service-api.d.ts +1 -1
- package/dist/cli/service-api.js +16 -34
- package/dist/cli/token-session.d.ts +2 -1
- package/dist/cli/token-session.js +2 -2
- package/dist/crm/cli/account.d.ts +60 -0
- package/dist/crm/cli/account.js +147 -0
- package/dist/crm/cli/files.js +2 -1
- package/dist/crm/cli/index.d.ts +3 -0
- package/dist/crm/cli/index.js +4 -0
- package/dist/crm/foreign-contacts.js +2 -1
- package/dist/crm/state-folders.d.ts +5 -0
- package/dist/crm/state-folders.js +2 -0
- package/dist/documents/file-mirror-model.d.ts +18 -1
- package/dist/documents/index.d.ts +7 -4
- package/dist/documents/index.js +4 -1
- package/dist/documents/model.d.ts +16 -1
- package/dist/errors/reasons.d.ts +1 -1
- package/dist/errors/reasons.js +15 -0
- package/dist/services/documents/block-diff.d.ts +13 -3
- package/dist/services/documents/block-diff.js +13 -7
- package/dist/services/documents/ingestion.d.ts +21 -2
- package/dist/services/documents/ingestion.js +29 -2
- package/dist/services/documents/plan.js +16 -7
- package/dist/services/documents/ports.d.ts +2 -0
- package/dist/services/documents/sync.d.ts +1 -0
- package/dist/services/documents/sync.js +9 -4
- package/dist/services/files/conflicts.d.ts +78 -0
- package/dist/services/files/conflicts.js +183 -0
- package/dist/services/files/guarded-write.d.ts +34 -0
- package/dist/services/files/guarded-write.js +42 -0
- package/dist/services/files/listing.d.ts +8 -0
- package/dist/services/files/listing.js +1 -1
- package/dist/services/files/local-files.d.ts +54 -0
- package/dist/services/files/local-files.js +143 -0
- package/dist/services/files/mirror-state.d.ts +14 -0
- package/dist/services/files/mirror-state.js +65 -0
- package/dist/services/files/mirror.d.ts +8 -15
- package/dist/services/files/mirror.js +164 -205
- package/dist/services/files/text-merge.d.ts +27 -0
- package/dist/services/files/text-merge.js +134 -0
- package/dist/services/files/versions.d.ts +36 -9
- package/dist/services/files/versions.js +40 -12
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +1 -0
- package/dist/store/sqlite/account-purge.js +3 -0
- package/dist/store/sqlite/crm-stage-entries.js +4 -1
- package/dist/store/sqlite/document-history.d.ts +84 -0
- package/dist/store/sqlite/document-history.js +158 -0
- package/dist/store/sqlite/erase-plan.d.ts +19 -0
- package/dist/store/sqlite/erase-plan.js +74 -0
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/messages.js +2 -1
- package/dist/store/sqlite/migrations.generated.js +17 -0
- package/dist/store/sqlite/notes.d.ts +9 -10
- package/dist/store/sqlite/notes.js +33 -21
- package/dist/store/sqlite/organization-erase.d.ts +29 -0
- package/dist/store/sqlite/organization-erase.js +83 -0
- package/dist/store/sqlite/organizations.d.ts +10 -1
- package/dist/store/sqlite/organizations.js +6 -1
- package/dist/store/sqlite/person-erase.js +4 -45
- package/dist/store/sqlite/schema/document-changes.d.ts +136 -0
- package/dist/store/sqlite/schema/document-changes.js +11 -0
- package/dist/store/sqlite/schema.d.ts +65 -0
- package/dist/store/sqlite/schema.js +5 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,112 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.722.0 — 23.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`account remove` for every CRM CLI, with its guard.** `addCrmCommands({ account })` mounts cli-core's
|
|
13
|
+
`account remove`, which refuses `--delete-data` while another profile here holds the same account, whose one copy
|
|
14
|
+
the store shares (`account-remove.account-shared`); `--dry-run` warns instead. `refuseTakenCrmAccount` and
|
|
15
|
+
`crmAccountClaim` (the `claim` of `tokenSessionCommand`) refuse a sign-in to an account and user another profile is
|
|
16
|
+
signed in to (`session.duplicate`), and a profile named `files` or `foreign-contacts`, the folders every account
|
|
17
|
+
shares (`profile.reserved`). A `held` hook says which account a profile holds; unset, it is the account
|
|
18
|
+
`session start` remembered. bitrix24-cli, amo-cli and hubspot-cli can drop their own copies
|
|
19
|
+
([CRM.md](docs/dev/CRM.md#one-account-one-profile)).
|
|
20
|
+
- **`tokenSessionCommand`'s `claim` gets the run's keyring** as its fifth argument, so a check of the other profiles'
|
|
21
|
+
sign-ins reads the same keyring a test hands in.
|
|
22
|
+
- **Earlier versions of every synced document, and a change log (store version 72).** The store keeps a document's
|
|
23
|
+
text, title and front matter before each change and before each removal, so a deleted page's last text is never
|
|
24
|
+
lost. `documents history <document>` lists the versions and `--revision <n>` shows one. `changes --since 1d` lists
|
|
25
|
+
what was added, changed, deleted, no longer visible, left the synced folders or came back, with titles. Both are
|
|
26
|
+
local reads, so agents get them over MCP too. `documentLibraryCommands` mounts them, and `addDocumentCommands` does
|
|
27
|
+
when the CLI gives `history`. A CLI with its own `documents` group calls `addDocumentHistoryCommands`
|
|
28
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#history-and-the-change-log)).
|
|
29
|
+
- **`keep_versions_for_days`, 365 by default.** A sync that completes its pass drops older versions and change log
|
|
30
|
+
rows of that account. A CLI adds `DOCUMENT_HISTORY_SETTINGS` to `settingsFor` and passes `keepVersionsForDays` to
|
|
31
|
+
`syncDocuments`. Without it the sync keeps one year.
|
|
32
|
+
- **A source can say a document is no longer visible rather than deleted.** A change takes `gone: "deleted"` or
|
|
33
|
+
`gone: "unavailable"`, and `SourceIndex.remove` and `deleteFileNotes` take the reason.
|
|
34
|
+
- **Office files edited in place, and earlier versions put back.** `addFileEditCommands` mounts under a CLI's files
|
|
35
|
+
group `sheets show|update` for .xlsx cells, `documents show|update` for .docx paragraphs, `history` for what this
|
|
36
|
+
profile's writes replaced, and `restore <path> [version]`, besides `update`. A show gives the file's sha256; every
|
|
37
|
+
edit and restore takes it as `--expected-fingerprint` and writes through `guardedFileWrite`, so a change made
|
|
38
|
+
meanwhile is a conflict with nothing uploaded and the replaced content is kept. The Office editors' refusals pass
|
|
39
|
+
through with their reasons ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#edit-office-files-in-place)).
|
|
40
|
+
|
|
41
|
+
### Changed — may break callers
|
|
42
|
+
|
|
43
|
+
- **A file mirror's guard on mass replacements names the count to allow.** A sync stopped before more than 50
|
|
44
|
+
replacements now says to pass `--allow-replacements <count>` with the count filled in, where its default hint said
|
|
45
|
+
`--replace`; `allowReplacements` already took a count. A CLI that offers neither option and relied on the default
|
|
46
|
+
hint should add `--allow-replacements <count>`. One that keeps its `--replace` switch passes
|
|
47
|
+
`allowReplacements: Number.POSITIVE_INFINITY` and its own `allowReplacements` hint, as before
|
|
48
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#plain-files-both-ways)).
|
|
49
|
+
- **Uses `@wirecat/cli-base` 0.127.0**, whose vocabulary has `mirrors`, `conflicts`, `--keep <side>`,
|
|
50
|
+
`--allow-deletions <count>`, `--allow-replacements <count>` and `--repin`: the mirror's conflict commands pass
|
|
51
|
+
`cli-dev lint` with no override for them.
|
|
52
|
+
- **`files update` refuses a .pdf, .docx or .xlsx** (`file.not-plain-text`): a read gives their extracted text, which
|
|
53
|
+
would replace the whole document. A CLI leaves the sha256 out of a truncated or extracted text read
|
|
54
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#write-one-file-at-the-hash-read)).
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- **Only a direct signal deletes a synced document's text.** A removal from a change feed without `gone`, a 404 or a
|
|
59
|
+
refusal when the content is read, and a file a finished walk did not find now mark the document no longer visible.
|
|
60
|
+
It leaves lists and search but keeps its text, and comes back as it was. Before, its text was blanked. The trash or
|
|
61
|
+
`gone: "deleted"` still deletes. A file that left the scope because the owner changed the chosen folders is marked
|
|
62
|
+
unsynced.
|
|
63
|
+
- **A messenger's `never` hides ten more commands, and a group left empty.** `messages forward`, `contacts block`
|
|
64
|
+
and `unblock`, `chats links show` and `reset`, `chats requests list`, `confirm` and `reject`, and `chats admins add`
|
|
65
|
+
and `remove` now refuse before connecting when their one method is in `lacks` or `never`, and `never` hides them
|
|
66
|
+
from help, `commands` and MCP. A group whose every command is hidden, such as `account sessions` or `chats folders`,
|
|
67
|
+
is hidden too, so a messenger can put those methods in `never` instead of `lacks`.
|
|
68
|
+
- **A server search no longer erases what the store knew about a message.** A hit is a partial copy: saved over a
|
|
69
|
+
held message, it now adds to its provider metadata instead of replacing it, so a Slack thread root found by
|
|
70
|
+
`search.messages` keeps the reply count a sync saved. A fetch from history still replaces the metadata.
|
|
71
|
+
- **A file mirror no longer merges edits to neighbouring lines.** Two changes with no unchanged line between them,
|
|
72
|
+
one on each side, are now a conflict, as in Git's merge. They used to be combined silently. This includes an
|
|
73
|
+
insertion right after the other side's edit, and edits to neighbouring Markdown blocks such as two list items.
|
|
74
|
+
Changes with at least one unchanged line between them still merge, and a checklist tick still merges with a text
|
|
75
|
+
edit. Document push keeps merging neighbouring blocks as before
|
|
76
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#plain-files-both-ways)).
|
|
77
|
+
|
|
78
|
+
## 0.721.0 — 23.11.2026
|
|
79
|
+
|
|
80
|
+
### Added
|
|
81
|
+
|
|
82
|
+
- **A file written only at the hash it was read at.** `guardedFileWrite` writes over a provider's file through its
|
|
83
|
+
`FileTarget` only while the file still has the sha256 the caller read: the current content is downloaded into the
|
|
84
|
+
profile's version store and hashed, another hash is `conflict` (`mirror.remote-changed`) with nothing uploaded, and
|
|
85
|
+
the target checks it again just before the upload. What it replaced stays in the version store. The shared builder
|
|
86
|
+
`addFileUpdateCommand` adds `files update <path> (--text | stdin) [--expected-fingerprint <sha256>]` to a CLI's files
|
|
87
|
+
group, a remote write that asks the delete key when it replaces a file
|
|
88
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#write-one-file-at-the-hash-read)).
|
|
89
|
+
- **A file mirror merges text files both sides changed, and its conflicts can be resolved.** A `.md`, `.markdown`,
|
|
90
|
+
`.txt`, `.csv` or `.tsv` file up to 1 MB that changed on both sides since the last sync is merged line by line
|
|
91
|
+
(Markdown also by blocks, so a checklist tick and an edit of the same item merge) and written to both sides, in
|
|
92
|
+
every mirror; CRLF, a byte-order mark and other encodings pass through byte for byte. Lines both sides changed
|
|
93
|
+
differently stay a conflict, now recorded in the mirror's state: `listFileConflicts`, `showFileConflict` (the three
|
|
94
|
+
versions, the conflicting lines and the file with conflict markers) and `resolveFileConflict` (keep a side, both,
|
|
95
|
+
or a final file, refused with nothing written when either side changed since), mounted by `fileConflictsCommand`
|
|
96
|
+
as `mirrors conflicts list|show|resolve`. The contents of every merge, conflict and resolution are kept for good,
|
|
97
|
+
and `versions list` names each one's role ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#plain-files-both-ways)).
|
|
98
|
+
|
|
99
|
+
### Changed — may break callers
|
|
100
|
+
|
|
101
|
+
- **A file mirror writes a merged text file to both sides where it used to report a conflict.** A caller that counted
|
|
102
|
+
on every both-sides change waiting for `keep` now finds the file in the new `FileMirrorResult.merged`, and a plan
|
|
103
|
+
step of the new kind `merge`; `VersionDirection` gains `both` and `VersionEvent.event` gains `merged`, `conflict`
|
|
104
|
+
and `resolved`, so a switch over them needs the new cases. `FileVersions` gains `read(sha256)`, and `prune` takes
|
|
105
|
+
the contents to keep (`pinned`): an implementation of its own adds both. `versions.has` is false for anything but a
|
|
106
|
+
sha256.
|
|
107
|
+
- **An old flat `api` key is refused, not honoured: rename it to the key the refusal names.** A config that still names
|
|
108
|
+
`api.contacts-list` after the generated `api` group put that command under `api contacts list` no longer has the key
|
|
109
|
+
checked beside the new one. Every command refuses to run, `mcp serve` refuses to start, and `config set` refuses the
|
|
110
|
+
key, each with `configuration_error` or `validation_error` saying "its command moved, so rename it to
|
|
111
|
+
permissions.api.contacts.list". A moved path keeps no alias, its key included (WC-CMD-8). Until a CLI regenerates
|
|
112
|
+
with groups, no key moved and nothing changes.
|
|
113
|
+
|
|
8
114
|
## 0.720.0 — 23.11.2026
|
|
9
115
|
|
|
10
116
|
### Added
|
|
@@ -11,7 +11,7 @@ import { fixVerb } from "./config-issues.js";
|
|
|
11
11
|
import { baseContext, environmentOf } from "./context.js";
|
|
12
12
|
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
13
13
|
import { itemOf, renderAnswer } from "./envelope.js";
|
|
14
|
-
import { knownBeside, knownPermissionKeys, unknownPermissionIssues, } from "./permission-keys.js";
|
|
14
|
+
import { knownBeside, knownPermissionKeys, renamedPermissionKeys, unknownPermissionIssues, } from "./permission-keys.js";
|
|
15
15
|
import { profileFree } from "./profile.js";
|
|
16
16
|
import { fromFile, NONE_NAMED } from "./settings.js";
|
|
17
17
|
import { nextStep } from "./steps.js";
|
|
@@ -232,12 +232,18 @@ export const refuseUnknownKey = (command, setting, value, permissionKey) => {
|
|
|
232
232
|
if (keys.length === 0)
|
|
233
233
|
return;
|
|
234
234
|
const known = knownPermissionKeys(command, permissionKey);
|
|
235
|
+
const renamed = renamedPermissionKeys(command);
|
|
235
236
|
for (const key of keys) {
|
|
236
237
|
if (known.has(key))
|
|
237
238
|
continue;
|
|
238
239
|
const beside = knownBeside(key, known);
|
|
240
|
+
const now = renamed.get(key);
|
|
239
241
|
throw new CliError("validation_error", `permissions.${key} names no command` +
|
|
240
|
-
(
|
|
242
|
+
(now !== undefined
|
|
243
|
+
? `: its command moved, so use permissions.${now}`
|
|
244
|
+
: beside.length > 0
|
|
245
|
+
? ` — the known ones there are ${beside.join(", ")}`
|
|
246
|
+
: ""));
|
|
241
247
|
}
|
|
242
248
|
};
|
|
243
249
|
/**
|
|
@@ -43,7 +43,9 @@ export declare const permissionIssues: (saved: readonly {
|
|
|
43
43
|
}[], known: ReadonlySet<string>, context: {
|
|
44
44
|
file: string;
|
|
45
45
|
tool: string;
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
|
+
/** Old key → the key of the command it moved to, so the refusal names what to rename it to. */
|
|
48
|
+
renamed?: ReadonlyMap<string, string>) => LocatedIssue[];
|
|
47
49
|
/** The file without the settings the issues name: what still loads, and what `config unset` would leave. */
|
|
48
50
|
export declare const withoutIssues: (raw: unknown, issues: readonly LocatedIssue[]) => unknown;
|
|
49
51
|
/** The path `config unset <setting>` names: a permission key keeps its dots; a number is a list item. */
|
|
@@ -237,9 +237,16 @@ export const savedPermissionKeys = (raw) => scopes(raw).flatMap(([path, scope])
|
|
|
237
237
|
? Object.keys(scope.permissions).map((key) => ({ key, at: [...path, "permissions", key] }))
|
|
238
238
|
: []);
|
|
239
239
|
/** A saved key no command checks would do nothing (BUG-137): one issue per key, wherever it is saved. */
|
|
240
|
-
export const permissionIssues = (saved, known, context
|
|
240
|
+
export const permissionIssues = (saved, known, context,
|
|
241
|
+
/** Old key → the key of the command it moved to, so the refusal names what to rename it to. */
|
|
242
|
+
renamed = new Map()) => saved
|
|
241
243
|
.filter(({ key }) => !known.has(key))
|
|
242
|
-
.map(({ at }) => locate("unknown_permission", at, context, (key) =>
|
|
244
|
+
.map(({ key: name, at }) => locate("unknown_permission", at, context, (key) => {
|
|
245
|
+
const now = renamed.get(name);
|
|
246
|
+
return now === undefined
|
|
247
|
+
? `${key} names no command`
|
|
248
|
+
: `${key} names no command: its command moved, so rename it to permissions.${now}`;
|
|
249
|
+
}));
|
|
243
250
|
const pathId = (path) => path.join("\u0000");
|
|
244
251
|
/**
|
|
245
252
|
* The file without the parts at `paths`, through objects and lists alike, and a map from a path in what is left
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type FileConflictResolveOptions, type FileMirrorStatePort, type FileVersions, type Mirror } from "../../documents.js";
|
|
3
|
+
import type { AppIdentity } from "../../ports/app.js";
|
|
4
|
+
import { type Body } from "../envelope.js";
|
|
5
|
+
/** What a file-mirror CLI gives `fileConflictsCommand`: its mirrors, their state and stores, and its remote. */
|
|
6
|
+
export interface FileConflictCommands {
|
|
7
|
+
/** Who the app is: its command names the examples, its folders are never read by `--file`. */
|
|
8
|
+
identity: AppIdentity;
|
|
9
|
+
/** How the app names the remote side, `disk` for Yandex Disk: `--keep`'s other choice and a kept copy's name. */
|
|
10
|
+
remote: string;
|
|
11
|
+
output(command: Command, body: Body): void;
|
|
12
|
+
/** The profile's mirrors, or the one with `id`; unknown ids and a profile without mirrors are refused. */
|
|
13
|
+
mirrors(command: Command, id?: string): Mirror[];
|
|
14
|
+
/** A path as the owner typed it (relative, or absolute inside the mirror), as a path inside the mirror. */
|
|
15
|
+
pathOf(mirror: Mirror, input: string): string;
|
|
16
|
+
stateOf(command: Command, mirror: Mirror): FileMirrorStatePort;
|
|
17
|
+
versionsOf(command: Command, mirror: Mirror): FileVersions;
|
|
18
|
+
/** The remote signed in for the mirror's account, the write guard and the mirrors' sync lock. */
|
|
19
|
+
connect(command: Command, mirror: Mirror): Promise<Pick<FileConflictResolveOptions, "target" | "principal" | "guard" | "operationId" | "lock" | "signal">>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `mirrors conflicts list|show|resolve` for a file mirror: the conflicts the last sync left, each with its three
|
|
23
|
+
* versions and the line merge that failed, and a resolution that writes one final content to both sides.
|
|
24
|
+
*/
|
|
25
|
+
export declare const fileConflictsCommand: (helpers: FileConflictCommands) => Command;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { CliError } from "@wirecat/cli-base";
|
|
3
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
4
|
+
import { Command, Option } from "commander";
|
|
5
|
+
import { listFileConflicts, resolveFileConflict, showFileConflict, } from "../../documents.js";
|
|
6
|
+
import { refusedPlace } from "../../sends/upload.js";
|
|
7
|
+
import { environmentOf } from "../context.js";
|
|
8
|
+
import { LOCAL_READ, ownerOnlyOption, REMOTE_WRITE } from "../effects.js";
|
|
9
|
+
import { itemOf, listOf, snakeKeys } from "../envelope.js";
|
|
10
|
+
const ID = "mirror id from mirrors list";
|
|
11
|
+
const PATH = "the file's path inside the mirror, like notes/plan.md";
|
|
12
|
+
/**
|
|
13
|
+
* `mirrors conflicts list|show|resolve` for a file mirror: the conflicts the last sync left, each with its three
|
|
14
|
+
* versions and the line merge that failed, and a resolution that writes one final content to both sides.
|
|
15
|
+
*/
|
|
16
|
+
export const fileConflictsCommand = (helpers) => {
|
|
17
|
+
const { remote, identity } = helpers;
|
|
18
|
+
const app = identity.command;
|
|
19
|
+
const one = (command, id) => helpers.mirrors(command, id)[0];
|
|
20
|
+
return annotate(new Command("conflicts"), { effects: LOCAL_READ })
|
|
21
|
+
.summary("files changed on both sides that a sync could not merge")
|
|
22
|
+
.description(`files changed on both sides that a sync could not merge: list them, show the three versions and the lines ` +
|
|
23
|
+
`that conflict, and resolve each by keeping a side or giving the final file`)
|
|
24
|
+
.addCommand(annotate(new Command("list"), {
|
|
25
|
+
effects: LOCAL_READ,
|
|
26
|
+
examples: [`${app} personal mirrors conflicts list --json`],
|
|
27
|
+
})
|
|
28
|
+
.summary("list the conflicts the last sync left")
|
|
29
|
+
.description("list the conflicts each mirror's last sync left, with why and when it found them")
|
|
30
|
+
.argument("[id]", `${ID}; every mirror of the profile when omitted`)
|
|
31
|
+
.action(function (id) {
|
|
32
|
+
const items = listFileConflicts(helpers.mirrors(this, id), (mirror) => helpers.stateOf(this, mirror));
|
|
33
|
+
helpers.output(this, listOf("mirrors conflicts list", {
|
|
34
|
+
items: items.map((item) => snakeKeys(item)),
|
|
35
|
+
limit: Math.max(1, items.length),
|
|
36
|
+
has_more: false,
|
|
37
|
+
}));
|
|
38
|
+
}))
|
|
39
|
+
.addCommand(annotate(new Command("show"), {
|
|
40
|
+
effects: LOCAL_READ,
|
|
41
|
+
examples: [`${app} personal mirrors conflicts show 1a2b3c4d notes/plan.md --json`],
|
|
42
|
+
})
|
|
43
|
+
.summary("show a conflict's three versions and the lines that conflict")
|
|
44
|
+
.description("show a conflict's three versions (the last sync's, the local and the remote) and each changed stretch " +
|
|
45
|
+
"of the line merge; merged is the whole file with conflict markers, a start for resolve --file")
|
|
46
|
+
.argument("<id>", ID)
|
|
47
|
+
.argument("<path>", PATH)
|
|
48
|
+
.action(async function (id, input) {
|
|
49
|
+
const mirror = one(this, id);
|
|
50
|
+
const view = await showFileConflict({
|
|
51
|
+
root: mirror.path,
|
|
52
|
+
path: helpers.pathOf(mirror, input),
|
|
53
|
+
state: helpers.stateOf(this, mirror),
|
|
54
|
+
versions: helpers.versionsOf(this, mirror),
|
|
55
|
+
remote,
|
|
56
|
+
});
|
|
57
|
+
helpers.output(this, itemOf(snakeKeys({ id, ...view })));
|
|
58
|
+
}))
|
|
59
|
+
.addCommand(annotate(new Command("resolve"), {
|
|
60
|
+
effects: REMOTE_WRITE,
|
|
61
|
+
offline: false,
|
|
62
|
+
examples: [
|
|
63
|
+
`${app} personal mirrors conflicts resolve 1a2b3c4d notes/plan.md --keep ${remote}`,
|
|
64
|
+
`${app} personal mirrors conflicts resolve 1a2b3c4d notes/plan.md --file ~/plan-final.md`,
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
.summary("settle a conflict on both sides: keep a side, both, or the final file")
|
|
68
|
+
.description(`settle a conflict on both sides at once: keep the local file, the ${remote}'s, or both (the ${remote}'s ` +
|
|
69
|
+
`beside the local one), or give the final file. Refused with nothing written when either side changed ` +
|
|
70
|
+
"since the conflict was found; every replaced version is kept")
|
|
71
|
+
.argument("<id>", ID)
|
|
72
|
+
.argument("<path>", PATH)
|
|
73
|
+
.addOption(new Option("--keep <side>", `keep the local file, the ${remote}'s, or both`).choices([
|
|
74
|
+
"local",
|
|
75
|
+
remote,
|
|
76
|
+
"both",
|
|
77
|
+
]))
|
|
78
|
+
.addOption(ownerOnlyOption("--file <file>", "the final content, written to both sides"))
|
|
79
|
+
.action(async function (id, input, args) {
|
|
80
|
+
if ((args.keep === undefined) === (args.file === undefined))
|
|
81
|
+
throw new CliError("validation_error", "give either --keep or --file", { param: "--keep" });
|
|
82
|
+
const file = args.file === undefined ? undefined : resolve(args.file);
|
|
83
|
+
if (file && refusedPlace(file, identity, environmentOf(this).env ?? process.env))
|
|
84
|
+
throw new CliError("validation_error", `--file may not read ${file}: it holds sign-ins or state`, {
|
|
85
|
+
param: "--file",
|
|
86
|
+
});
|
|
87
|
+
const mirror = one(this, id);
|
|
88
|
+
const keep = (args.keep === remote ? "remote" : args.keep);
|
|
89
|
+
const resolved = await resolveFileConflict({
|
|
90
|
+
...(await helpers.connect(this, mirror)),
|
|
91
|
+
root: mirror.path,
|
|
92
|
+
folder: mirror.folder,
|
|
93
|
+
path: helpers.pathOf(mirror, input),
|
|
94
|
+
state: helpers.stateOf(this, mirror),
|
|
95
|
+
versions: helpers.versionsOf(this, mirror),
|
|
96
|
+
remote,
|
|
97
|
+
choice: keep ? { keep } : { file: file },
|
|
98
|
+
});
|
|
99
|
+
const resolution = resolved.resolution === "remote" ? remote : resolved.resolution;
|
|
100
|
+
helpers.output(this, itemOf(snakeKeys({ id, ...resolved, resolution })));
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type CellValue, type XlsxEdit } from "../../office/index.js";
|
|
3
|
+
import { type FileUpdateCommands, type FileUpdatePort } from "./file-update.js";
|
|
4
|
+
export interface FileEditCommands extends FileUpdateCommands {
|
|
5
|
+
/**
|
|
6
|
+
* The CLI's read path, signed in: the target and the profile's version store, for a command that changes nothing.
|
|
7
|
+
* `command` is the one running.
|
|
8
|
+
*/
|
|
9
|
+
read(act: (port: FileUpdatePort) => Promise<object>, command: Command): Promise<object>;
|
|
10
|
+
/**
|
|
11
|
+
* `restore <path>` with no version: the CLI's own restore from the provider's trash, which answers what it did. A
|
|
12
|
+
* CLI without one leaves it out, and the version is then required.
|
|
13
|
+
*/
|
|
14
|
+
restoreFromTrash?(input: string, command: Command): Promise<object>;
|
|
15
|
+
}
|
|
16
|
+
/** `Sheet1!A1:C10`, `'My sheet'!B2`, `Sheet1` or `A1:C10`, as the sheet and the cells. */
|
|
17
|
+
export declare const sheetRangeOf: (input: string | undefined) => {
|
|
18
|
+
sheet?: string;
|
|
19
|
+
range?: string;
|
|
20
|
+
};
|
|
21
|
+
/** The cells `values` fills from the range's top-left cell; a range of more than one cell must have their shape. */
|
|
22
|
+
export declare const cellEditsOf: (sheet: string, range: string, values: CellValue[][]) => XlsxEdit[];
|
|
23
|
+
/**
|
|
24
|
+
* Mounts `<files> update`, `sheets show|update`, `documents show|update`, `history` and `restore` under the CLI's own
|
|
25
|
+
* files group: Office files edited in place and earlier versions put back, every write at the sha256 it was read at
|
|
26
|
+
* and with the replaced content kept (`guardedFileWrite`). The CLI keeps no `restore` of its own; a trash restore
|
|
27
|
+
* goes in as `restoreFromTrash`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const addFileEditCommands: (files: Command, helpers: FileEditCommands) => void;
|