@retiform-ai/cli 0.0.0-stage → 0.7.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/LICENSE +55 -0
- package/README.md +158 -2
- package/dist/retiform.js +2537 -0
- package/package.json +37 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
16
|
+
|
|
17
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
18
|
+
|
|
19
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
20
|
+
|
|
21
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
22
|
+
|
|
23
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
24
|
+
|
|
25
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
26
|
+
|
|
27
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
28
|
+
|
|
29
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
30
|
+
|
|
31
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
34
|
+
|
|
35
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
36
|
+
|
|
37
|
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
38
|
+
|
|
39
|
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
40
|
+
|
|
41
|
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
42
|
+
|
|
43
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,3 +1,159 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @retiform-ai/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Uploads a folder of documents to your tenant on Retiform, shared memory for AI agents, signed in as yourself. It applies the same
|
|
4
|
+
rules as the console's Documents page (027 `contracts/upload-rules.md`). Requires Node.js 22 or later.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npx @retiform-ai/cli upload ./notes
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
To install the `retiform` command, run `npm i -g @retiform-ai/cli`. It was called `kg` (package `@retiform-ai/kg`) before
|
|
11
|
+
0.7.0. Your existing sign-in keeps working under the new name, and the old package still runs the same command, with a
|
|
12
|
+
warning, until it is removed.
|
|
13
|
+
|
|
14
|
+
The command uploads to the trial at `https://api.retiform.ai`. Name another platform with `--endpoint`, such as the
|
|
15
|
+
development environment:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @retiform-ai/cli upload ./notes --endpoint https://api.dev.retiform.ai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The first run shows an address and a code. Open the address, check the code, and sign in with your email. Later runs
|
|
22
|
+
renew that sign-in without asking.
|
|
23
|
+
|
|
24
|
+
Before it sends anything, the command says where the files go and asks you to confirm:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
Uploading to tenant Notes (t-abcdefghijkl) as you@example.com on api.retiform.ai.
|
|
28
|
+
Send 10 files to tenant Notes (t-abcdefghijkl) as you@example.com on api.retiform.ai? [y/N]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Only `y` or `yes` sends. Check the account: a sign-in stored on a shared computer may be someone else's. `retiform whoami`
|
|
32
|
+
shows it, and `retiform logout` removes it.
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
| Command | Does |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `retiform upload <folder-or-file>... [--endpoint <origin>] [--tenant <id>] [--yes] [--dry-run] [--confirm] [--wait] [--json]` | uploads Markdown, HTML, plain-text and Word files. PDF files are sent too; the platform reads their pages, within a monthly page limit. With `--wait`, it then follows each sent document until it is searchable or failed, for up to 10 minutes |
|
|
39
|
+
| `retiform login [--endpoint <origin>]` | signs in without uploading |
|
|
40
|
+
| `retiform logout [--endpoint <origin>]` | revokes and deletes the stored sign-in |
|
|
41
|
+
| `retiform whoami [--endpoint <origin>] [--json]` | shows the signed-in account, its tenant and role, without signing in |
|
|
42
|
+
| `retiform delete <external-id>... [--endpoint <origin>] [--tenant <id>] [--yes] [--dry-run] [--json]` | deletes each document whose external id is given exactly, with its revisions and passages; asks first, like `retiform upload` |
|
|
43
|
+
| `retiform link (--project <id> \| --name <name>) [--endpoint <origin>] [--json]` | links a repository for the Retiform plugin for Claude Code |
|
|
44
|
+
| `retiform codex install [--endpoint <origin>] [--dry-run]` | gives the Codex CLI the same session start as the plugin |
|
|
45
|
+
| `retiform login --read [--store-file] [--endpoint <origin>]` | signs in a second time, to read (#1137); kept apart from the upload sign-in |
|
|
46
|
+
| `retiform login --client-id <id> --client-secret-stdin [--store-file] [--endpoint <origin>]` | for a job no person attends (CI): signs in as one of the tenant's service applications, its secret read from standard input. Every command then acts as that application until `retiform logout`. `--store-file` (0.6.1) keeps it in `credentials.json` only, never in the system store: use it in a job that deletes that folder when it ends |
|
|
47
|
+
| `retiform recall [--label <l>]... [--topic <t>] [--since <date>] [--tenant-wide] [--session <label>] [--json]` | current memory entries, newest first, or ranked by `--topic`; in a linked repository, the Project's (with `--tenant-wide`, the tenant's own too) |
|
|
48
|
+
| `retiform context "<question>" [--budget <tokens>] [--session <label>] [--json]` | cited passages and entities for a question, within `--budget` tokens (100 to 16000; 2000 when absent) |
|
|
49
|
+
| `retiform record "<statement>" [--label <l>]... [--session <label>] [--json]` | records a memory entry, about the linked Project when there is one |
|
|
50
|
+
| `retiform handoff [--session <label>] [--json]` | the newest entry labelled `handoff` for the linked Project |
|
|
51
|
+
|
|
52
|
+
- `--dry-run` signs in, then prints what would be sent and skipped. It sends nothing.
|
|
53
|
+
- `--confirm` sends again the files that came back *needs confirmation*, accepting the change it printed for each.
|
|
54
|
+
- `--tenant` refuses to send unless you belong to that tenant. Because it names the tenant, the command then sends
|
|
55
|
+
without asking.
|
|
56
|
+
- `--yes` sends without asking. In a script or CI job, where the command cannot ask, give `--yes` or `--tenant`;
|
|
57
|
+
without either it stops before signing in, and sends nothing.
|
|
58
|
+
- `--json` prints one JSON object per file and a summary object.
|
|
59
|
+
|
|
60
|
+
Hidden files and folders (any name starting with `.`) are never read, and are listed as *skipped*. Sending the same
|
|
61
|
+
folder again is safe: unchanged files are reported as *unchanged*.
|
|
62
|
+
|
|
63
|
+
Each file becomes the document named by its path. Under a folder you name, that is the folder's name, then the path
|
|
64
|
+
inside it: `retiform upload notes` sends `notes/a/b.md`. A file you name on its own is named by its path from the current
|
|
65
|
+
folder, so `retiform upload specs/*/spec.md` from a repository's top folder sends `specs/001-x/spec.md` and so on, the same
|
|
66
|
+
names `retiform upload specs` gives them. A file outside the current folder is named by its file name alone. Two different
|
|
67
|
+
files that would get the same name stop the command before anything is sent.
|
|
68
|
+
|
|
69
|
+
The console's Documents page names files the same way. A folder you choose or drop there gets the names `retiform upload`
|
|
70
|
+
gives that folder. Files you choose one by one are named by their file names, as `retiform` names files in the current
|
|
71
|
+
folder. Sending the same files once as files and once as a folder makes two sets of documents.
|
|
72
|
+
|
|
73
|
+
`added` means Retiform has stored the file. It becomes searchable once processed, usually within a minute. `retiform`'s
|
|
74
|
+
sign-in can only upload, so it can't follow that processing (#993): the console's Documents page shows when each
|
|
75
|
+
document is ready, and `retiform upload` ends with its address.
|
|
76
|
+
|
|
77
|
+
Builds from source before #785 named a file given on its own by its file name alone. If you uploaded files that way
|
|
78
|
+
from a subfolder, sending them again now creates new documents under their paths. Delete the old ones on the
|
|
79
|
+
console's Documents page.
|
|
80
|
+
|
|
81
|
+
`retiform link` writes `.retiform/project.json` at the root of the Git repository you run it in, for the Retiform plugin
|
|
82
|
+
for Claude Code. Commit the file, and teammates who install the plugin share the same decisions without linking
|
|
83
|
+
again. Use `--project` with the Project you picked through the plugin's link skill, or `--name` to create a new
|
|
84
|
+
Project. It shows your tenant first. If a valid link already exists, it changes nothing.
|
|
85
|
+
|
|
86
|
+
`retiform codex install` gives OpenAI's Codex CLI the same start to each session as the Retiform plugin gives Claude
|
|
87
|
+
Code. It copies the hook into `$CODEX_HOME/retiform/` (`~/.codex/retiform/` without `CODEX_HOME`) and adds its entry to
|
|
88
|
+
`$CODEX_HOME/hooks.json`, keeping your other hooks. Running it again replaces only its own entry. It makes no network
|
|
89
|
+
call. It then prints the steps left to you: `codex mcp add retiform --url https://api.retiform.ai/mcp` and `codex mcp
|
|
90
|
+
login retiform` to connect Codex, trusting the hook with `/hooks` in Codex, and `retiform link` in each repository. With
|
|
91
|
+
`--dry-run` it only says what it would write. A `hooks.json` that is not a JSON object is left as it is, and the
|
|
92
|
+
command stops with exit status 1.
|
|
93
|
+
|
|
94
|
+
When too many of your documents are still processing, the command says so and waits for them, up to about five
|
|
95
|
+
minutes for a file, before sending it again. If they are still processing after that, the file fails and the command
|
|
96
|
+
stops, naming the limit; send the folder again later.
|
|
97
|
+
|
|
98
|
+
## Exit status
|
|
99
|
+
|
|
100
|
+
| Status | When |
|
|
101
|
+
|---|---|
|
|
102
|
+
| 0 | every file was added, a new revision, unchanged or skipped |
|
|
103
|
+
| 1 | at least one file failed, needs confirmation, or was not sent; or you answered no (nothing sent) |
|
|
104
|
+
| 1 | `retiform link`: the platform refused to create the Project, or the file could not be written |
|
|
105
|
+
| 1 | `retiform codex install`: `hooks.json` could not be read or merged (it is left as it is) |
|
|
106
|
+
| 2 | the arguments or the folder could not be used, or the command could not ask and had neither `--yes` nor `--tenant` (nothing sent) |
|
|
107
|
+
| 3 | sign-in, or the platform's configuration, failed (nothing sent) |
|
|
108
|
+
|
|
109
|
+
## Your sign-in
|
|
110
|
+
|
|
111
|
+
The command keeps only a refresh token, in your system's credential store (Windows Credential Manager, the macOS
|
|
112
|
+
Keychain or the Secret Service on Linux), under `kg-upload:<sign-in domain>`. Where no store is available, it keeps
|
|
113
|
+
the token in `credentials.json` under `$XDG_CONFIG_HOME/kg` (or `~/.config/kg`; `%APPDATA%\kg` on Windows), readable
|
|
114
|
+
by you only, and tells you so. No option or environment variable accepts a token. This sign-in can upload; it cannot
|
|
115
|
+
read your documents.
|
|
116
|
+
|
|
117
|
+
On Linux the system store means the Secret Service (gnome-keyring, KWallet and the like). On a machine without one, a
|
|
118
|
+
server or a CI runner, kg 0.6.1 and retiform 0.7.0 and later use the file and say so. Earlier versions could put the sign-in in the
|
|
119
|
+
kernel keyring instead, without saying so; that keyring is shared by your user's processes and is cleared at reboot.
|
|
120
|
+
If you used one of those versions on such a machine, run `kg logout` with it, or sign in again after a reboot.
|
|
121
|
+
`retiform logout` exits 3 and names the entry when the system store keeps a sign-in it was asked to remove.
|
|
122
|
+
|
|
123
|
+
## Reading and recording (#1137)
|
|
124
|
+
|
|
125
|
+
`retiform recall`, `retiform context` and `retiform handoff` need a second sign-in that can only read your tenant. You opt in once per
|
|
126
|
+
machine with `retiform login --read`; until then they say so and exit with status 3, and nothing else on the machine can
|
|
127
|
+
read. `retiform record` writes with the upload sign-in (`retiform login`), which holds `kg:write`; the read sign-in cannot write.
|
|
128
|
+
Where the platform offers the read sign-in an application of its own (`readClientId` in its configuration), it signs
|
|
129
|
+
in through that one, so it can be switched off without touching uploads. It is kept apart from the upload sign-in, under `kg-read:<sign-in domain>`, and in the system's
|
|
130
|
+
credential store only: where none is available, `retiform login --read --store-file` keeps it in `credentials.json` as
|
|
131
|
+
above, which you must ask for, since anyone who reads that file can read your tenant. `retiform logout` revokes and removes
|
|
132
|
+
both sign-ins.
|
|
133
|
+
|
|
134
|
+
They act as you, not as an agent:
|
|
135
|
+
|
|
136
|
+
- `retiform recall`, `retiform context` and `retiform handoff` count against your plan's monthly retrieval calls, as the MCP tools do,
|
|
137
|
+
and the console's context usage files them under you, not under an agent.
|
|
138
|
+
- `retiform record` records as you. A statement that looks like it holds a credential is refused, as is one past the plan's
|
|
139
|
+
memory entries.
|
|
140
|
+
- `--session <label>` (or `KG_SESSION_LABEL`) declares a session label on each call, 1 to 40 characters of `A-Z a-z 0-9 . _ : -` (others are refused, since the
|
|
141
|
+
platform would drop them), so that a
|
|
142
|
+
script's entries say where they came from. It is the caller's own text, not verified.
|
|
143
|
+
|
|
144
|
+
In a repository linked with `retiform link`, they work on that Project; elsewhere, on the tenant. `--json` prints the
|
|
145
|
+
platform's answer; without it, a few readable lines.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
Apache-2.0 ([LICENSE](LICENSE)). The bundle includes the console's upload rules (`console/src/upload`), which ship
|
|
150
|
+
under the same license.
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npm ci
|
|
156
|
+
npm run typecheck
|
|
157
|
+
npm test
|
|
158
|
+
npm run build # dist/retiform.js, bundling ../console/src/upload
|
|
159
|
+
```
|