nbinlineai.fastcore_tools

Bounded filesystem and Python documentation tools for the live kernel.

Paths refer to the kernel filesystem and its working directory. Reading a saved notebook file does not reveal unsaved cells in JupyterLab’s live document model.

path_info

source

path_info(path: str = '.') -> str

Show the kernel working directory and a path’s resolved type and size.

Parameter Type Default Description
path str '.' Path to inspect from the kernel working directory.
returns str Bounded working-directory and path report.

list_files

source

list_files(path: str = '.', pattern: str = '*', recursive: bool = False, limit: int = 30) -> str

List visible paths under a directory, optionally matching entry names.

The scan skips hidden entries, common generated folders, and symlinks. A recursive scan descends at most six levels and visits at most 2,000 entries. The result says when a limit leaves paths unlisted.

Parameter Type Default Description
path str '.' Directory to list from the kernel working directory.
pattern str '*' Glob pattern matched against each entry name.
recursive bool False Whether to descend into visible subdirectories.
limit int 30 Maximum matching paths to show, at most 100.
returns str Bounded visible-path listing, with a partial notice when needed.

view_file

source

view_file(path: str, start_line: int = 1, end_line: int = 40) -> str

Read a bounded range of one UTF-8 text file with one-based line numbers.

Parameter Type Default Description
path str required UTF-8 text file to read, at most 1 MB.
start_line int 1 First one-based line to show.
end_line int 40 Last inclusive line to show, at most 80 lines total.
returns str Bounded text excerpt with one-based line numbers.

create_file

source

create_file(path: str, contents: str) -> str

Create a new UTF-8 text file without replacing an existing path.

The tool creates parent directories when needed. The path may be anywhere the kernel can write, except a notebook file. Exclusive creation prevents the tool from replacing an existing file.

Parameter Type Default Description
path str required New text file path; existing paths and notebook files are refused.
contents str required UTF-8 text of at most 8,000 characters.
returns str Bounded new-file receipt.

file_str_replace

source

file_str_replace(path: str, old_str: str, new_str: str, expected_matches: int = 1) -> str

Replace a literal only when its occurrence count matches expectation.

The edit checks a regular UTF-8 file of at most 1 MB. It checks the file again before an atomic replacement and returns a bounded diff.

Parameter Type Default Description
path str required Existing text file path, excluding notebook files.
old_str str required Nonempty literal text to replace.
new_str str required Replacement text, at most 8,000 characters.
expected_matches int 1 Required occurrence count, at most 100.
returns str Bounded edit result and diff.

file_insert_line

source

file_insert_line(path: str, line: int, new_str: str) -> str

Insert text after a one-based line. Zero inserts before the first line.

Supplied text is inserted verbatim. Added boundary separators use the file’s line ending style. Size, change-detection and atomic replacement checks match the other file edits.

Parameter Type Default Description
path str required Existing text file path, excluding notebook files.
line int required One-based line after which to insert, or zero for the start.
new_str str required Nonempty text to insert, at most 8,000 characters.
returns str Bounded edit result and diff.

file_replace_lines

source

file_replace_lines(path: str, start_line: int, end_line: int, new_content: str) -> str

Replace an inclusive, one-based line range with UTF-8 text.

The edit keeps the file’s line ending style and uses the same size, change-detection, and atomic replacement checks as other file edits.

Parameter Type Default Description
path str required Existing text file path, excluding notebook files.
start_line int required First one-based line to replace.
end_line int required Last inclusive line to replace.
new_content str required Replacement UTF-8 text, at most 8,000 characters.
returns str Bounded edit result and diff.

show_doc

source

show_doc(name: str, module: str = '') -> str

Show docs for a live name, or import module and inspect its public name.

An explicit module import runs that module’s initialization. Use name=“” with module to show the module’s own docs. Static attribute lookup does not call the named symbol. Without a module, name resolves from the live kernel.

Parameter Type Default Description
name str required Live public name, or public name within module; empty selects the module.
module str '' Installed module to import explicitly; import runs its initialization.
returns str Bounded Markdown text with rich notebook display.