@lotics/cli 0.91.0 → 0.92.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.
@@ -55,6 +55,25 @@ export interface ToolInfo {
55
55
  description: string;
56
56
  input_schema: unknown;
57
57
  }
58
+ /**
59
+ * A single knowledge doc with its HYDRATED body — the shape of
60
+ * `GET /v1/knowledge_docs/{id}`. `content` is resolved server-side from the
61
+ * doc's content file (or the parked column for a legacy row), so this is the
62
+ * one content-read path a non-sandbox client has. `content_file_id` is the
63
+ * concurrency token the REST PATCH echoes; the `update_knowledge` TOOL CASes
64
+ * internally, so a CLI caller never needs to pass it.
65
+ */
66
+ export interface KnowledgeDocDetail {
67
+ id: string;
68
+ workspace_id: string;
69
+ name: string;
70
+ description: string;
71
+ content: string;
72
+ content_file_id: string | null;
73
+ files: unknown[];
74
+ created_at: string;
75
+ updated_at: string;
76
+ }
58
77
  export interface FileUploadResult {
59
78
  files: Array<{
60
79
  id: string;
@@ -142,6 +161,13 @@ export declare class LoticsClient {
142
161
  format?: "json" | "text";
143
162
  timeoutMs?: number;
144
163
  }): Promise<ToolExecuteResult>;
164
+ /**
165
+ * Fetch one knowledge doc with its hydrated `content` — the single content-read
166
+ * path for a non-sandbox client (the `list_knowledge` tool returns metadata
167
+ * only, and the sandbox-staging read path is unavailable here). Works for both
168
+ * the file-model and legacy parked-column rows. Mirrors GET /v1/knowledge_docs/{id}.
169
+ */
170
+ getKnowledgeDoc(knowledge_doc_id: string): Promise<KnowledgeDocDetail>;
145
171
  getApp(app_id: string): Promise<{
146
172
  id: string;
147
173
  name: string;
@@ -187,6 +187,16 @@ export class LoticsClient {
187
187
  }
188
188
  return this.request("POST", "/v1/tools/execute", body);
189
189
  }
190
+ // --- Knowledge docs ---
191
+ /**
192
+ * Fetch one knowledge doc with its hydrated `content` — the single content-read
193
+ * path for a non-sandbox client (the `list_knowledge` tool returns metadata
194
+ * only, and the sandbox-staging read path is unavailable here). Works for both
195
+ * the file-model and legacy parked-column rows. Mirrors GET /v1/knowledge_docs/{id}.
196
+ */
197
+ async getKnowledgeDoc(knowledge_doc_id) {
198
+ return this.request("GET", `/v1/knowledge_docs/${encodeURIComponent(knowledge_doc_id)}`);
199
+ }
190
200
  // --- Apps ---
191
201
  async getApp(app_id) {
192
202
  return this.request("GET", `/v1/apps/${encodeURIComponent(app_id)}`);
@@ -21,13 +21,17 @@ names, exceptions, and policies. Do **not** put in it general skills the model a
21
21
  the doc, the doc is noise. A knowledge doc earns its place only by carrying external facts
22
22
  tied to your workspace.
23
23
 
24
- ## Creating a doc — `create_knowledge`
24
+ ## Creating a doc — `lotics knowledge create`
25
25
 
26
26
  ```bash
27
- lotics run create_knowledge @doc.json # content is large → read from a file or stdin
27
+ lotics knowledge create --name "Shipping tariffs" \
28
+ --description "HS-coded rates; searchable by lane and code" \
29
+ --from ./tariffs.md # the body is a Markdown file; or --content '<inline>'
28
30
  ```
29
31
 
30
- `create_knowledge` takes three things:
32
+ This reads the body from your filesystem and creates the doc through `create_knowledge`
33
+ (prints the new id). A raw `lotics run create_knowledge @doc.json` works too — read a large
34
+ `content` from a file or stdin. Either way, `create_knowledge` takes three things:
31
35
 
32
36
  - `name` — what it is.
33
37
  - `description` — what the doc is **and how to retrieve from it**: its vocabulary, synonyms for
@@ -57,40 +61,42 @@ So: shared + active → the agent can find and read it. Shared but deactivated
57
61
  that member's agent. This is the token economy in action — activation is how a member curates
58
62
  which rulebooks their agent carries.
59
63
 
60
- ## How an agent uses a doc — the retrieval funnel
64
+ ## How an agent uses a doc — catalog, then read
61
65
 
62
- The agent narrows from "which doc" to "which lines" in three steps. All four tools respect
63
- access + activation, so they only ever surface docs the caller may use.
66
+ Docs are not injected wholesale. The agent finds the right doc from a **catalog**, then reads
67
+ only what it needs. Both steps respect access + activation, so only docs the caller may use ever
68
+ surface.
64
69
 
65
- 1. **Find the doc** — `search_knowledge` (keyword query matching docs + a snippet) or
66
- `query_knowledge` (list every active doc). Returns *docs*, not the lines inside them.
67
- 2. **Locate lines within one doc**`grep_knowledge` (regex over the lines of a single doc,
68
- returns matches with line numbers). Matching is **diacritics-insensitive by default** — a
69
- plain-ASCII query matches accented Vietnamese text and can be case-insensitive too.
70
- 3. **Read the section** `read_knowledge`. Pass `outline: true` first to get the Markdown
71
- header map (a table of contents with line numbers), then read a section with `offset` (the
72
- 1-based first line) + `limit` (line count). A large doc never returns whole; reads are
73
- line-numbered and paged.
70
+ 1. **Catalog** — `list_knowledge` returns every usable doc as `{ id, name, description }` — no
71
+ bodies. This is why the *description* carries the weight: it is what the agent reads before
72
+ deciding to open a doc. Write it to sell the doc — its vocabulary, the colloquial synonyms an
73
+ ambiguous query would use, and what it covers.
74
+ 2. **Read** the chat agent stages the chosen doc's content file into a code run and greps it
75
+ there (the body arrives as a file to `cat`/`grep`). Over this CLI you read a body directly
76
+ with `lotics knowledge get <id>`.
74
77
 
75
- The whole point of the funnel is that the agent lands on the exact section that answers the
76
- question without ever loading the rest. Structure your content so it works:
78
+ Structure your content so a reader lands on the answer without loading the rest:
77
79
 
78
- - Organize under clear Markdown headers, so the doc can be outlined and read by section.
80
+ - Organize under clear Markdown headers.
79
81
  - Keep each searchable unit self-contained — a section for prose, **one record per line** for
80
82
  dense/tabular data (a price row, a code entry) — carrying both the terms someone would search
81
83
  for and its answer.
82
84
  - Lead with the most-queried fields.
83
85
  - Note colloquial synonyms next to official terms, so an ambiguous query still matches.
84
86
 
85
- ## Updating a doc — `update_knowledge`
87
+ ## Updating a doc — `lotics knowledge update`
86
88
 
87
- Send only the fields you're changing. Content edits are **diffs**, not a full rewrite: pass an
88
- `edits` array (replace / insert / append operations) plus the `expected_version` you got from
89
- `read_knowledge` (optimistic concurrency — a stale version is rejected). Over the CLI, the default
90
- `read_knowledge` text output omits the version — read `current_version` from `lotics run read_knowledge … --json`.
91
- Refine structure as you
92
- learn what users actually ask: add the synonym that failed to match, split the section that was
93
- too coarse to grep. See `lotics tools update_knowledge` for the edit shape.
89
+ ```bash
90
+ lotics knowledge update kdc_... --from ./tariffs.md # replace the body (--name / --description too)
91
+ ```
92
+
93
+ Send only the fields you're changing. `--from` / `--content` replaces the body; `--name` /
94
+ `--description` change metadata. `update_knowledge` resolves concurrency **internally** it
95
+ re-reads the current content pointer and version-chains the new body so there is no version
96
+ token to pass from the CLI. (The chat agent may instead send an `edits` array — anchored
97
+ replace / insert / append — for a surgical change; see `lotics tools update_knowledge`.) Refine
98
+ structure as you learn what users actually ask: add the synonym that failed to match, split the
99
+ section that was too coarse to read.
94
100
 
95
101
  ## Package-managed knowledge
96
102
 
@@ -103,12 +109,12 @@ same either way; the package layer just manages distribution and version pinning
103
109
  ## Reaching the tools
104
110
 
105
111
  ```bash
106
- lotics tools # all categories (knowledge tools are under "Knowledge")
107
- lotics tools grep_knowledge # one tool: full description + input schema
108
- lotics run create_knowledge @doc.json
109
- echo '{"query":"tariff"}' | lotics run search_knowledge
112
+ lotics knowledge list # catalog: id, name, description
113
+ lotics knowledge get kdc_... -o doc.md # read a body to a file (omit -o for stdout)
114
+ lotics tools update_knowledge # full input schema for any knowledge tool
110
115
  ```
111
116
 
112
- The Knowledge category covers `create_knowledge`, `update_knowledge`, `query_knowledge`,
113
- `search_knowledge`, `grep_knowledge`, `read_knowledge`, and `delete_knowledge`. Sharing a doc
114
- to other members is `share_resource` / `unshare_resource` (category **Admin**).
117
+ The Knowledge category covers `list_knowledge`, `create_knowledge`, `update_knowledge`, and
118
+ `delete_knowledge` fronted by the `lotics knowledge list | create | get | update | rm`
119
+ commands. Sharing a doc to other members is `share_resource` / `unshare_resource` (category
120
+ **Admin**).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.91.0",
3
+ "version": "0.92.0",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,6 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@lotics/docx": "*",
25
+ "@lotics/ooxml": "*",
25
26
  "@lotics/shared": "*",
26
27
  "@lotics/xlsx": "*",
27
28
  "@types/node": "^22.15.21",