nanoscrypt 0.2.0__tar.gz
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.
- nanoscrypt-0.2.0/.env.example +15 -0
- nanoscrypt-0.2.0/.github/workflows/ci.yml +33 -0
- nanoscrypt-0.2.0/.github/workflows/publish-pypi.yml +42 -0
- nanoscrypt-0.2.0/.gitignore +50 -0
- nanoscrypt-0.2.0/CHANGELOG.md +50 -0
- nanoscrypt-0.2.0/PKG-INFO +769 -0
- nanoscrypt-0.2.0/README.md +737 -0
- nanoscrypt-0.2.0/examples/basic_usage.py +35 -0
- nanoscrypt-0.2.0/nanoscrypt.toml.example +43 -0
- nanoscrypt-0.2.0/pyproject.toml +65 -0
- nanoscrypt-0.2.0/src/nanoscrypt/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/app.py +56 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/dependencies.py +92 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/agents.py +94 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/approval.py +66 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/audit.py +67 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/health.py +12 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/sessions.py +24 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/tasks.py +47 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/routers/tools.py +55 -0
- nanoscrypt-0.2.0/src/nanoscrypt/api/schemas.py +99 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/agents.py +118 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/init.py +43 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/run.py +572 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/serve.py +14 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/commands/tools.py +92 -0
- nanoscrypt-0.2.0/src/nanoscrypt/cli/main.py +30 -0
- nanoscrypt-0.2.0/src/nanoscrypt/config/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/config/settings.py +123 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/approval.py +152 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/audit.py +61 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/code_agent.py +406 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/command_handlers.py +219 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/command_router.py +22 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/compressor.py +91 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/context.py +229 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/events.py +80 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/generator.py +61 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/guardrails.py +206 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/harness.py +120 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/hooks.py +74 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/loop.py +76 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/memmachine_engine.py +78 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/memory.py +270 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/orchestrator.py +1019 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/pipeline.py +119 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/planner.py +38 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/postprocessor.py +442 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/registry.py +200 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/repair.py +393 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/runtime.py +429 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/validator.py +1009 -0
- nanoscrypt-0.2.0/src/nanoscrypt/core/versioning.py +157 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/base.py +22 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/litellm_provider.py +286 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/prompts/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/prompts/generator.py +158 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/prompts/planner.py +35 -0
- nanoscrypt-0.2.0/src/nanoscrypt/llm/prompts/repair.py +217 -0
- nanoscrypt-0.2.0/src/nanoscrypt/logging.py +29 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/agent.py +27 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/application.py +46 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/database.py +147 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/permissions.py +19 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/plan.py +39 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/session.py +22 -0
- nanoscrypt-0.2.0/src/nanoscrypt/models/tool.py +46 -0
- nanoscrypt-0.2.0/src/nanoscrypt/py.typed +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/utils/__init__.py +1 -0
- nanoscrypt-0.2.0/src/nanoscrypt/utils/async_runner.py +52 -0
- nanoscrypt-0.2.0/src/nanoscrypt/utils/filesystem.py +38 -0
- nanoscrypt-0.2.0/src/nanoscrypt/utils/hashing.py +8 -0
- nanoscrypt-0.2.0/tests/conftest.py +54 -0
- nanoscrypt-0.2.0/tests/e2e/test_api.py +81 -0
- nanoscrypt-0.2.0/tests/e2e/test_cli.py +47 -0
- nanoscrypt-0.2.0/tests/integration/test_full_lifecycle.py +142 -0
- nanoscrypt-0.2.0/tests/test_context.py +26 -0
- nanoscrypt-0.2.0/tests/test_guardrails.py +56 -0
- nanoscrypt-0.2.0/tests/test_harness.py +73 -0
- nanoscrypt-0.2.0/tests/test_personal_memory.py +65 -0
- nanoscrypt-0.2.0/tests/test_versioning.py +60 -0
- nanoscrypt-0.2.0/tests/unit/test_code_agent.py +100 -0
- nanoscrypt-0.2.0/tests/unit/test_command_router.py +99 -0
- nanoscrypt-0.2.0/tests/unit/test_context.py +71 -0
- nanoscrypt-0.2.0/tests/unit/test_enterprise.py +79 -0
- nanoscrypt-0.2.0/tests/unit/test_generator.py +66 -0
- nanoscrypt-0.2.0/tests/unit/test_planner.py +49 -0
- nanoscrypt-0.2.0/tests/unit/test_registry.py +81 -0
- nanoscrypt-0.2.0/tests/unit/test_repair.py +103 -0
- nanoscrypt-0.2.0/tests/unit/test_runtime.py +79 -0
- nanoscrypt-0.2.0/tests/unit/test_validator.py +182 -0
- nanoscrypt-0.2.0/tests/unit/test_versioning.py +53 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# LLM API Keys (depending on the provider you use with LiteLLM)
|
|
2
|
+
OPENAI_API_KEY=your-openai-api-key-here
|
|
3
|
+
ANTHROPIC_API_KEY=your-anthropic-api-key-here
|
|
4
|
+
GEMINI_API_KEY=your-gemini-api-key-here
|
|
5
|
+
|
|
6
|
+
# LiteLLM / LLM Provider settings
|
|
7
|
+
# LITELLM_LOGGING=INFO
|
|
8
|
+
|
|
9
|
+
# Nanoscrypt Setting Overrides (env variables override nanoscrypt.toml)
|
|
10
|
+
# NANOSCRYPT_LLM__MODEL=ollama/qwen2.5-coder
|
|
11
|
+
# NANOSCRYPT_LLM__TEMPERATURE=0.2
|
|
12
|
+
# NANOSCRYPT_LLM__MAX_TOKENS=131072
|
|
13
|
+
# NANOSCRYPT_RUNTIME__WORKSPACE_ROOT=./workspaces
|
|
14
|
+
# NANOSCRYPT_REGISTRY__DATABASE_URL=sqlite+aiosqlite:///./registry/tools.db
|
|
15
|
+
# NANOSCRYPT_REGISTRY__TOOLS_DIR=./generated_tools
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI Test Suite
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Run Unit Tests
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install .[dev,cli]
|
|
30
|
+
|
|
31
|
+
- name: Run Pytest Test Suite
|
|
32
|
+
run: |
|
|
33
|
+
pytest tests/unit/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Publish Python Package to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
name: Build distribution 📦 and publish to PyPI 🚀
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
# Required for Trusted Publishing (OIDC) on PyPI
|
|
15
|
+
id-token: write
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout source code
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.10"
|
|
26
|
+
|
|
27
|
+
- name: Install build dependencies
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
pip install build hatchling
|
|
31
|
+
|
|
32
|
+
- name: Build binary wheel and source tarball
|
|
33
|
+
run: |
|
|
34
|
+
python -m build
|
|
35
|
+
|
|
36
|
+
- name: Publish package distributions to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
38
|
+
with:
|
|
39
|
+
# Uses PyPI Trusted Publishing (OIDC) by default if configured,
|
|
40
|
+
# or API token secret if PYPI_API_TOKEN secret is set in repo
|
|
41
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
42
|
+
skip-existing: true
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Python bytecode and caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Virtual environments
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
ENV/
|
|
11
|
+
|
|
12
|
+
# Testing and coverage
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
htmlcov/
|
|
16
|
+
.coverage.*
|
|
17
|
+
|
|
18
|
+
# Tool caches
|
|
19
|
+
.mypy_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.pyre/
|
|
22
|
+
|
|
23
|
+
# Packaging/build artifacts
|
|
24
|
+
dist/
|
|
25
|
+
build/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
|
|
28
|
+
# IDE/editor files
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# OS files
|
|
35
|
+
.DS_Store
|
|
36
|
+
Thumbs.db
|
|
37
|
+
|
|
38
|
+
# Environment files
|
|
39
|
+
.env
|
|
40
|
+
.env.*
|
|
41
|
+
!.env.example
|
|
42
|
+
|
|
43
|
+
# Auto-generated directories
|
|
44
|
+
generated_tools/
|
|
45
|
+
workspaces/
|
|
46
|
+
venv_cache/
|
|
47
|
+
|
|
48
|
+
# Local config and databases
|
|
49
|
+
nanoscrypt.toml
|
|
50
|
+
registry/
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Nanoscrypt project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-07-31
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Dynamic Workspace Root Path Resolution**: Enforced pure `pathlib.Path` root workspace traversal inside `generator.py` and `repair.py` system prompts (`cwd.parts.index("workspaces")`) so synthesized tools resolve relative target paths directly to the project root directory rather than temporary execution subdirectories.
|
|
12
|
+
- **Runtime Environment Context Injection**: Injected `PROJECT_ROOT` environment variable (`env["PROJECT_ROOT"]`) inside `RuntimeManager.execute_tool` (`runtime.py`) during `subprocess.run` tool invocation.
|
|
13
|
+
- **Token Estimation Fallback**: Upgraded `LiteLLMProvider` (`litellm_provider.py`) to automatically estimate token usage (`self.count_tokens()`) when local LLM servers (e.g. Ollama `ollama/qwen2.5-coder`) omit token usage statistics in response headers.
|
|
14
|
+
- **Target Path Directory Safety Guards**: Added target path validation (`target_path.is_dir()`) and non-empty string checks in prompt standards to prevent generated file tools from calling `unlink()` on directory paths.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **AST Security Policy Violation (`import os`)**: Resolved AST validation failures (`Import of dangerous module 'os' is blocked by policy`) by removing `import os` references from system prompt code templates in `generator.py` and `repair.py`, standardizing exclusively on `from pathlib import Path`.
|
|
18
|
+
- **Parameter Variable Propagation (`NameError`)**: Resolved `NameError: name 'file_or_folder_path' is not defined` by updating system prompt instructions in `generator.py` and `repair.py` to ensure target path constructors receive the function's actual parameter variable (e.g. `Path(file_path)` or `Path(folder_path)`).
|
|
19
|
+
- **Windows Permission Exceptions (`[WinError 5] Access is denied`)**: Prevented Windows permission errors caused by unlinking directory targets when prompts omit target file parameters by enforcing `if target_path.is_dir(): return {"error": "..."}` guards in `generator.py`, `repair.py`, and default tool implementations (`create_file/v1/tool.py`).
|
|
20
|
+
- **Missing Module Import in Runtime (`runtime.py`)**: Fixed `NameError: name 'os' is not defined` inside `runtime.py` by adding `import os` to top-level runtime imports.
|
|
21
|
+
- **Session Workspace Teardown File Loss**: Fixed issue where files and directories created by tools were wiped out by `cleanup_workspace` upon session completion by ensuring tools create target outputs directly in the root workspace directory.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- **Planner Routing Guidelines (`planner.py`)**: Refined decision rules for `reuse_tool` vs `generate_tool` in `planner.py` to force `generate_tool` when the user requests generating a new tool by name, preventing invalid parameter reuse on existing registered tools (e.g. attempting to pass `file_path="test_tool_dir/"` to `create_file`).
|
|
25
|
+
- **Tool Implementations (`create_file` & `create_folder`)**: Synchronized version 1 implementations of `create_file` and `create_folder` in both disk storage (`generated_tools/`) and SQLite database (`registry/tools.db`) with pure `pathlib.Path` root workspace path resolution.
|
|
26
|
+
|
|
27
|
+
## [0.1.0] - 2026-07-18
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **Windows Console Encoding Safe-Guard**: Dynamically reconfigure standard output streams (`sys.stdout`/`sys.stderr`) to UTF-8 on system startup inside `cli/main.py` to prevent cp1252 encoding crashes when rendering modern terminal formatting characters.
|
|
31
|
+
- **Dynamic LLM-Driven Dependency Resolver**: Integrated dynamic LLM-based verification to resolve Python module imports to their respective distribution packages (e.g., mapping `fitz` -> `pymupdf` or `PIL` -> `pillow`) at runtime.
|
|
32
|
+
- **Google CAPTCHA Bypass Guidelines**: Configured standard prompt-level fallbacks in `generator.py` and `repair.py` systems to prioritize DuckDuckGo HTML search and desktop User-Agent headers when scraping, preventing automated requests from getting trapped in Google CAPTCHA redirects (`/sorry/index`).
|
|
33
|
+
- **Shared Virtual Environment Cache**: Introduced a centralized shared virtual environment (`shared_env`) inside `runtime.py`. It tracks installed dependencies in a local index file, ensuring packages (like `requests` or `pandas`) are installed once and reused instantly across all generated tools instead of downloading from scratch on every run.
|
|
34
|
+
- **Enterprise-Grade Prompt Engineering Overhaul**: Completely rewrote all three LLM system prompts (`generator.py`, `repair.py`, `planner.py`) with structured sections covering:
|
|
35
|
+
- Type safety with `isinstance()` guards and typing annotations
|
|
36
|
+
- Network resilience with exponential backoff retry loops (3 attempts, 2s/4s/8s)
|
|
37
|
+
- Isolated logging (stderr only, stdout reserved for JSON output)
|
|
38
|
+
- Resource cleanup enforcement via context managers
|
|
39
|
+
- Advanced unit test assertions (structural dict verification, success + error path coverage)
|
|
40
|
+
- CAPTCHA/bot detection avoidance with DuckDuckGo fallback patterns
|
|
41
|
+
- File format detection rules in the planner for accurate dependency hints
|
|
42
|
+
- Actionable tool purpose specification guidelines to reduce vague code generation
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- **Type-Safe Parameter Extractor Fallbacks**: Refactored the orchestrator parameter parser in `orchestrator.py` to check inputs against target tool schemas. If parameters are missing during validation passes, the engine dynamically injects type-safe dummy values to bypass false-positive Repair Loop traps.
|
|
46
|
+
- **Decoupled Package Registries**: Deleted static package mapping configurations and restructured `validator.py` and `postprocessor.py` to execute LLM queries dynamically to verify imported module package satisfying rules.
|
|
47
|
+
- **Unit Test Coverage**: Patched validator unit tests inside `tests/unit/test_validator.py` to mock LLM interactions, ensuring backward compatibility with the new dynamic resolver.
|
|
48
|
+
|
|
49
|
+
### Removed
|
|
50
|
+
- **Static Registries**: Deleted the hardcoded configuration file `src/nanoscrypt/config/package_mappings.json` and associated static mapping dictionaries from `validator.py` and `postprocessor.py`.
|