Skip to content

Commit 600a57e

Browse files
committed
docs: document session tools
1 parent f84460e commit 600a57e

15 files changed

Lines changed: 76 additions & 10 deletions

src/agents/sessions/tools/bash.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Built-in bash session tool.
3+
*
4+
* Executes local shell commands with streaming output accumulation and TUI renderers.
5+
*/
16
import { spawn } from "node:child_process";
27
import { existsSync } from "node:fs";
38
import { Container, Text, truncateToWidth } from "@earendil-works/pi-tui";

src/agents/sessions/tools/edit.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Built-in edit session tool.
3+
*
4+
* Applies exact targeted replacements with queued file mutation, diff previews, and TUI renderers.
5+
*/
16
import { constants } from "node:fs";
27
import {
38
access as fsAccess,

src/agents/sessions/tools/file-mutation-queue.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Per-file mutation queue.
3+
*
4+
* Serializes edits/writes targeting the same real file while allowing independent files to mutate in parallel.
5+
*/
16
import { realpathSync } from "node:fs";
27
import { resolve } from "node:path";
38

src/agents/sessions/tools/find.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Built-in find session tool.
3+
*
4+
* Searches files by glob through fd/local operations and returns bounded, renderable results.
5+
*/
16
import { spawn } from "node:child_process";
27
import { existsSync } from "node:fs";
38
import path from "node:path";

src/agents/sessions/tools/grep.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Built-in grep session tool.
3+
*
4+
* Searches files with ripgrep/local operations, optional context, and bounded output rendering.
5+
*/
16
import { spawn } from "node:child_process";
27
import { readFileSync, statSync } from "node:fs";
38
import path from "node:path";

src/agents/sessions/tools/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Session tool public barrel.
3+
*
4+
* Re-exports built-in tool factories, operation interfaces, contracts, and shared truncation helpers.
5+
*/
16
export {
27
type BashSpawnContext,
38
type BashSpawnHook,

src/agents/sessions/tools/ls.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Built-in ls session tool.
3+
*
4+
* Lists directory entries through local or injected operations with bounded output rendering.
5+
*/
16
import { existsSync, readdirSync, statSync } from "node:fs";
27
import nodePath from "node:path";
38
import { Text } from "@earendil-works/pi-tui";

src/agents/sessions/tools/output-accumulator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
/**
2+
* Streaming output accumulator for tool execution.
3+
*
4+
* Keeps bounded display tails in memory while spilling full output to private temp files when needed.
5+
*/
16
import type { WriteStream } from "node:fs";
7+
import { createPrivateTempWriteStream } from "./private-temp-file.js";
28
import {
39
DEFAULT_MAX_BYTES,
410
DEFAULT_MAX_LINES,
511
type TruncationResult,
612
truncateTail,
713
} from "./truncate.js";
8-
import { createPrivateTempWriteStream } from "./private-temp-file.js";
914

1015
export interface OutputAccumulatorOptions {
1116
maxLines?: number;

src/agents/sessions/tools/path-utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Session tool path normalization helpers.
3+
*
4+
* Expands user/file URL inputs and resolves read/write paths against the active cwd with macOS filename variants.
5+
*/
16
import { accessSync, constants } from "node:fs";
27
import * as os from "node:os";
38
import { isAbsolute, resolve as resolvePath } from "node:path";

src/agents/sessions/tools/private-temp-file.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/**
2+
* Private temporary file helper for tool output spillover.
3+
*
4+
* Creates owner-only log files without reusing predictable names.
5+
*/
16
import { randomBytes } from "node:crypto";
27
import { createWriteStream, type WriteStream } from "node:fs";
38
import { tmpdir } from "node:os";
49
import { join } from "node:path";
510

6-
/**
7-
* Creates private temporary log files for tool output spillover.
8-
*/
911
/** Opens a unique write stream with owner-only permissions. */
1012
export function createPrivateTempWriteStream(prefix: string): {
1113
path: string;

0 commit comments

Comments
 (0)