@ottocode/sdk 0.1.307 → 0.1.309

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ottocode/sdk",
3
- "version": "0.1.307",
3
+ "version": "0.1.309",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "nitishxyz",
6
6
  "license": "MIT",
@@ -42,6 +42,31 @@ function killProcessTree(pid: number) {
42
42
  }
43
43
  }
44
44
 
45
+ const REDIRECTED_SEARCH_COMMANDS = new Set(['grep', 'egrep', 'fgrep', 'rg']);
46
+
47
+ /**
48
+ * Detect commands that start with a standalone grep-style search binary.
49
+ * Pipelines like `ps aux | grep x` are allowed; only segments that begin
50
+ * with grep/rg are redirected to the dedicated `search` tool.
51
+ */
52
+ export function findRedirectedSearchCommand(cmd: string): string | null {
53
+ const segments = cmd.split(/&&|\|\||;|\n/);
54
+ for (const segment of segments) {
55
+ const tokens = segment.trim().split(/\s+/);
56
+ let index = 0;
57
+ while (
58
+ index < tokens.length &&
59
+ /^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[index] ?? '')
60
+ ) {
61
+ index++;
62
+ }
63
+ if (tokens[index] === 'command') index++;
64
+ const bin = tokens[index]?.split('/').pop() ?? '';
65
+ if (REDIRECTED_SEARCH_COMMANDS.has(bin)) return bin;
66
+ }
67
+ return null;
68
+ }
69
+
45
70
  export type ShellOutputMode = 'auto' | 'full' | 'tail';
46
71
 
47
72
  const DEFAULT_TAIL_LINES = 100;
@@ -6,6 +6,8 @@
6
6
 
7
7
  For repository discovery, use `search` for content/code search and `glob` for filename/path discovery. Reserve `shell` for execution, builds, tests, diagnostics, and other command-line tasks.
8
8
 
9
+ **Strongly prefer the `search` tool over `grep`/`rg`, and `glob` over `find`.** The `search` tool is indexed and faster, returns structured `file:line` matches, and supports regex, `glob` includes, `path` scoping, and `ignoreCase` — use it for all repository content search. Only fall back to `grep`/`rg` via shell for cases `search` cannot handle (e.g. gitignored files like node_modules or build output). Pipelines that filter program output (e.g. `ps aux | grep node`) are fine.
10
+
9
11
  ## Usage tips
10
12
 
11
13
  - Chain commands with `&&` to fail-fast.
@@ -32,5 +32,6 @@ After making changes:
32
32
  ## Searching & discovery
33
33
 
34
34
  - Use the `search` tool for content/code search and `glob` for filename patterns.
35
+ - Strongly prefer `search` over running `grep`/`rg` through `shell` — it is indexed, faster, and returns structured `file:line` matches with less output to process.
35
36
  - Reserve `shell` for execution, builds, tests, and other command-line tasks.
36
37
  - Batch independent reads/searches in a single turn for performance.
@@ -10,7 +10,7 @@ You are otto, the supervisor agent for ottocode. You wake up after a main sessio
10
10
  - Ambiguous → leave it in done_pending and ask the main agent to confirm via enqueue_session_message.
11
11
  3. Decide the next move:
12
12
  - All tasks completed → complete the goal (goal_update with completeGoal) and stop. Do not enqueue anything.
13
- - Tasks remain and the last run succeeded → enqueue a short continuation into the main session listing the next task(s).
13
+ - Tasks remain and the last run succeeded → enqueue a short continuation into the main session listing the next task(s), reminding the agent to mark the task in_progress before starting it.
14
14
  - The last run errored → enqueue a continuation describing the error and asking the main agent to recover or retry.
15
15
  - Sub-agents are still running for tasks → do not enqueue duplicate work for those tasks.
16
16
  4. If nothing useful can be done (no goal, nothing stale, nothing errored), do nothing and finish.
@@ -24,6 +24,12 @@ When instructions conflict, obey (highest → lowest):
24
24
  - When `details.reason === 'previous_tool_failed'`, retry the failing tool (`details.expectedTool` when provided, else the latest tool) — don't switch tools.
25
25
  - State the failure briefly, say how you'll fix it, then retry.
26
26
 
27
+ ## Delegation
28
+
29
+ - If you delegate a task to a sub-agent, treat that delegated task as owned by the sub-agent.
30
+ - Do not perform the same delegated work yourself unless the sub-agent fails, the user explicitly asks for independent verification, or the task explicitly requires parallel independent work.
31
+ - After delegating, continue only unrelated work, wait for the automatic result, or use `list_subagents` / `message_subagent` to coordinate.
32
+
27
33
  ## Finishing your turn
28
34
 
29
35
  Your turn ends when you stop calling tools. The answer/work you already streamed IS your final response.
@@ -97,7 +97,7 @@ assistant: Clients are marked as failed in the `connectToServer` function in src
97
97
  For software engineering requests (bugs, features, refactors, explanations):
98
98
 
99
99
  1. Use `update_todos` to plan multi-step work.
100
- 2. Explore the codebase with the search tools (`search`, `glob`, `tree`, `read`). Batch independent searches in parallel.
100
+ 2. Explore the codebase with the search tools (`search`, `glob`, `tree`, `read`). Prefer `search` over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches. Batch independent searches in parallel.
101
101
  3. Implement the solution.
102
102
  4. Verify — run the project's build/lint/test commands with `shell`. Check `README.md` / `AGENTS.md` to find the right command.
103
103
  5. Review diffs with `git_status` / `git_diff`.
@@ -24,7 +24,7 @@ You are a coding agent running in otto, a terminal-based coding assistant. Preci
24
24
 
25
25
  # Working on tasks
26
26
 
27
- 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches.
27
+ 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches. Prefer `search` over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches.
28
28
  2. Plan — use `update_todos` for multi-step work. Mark one step `in_progress` at a time.
29
29
  3. Implement — prefer the targeted editing tools available to you for small in-file changes; use patch-style edits for structural or multi-file changes when available; use `write` only for new files or near-total rewrites.
30
30
  4. Verify — run project-specific build/lint/test commands via `shell`. Check `README.md` / `AGENTS.md` for the right command.
@@ -36,7 +36,7 @@ Your reasoning is powerful, but it can override what you actually read. Guard ag
36
36
 
37
37
  # Working on tasks
38
38
 
39
- 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches.
39
+ 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches. Prefer `search` over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches.
40
40
  2. Plan — use `update_todos` for multi-step work. Mark one step `in_progress` at a time.
41
41
  3. Implement — prefer the targeted editing tools available to you for small in-file changes; use patch-style edits for structural or multi-file changes when available; use `write` only for new files or near-total rewrites.
42
42
  4. Verify — run project-specific build/lint/test commands via `shell`. Check `README.md` / `AGENTS.md` for the right command.
@@ -19,7 +19,7 @@ You are Gemini, operating as otto — an interactive CLI coding agent specializi
19
19
 
20
20
  For bug fixes, features, refactors, or explanations:
21
21
 
22
- 1. **Understand.** Use `search` / `glob` / `tree` / `read` extensively (in parallel when independent) to understand structure, patterns, and conventions.
22
+ 1. **Understand.** Use `search` / `glob` / `tree` / `read` extensively (in parallel when independent) to understand structure, patterns, and conventions. Prefer `search` over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches.
23
23
  2. **Plan.** Build a grounded plan. Share an extremely concise plan with the user if it helps. Include a self-verification loop (unit tests, debug logging) when relevant.
24
24
  3. **Implement.** Use the tools actually available in your toolset for edits and verification — strictly adhering to Core Mandates.
25
25
  4. **Verify (tests).** Identify test commands from `README`, `package.json`, or existing test patterns. NEVER assume standard test commands.
@@ -36,7 +36,7 @@ Your reasoning is powerful, but it can override what you actually read. Guard ag
36
36
 
37
37
  # Working on tasks
38
38
 
39
- 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches.
39
+ 1. Understand — use `search`, `glob`, `tree`, `read` to map the code. Batch independent searches. Prefer `search` over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches.
40
40
  2. Plan — use `update_todos` for multi-step work. Mark one step `in_progress` at a time.
41
41
  3. Implement — prefer the targeted editing tools available to you for small in-file changes; use patch-style edits for structural or multi-file changes when available; use `write` only for new files or near-total rewrites.
42
42
  4. Verify — run project-specific build/lint/test commands via `shell`. Check `README.md` / `AGENTS.md` for the right command.
@@ -172,8 +172,8 @@ For casual greetings, acknowledgements, or one-off conversational messages, resp
172
172
 
173
173
  # Tool usage policy
174
174
 
175
- - For content/code search: use the `search` tool.
176
- - For file pattern matching: prefer `glob` tool.
175
+ - For content/code search: use the `search` tool. Prefer it over `grep`/`rg` via shell — it is indexed, faster, and returns structured `file:line` matches.
176
+ - For file pattern matching: prefer `glob` tool over `find` via shell.
177
177
  - Reserve shell for execution, builds, tests, and other command-line tasks.
178
178
  - Read files in chunks ≤ 250 lines; command output truncates after ~10 KB or ~256 lines.
179
179
  - Batch independent operations (multiple reads, multiple searches) in a single turn. Only serialize when the next call depends on the previous result.
@@ -24,6 +24,7 @@ const XAI_GROK_CLI_MODELS: ModelInfo[] = [
24
24
  toolCall: true,
25
25
  reasoningText: true,
26
26
  editToolCapability: 'structured',
27
+ limit: { context: 512_000 },
27
28
  provider: { npm: '@ai-sdk/xai' },
28
29
  },
29
30
  {
@@ -34,6 +35,7 @@ const XAI_GROK_CLI_MODELS: ModelInfo[] = [
34
35
  attachment: false,
35
36
  toolCall: true,
36
37
  reasoningText: true,
38
+ limit: { context: 200_000 },
37
39
  provider: { npm: '@ai-sdk/xai' },
38
40
  },
39
41
  ];