Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions opensin_agent_platform/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AGENTS.md

## Boundary Guidance for Agents

When modifying this repo:

- Prefer Python development-surface work.
- Keep claims scoped to this repo’s implementation and package surface.
- Do not redefine product, ops, docs, or org-wide canonical ownership from here.
- If a concern belongs to `OpenSIN`, `opensin-ai-cli`, `OpenSIN-WebApp`, or `ai-agent-system`, name that boundary clearly.
54 changes: 54 additions & 0 deletions opensin_agent_platform/BOUNDARIES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# opensin-ai-code Boundaries

## Role
`opensin-ai-code` is the Python agent development surface in the OpenSIN-AI ecosystem.

Short version:

- **This repo = Python development surface for agent building and experimentation**
- **Not this repo = sole owner of the global runtime stack, product shell, or control-plane truth**

---

## Canonical Ownership

| Concern | Canonical Repo |
|---|---|
| Python agent development surface | `opensin-ai-code` |
| Free/open runtime core | `OpenSIN` |
| Rust CLI runtime surface | `opensin-ai-cli` |
| Product web app | `OpenSIN-WebApp` |
| Internal ops control plane | `ai-agent-system` |
| Official documentation | `OpenSIN-documentation` |

---

## This repo MUST own

- Python-first developer workflows
- Python agent scaffolding and development ergonomics
- Python-side abstractions specific to this repo’s package surface
- repo-local tests and docs for the Python development surface

---

## This repo MUST NOT own

- sole canonical ownership of all runtime primitives across the org
- product app behavior
- control-plane behavior
- official docs canon
- architecture SSOT

---

## Hard rules

### 1. Development surface, not global monopoly
This repo may provide a Python implementation surface, but it must not describe itself as the only authoritative owner of runtime concerns already owned elsewhere.

### 2. Scope claims must be repo-local
Feature descriptions should be explicit about whether they are repo-local, shared, mirrored, experimental, or aligned with another canonical runtime.

### 3. Product and ops boundaries stay out
Anything primarily about user-facing product UX or fleet operations belongs elsewhere.
59 changes: 59 additions & 0 deletions opensin_agent_platform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# opensin_agent_platform

> **Origin:** absorbed from the standalone repository `OpenSIN-AI/opensin-ai-code` in April 2026 as part of the OpenSIN-AI repo consolidation.

## Why this folder exists

`opensin-ai-code` was a separate public repo that described itself as the
"Python Agent Development Platform" (`pip install opensin-ai-code`). It
contained 98 Python source files under `src/` but no `pyproject.toml` or
`setup.py` — so the advertised `pip install` path never actually worked.

At the same time, the `OpenSIN` monolith already ships the canonical
Python implementation as `opensin_core`, `opensin_cli`, `opensin_api`,
and `opensin_sdk`. Two public repos were claiming the same ground with
different code.

To stop the drift, the full source tree of `opensin-ai-code` is preserved
here, inside the canonical `OpenSIN` repo, as `opensin_agent_platform/`.
The standalone repo is archived and redirects here.

## Status

**Preserved, not yet wired into the main build.**

- The source lives under `opensin_agent_platform/src/` exactly as it did upstream.
- It is **not** imported from `opensin_core`, `opensin_cli`, or `opensin_api` today.
- No `pip install -e .` is declared yet — a follow-up PR will add a proper
`pyproject.toml` under this folder *or* migrate the pieces that still
provide value into the existing `opensin_*` packages and retire the rest.

## Overlap with `opensin_core`

Both trees define modules named `hooks`, `plugins`, `skills`, and share
conceptual components (QueryEngine, Tool system, Permission system,
Subagent system, MCP client, Sandbox, Memory).

The rationalization plan — to be executed in a follow-up PR:

1. Pick `opensin_core` as the canonical home.
2. For each concept that exists in both, diff the implementations.
3. Port any genuinely newer or better logic from
`opensin_agent_platform/src/` into the matching `opensin_core/*`
subpackage.
4. Delete the migrated pieces from this folder.
5. When the folder is empty of useful code, remove it entirely.

Until then, **treat `opensin_agent_platform/` as read-only reference material**.
Do not import from it in production paths.

## Upstream README

The original upstream README is preserved as `README.upstream.md` for
historical reference.

## Redirect mapping

| Old | New |
|---|---|
| `github.com/OpenSIN-AI/opensin-ai-code` | `github.com/OpenSIN-AI/OpenSIN/tree/main/opensin_agent_platform` |
176 changes: 176 additions & 0 deletions opensin_agent_platform/README.upstream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# OpenSIN-AI Code — Python Agent Development Platform

[![Documentation](https://img.shields.io/badge/docs-docs.opensin.ai-blue)](https://docs.opensin.ai/docs/guide/opensin-ai-code)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Python](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)

OpenSIN-AI Code ist die Python-basierte Agent Development Platform der OpenSIN-AI Organisation. Metadata-driven Architektur für schnellen Prototyping und Porting.

> **Teil des OpenSIN-AI Ökosystems:** [175 Repos | 17 Teams | 92 Worker | 7 MCP Server](https://github.com/OpenSIN-AI/OpenSIN-overview)

## 🚀 Quick Start

```bash
# Install the platform
pip install opensin-ai-code

# Create your first agent
opensin-ai agent create researcher --model gpt-4

# Test your agent
opensin-ai agent test researcher --prompt "What is AI?"

# Create a team
opensin-ai team create research-team --strategy sequential

# Execute a team task
opensin-ai team exec research-team --task "Research AI trends"
```

## 🔧 Installation

### From PyPI
```bash
pip install opensin-ai-code
```

### From Source
```bash
git clone https://github.com/OpenSIN-AI/opensin-ai-code.git
cd opensin-ai-code
pip install -e .
```

### Development Installation
```bash
git clone https://github.com/OpenSIN-AI/opensin-ai-code.git
cd opensin-ai-code
pip install -e ".[dev]"
```

## 📦 Packages

| Package | Description | Status |
|---------|-------------|--------|
| [`opensin-ai-core`](src/) | Core engine with QueryEngine, Hook System, Tool System, Permission System, Subagent System, MCP Client, Sandbox, Memory System | ✅ Stable |
| [`opensin-ai-cli`](src/main.py) | Command-line interface for managing agents and teams | ✅ Stable |
| [`opensin-ai-sdk`](src/) | Python SDK for programmatic access (integrated) | ✅ Stable |

## 🧠 Core Features

### QueryEngine
Async generator pattern with ReAct loop, token budget tracking, and automatic context compaction.

### Hook System
20+ hook events with 5 execution modes (shell, HTTP, function, agent, prompt) for powerful automation.

### Tool System
Rich tool interface with 8 built-in tools, deferred loading, and permission-aware filtering.

### Permission System
Multi-source permission rules with auto-mode classifier and bypass-immune safety checks.

### Subagent System
Fork pattern with cache-identical prefixes, worktree isolation, and background-to-foreground transitions.

### MCP Client
Multi-transport support (stdio, SSE, HTTP, WS, in-process) with OAuth authentication.

### Sandbox
Secure code execution with filesystem/network rules and git escape prevention.

### Memory System
File-based memory with index and topic files, SIN.md auto-discovery, and session memory extraction.

## 🔗 OpenSIN-AI Ökosystem

OpenSIN-AI Code ist Teil des umfassendsten AI Agent Systems der Welt:

| Komponente | Repo | Zweck |
|------------|------|-------|
| **OpenSIN Core** | [OpenSIN-AI/OpenSIN](https://github.com/OpenSIN-AI/OpenSIN) | Free Core Engine (Python, 310+ Pakete) |
| **OpenSIN Backend** | [OpenSIN-AI/OpenSIN-backend](https://github.com/OpenSIN-AI/OpenSIN-backend) | A2A Fleet Control Plane (SIN Solver) |
| **OpenSIN-Code** | [OpenSIN-AI/OpenSIN-Code](https://github.com/OpenSIN-AI/OpenSIN-Code) | Autonomes CLI + SDK |
| **opensin-ai-cli** | [OpenSIN-AI/opensin-ai-cli](https://github.com/OpenSIN-AI/opensin-ai-cli) | AI Coding Assistant in Rust |
| **opensin-ai-platform** | [OpenSIN-AI/opensin-ai-platform](https://github.com/OpenSIN-AI/opensin-ai-platform) | Plugin Ecosystem & GitHub Automation |
| **17 Teams** | [OpenSIN-overview](https://github.com/OpenSIN-AI/OpenSIN-overview) | 92 Worker Agents |
| **7 MCP Server** | [OpenSIN-overview](https://github.com/OpenSIN-AI/OpenSIN-overview) | Chrome Extension, Computer Use, Memory, Auth |

## 🧭 OpenSIN-AI Agent Roadmap

- Feature spec: [OpenSIN-overview/docs/opensin-ai-agent-feature-spec.md](https://github.com/OpenSIN-AI/OpenSIN-overview/blob/main/docs/opensin-ai-agent-feature-spec.md)
- Comparison guide: [OpenSIN-documentation/docs/guide/opensin-ai-agent-features.md](https://github.com/OpenSIN-AI/OpenSIN-documentation/blob/main/docs/guide/opensin-ai-agent-features.md)
- This repo is the Python agent development surface aligned with the OpenSIN-AI Agent roadmap.

## 📚 Documentation

Full documentation is available at [docs.opensin.ai](https://docs.opensin.ai), with comprehensive coverage of:

- [Getting Started](https://docs.opensin.ai/guide/getting-started)
- [API Reference](https://docs.opensin.ai/api/overview)
- [Tutorials](https://docs.opensin.ai/tutorials/agent-basics)
- [Integrations](https://docs.opensin.ai/integrations/telegram)
- [Architecture](https://docs.opensin.ai/architecture/overview)
- [Best Practices](https://docs.opensin.ai/best-practices/overview)
- [SIN Features](https://docs.opensin.ai/guide/sin-features)

## 🐳 Local Development

```bash
# Clone the repository
git clone https://github.com/OpenSIN-AI/opensin-ai-code.git
cd opensin-ai-code

# Setup development environment
./scripts/setup.sh

# Run tests
./scripts/test.sh

# Start development server (for API mode)
opensin-ai server start
```

## 🧪 Testing

```bash
# Run all tests
./scripts/test.sh

# Run specific test suites
python -m pytest src/core/ -v
python -m pytest src/cli/ -v
python -m pytest tests/integration/ -v
```

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📊 Project Stats

- **2,138+** lines of Python code
- **66** Python files
- **26** subsystem packages
- **1** core platform
- **Complete metadata-driven architecture**

## 🌐 Community

- **Documentation:** https://docs.opensin.ai
- **GitHub:** https://github.com/OpenSIN-AI/opensin-ai-code
- **Discord:** https://discord.gg/opensin-ai-code
- **Issues:** https://github.com/OpenSIN-AI/opensin-ai-code/issues

## 📄 License

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

---
Built with ❤️ by the OpenSIN-AI Team
19 changes: 19 additions & 0 deletions opensin_agent_platform/src/QueryEngine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

from .query_engine import QueryEnginePort
from .runtime import PortRuntime


class QueryEngineRuntime(QueryEnginePort):
def route(self, prompt: str, limit: int = 5) -> str:
matches = PortRuntime().route_prompt(prompt, limit=limit)
lines = ['# Query Engine Route', '', f'Prompt: {prompt}', '']
if not matches:
lines.append('No mirrored command/tool matches found.')
return '\n'.join(lines)
lines.append('Matches:')
lines.extend(f'- [{match.kind}] {match.name} ({match.score}) — {match.source_hint}' for match in matches)
return '\n'.join(lines)


__all__ = ['QueryEnginePort', 'QueryEngineRuntime']
15 changes: 15 additions & 0 deletions opensin_agent_platform/src/Tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

from dataclasses import dataclass


@dataclass(frozen=True)
class ToolDefinition:
name: str
purpose: str


DEFAULT_TOOLS = (
ToolDefinition('port_manifest', 'Summarize the active Python workspace'),
ToolDefinition('query_engine', 'Render a Python-first porting summary'),
)
29 changes: 29 additions & 0 deletions opensin_agent_platform/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Python porting workspace for the OpenSIN-AI Code rewrite effort."""

from .commands import PORTED_COMMANDS, build_command_backlog
from .parity_audit import ParityAuditResult, run_parity_audit
from .port_manifest import PortManifest, build_port_manifest
from .query_engine import QueryEnginePort, TurnResult
from .runtime import PortRuntime, RuntimeSession
from .session_store import StoredSession, load_session, save_session
from .system_init import build_system_init_message
from .tools import PORTED_TOOLS, build_tool_backlog

__all__ = [
'ParityAuditResult',
'PortManifest',
'PortRuntime',
'QueryEnginePort',
'RuntimeSession',
'StoredSession',
'TurnResult',
'PORTED_COMMANDS',
'PORTED_TOOLS',
'build_command_backlog',
'build_port_manifest',
'build_system_init_message',
'build_tool_backlog',
'load_session',
'run_parity_audit',
'save_session',
]
16 changes: 16 additions & 0 deletions opensin_agent_platform/src/assistant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Python package placeholder for the archived `assistant` subsystem."""

from __future__ import annotations

import json
from pathlib import Path

SNAPSHOT_PATH = Path(__file__).resolve().parent.parent / 'reference_data' / 'subsystems' / 'assistant.json'
_SNAPSHOT = json.loads(SNAPSHOT_PATH.read_text())

ARCHIVE_NAME = _SNAPSHOT['archive_name']
MODULE_COUNT = _SNAPSHOT['module_count']
SAMPLE_FILES = tuple(_SNAPSHOT['sample_files'])
PORTING_NOTE = f"Python placeholder package for '{ARCHIVE_NAME}' with {MODULE_COUNT} archived module references."

__all__ = ['ARCHIVE_NAME', 'MODULE_COUNT', 'PORTING_NOTE', 'SAMPLE_FILES']
Loading
Loading