Skip to main content

AI workflow utilities for the AI Context Standard

Project description

ai-context-tools

AI workflow utilities for the AI Context Standard.

Version: tracks AI Context Standard version (currently 0.8.4)


Installation

pip install ai-context-tools

Or for development (from the workspace):

pip install -e C:/Users/takahashi/GitHub/ai-context-tools

Publishing to PyPI

Uses GitHub Actions with PyPI Trusted Publisher (OIDC — no API token needed).

One-time setup on PyPI: Configure a Trusted Publisher at
https://pypi.org/manage/account/publishing/
(or for a new package not yet on PyPI, use the "pending publisher" form)

Settings to enter:

  • PyPI project name: ai-context-tools
  • Owner: freesemt
  • Repository: ai-context-tools
  • Workflow: upload_to_pypi.yml
  • Environment: (leave blank)

To publish: Go to Actions → "Manual Upload Python Package to PyPI" → Run workflow.

The workflow builds the package, uploads to PyPI via OIDC, and creates a version tag (e.g. v0.8.2).


Tools

aic_tools.notebook — Read notebook cell outputs

Bypasses the built-in read_notebook_cell_output tool size limit by reading the .ipynb JSON directly from disk.

When to use (routing rule for AI assistants): After copilot_getNotebookSummary, check each cell's mime types. If a cell has application/vnd.code.notebook.stdout, use this tool — the built-in tool will fail silently with "output too large".

CLI:

python -m aic_tools.notebook <notebook.ipynb> <cell_number> [max_lines]

# Examples:
python -m aic_tools.notebook experiments/08d.ipynb 14
python -m aic_tools.notebook experiments/08d.ipynb 14 0   # all lines

Entry point (after install):

aic-notebook experiments/08d.ipynb 14

Python API:

from aic_tools.notebook import read_cell_output
read_cell_output("experiments/08d.ipynb", 14)
read_cell_output("experiments/08d.ipynb", 14, max_lines=0)  # all lines

aic_tools.nb_status — Read notebook execution status

Reports which cells have been executed (and in what order) by reading the execution_count field stored in the .ipynb file.

When to use (routing rule for AI assistants):

⚠️ disk vs. live kernel: execution counts are read from the saved .ipynb file. If the file was externally rewritten while open in VS Code (e.g. via json.dump), VS Code reloads from disk and loses unsaved counts. In that case, the kernel variables section of copilot_getNotebookSummary is the authoritative live source — a variable being present there proves the cell ran, regardless of what the execution count says.

Use aic-nb-status for quick offline checks or to cross-check after a suspected external file write.

CLI:

python -m aic_tools.nb_status <notebook.ipynb>
python -m aic_tools.nb_status <notebook.ipynb> --executed-only
python -m aic_tools.nb_status <notebook.ipynb> --json

Entry point (after install):

aic-nb-status experiments/13h.ipynb
aic-nb-status experiments/13h.ipynb --executed-only

Python API:

from aic_tools.nb_status import get_execution_status
rows = get_execution_status("experiments/13h.ipynb")
# Returns list of dicts: cell_number, cell_id, cell_type, execution_count, first_line

aic_tools.runcell — Execute a notebook cell with fresh outputs

Executes cells 1..N of a notebook via nbclient and prints the target cell's outputs to the terminal with no size limit. The companion to aic_tools.notebook (which reads stale outputs from disk).

When to use (routing rule for AI assistants):

  • Use aic_tools.notebook when the cell's last-saved output is enough.
  • Use aic_tools.runcell when you need fresh output — e.g. after editing code that the cell depends on, or when verifying a one-line fix without re-running the entire notebook in the GUI.

Install execution dependencies (nbclient, nbformat, ipykernel):

pip install ai-context-tools[run]

CLI:

python -m aic_tools.runcell <notebook.ipynb> <cell_number> \
    [--kernel NAME] [--timeout SEC] [--write] [--max-lines N]

# Examples:
python -m aic_tools.runcell experiments/08d.ipynb 14
python -m aic_tools.runcell experiments/08d.ipynb 14 --write    # save outputs
python -m aic_tools.runcell experiments/08d.ipynb 14 --kernel python3

Entry point (after install):

aic-runcell experiments/08d.ipynb 14

Python API:

from aic_tools.runcell import run_up_to_cell
cell = run_up_to_cell("experiments/08d.ipynb", 14)

Behaviour:

  • Executes cells 1 through cell_number in order (markdown cells are skipped by nbclient automatically) so the kernel state is correctly built up.
  • Read-only by default — the .ipynb is not modified unless --write is passed.
  • Exit code 1 on cell error, file-not-found, or invalid arguments.

Versioning

Package version tracks the AI Context Standard version that introduced each tool. 0.8.2 = notebook reader introduced in Standard v0.8.2.


Relationship to other tools

Tool Language Role
ai-context-vscode TypeScript / VS Code extension Live notebook cell output reading + VS Code version recording (supersedes vscode-version-recorder)
ai-context-tools (this package) Python AI workflow utilities (notebook output reading, etc.)

All tools support the AI Context Standard.

VS Code users: The ai-context-vscode extension reads live cell outputs from the VS Code document model — no save required. This Python package serves as the fallback for terminal-only sessions or non-VS Code editors.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_context_tools-0.8.6.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_context_tools-0.8.6-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file ai_context_tools-0.8.6.tar.gz.

File metadata

  • Download URL: ai_context_tools-0.8.6.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_context_tools-0.8.6.tar.gz
Algorithm Hash digest
SHA256 2e3bc0abba1e03c853c630cecc32e4dc178b4d148f384bdde2248394b59500a7
MD5 3872ca5118c0352caf813d0196ceb6a4
BLAKE2b-256 653f0ab7fc5328c05e2f8e6bb143f286088bdeb7b2b699551f467c2c7b66dd15

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_context_tools-0.8.6.tar.gz:

Publisher: upload_to_pypi.yml on freesemt/ai-context-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_context_tools-0.8.6-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_context_tools-0.8.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5c7814942a63f615c60b85116f13c850d079e0d8f6ecca9ce6d512f095c251da
MD5 f0116ab400a451d5d4bd8e845e2faaa1
BLAKE2b-256 c89a1f8dba5f0d6359825f566b3a1e3b55e62999999168ef1493d3f3961749c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_context_tools-0.8.6-py3-none-any.whl:

Publisher: upload_to_pypi.yml on freesemt/ai-context-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page