feat: --hint flag — use kbagent as a Python SDK#153
Merged
Conversation
Add --hint client|service global flag that generates equivalent Python code instead of executing commands. Makes kbagent a programmable SDK — users install one tool and get both CLI and importable Python modules. Two modes: - --hint client: generates KeboolaClient code with explicit URL + token - --hint service: generates service layer code using CLI config Covers 47 API-backed commands across all command groups (config, storage, job, branch, workspace, sharing, component, encrypt, lineage, org, tool). Commands without hints (local-only like project list, branch use) show a clear "no hint available" message instead of silently executing. Hint mode bypasses permission checks and auto-update (no API calls made).
Escape quotes, newlines, and triple-quote sequences in parameter values before embedding them into generated Python string literals. Without this, a crafted parameter value (e.g. a malicious component ID or bucket name) could inject arbitrary Python code into the --hint output, which an AI agent might then execute. Adds _escape_for_python_string() and _sanitize_for_comment() to renderer. Includes 4 security regression tests (quote breakout, list injection, docstring injection, newline injection).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--hint client|serviceglobal flag that generates equivalent Python code instead of executing commands--hint client(KeboolaClient with explicit URL+token) and--hint service(service layer with CLI config)What it looks like
New files
src/keboola_agent_cli/hints/— models, registry, renderers, 11 definition filestests/test_hints.py— 26 testsdocs/hint-mode.md— user documentationplugins/.../references/programming-with-cli.md— SDK programming guideTest plan
make checkpasses (1543 tests, 0 failures)--hint clientgenerates valid Python (compile() check)--hint servicegenerates ConfigStore code with explicit config_dir--hintvalue shows usage help