@octen.ai/cli 0.5.4 → 0.6.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
@@ -61,7 +61,7 @@ Search the live web.
61
61
  octen search "latest LLM benchmarks" -n 10 --topic news --highlight --time-range week
62
62
  ```
63
63
 
64
- Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+`--highlight-max-tokens`, min 100), `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--include-domains`, `--exclude-domains`, `--full-content`, `--images`, `--videos`, `--format` (text|markdown), `--safesearch`.
64
+ Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+`--highlight-max-tokens`, min 100), `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--include-domains`, `--exclude-domains`, `--language` (comma-separated ISO 639-1 codes, e.g. `en,ja` — one of `ar de en es fr hi id it ja ko nl pl pt ru th tr vi zh`), `--full-content`, `--images`, `--videos`, `--format` (text|markdown), `--safesearch`.
65
65
 
66
66
  ---
67
67
 
@@ -85,7 +85,7 @@ Use it for comparisons across many sources (pricing, products, vendors), surveys
85
85
  octen broad-search "compare cloud GPU pricing across providers" --max-queries 5 -n 10
86
86
  ```
87
87
 
88
- Options: `--max-queries` (decompose into up to N sub-queries, 1–30, default 5), plus all `octen search` flags (`-n/--count` per sub-query, `--topic`, `--highlight`, `--full-content`, `--time-range`, `--start-time`/`--end-time`, `--include-domains`/`--exclude-domains`, `--include-text`/`--exclude-text`, `--images`, `--videos`, `--format`, `--safesearch`).
88
+ Options: `--max-queries` (decompose into up to N sub-queries, 1–30, default 5), plus all `octen search` flags (`-n/--count` per sub-query, `--topic`, `--highlight`, `--full-content`, `--time-range`, `--start-time`/`--end-time`, `--include-domains`/`--exclude-domains`, `--include-text`/`--exclude-text`, `--language`, `--images`, `--videos`, `--format`, `--safesearch`).
89
89
 
90
90
  ---
91
91
 
@@ -128,7 +128,7 @@ Sampling: `--temperature`, `--top-p`, `--top-k`, `--min-p`, `--top-a`, `--repeti
128
128
 
129
129
  Reasoning: `--reasoning-effort` (xhigh|high|medium|low|minimal|none), `--reasoning-max-tokens`. When a model emits reasoning it is shown under a dim `reasoning:` prefix in pretty mode.
130
130
 
131
- Web search (only meaningful with `--search` and/or `--broad-search`): `--search-max-searches <n>` (octen_search only; default 5), `--search-max-queries <n>` (octen_broad_search only; 1-30, default 5), `--search-topic` (general|news), `--search-count <n>` (1-100), `--search-include-domains <list>`, `--search-exclude-domains <list>`, `--search-include-text <list>`/`--search-exclude-text <list>` (max 5 each), `--search-time-basis` (auto|published|crawled), `--search-time-range` (day|week|month|year or d|w|m|y), `--search-start-time <when>`, `--search-end-time <when>`, `--search-format` (markdown|text), `--search-safesearch` (off|strict), `--search-include-images`, `--search-full-content` (+`--search-full-content-max-tokens <n>`), `--search-highlight-max-tokens <n>`. The shared options apply to whichever tool(s) are enabled.
131
+ Web search (only meaningful with `--search` and/or `--broad-search`): `--search-max-searches <n>` (octen_search only; default 5), `--search-max-queries <n>` (octen_broad_search only; 1-30, default 5), `--search-topic` (general|news), `--search-count <n>` (1-100), `--search-include-domains <list>`, `--search-exclude-domains <list>`, `--search-include-text <list>`/`--search-exclude-text <list>` (max 5 each), `--search-time-basis` (auto|published|crawled), `--search-time-range` (day|week|month|year or d|w|m|y), `--search-start-time <when>`, `--search-end-time <when>`, `--search-format` (markdown|text), `--search-safesearch` (off|strict), `--search-language <list>` (comma-separated ISO 639-1 codes, e.g. `en,ja` — one of `ar de en es fr hi id it ja ko nl pl pt ru th tr vi zh`), `--search-include-images`, `--search-full-content` (+`--search-full-content-max-tokens <n>`), `--search-highlight-max-tokens <n>`. The shared options apply to whichever tool(s) are enabled.
132
132
 
133
133
  ---
134
134
 
@@ -90,6 +90,7 @@ export interface SearchOpts {
90
90
  endTime?: string;
91
91
  format?: SearchFormat;
92
92
  safesearch?: SearchSafesearch;
93
+ language?: string[];
93
94
  includeImages?: boolean;
94
95
  fullContent?: boolean;
95
96
  fullContentMaxTokens?: number;
package/dist/api/chat.js CHANGED
@@ -48,6 +48,7 @@ function buildWebSearchParameters(s) {
48
48
  put("end_time", normalizeTimeBound("--search-end-time", s.endTime, true));
49
49
  put("format", s.format);
50
50
  put("safesearch", s.safesearch);
51
+ put("language", s.language);
51
52
  put("include_images", s.includeImages);
52
53
  if (s.fullContent) {
53
54
  parameters["full_content"] = {
@@ -43,6 +43,7 @@ export interface SearchOpts {
43
43
  endTime?: string;
44
44
  format?: "text" | "markdown";
45
45
  safesearch?: "off" | "strict";
46
+ language?: string[];
46
47
  highlight?: boolean;
47
48
  highlightMaxTokens?: number;
48
49
  fullContent?: boolean;
@@ -56,6 +56,7 @@ export function buildSearchOptions(o) {
56
56
  put("end_time", normalizeTimeBound("--end-time", o.endTime, true));
57
57
  put("format", o.format);
58
58
  put("safesearch", o.safesearch);
59
+ put("language", o.language);
59
60
  put("include_images", o.images);
60
61
  put("include_videos", o.videos);
61
62
  if (o.highlight)
@@ -19,6 +19,7 @@ export function registerBroadSearch(program) {
19
19
  .option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
20
20
  .option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
21
21
  .option("--format <f>", "text|markdown").option("--safesearch <s>", "off|strict")
22
+ .option("--language <list>", "ISO 639-1 codes, comma-separated, e.g. en,ja", (v) => v.split(","))
22
23
  .option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
23
24
  .option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
24
25
  .option("--images").option("--videos")
@@ -95,6 +95,7 @@ export function registerChat(program) {
95
95
  .option("--search-end-time <when>", "search tools: end time filter")
96
96
  .option("--search-format <f>", "search tools: markdown|text")
97
97
  .option("--search-safesearch <s>", "search tools: off|strict")
98
+ .option("--search-language <list>", "search tools: ISO 639-1 codes, comma-separated, e.g. en,ja", splitList)
98
99
  .option("--search-include-images", "search tools: include image results")
99
100
  .option("--search-full-content", "search tools: include full page content")
100
101
  .option("--search-full-content-max-tokens <n>", "search tools: max tokens for full content", parseIntOpt("--search-full-content-max-tokens"))
@@ -140,6 +141,7 @@ export function registerChat(program) {
140
141
  endTime: opts.searchEndTime,
141
142
  format: opts.searchFormat,
142
143
  safesearch: opts.searchSafesearch,
144
+ language: opts.searchLanguage,
143
145
  includeImages: opts.searchIncludeImages,
144
146
  fullContent: Boolean(opts.searchFullContent),
145
147
  fullContentMaxTokens: opts.searchFullContentMaxTokens,
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync, appendFileSync, writeFileSync, mkdirSync } from "node:fs";
1
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { OctenValidationError } from "../api/errors.js";
@@ -114,6 +114,79 @@ function fishScript(model) {
114
114
  }
115
115
  return lines.join("\n") + "\n";
116
116
  }
117
+ /**
118
+ * A native zsh completion function — a `#compdef octen` file meant to live on
119
+ * `fpath` and be autoloaded by `compinit`. Unlike the `bashcompinit` `eval` shim,
120
+ * a file on `fpath` is re-discovered every time `compinit` runs, so a later
121
+ * `compinit` (e.g. appended by another tool's installer) reloads it instead of
122
+ * silently dropping the registration. This is the order-robust install target.
123
+ */
124
+ function zshCompletionFile(model) {
125
+ const subs = model.subcommands.join(" ");
126
+ const globals = model.globalFlags.join(" ");
127
+ const branches = model.subcommands
128
+ .map((sub) => {
129
+ const flags = [...(model.subFlags[sub] ?? []), ...model.globalFlags].join(" ");
130
+ return ` ${sub})\n opts="${flags}"\n ;;`;
131
+ })
132
+ .join("\n");
133
+ return `#compdef octen
134
+ # octen zsh completion (native, fpath-autoloaded). Do not edit by hand;
135
+ # regenerate with: octen completion zsh --install
136
+ _octen() {
137
+ local cur sub i opts
138
+ cur=\${words[CURRENT]}
139
+ sub=""
140
+ for (( i = 2; i < CURRENT; i++ )); do
141
+ case \${words[i]} in
142
+ -*) ;;
143
+ *) sub=\${words[i]}; break ;;
144
+ esac
145
+ done
146
+ if [[ -z $sub ]]; then
147
+ opts="${subs} ${globals}"
148
+ else
149
+ case $sub in
150
+ ${branches}
151
+ *)
152
+ opts="${globals}"
153
+ ;;
154
+ esac
155
+ fi
156
+ compadd -- \${=opts}
157
+ }
158
+ _octen "$@"
159
+ `;
160
+ }
161
+ /** Native bash completion file body (function + `complete`), for the bash-
162
+ * completion user dir which lazy-loads it on demand regardless of rc ordering. */
163
+ function bashCompletionFile(model) {
164
+ return `${bashFunction(model)}\n`;
165
+ }
166
+ const ZSH_BLOCK_START = "# >>> octen completion >>>";
167
+ const ZSH_BLOCK_END = "# <<< octen completion <<<";
168
+ /** The `~/.zshrc` block that puts our completions dir on `fpath` and (re)runs
169
+ * `compinit` so the `_octen` file is discovered no matter where it lands. */
170
+ function zshRcBlock() {
171
+ return [
172
+ ZSH_BLOCK_START,
173
+ 'fpath=("$HOME/.octen/completions" $fpath)',
174
+ "autoload -Uz compinit && compinit",
175
+ ZSH_BLOCK_END,
176
+ ].join("\n");
177
+ }
178
+ /** Remove the legacy `# octen CLI completion` + `eval` block older versions
179
+ * appended, so re-running `--install` cleanly upgrades to the fpath approach. */
180
+ function stripLegacyEvalBlock(contents, shell) {
181
+ const evalLine = `eval "$(octen completion ${shell})"`;
182
+ const legacyBlock = `\n# octen CLI completion\n${evalLine}\n`;
183
+ const withoutBlock = contents.split(legacyBlock).join("");
184
+ // Also drop any bare eval line left on its own (e.g. hand-placed).
185
+ return withoutBlock
186
+ .split("\n")
187
+ .filter((l) => l.trim() !== evalLine)
188
+ .join("\n");
189
+ }
117
190
  export function buildCompletionScript(program, shell) {
118
191
  const model = buildModel(program);
119
192
  switch (shell) {
@@ -128,9 +201,13 @@ export function buildCompletionScript(program, shell) {
128
201
  }
129
202
  }
130
203
  /**
131
- * Persist completion into the user's shell config.
132
- * - bash/zsh: append an idempotent `eval "$(octen completion <shell>)"` line to
133
- * the rc file, so it stays in sync with the CLI and loads in new shells.
204
+ * Persist completion into the user's shell so it survives re-initialization.
205
+ * - zsh: write a native `#compdef` `_octen` file into `~/.octen/completions`
206
+ * (an fpath dir) and ensure `~/.zshrc` adds that dir to `fpath` + runs
207
+ * `compinit`. Because it lives on `fpath`, a later `compinit` re-discovers it
208
+ * instead of dropping it — the failure mode of the old `eval` line.
209
+ * - bash: write a native completion file into the bash-completion user dir,
210
+ * which is lazy-loaded on demand regardless of rc ordering.
134
211
  * - fish: write the generated script into the auto-loaded completions dir.
135
212
  */
136
213
  function installCompletion(shell, program, home) {
@@ -141,15 +218,30 @@ function installCompletion(shell, program, home) {
141
218
  writeFileSync(file, buildCompletionScript(program, "fish"), "utf8");
142
219
  return { action: "written", path: file };
143
220
  }
144
- const rc = shell === "zsh" ? join(home, ".zshrc") : join(home, ".bashrc");
145
- const line = `eval "$(octen completion ${shell})"`;
146
- const existing = existsSync(rc) ? readFileSync(rc, "utf8") : "";
147
- if (existing.includes(line)) {
148
- return { action: "already", path: rc };
221
+ const model = buildModel(program);
222
+ if (shell === "zsh") {
223
+ // 1) (Re)write the native completion file into an fpath dir.
224
+ const dir = join(home, ".octen/completions");
225
+ mkdirSync(dir, { recursive: true });
226
+ const file = join(dir, "_octen");
227
+ writeFileSync(file, zshCompletionFile(model), "utf8");
228
+ // 2) Ensure ~/.zshrc puts that dir on fpath and runs compinit.
229
+ const rc = join(home, ".zshrc");
230
+ const existing = existsSync(rc) ? readFileSync(rc, "utf8") : "";
231
+ if (existing.includes(ZSH_BLOCK_START)) {
232
+ return { action: "already", path: rc, file };
233
+ }
234
+ const cleaned = stripLegacyEvalBlock(existing, "zsh");
235
+ const prefix = cleaned === "" || cleaned.endsWith("\n") ? "" : "\n";
236
+ writeFileSync(rc, `${cleaned}${prefix}\n${zshRcBlock()}\n`, "utf8");
237
+ return { action: "installed", path: rc, file };
149
238
  }
150
- const prefix = existing === "" || existing.endsWith("\n") ? "" : "\n";
151
- appendFileSync(rc, `${prefix}\n# octen CLI completion\n${line}\n`, "utf8");
152
- return { action: "installed", path: rc };
239
+ // bash: drop a native completion file into the bash-completion user dir.
240
+ const dir = join(home, ".local/share/bash-completion/completions");
241
+ mkdirSync(dir, { recursive: true });
242
+ const file = join(dir, "octen");
243
+ writeFileSync(file, bashCompletionFile(model), "utf8");
244
+ return { action: "written", path: file };
153
245
  }
154
246
  export function registerCompletion(program, internal = {}) {
155
247
  program
@@ -166,18 +258,21 @@ export function registerCompletion(program, internal = {}) {
166
258
  }
167
259
  const home = internal.home ?? os.homedir();
168
260
  const result = installCompletion(shell, program, home);
169
- if (result.action === "already") {
170
- process.stdout.write(`completion already installed in ${quotePath(result.path)}\n`);
171
- }
172
- else if (result.action === "written") {
261
+ if (shell === "fish") {
173
262
  process.stdout.write(`wrote fish completion to ${quotePath(result.path)} (new shells pick it up automatically)\n`);
263
+ return;
174
264
  }
175
- else {
176
- process.stdout.write(`added octen completion to ${quotePath(result.path)}\n`);
265
+ if (shell === "bash") {
266
+ process.stdout.write(`wrote octen bash completion to ${quotePath(result.path)} (new shells pick it up automatically)\n`);
267
+ return;
177
268
  }
178
- if (shell !== "fish") {
179
- const rc = shell === "zsh" ? "~/.zshrc" : "~/.bashrc";
180
- process.stdout.write(`run \`source ${rc}\` (or open a new terminal) to activate it now\n`);
269
+ // zsh: file on fpath + rc block.
270
+ if (result.action === "already") {
271
+ process.stdout.write(`octen completion already configured in ${quotePath(result.path)} (refreshed ${quotePath(result.file)})\n`);
272
+ }
273
+ else {
274
+ process.stdout.write(`installed octen completion: wrote ${quotePath(result.file)} and updated ${quotePath(result.path)}\n`);
181
275
  }
276
+ process.stdout.write("run `source ~/.zshrc` (or open a new terminal) to activate it now\n");
182
277
  });
183
278
  }
@@ -16,6 +16,7 @@ export function registerSearch(program, fixedTopic) {
16
16
  .option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
17
17
  .option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
18
18
  .option("--format <f>", "text|markdown").option("--safesearch <s>", "off|strict")
19
+ .option("--language <list>", "ISO 639-1 codes, comma-separated, e.g. en,ja", (v) => v.split(","))
19
20
  .option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
20
21
  .option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
21
22
  .option("--images").option("--videos");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octen.ai/cli",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Command-line tool for Octen — web search, extract, chat, embeddings, and one-command MCP/Skills setup.",
5
5
  "type": "module",
6
6
  "license": "MIT",