WeavePy 0.1.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.
@@ -0,0 +1,88 @@
1
+ # CI/CD Pipeline for thegent-mesh
2
+ # Applies: CI/CD, TDD, Shift-Left Testing
3
+
4
+ name: CI
5
+
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ lint:
14
+ name: Lint
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: '3.11'
23
+
24
+ - name: Install ruff
25
+ run: pip install ruff
26
+
27
+ - name: Check formatting
28
+ run: ruff format --check src/
29
+
30
+ - name: Run linter
31
+ run: ruff check src/
32
+
33
+ test:
34
+ name: Test
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+
39
+ - name: Set up Python
40
+ uses: actions/setup-python@v5
41
+ with:
42
+ python-version: '3.11'
43
+
44
+ - name: Install dependencies
45
+ run: |
46
+ pip install -e ".[dev,test]"
47
+
48
+ - name: Run tests
49
+ run: pytest src/ -v --cov=src --cov-report=xml
50
+
51
+ - name: Upload coverage
52
+ uses: codecov/codecov-action@v4
53
+ with:
54
+ files: coverage.xml
55
+
56
+ type-check:
57
+ name: Type Check
58
+ runs-on: ubuntu-latest
59
+ steps:
60
+ - uses: actions/checkout@v4
61
+
62
+ - name: Set up Python
63
+ uses: actions/setup-python@v5
64
+ with:
65
+ python-version: '3.11'
66
+
67
+ - name: Install mypy
68
+ run: pip install mypy
69
+
70
+ - name: Run type checker
71
+ run: mypy src/
72
+
73
+ security:
74
+ name: Security Audit
75
+ runs-on: ubuntu-latest
76
+ steps:
77
+ - uses: actions/checkout@v4
78
+
79
+ - name: Set up Python
80
+ uses: actions/setup-python@v5
81
+ with:
82
+ python-version: '3.11'
83
+
84
+ - name: Install bandit
85
+ run: pip install bandit
86
+
87
+ - name: Run security audit
88
+ run: bandit -r src/
@@ -0,0 +1,33 @@
1
+
2
+ # Agent Rules
3
+
4
+ **This project is managed through AgilePlus.**
5
+
6
+ ## AgilePlus Mandate
7
+
8
+ All work MUST be tracked in AgilePlus:
9
+ - Reference: /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus
10
+ - CLI: cd /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus && agileplus <command>
11
+
12
+ ## Branch Discipline
13
+
14
+ - Feature branches in repos/worktrees/<project>/<category>/<branch>
15
+ - Canonical repository tracks main only
16
+ - Return to main for merge/integration checkpoints
17
+
18
+ ## Work Requirements
19
+
20
+ 1. Check for AgilePlus spec before implementing
21
+ 2. Update work package status as work progresses
22
+ 3. No code without corresponding AgilePlus spec
23
+
24
+ ## UTF-8 Encoding
25
+
26
+ All markdown files must use UTF-8. Avoid smart quotes, em-dashes, and special characters.
27
+
28
+ ```bash
29
+ # Validate encoding (in AgilePlus repo)
30
+ cd /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus
31
+ agileplus validate-encoding --all --fix
32
+ ```
33
+
@@ -0,0 +1,39 @@
1
+
2
+ # Project Instructions
3
+
4
+ **This project is managed through AgilePlus.**
5
+
6
+ ## AgilePlus Mandate
7
+
8
+ All work MUST be tracked in AgilePlus:
9
+ - Reference: /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus
10
+ - CLI: cd /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus && agileplus <command>
11
+
12
+ ## Work Requirements
13
+
14
+ 1. Check for AgilePlus spec before implementing
15
+ 2. Create spec for new work: agileplus specify --title "<feature>" --description "<desc>"
16
+ 3. Update work package status: agileplus status <feature-id> --wp <wp-id> --state <state>
17
+ 4. No code without corresponding AgilePlus spec
18
+
19
+ ## Branch Discipline
20
+
21
+ - Feature branches in repos/worktrees/<project>/<category>/<branch>
22
+ - Canonical repository tracks main only
23
+ - Return to main for merge/integration checkpoints
24
+
25
+ ## UTF-8 Encoding
26
+
27
+ All markdown files must use UTF-8. Validate with:
28
+ ```bash
29
+ cd /Users/kooshapari/CodeProjects/Phenotype/repos/AgilePlus
30
+ agileplus validate-encoding --all --fix
31
+ ```
32
+
33
+ ## AgilePlus Reference
34
+
35
+ - Specs: AgilePlus/kitty-specs/<feature-id>/
36
+ - Docs: AgilePlus/docs/
37
+ - Workflows: AgilePlus/docs/workflow/
38
+ - Worklog: AgilePlus/.work-audit/worklog.md
39
+
weavepy-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: WeavePy
3
+ Version: 0.1.0
4
+ Summary: Coordination mesh for multi-agent orchestration
5
+ Author-email: Koosha Pari <koosha@example.com>
6
+ License-Expression: MIT
7
+ Keywords: coordination,mesh,multi-agent,orchestration
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Provides-Extra: dev
17
+ Requires-Dist: mypy>=1.0; extra == 'dev'
18
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
19
+ Requires-Dist: pytest>=7.0; extra == 'dev'
20
+ Requires-Dist: ruff>=0.1; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # thegent-mesh
24
+
25
+ Coordination mesh for multi-agent orchestration.
26
+
27
+ ## Features
28
+
29
+ - **Task Queue**: Maildir-style atomic queue for task distribution
30
+ - **Smart Merge**: AST-aware merging (Mergiraf-style) for conflict resolution
31
+ - **Request Coalescing**: Singleflight pattern for deduplicating requests
32
+ - **Coordination**: HLC timestamps, OCC, lease-based file ownership
33
+ - **Git Parallelism**: Parallel git operations with coordination
34
+ - **Process Detection**: Detect and coordinate running processes
35
+
36
+ ## Architecture
37
+
38
+ Based on thegent's mesh/ module for multi-agent coordination.
39
+
40
+ ## CLI Commands
41
+
42
+ ```bash
43
+ # Task queue operations
44
+ thegent-mesh queue push <task>
45
+ thegent-mesh queue pop
46
+ thegent-mesh queue list
47
+
48
+ # Merge operations
49
+ thegent-mesh merge <file1> <file2>
50
+
51
+ # Coordination
52
+ thegent-mesh coord status
53
+ thegent-mesh coord acquire <resource>
54
+ ```
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,36 @@
1
+ # thegent-mesh
2
+
3
+ Coordination mesh for multi-agent orchestration.
4
+
5
+ ## Features
6
+
7
+ - **Task Queue**: Maildir-style atomic queue for task distribution
8
+ - **Smart Merge**: AST-aware merging (Mergiraf-style) for conflict resolution
9
+ - **Request Coalescing**: Singleflight pattern for deduplicating requests
10
+ - **Coordination**: HLC timestamps, OCC, lease-based file ownership
11
+ - **Git Parallelism**: Parallel git operations with coordination
12
+ - **Process Detection**: Detect and coordinate running processes
13
+
14
+ ## Architecture
15
+
16
+ Based on thegent's mesh/ module for multi-agent coordination.
17
+
18
+ ## CLI Commands
19
+
20
+ ```bash
21
+ # Task queue operations
22
+ thegent-mesh queue push <task>
23
+ thegent-mesh queue pop
24
+ thegent-mesh queue list
25
+
26
+ # Merge operations
27
+ thegent-mesh merge <file1> <file2>
28
+
29
+ # Coordination
30
+ thegent-mesh coord status
31
+ thegent-mesh coord acquire <resource>
32
+ ```
33
+
34
+ ## License
35
+
36
+ MIT
@@ -0,0 +1,16 @@
1
+ # Plan: TheGent Mesh
2
+
3
+ ## Timeline: 2024-2026 (Completed)
4
+
5
+ ## Phase 1: Integration (2024)
6
+ - Mesh connection
7
+ - Basic routing
8
+
9
+ ## Phase 2: Management (2025)
10
+ - Traffic policies
11
+ - Discovery
12
+
13
+ ## Verification
14
+
15
+ - [x] Integration works
16
+ - [ ] Enhanced routing
@@ -0,0 +1,26 @@
1
+ # Spec: TheGent Mesh
2
+
3
+ ## Meta
4
+
5
+ - **ID**: 001
6
+ - **Title**: TheGent Mesh
7
+ - **Created**: 2026-03-25
8
+ - **State**: shipped
9
+
10
+ ## Overview
11
+
12
+ Service mesh integration for TheGent agent communication.
13
+
14
+ ## Past Work (Completed)
15
+ - Mesh integration
16
+ - Traffic management
17
+ - Service discovery
18
+
19
+ ## Future Work
20
+ - Enhanced routing
21
+ - Security policies
22
+
23
+ ## Verification
24
+
25
+ - Mesh integration works
26
+ - Services communicate
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "WeavePy"
7
+ version = "0.1.0"
8
+ description = "Coordination mesh for multi-agent orchestration"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Koosha Pari", email = "koosha@example.com" }
14
+ ]
15
+ keywords = ["multi-agent", "coordination", "mesh", "orchestration"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ ]
25
+ dependencies = []
26
+
27
+ [project.optional-dependencies]
28
+ dev = [
29
+ "pytest>=7.0",
30
+ "pytest-asyncio>=0.21",
31
+ "ruff>=0.1",
32
+ "mypy>=1.0",
33
+ ]
34
+
35
+ [project.scripts]
36
+ thegent-mesh = "thegent_mesh.cli:main"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["src/thegent_mesh"]
40
+
41
+ [tool.ruff]
42
+ line-length = 100
43
+ target-version = "py310"
44
+
45
+ [tool.ruff.lint]
46
+ select = ["E", "F", "W", "I", "N", "UP", "B", "C4"]
47
+ ignore = ["E501"]
48
+
49
+ [tool.mypy]
50
+ python_version = "3.10"
51
+ warn_return_any = true
52
+ warn_unused_configs = true
53
+ disallow_untyped_defs = true
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # lib/mesh/agent-run.sh — Start Agent in Managed Mesh Session
4
+ # =============================================================================
5
+
6
+ # Source library dependencies
7
+ LIB_DIR=$(dirname "${BASH_SOURCE[0]}")
8
+ source "$LIB_DIR/session.sh"
9
+ source "$LIB_DIR/inject.sh"
10
+ source "$LIB_DIR/scanner.sh"
11
+
12
+ MESH_AGENT_TYPE="${1:-claude-code}"
13
+ MESH_AGENT_PROMPT="${2:-}"
14
+ MESH_AGENT_WORKDIR="${3:-$(pwd)}"
15
+
16
+ # 1. Create session
17
+ # Use a short UUID for session identification
18
+ SESSION_ID=$(uuidgen | tr '[:upper:]' '[:lower:]' | cut -d- -f1)
19
+ SESSION_NAME=$(mesh_session::get_name "$SESSION_ID")
20
+
21
+ echo "Starting agent $MESH_AGENT_TYPE in session $SESSION_NAME..."
22
+
23
+ # Create new tmux session in specified working directory
24
+ tmux new-session -d -s "$SESSION_NAME" -c "$MESH_AGENT_WORKDIR"
25
+
26
+ # 2. Wait for shell ready
27
+ if ! mesh_inject::wait_for_agent "$SESSION_NAME" "shell" 30; then
28
+ echo "Timeout waiting for shell in $SESSION_NAME"
29
+ exit 1
30
+ fi
31
+
32
+ # 3. Start agent
33
+ # Command mapping for common agents
34
+ declare -gA MESH_AGENT_COMMANDS=(
35
+ ["claude-code"]="claude"
36
+ ["aider"]="aider"
37
+ ["cursor"]="cursor"
38
+ )
39
+ CMD="${MESH_AGENT_COMMANDS[$MESH_AGENT_TYPE]:-$MESH_AGENT_TYPE}"
40
+
41
+ # Inject start command
42
+ mesh_inject::command "$SESSION_NAME" "$CMD"
43
+
44
+ # 4. Wait for agent ready
45
+ if ! mesh_inject::wait_for_agent "$SESSION_NAME" "$MESH_AGENT_TYPE" 60; then
46
+ echo "Timeout waiting for agent $MESH_AGENT_TYPE in $SESSION_NAME"
47
+ # Don't exit, maybe it started but prompt didn't match
48
+ fi
49
+
50
+ # 5. Send initial prompt
51
+ if [[ -n "$MESH_AGENT_PROMPT" ]]; then
52
+ mesh_inject::command "$SESSION_NAME" "$MESH_AGENT_PROMPT"
53
+ fi
54
+
55
+ echo "Agent $MESH_AGENT_TYPE started successfully in session $SESSION_NAME"
56
+ echo "To attach: tmux attach -t $SESSION_NAME"
57
+ echo "$SESSION_NAME"
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # lib/mesh/inject.sh — Reliable tmux Command Injection
4
+ # =============================================================================
5
+
6
+ MESH_INJECT_DELAY="${MESH_INJECT_DELAY:-1.5}"
7
+
8
+ mesh_inject::command() {
9
+ local target="$1" # session:window.pane or session
10
+ local command="$2"
11
+ local delay="${3:-$MESH_INJECT_DELAY}"
12
+
13
+ # Send keys literally (-l) to avoid tmux interpretation of special chars
14
+ tmux send-keys -t "$target" -l "$command"
15
+
16
+ # Critical delay - prevents command loss in rapid fire or slow agents
17
+ sleep "$delay"
18
+
19
+ # Send Enter to execute
20
+ tmux send-keys -t "$target" Enter
21
+ }
22
+
23
+ mesh_inject::wait_for_ready() {
24
+ local target="$1"
25
+ local pattern="$2"
26
+ local timeout="${3:-120}"
27
+ local interval="${4:-1}"
28
+ local elapsed=0
29
+
30
+ while [ "$elapsed" -lt "$timeout" ]; do
31
+ local output
32
+ output=$(tmux capture-pane -p -t "$target" -S -10 2>/dev/null)
33
+ if echo "$output" | grep -qE "$pattern"; then
34
+ return 0
35
+ fi
36
+ sleep "$interval"
37
+ elapsed=$((elapsed + interval))
38
+ done
39
+ return 1 # Timeout
40
+ }
41
+
42
+ # Common agent readiness patterns
43
+ declare -gA MESH_READY_PATTERNS=(
44
+ ["aider"]="^aider>|^───"
45
+ ["claude-code"]="^>|claude>"
46
+ ["shell"]="\\$|%|#|➜|❯|>"
47
+ )
48
+
49
+ mesh_inject::get_ready_pattern() {
50
+ local agent_type="$1"
51
+ echo "${MESH_READY_PATTERNS[$agent_type]:-\$|%|#|➜|❯|>}"
52
+ }
53
+
54
+ mesh_inject::wait_for_agent() {
55
+ local target="$1"
56
+ local agent_type="$2"
57
+ local timeout="${3:-120}"
58
+
59
+ local pattern
60
+ pattern=$(mesh_inject::get_ready_pattern "$agent_type")
61
+
62
+ mesh_inject::wait_for_ready "$target" "$pattern" "$timeout"
63
+ }