@leemour/cli-messaging 0.145.0 → 0.146.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/README.md CHANGED
@@ -21,7 +21,7 @@ provider has travels in `providerMetadata`.
21
21
  | `.` | `Chat`, `Message`, `Contact`, `Page`… · `formatLocator` / `parseLocator` · `renderMessages` · `pickChat` / `pickPerson` |
22
22
  | `./store` | `openCache` — `node:sqlite` under Node, `bun:sqlite` under Bun, WAL and a busy timeout on both · `openStore` — the shared message store, every method async: one file for every messenger (`MESSAGING_STORE` overrides where), forward-only migrations with `min_compatible`, every sender an identity with a person of their own, edits kept as revisions, a message by its id, deletions kept as tombstones, trigram search · `find` — by text, by sender, or both; `together` for the chats where every sender wrote, `perChat` to cap each chat · `savePeople` and `people` — usernames and bot flags, and a `PeopleLookup` for `pickPerson` |
23
23
  | `./sends` | the send guard: a level per command path (`permissions`: deny, readonly, ask, allow — `readOnly` and `allow` read as levels), a recipient list, an hourly limit, and a journal of every attempt that never holds the text; `newSendId` for a send's identity across retries |
24
- | `./cli` | the command skeleton: `run` (never throws, returns an exit code), the global flags, `settingsFor` (flag → environment → file → default, one strict file schema with each CLI's own fields), the profile as the first word, `--timeout` that closes what a command holds, paging, and run records: `--record` keeps a run's ids and timings (never content), a failure is kept unless `--no-record`, and `runsCommand` gives `runs list\|show\|path` · `configCommand(app, config)` shows and changes the settings with where each came from, and `config migrate --dry-run` previews translation of legacy access settings before `config migrate` saves it; `migratePermissionConfig` provides the same layer-preserving transformation to consumers · `completeCommand(messenger, config, options?)` gives shell completion, account-scoped chat and person ids from the store and never a connection; `options.sources` can supply local suggestions for a separate command group and `options.account` can read an existing local account binding · `storeSummary(env)` gives its local store diagnostics to consumers retaining their own doctor command · `doctorCommand(messenger)` reports the installation's state from disk (the store, the account, sends, runs, the messenger's own checks), and connects only with `--online`; `doctor report create` writes that, the failed run and the recent sends to a file with every id a label · `skillCommand(app, url)` prints the CLI's own SKILL.md for an agent (`skill show`) · `commandsCommand(app)` describes every command as JSON, with `contract` (`CONTRACT`, the major version of the output types) and which commands write · the shared read commands: a CLI describes its messenger once (`Messenger`: its app, a `connect` that returns a `MessengerAdapter`, how `me` maps to a chat) and gets `accountCommand`, `chatsCommand` (`list`, `show`), `contactsCommand` (`list`, `show`) `recipientsCommand`, `sendsCommand`, `watchCommand` (new messages as they arrive, `--jsonl`, until Ctrl-C or `--timeout`; `--events` adds edits, deletions and reactions, each kept in the store), `storeCommand` (the local store: `store fetch` puts a chat's history into it, resumable, FloodWait-aware, `--since` to stop at a time, `--background` for a detached job that `store jobs list|show|cancel` follow, `--estimate` to only price what is left from the store alone; `store status` what it holds; `store export` a chat's messages out of it, as JSON or `--format markdown`; `store clear --left` deletes the chats the account has left; `store info`, `store check`, `store migrate`, `store backup` and `store restore` look after the file itself — its size and schema, whether it is healthy and which chats are behind, bringing it up to this build, and a copy to go back to), `inboxCommand` (other people's unread messages in every chat, or with `--new` what arrived since the last check — each message once, the point moved only by a run that printed; copied from max-cli), `serveCommand` (keeps the store current until stopped — one per profile by a lock file, catch-up on, started by a person, `server start` or a unit), `serverCommand` (`server start|stop|restart|status|logs`: `serve` in the background, as max-cli's `server`; `install|uninstall` add a systemd user unit or a launchd agent per profile, and `install` starts nothing), and `messagesCommand` (`list`, `show`, `context`, `search` over the store by any three letters inside a word, or `--regex`, `send` through the send guard (`--reply-to`, `--silent`, `--no-preview`, `--md`, `--file` and `--photo` with the text as the caption, and `--at` to send later, with `scheduled` listing the queue), `edit` of the owner's own message, `forward` to another chat and `pin`/`unpin` through it too (the adapter's optional `edit`, `forward`, `pin` and `unpin`), and `delete` — at most 10, for the owner unless `--for-everyone`; it asks first by default, and `--allow-dangerous` is the yes · `reactionsCommand` (`add`, `remove`: the owner's reaction on a message, through the guard; the adapter's optional `react`) · `pollsCommand` (`show` a poll with its answer ids, `vote` by id or `--retract`, `close` the owner's own, `create` one — a vote guarded as a reaction, closing as an edit, a new poll as a message with a send id); a `msg:` locator names a message) — every read saved to the store, `--offline` answered from it, each call a run event · `mcpCommand(messenger)` serves the profile to an agent over MCP on stdin and stdout (copied from max-cli: one connection held for minutes, one call at a time, read tools named `<cli>_<command words>` answering what `--json` prints, `<cli>_status` without connecting; the write tools — `<cli>_messages_send`, `_edit`, `_forward`, `_pin`, `_unpin`, `_delete`, `<cli>_reactions_add`, `_remove`, `<cli>_chats_mark_read`, `<cli>_polls_vote`, `_close` and `_create` — are offered by the profile's `permissions` and run through the same guard as their commands; a write at level `ask` shows the owner a form first (`--allow-dangerous` or `--yes` skips it), `--confirm-send` puts every write through the form, and `messages_delete` never deletes for everyone), and `mcp config` prints the entry for a desktop client |
24
+ | `./cli` | the command skeleton: `run` (never throws, returns an exit code), the global flags, `settingsFor` (flag → environment → file → default, one strict file schema with each CLI's own fields), the profile as the first word, `--timeout` that closes what a command holds, paging, and run records: `--record` keeps a run's ids and timings (never content), a failure is kept unless `--no-record`, and `runsCommand` gives `runs list\|show\|path` · `configCommand(app, config)` shows and changes the settings with where each came from, and `config migrate --dry-run` previews translation of legacy access settings before `config migrate` saves it; `migratePermissionConfig` provides the same layer-preserving transformation to consumers · `completeCommand(messenger, config, options?)` gives shell completion, account-scoped chat and person ids from the store and never a connection; `options.sources` can supply local suggestions for a separate command group and `options.account` can read an existing local account binding · `storeSummary(env)` gives its local store diagnostics to consumers retaining their own doctor command · `doctorCommand(messenger)` reports the installation's state from disk (the store, the account, sends, runs, the messenger's own checks), and connects only with `--online`; `doctor report create` writes that, the failed run and the recent sends to a file with every id a label · `skillCommand(app, url)` prints the CLI's own SKILL.md for an agent (`skill show`) · `commandsCommand(app)` describes every command as JSON, with `contract` (`CONTRACT`, the major version of the output types) and which commands write · the shared read commands: a CLI describes its messenger once (`Messenger`: its app, a `connect` that returns a `MessengerAdapter`, how `me` maps to a chat) and gets `accountCommand`, `chatsCommand` (`list`, `show`), `contactsCommand` (`list`, `show`) `recipientsCommand`, `sendsCommand`, `watchCommand` (new messages as they arrive, `--jsonl`, until Ctrl-C or `--timeout`; `--events` adds edits, deletions and reactions, each kept in the store), `storeCommand` (the local store: `store fetch` puts a chat's history into it, resumable, FloodWait-aware, `--since` to stop at a time, `--background` for a detached job that `store jobs list|show|cancel` follow, `--estimate` to only price what is left from the store alone; `store status` what it holds; `store export` a chat's messages out of it, as JSON or `--format markdown`; `store clear --left` deletes the chats the account has left; `store info`, `store check`, `store migrate`, `store backup` and `store restore` look after the file itself — its size and schema, whether it is healthy and which chats are behind, bringing it up to this build, and a copy to go back to), `inboxCommand` (other people's unread messages in every chat, or with `--new` what arrived since the last check — each message once, the point moved only by a run that printed; copied from max-cli), `serveCommand` (keeps the store current until stopped — one per profile by a lock file, catch-up on, started by a person, `server start` or a unit), `serverCommand` (`server start|stop|restart|status|logs`: `serve` in the background, as max-cli's `server`; `install|uninstall` add a systemd user unit or a launchd agent per profile, and `install` starts nothing), and `messagesCommand` (`list`, `show`, `context`, `search` over the store by any three letters inside a word, or `--regex`, `send` through the send guard (`--reply-to`, `--silent`, `--no-preview`, `--md`, `--file` and `--photo` with the text as the caption, and `--at` to send later, with `scheduled` listing the queue), `edit` of the owner's own message, `forward` to another chat and `pin`/`unpin` through it too (the adapter's optional `edit`, `forward`, `pin` and `unpin`), and `delete` — at most 10, for the owner unless `--for-everyone`; it asks first by default, and `--allow-dangerous` is the yes · `reactionsCommand` (`add`, `remove`: the owner's reaction on a message, through the guard; the adapter's optional `react`) · `pollsCommand` (`show` a poll with its answer ids, `vote` by id or `--retract`, `close` the owner's own, `create` one — a vote guarded as a reaction, closing as an edit, a new poll as a message with a send id); a `msg:` locator names a message) — every read saved to the store, `--offline` answered from it, each call a run event · `mcpCommand(messenger)` serves the profile to an agent over MCP on stdin and stdout (copied from max-cli: one connection held for minutes, one call at a time, read tools named `<cli>_<command words>` answering what `--json` prints, `<cli>_status` without connecting; the write tools — `<cli>_messages_send`, `_edit`, `_forward`, `_pin`, `_unpin`, `_delete`, `<cli>_reactions_add`, `_remove`, `<cli>_chats_mark_read`, `<cli>_polls_vote`, `_close` and `_create` — are offered by the profile's `permissions` and run through the same guard as their commands; a write at level `ask` shows the owner a form first (`--allow-dangerous` or `--yes` skips it), `--confirm-send` puts every write through the form, and `messages_delete` never deletes for everyone), and `mcp config` prints the entry for a desktop client · `mcp --http` serves the same tools over HTTP on 127.0.0.1 behind the owner's tunnel with a one-owner login; a CLI with its own MCP server mounts `serveOverHttp(build, options)` with `OVER_HTTP`, `httpTokenFile` and `revokeAll` |
25
25
  | `./testing` | the adapter kit — **not stable yet**, so it may change in any release: `fakeAdapter(seed)`, a messenger in memory with every method group, for command tests; `contractCases({ connect })`, the port's promises as cases any test runner runs over an adapter; `contractSeed`, the chats and messages they read. How to write an adapter and run them: [the adapter guide](docs/dev/ADAPTERS.md) |
26
26
 
27
27
  ⚠ **Errors are recognised by shape, not by class** (`isCliFailure`). A package linked during
@@ -709,3 +709,37 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
709
709
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
710
710
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
711
711
 
712
+ ================================================================================
713
+
714
+ Snowball 3.1.1 stemmers (Russian, Spanish, English), generated JavaScript in dist/search/snowball/,
715
+ from https://github.com/snowballstem/snowball at cd195b51e948a902a4312f023f4a14392516a543.
716
+
717
+ Copyright (c) 2001, Dr Martin Porter
718
+ Copyright (c) 2004,2005, Richard Boulton
719
+ Copyright (c) 2013, Yoshiki Shibukawa
720
+ Copyright (c) 2006-2025, Olly Betts
721
+ All rights reserved.
722
+
723
+ Redistribution and use in source and binary forms, with or without
724
+ modification, are permitted provided that the following conditions
725
+ are met:
726
+
727
+ 1. Redistributions of source code must retain the above copyright notice,
728
+ this list of conditions and the following disclaimer.
729
+ 2. Redistributions in binary form must reproduce the above copyright notice,
730
+ this list of conditions and the following disclaimer in the documentation
731
+ and/or other materials provided with the distribution.
732
+ 3. Neither the name of the Snowball project nor the names of its contributors
733
+ may be used to endorse or promote products derived from this software
734
+ without specific prior written permission.
735
+
736
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
737
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
738
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
739
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
740
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
741
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
742
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
743
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
744
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
745
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,7 +1,10 @@
1
1
  export { botInstructions } from "../mcp/bot/instructions.js";
2
2
  export { type BotServerOptions, botToolName, createBotServer, type RunBotCommand } from "../mcp/bot/server.js";
3
3
  export { BOT_TOOLS, type BotTool, type BotToolKit, chat as botChatArgument, flag as botFlag, format as botFormat, type Invocation as BotInvocation, limit as botLimit, marks as botMarks, option as botOption, text as botText, withAcross, } from "../mcp/bot/tools.js";
4
+ export { revokeAll } from "../mcp/http/oauth.js";
5
+ export { type HttpOptions, MCP_PATH, serveOverHttp } from "../mcp/http/serve.js";
4
6
  export { answerMcpTool, failMcpTool, McpPicture, type PersonalMcpDefaults, type PersonalMcpRegistration, type PersonalMcpTool, personalMcpConfirmer, personalMcpToolKey, personalMcpTools, registerPersonalMcpTools, warmEmbedders, } from "../mcp/personal.js";
7
+ export { OVER_HTTP } from "../mcp/server.js";
5
8
  export { answerMessagesSearch, MESSAGES_SEARCH_DESCRIPTION, type MessagesSearchArgs, messagesSearchInput, } from "../mcp/tools/search.js";
6
9
  export { guardedClose, guardedCreatePoll, guardedVote } from "../sends/polls.js";
7
10
  export type { InboxReader } from "../services/inbox.js";
@@ -39,7 +42,7 @@ export { conversationsCommand } from "./messenger/conversations-command.js";
39
42
  export { doctorCommand } from "./messenger/doctor-command.js";
40
43
  export { recipientsCommand, sendsCommand } from "./messenger/guard-commands.js";
41
44
  export { inboxCommand } from "./messenger/inbox.js";
42
- export { type McpEnvironment, mcpCommand, serverEntry } from "./messenger/mcp-command.js";
45
+ export { httpTokenFile, type McpEnvironment, mcpCommand, serverEntry } from "./messenger/mcp-command.js";
43
46
  export { messagesCommand, sendCommand } from "./messenger/messages-command.js";
44
47
  export { deleteCommand } from "./messenger/messages-delete-command.js";
45
48
  export { editCommand } from "./messenger/messages-edit-command.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EACL,SAAS,EACT,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,IAAI,IAAI,eAAe,EACvB,IAAI,IAAI,OAAO,EACf,MAAM,IAAI,SAAS,EACnB,KAAK,UAAU,IAAI,aAAa,EAChC,KAAK,IAAI,QAAQ,EACjB,KAAK,IAAI,QAAQ,EACjB,MAAM,IAAI,SAAS,EACnB,IAAI,IAAI,OAAO,EACf,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,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EACb,KAAK,EACL,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
package/dist/cli/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  export { botInstructions } from "../mcp/bot/instructions.js";
2
2
  export { botToolName, createBotServer } from "../mcp/bot/server.js";
3
3
  export { BOT_TOOLS, chat as botChatArgument, flag as botFlag, format as botFormat, limit as botLimit, marks as botMarks, option as botOption, text as botText, withAcross, } from "../mcp/bot/tools.js";
4
+ export { revokeAll } from "../mcp/http/oauth.js";
5
+ export { MCP_PATH, serveOverHttp } from "../mcp/http/serve.js";
4
6
  export { answerMcpTool, failMcpTool, McpPicture, personalMcpConfirmer, personalMcpToolKey, personalMcpTools, registerPersonalMcpTools, warmEmbedders, } from "../mcp/personal.js";
7
+ export { OVER_HTTP } from "../mcp/server.js";
5
8
  export { answerMessagesSearch, MESSAGES_SEARCH_DESCRIPTION, messagesSearchInput, } from "../mcp/tools/search.js";
6
9
  export { guardedClose, guardedCreatePoll, guardedVote } from "../sends/polls.js";
7
10
  export { INBOX_CHATS, newIn, REVIEW_CHATS, reviewIn, unanswered, unreadIn } from "../services/inbox.js";
@@ -38,7 +41,7 @@ export { conversationsCommand } from "./messenger/conversations-command.js";
38
41
  export { doctorCommand } from "./messenger/doctor-command.js";
39
42
  export { recipientsCommand, sendsCommand } from "./messenger/guard-commands.js";
40
43
  export { inboxCommand } from "./messenger/inbox.js";
41
- export { mcpCommand, serverEntry } from "./messenger/mcp-command.js";
44
+ export { httpTokenFile, mcpCommand, serverEntry } from "./messenger/mcp-command.js";
42
45
  export { messagesCommand, sendCommand } from "./messenger/messages-command.js";
43
46
  export { deleteCommand } from "./messenger/messages-delete-command.js";
44
47
  export { editCommand } from "./messenger/messages-edit-command.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAyB,WAAW,EAAE,eAAe,EAAsB,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EACL,SAAS,EAGT,IAAI,IAAI,eAAe,EACvB,IAAI,IAAI,OAAO,EACf,MAAM,IAAI,SAAS,EAEnB,KAAK,IAAI,QAAQ,EACjB,KAAK,IAAI,QAAQ,EACjB,MAAM,IAAI,SAAS,EACnB,IAAI,IAAI,OAAO,EACf,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EAIV,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAE3B,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEhF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAoB,OAAO,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAA0C,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,EACL,SAAS,EACT,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB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AAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,WAAW,EACX,mBAAmB,EAEnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,uBAAuB,EAA4B,MAAM,2BAA2B,CAAA;AAC7F,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,iBAAiB,GAClB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAgE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC/G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAIL,gBAAgB,EAEhB,WAAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EAGR,aAAa,EACb,KAAK,EAKL,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAuB,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2001, Dr Martin Porter
2
+ Copyright (c) 2004,2005, Richard Boulton
3
+ Copyright (c) 2013, Yoshiki Shibukawa
4
+ Copyright (c) 2006-2025, Olly Betts
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions
9
+ are met:
10
+
11
+ 1. Redistributions of source code must retain the above copyright notice,
12
+ this list of conditions and the following disclaimer.
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+ 3. Neither the name of the Snowball project nor the names of its contributors
17
+ may be used to endorse or promote products derived from this software
18
+ without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,445 @@
1
+ // @ts-check
2
+
3
+ export default class BaseStemmer {
4
+ constructor() {
5
+ /** @protected */
6
+ this.current = '';
7
+ this.c = 0;
8
+ this.limit = 0;
9
+ this.limit_backward = 0;
10
+ this.bra = 0;
11
+ this.ket = 0;
12
+ this.af = 0;
13
+ }
14
+
15
+ /**
16
+ * @param {string} value
17
+ */
18
+ setCurrent(value) {
19
+ this.current = value;
20
+ this.c = 0;
21
+ this.limit = this.current.length;
22
+ this.limit_backward = 0;
23
+ this.bra = this.c;
24
+ this.ket = this.limit;
25
+ }
26
+
27
+ /**
28
+ * @return {string}
29
+ */
30
+ getCurrent() {
31
+ return this.current;
32
+ }
33
+
34
+ /**
35
+ * @param {BaseStemmer} other
36
+ */
37
+ copy_from(other) {
38
+ /** @protected */
39
+ this.current = other.current;
40
+ this.c = other.c;
41
+ this.limit = other.limit;
42
+ this.limit_backward = other.limit_backward;
43
+ this.bra = other.bra;
44
+ this.ket = other.ket;
45
+ }
46
+
47
+ /**
48
+ * @param {Array<number>} s
49
+ * @param {number} min
50
+ * @param {number} max
51
+ * @return {boolean}
52
+ */
53
+ in_grouping(s, min, max) {
54
+ /** @protected */
55
+ if (this.c >= this.limit) return false;
56
+ let ch = this.current.charCodeAt(this.c);
57
+ if (ch > max || ch < min) return false;
58
+ ch -= min;
59
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) === 0) return false;
60
+ this.c++;
61
+ return true;
62
+ }
63
+
64
+ /**
65
+ * @param {Array<number>} s
66
+ * @param {number} min
67
+ * @param {number} max
68
+ * @return {boolean}
69
+ */
70
+ go_in_grouping(s, min, max) {
71
+ /** @protected */
72
+ while (this.c < this.limit) {
73
+ let ch = this.current.charCodeAt(this.c);
74
+ if (ch > max || ch < min)
75
+ return true;
76
+ ch -= min;
77
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) === 0)
78
+ return true;
79
+ this.c++;
80
+ }
81
+ return false;
82
+ }
83
+
84
+ /**
85
+ * @param {Array<number>} s
86
+ * @param {number} min
87
+ * @param {number} max
88
+ * @return {boolean}
89
+ */
90
+ in_grouping_b(s, min, max) {
91
+ /** @protected */
92
+ if (this.c <= this.limit_backward) return false;
93
+ let ch = this.current.charCodeAt(this.c - 1);
94
+ if (ch > max || ch < min) return false;
95
+ ch -= min;
96
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) === 0) return false;
97
+ this.c--;
98
+ return true;
99
+ }
100
+
101
+ /**
102
+ * @param {Array<number>} s
103
+ * @param {number} min
104
+ * @param {number} max
105
+ * @return {boolean}
106
+ */
107
+ go_in_grouping_b(s, min, max) {
108
+ /** @protected */
109
+ while (this.c > this.limit_backward) {
110
+ let ch = this.current.charCodeAt(this.c - 1);
111
+ if (ch > max || ch < min) return true;
112
+ ch -= min;
113
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) === 0) return true;
114
+ this.c--;
115
+ }
116
+ return false;
117
+ }
118
+
119
+ /**
120
+ * @param {Array<number>} s
121
+ * @param {number} min
122
+ * @param {number} max
123
+ * @return {boolean}
124
+ */
125
+ out_grouping(s, min, max) {
126
+ /** @protected */
127
+ if (this.c >= this.limit) return false;
128
+ let ch = this.current.charCodeAt(this.c);
129
+ if (ch > max || ch < min) {
130
+ this.c++;
131
+ return true;
132
+ }
133
+ ch -= min;
134
+ if ((s[ch >>> 3] & (0X1 << (ch & 0x7))) === 0) {
135
+ this.c++;
136
+ return true;
137
+ }
138
+ return false;
139
+ }
140
+
141
+ /**
142
+ * @param {Array<number>} s
143
+ * @param {number} min
144
+ * @param {number} max
145
+ * @return {boolean}
146
+ */
147
+ go_out_grouping(s, min, max) {
148
+ /** @protected */
149
+ while (this.c < this.limit) {
150
+ let ch = this.current.charCodeAt(this.c);
151
+ if (ch <= max && ch >= min) {
152
+ ch -= min;
153
+ if ((s[ch >>> 3] & (0X1 << (ch & 0x7))) !== 0) {
154
+ return true;
155
+ }
156
+ }
157
+ this.c++;
158
+ }
159
+ return false;
160
+ }
161
+
162
+ /**
163
+ * @param {Array<number>} s
164
+ * @param {number} min
165
+ * @param {number} max
166
+ * @return {boolean}
167
+ */
168
+ out_grouping_b(s, min, max) {
169
+ /** @protected */
170
+ if (this.c <= this.limit_backward) return false;
171
+ let ch = this.current.charCodeAt(this.c - 1);
172
+ if (ch > max || ch < min) {
173
+ this.c--;
174
+ return true;
175
+ }
176
+ ch -= min;
177
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) === 0) {
178
+ this.c--;
179
+ return true;
180
+ }
181
+ return false;
182
+ }
183
+
184
+ /**
185
+ * @param {Array<number>} s
186
+ * @param {number} min
187
+ * @param {number} max
188
+ * @return {boolean}
189
+ */
190
+ go_out_grouping_b(s, min, max) {
191
+ /** @protected */
192
+ while (this.c > this.limit_backward) {
193
+ let ch = this.current.charCodeAt(this.c - 1);
194
+ if (ch <= max && ch >= min) {
195
+ ch -= min;
196
+ if ((s[ch >>> 3] & (0x1 << (ch & 0x7))) !== 0) {
197
+ return true;
198
+ }
199
+ }
200
+ this.c--;
201
+ }
202
+ return false;
203
+ }
204
+
205
+ /**
206
+ * @param {string} s
207
+ * @return {boolean}
208
+ */
209
+ eq_s(s) {
210
+ /** @protected */
211
+ if (this.limit - this.c < s.length) return false;
212
+ if (!this.current.startsWith(s, this.c)) return false;
213
+ this.c += s.length;
214
+ return true;
215
+ }
216
+
217
+ /**
218
+ * @param {string} s
219
+ * @return {boolean}
220
+ */
221
+ eq_s_b(s) {
222
+ /** @protected */
223
+ if (this.c - this.limit_backward < s.length) return false;
224
+ if (!this.current.endsWith(s, this.c)) return false;
225
+ this.c -= s.length;
226
+ return true;
227
+ }
228
+
229
+ /**
230
+ * @param {Array<Array<string|number>>} v
231
+ * @param {?function(): boolean} call_among_func
232
+ * @return {number}
233
+ */
234
+ find_among(v, call_among_func) {
235
+ /** @protected */
236
+ let i = 0;
237
+ let j = v.length;
238
+
239
+ const c = this.c;
240
+ const l = this.limit;
241
+
242
+ let common_i = 0;
243
+ let common_j = 0;
244
+
245
+ let first_key_inspected = false;
246
+
247
+ while (true) {
248
+ const k = i + ((j - i) >>> 1);
249
+ let diff = 0;
250
+ let common = common_i < common_j ? common_i : common_j; // smaller
251
+ // w[0]: string, w[1]: result, w[2]: substring_i (optional), w[3]: function (optional)
252
+ const w = v[k];
253
+ let i2;
254
+ // @ts-expect-error: w[0] always string.
255
+ for (i2 = common; i2 < w[0].length; i2++) {
256
+ if (c + common === l) {
257
+ diff = -1;
258
+ break;
259
+ }
260
+ // @ts-expect-error: w[0] always string.
261
+ diff = this.current.charCodeAt(c + common) - w[0].charCodeAt(i2);
262
+ if (diff !== 0) break;
263
+ common++;
264
+ }
265
+ if (diff < 0) {
266
+ j = k;
267
+ common_j = common;
268
+ } else {
269
+ i = k;
270
+ common_i = common;
271
+ }
272
+ if (j - i <= 1) {
273
+ if (i > 0) break; // v->s has been inspected
274
+ if (j === i) break; // only one item in v
275
+
276
+ // - but now we need to go round once more to get
277
+ // v->s inspected. This looks messy, but is actually
278
+ // the optimal approach.
279
+
280
+ if (first_key_inspected) break;
281
+ first_key_inspected = true;
282
+ }
283
+ }
284
+ while (true) {
285
+ const w = v[i];
286
+ // @ts-expect-error: w[0] always string.
287
+ if (common_i >= w[0].length) {
288
+ // @ts-expect-error: w[0] always string.
289
+ this.c = c + w[0].length;
290
+ // @ts-expect-error: w[1] always number.
291
+ if (w.length < 4) return w[1];
292
+ // @ts-expect-error: w[3] always number.
293
+ this.af = w[3];
294
+ // @ts-expect-error: call_among_func never null here.
295
+ if (call_among_func.call(this)) {
296
+ // @ts-expect-error: w[0] always string.
297
+ this.c = c + w[0].length;
298
+ // @ts-expect-error: w[3] always number.
299
+ return w[1];
300
+ }
301
+ }
302
+ // Tests for undefined (if w.length < 2) or 0.
303
+ if (!w[2]) return 0;
304
+ // @ts-expect-error: w[2] always number.
305
+ i -= w[2];
306
+ }
307
+ }
308
+
309
+ // find_among_b is for backwards processing. Same comments apply
310
+ /**
311
+ * @param {Array<Array<string|number>>} v
312
+ * @param {?function(): boolean} call_among_func
313
+ */
314
+ find_among_b(v, call_among_func) {
315
+ /** @protected */
316
+ let i = 0;
317
+ let j = v.length
318
+
319
+ const c = this.c;
320
+ const lb = this.limit_backward;
321
+
322
+ let common_i = 0;
323
+ let common_j = 0;
324
+
325
+ let first_key_inspected = false;
326
+
327
+ while (true) {
328
+ const k = i + ((j - i) >> 1);
329
+ let diff = 0;
330
+ let common = common_i < common_j ? common_i : common_j;
331
+ const w = v[k];
332
+ let i2;
333
+ // @ts-expect-error: w[0] always string.
334
+ for (i2 = w[0].length - 1 - common; i2 >= 0; i2--) {
335
+ if (c - common === lb) {
336
+ diff = -1;
337
+ break;
338
+ }
339
+ // @ts-expect-error: w[0] always string.
340
+ diff = this.current.charCodeAt(c - 1 - common) - w[0].charCodeAt(i2);
341
+ if (diff !== 0) break;
342
+ common++;
343
+ }
344
+ if (diff < 0) {
345
+ j = k;
346
+ common_j = common;
347
+ } else {
348
+ i = k;
349
+ common_i = common;
350
+ }
351
+ if (j - i <= 1) {
352
+ if (i > 0) break;
353
+ if (j === i) break;
354
+ if (first_key_inspected) break;
355
+ first_key_inspected = true;
356
+ }
357
+ }
358
+ while (true) {
359
+ const w = v[i];
360
+ // @ts-expect-error: w[0] always string.
361
+ if (common_i >= w[0].length) {
362
+ // @ts-expect-error: w[0] always string.
363
+ this.c = c - w[0].length;
364
+ if (w.length < 4) return w[1];
365
+ // @ts-expect-error: w[3] always number.
366
+ this.af = w[3];
367
+ // @ts-expect-error: call_among_func never null here.
368
+ if (call_among_func.call(this)) {
369
+ // @ts-expect-error: w[0] always string.
370
+ this.c = c - w[0].length;
371
+ return w[1];
372
+ }
373
+ }
374
+ // Tests for undefined (if w.length < 2) or 0.
375
+ if (!w[2]) return 0;
376
+ // @ts-expect-error: w[2] always number.
377
+ i -= w[2];
378
+ }
379
+ }
380
+
381
+ /* to replace chars between c_bra and c_ket in this.current by the
382
+ * chars in s.
383
+ */
384
+ /**
385
+ * @param {number} c_bra
386
+ * @param {number} c_ket
387
+ * @param {string} s
388
+ * @return {number}
389
+ */
390
+ #replace_s(c_bra, c_ket, s) {
391
+ const adjustment = s.length - (c_ket - c_bra);
392
+ this.current = this.current.slice(0, c_bra) + s + this.current.slice(c_ket);
393
+ this.limit += adjustment;
394
+ if (this.c >= c_ket) this.c += adjustment;
395
+ else if (this.c > c_bra) this.c = c_bra;
396
+ return adjustment;
397
+ }
398
+
399
+ /**
400
+ */
401
+ #slice_check() {
402
+ console.assert(this.bra >= 0);
403
+ console.assert(this.bra <= this.ket);
404
+ console.assert(this.ket <= this.limit);
405
+ console.assert(this.limit <= this.current.length);
406
+ }
407
+
408
+ /**
409
+ * @param {string} s
410
+ */
411
+ slice_from(s) {
412
+ /** @protected */
413
+ this.#slice_check();
414
+ this.#replace_s(this.bra, this.ket, s);
415
+ this.ket = this.bra + s.length;
416
+ }
417
+
418
+ /**
419
+ */
420
+ slice_del() {
421
+ /** @protected */
422
+ this.slice_from("");
423
+ }
424
+
425
+ /**
426
+ * @param {number} c_bra
427
+ * @param {number} c_ket
428
+ * @param {string} s
429
+ */
430
+ insert(c_bra, c_ket, s) {
431
+ /** @protected */
432
+ const adjustment = this.#replace_s(c_bra, c_ket, s);
433
+ if (c_bra <= this.bra) this.bra += adjustment;
434
+ if (c_bra <= this.ket) this.ket += adjustment;
435
+ }
436
+
437
+ /**
438
+ * @return {string}
439
+ */
440
+ slice_to() {
441
+ /** @protected */
442
+ this.#slice_check();
443
+ return this.current.slice(this.bra, this.ket);
444
+ }
445
+ }