@ctxthuta/cxops 0.0.0-stage → 1.0.1
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.
- package/.agents/agents/academic_researcher/agent.md +97 -0
- package/.agents/agents/ai_ml_engineer/agent.md +43 -0
- package/.agents/agents/backend_engineer/agent.md +44 -0
- package/.agents/agents/code_reviewer/agent.md +38 -0
- package/.agents/agents/cxagents/agent.md +47 -0
- package/.agents/agents/devops_engineer/agent.md +41 -0
- package/.agents/agents/frontend_engineer/agent.md +43 -0
- package/.agents/agents/qa_engineer/agent.md +42 -0
- package/.agents/agents/rnd_researcher/agent.md +44 -0
- package/.agents/agents/software_engineer/agent.md +37 -0
- package/.agents/agents/system_architect/agent.md +56 -0
- package/.agents/agents/uiux_designer/agent.md +52 -0
- package/AGENTS.md +226 -0
- package/IMPLEMENTATION_GUIDE.md +241 -0
- package/README.md +147 -2
- package/bin/cxops.js +430 -0
- package/package.json +52 -4
- package/plugin/agents/academic_researcher.md +97 -0
- package/plugin/agents/ai_ml_engineer.md +43 -0
- package/plugin/agents/backend_engineer.md +44 -0
- package/plugin/agents/code_reviewer.md +38 -0
- package/plugin/agents/cxagents.md +47 -0
- package/plugin/agents/devops_engineer.md +41 -0
- package/plugin/agents/frontend_engineer.md +43 -0
- package/plugin/agents/qa_engineer.md +42 -0
- package/plugin/agents/rnd_researcher.md +44 -0
- package/plugin/agents/software_engineer.md +37 -0
- package/plugin/agents/system_architect.md +56 -0
- package/plugin/agents/uiux_designer.md +52 -0
- package/plugin/plugin.json +23 -0
- package/plugin/rules/AGENTS.md +226 -0
- package/plugin/skills/academic-researcher/SKILL.md +29 -0
- package/plugin/skills/ai-ml-engineer/SKILL.md +28 -0
- package/plugin/skills/backend-engineer/SKILL.md +35 -0
- package/plugin/skills/code-reviewer/SKILL.md +26 -0
- package/plugin/skills/cxagents/SKILL.md +35 -0
- package/plugin/skills/devops-engineer/SKILL.md +27 -0
- package/plugin/skills/frontend-engineer/SKILL.md +41 -0
- package/plugin/skills/qa-engineer/SKILL.md +25 -0
- package/plugin/skills/rnd-researcher/SKILL.md +31 -0
- package/plugin/skills/software-engineer/SKILL.md +28 -0
- package/plugin/skills/system-architect/SKILL.md +43 -0
- package/plugin/skills/uiux-designer/SKILL.md +41 -0
- package/requirements.txt +5 -0
- package/src/agents/personas.py +618 -0
- package/src/dashboard.py +376 -0
- package/src/main.py +49 -0
- package/src/team.py +125 -0
- package/src/tools/arxiv_search.py +90 -0
- package/src/tools/code_tools.py +92 -0
- package/src/tools/cortex_tools.py +175 -0
- package/src/tools/test_runner.py +45 -0
- package/src/tools/web_research.py +106 -0
- package/verify_agents.py +61 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Workspace Code & File Management Tools."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
def view_file(path: str, start_line: int = 1, end_line: int = None) -> str:
|
|
7
|
+
"""Reads the contents of a file in the workspace with line numbers.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
path: Path to the file.
|
|
11
|
+
start_line: First line to read (1-indexed).
|
|
12
|
+
end_line: Last line to read (inclusive). If None, reads to end.
|
|
13
|
+
"""
|
|
14
|
+
if not os.path.exists(path):
|
|
15
|
+
return f"ERROR: File not found at '{path}'."
|
|
16
|
+
try:
|
|
17
|
+
with open(path, "r", encoding="utf-8", errors="ignore") as f:
|
|
18
|
+
lines = f.readlines()
|
|
19
|
+
|
|
20
|
+
end = end_line if end_line and end_line <= len(lines) else len(lines)
|
|
21
|
+
start = max(1, start_line)
|
|
22
|
+
|
|
23
|
+
output = [f"=== File: {path} (Lines {start}-{end} of {len(lines)}) ==="]
|
|
24
|
+
for idx in range(start - 1, end):
|
|
25
|
+
output.append(f"{idx + 1:4d} | {lines[idx].rstrip()}")
|
|
26
|
+
return "\n".join(output)
|
|
27
|
+
except Exception as e:
|
|
28
|
+
return f"ERROR reading file '{path}': {str(e)}"
|
|
29
|
+
|
|
30
|
+
def create_file(path: str, content: str) -> str:
|
|
31
|
+
"""Creates a new file with the specified content. Automatically creates parent directories.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
path: Path where the file should be written.
|
|
35
|
+
content: The text content of the file.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
p = Path(path)
|
|
39
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
40
|
+
with open(p, "w", encoding="utf-8") as f:
|
|
41
|
+
f.write(content)
|
|
42
|
+
return f"Successfully created file: {path} ({len(content)} bytes)"
|
|
43
|
+
except Exception as e:
|
|
44
|
+
return f"ERROR creating file '{path}': {str(e)}"
|
|
45
|
+
|
|
46
|
+
def edit_file(path: str, target: str, replacement: str) -> str:
|
|
47
|
+
"""Replaces exact target text with replacement text in an existing file.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
path: Path to the file.
|
|
51
|
+
target: The exact string to replace.
|
|
52
|
+
replacement: The replacement content.
|
|
53
|
+
"""
|
|
54
|
+
if not os.path.exists(path):
|
|
55
|
+
return f"ERROR: File '{path}' does not exist."
|
|
56
|
+
try:
|
|
57
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
58
|
+
data = f.read()
|
|
59
|
+
|
|
60
|
+
if target not in data:
|
|
61
|
+
return f"ERROR: Target string not found in '{path}'. Please ensure exact whitespace matching."
|
|
62
|
+
|
|
63
|
+
count = data.count(target)
|
|
64
|
+
new_data = data.replace(target, replacement)
|
|
65
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
66
|
+
f.write(new_data)
|
|
67
|
+
return f"Successfully replaced {count} occurrence(s) of target in '{path}'."
|
|
68
|
+
except Exception as e:
|
|
69
|
+
return f"ERROR editing file '{path}': {str(e)}"
|
|
70
|
+
|
|
71
|
+
def list_directory(path: str = ".") -> str:
|
|
72
|
+
"""Lists files and directories at the given path.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
path: Directory path to list (default: current directory).
|
|
76
|
+
"""
|
|
77
|
+
if not os.path.exists(path):
|
|
78
|
+
return f"ERROR: Directory '{path}' does not exist."
|
|
79
|
+
try:
|
|
80
|
+
entries = os.listdir(path)
|
|
81
|
+
dirs = []
|
|
82
|
+
files = []
|
|
83
|
+
for e in sorted(entries):
|
|
84
|
+
full = os.path.join(path, e)
|
|
85
|
+
if os.path.isdir(full):
|
|
86
|
+
dirs.append(f" [DIR] {e}/")
|
|
87
|
+
else:
|
|
88
|
+
size = os.path.getsize(full)
|
|
89
|
+
files.append(f" [FILE] {e} ({size} bytes)")
|
|
90
|
+
return f"=== Directory Listing: {path} ===\n" + "\n".join(dirs + files)
|
|
91
|
+
except Exception as e:
|
|
92
|
+
return f"ERROR listing directory '{path}': {str(e)}"
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""ThutaCortex integration tools for Thea Senior Engineering Team.
|
|
2
|
+
|
|
3
|
+
Enables agents to search existing institutional knowledge, read product architectures,
|
|
4
|
+
and ingest atomic concepts, research reports, and literature references into Thuta Tun's
|
|
5
|
+
second brain (/home/lenovo/Documents/ThutaCortex).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
VAULT_DIR = Path("/home/lenovo/Documents/ThutaCortex")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _has_emoji(s: str) -> bool:
|
|
16
|
+
"""Checks if a string contains emojis or prohibited symbols."""
|
|
17
|
+
for ch in s:
|
|
18
|
+
cp = ord(ch)
|
|
19
|
+
if (
|
|
20
|
+
0x1F600 <= cp <= 0x1F64F
|
|
21
|
+
or 0x1F300 <= cp <= 0x1F5FF
|
|
22
|
+
or 0x1F680 <= cp <= 0x1F6FF
|
|
23
|
+
or 0x1F700 <= cp <= 0x1F77F
|
|
24
|
+
or 0x1F780 <= cp <= 0x1F7FF
|
|
25
|
+
or 0x1F800 <= cp <= 0x1F8FF
|
|
26
|
+
or 0x1F900 <= cp <= 0x1F9FF
|
|
27
|
+
or 0x1FA00 <= cp <= 0x1FA6F
|
|
28
|
+
or 0x1FA70 <= cp <= 0x1FAFF
|
|
29
|
+
or 0x2600 <= cp <= 0x26FF
|
|
30
|
+
or 0x2700 <= cp <= 0x27BF
|
|
31
|
+
):
|
|
32
|
+
return True
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def search_cortex(query: str, subfolder: str = "") -> str:
|
|
37
|
+
"""Searches markdown notes in ThutaCortex second brain.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
query: Keywords or phrases to search for.
|
|
41
|
+
subfolder: Optional subfolder within the vault (e.g. 'Projects', 'Resources/Concepts', 'Areas').
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Formatted summary of matching notes with relative paths and excerpts.
|
|
45
|
+
"""
|
|
46
|
+
if not VAULT_DIR.exists():
|
|
47
|
+
return f"Error: ThutaCortex vault not found at {VAULT_DIR}."
|
|
48
|
+
|
|
49
|
+
vault_resolved = VAULT_DIR.resolve()
|
|
50
|
+
target_dir = (VAULT_DIR / subfolder).resolve() if subfolder else vault_resolved
|
|
51
|
+
if not str(target_dir).startswith(str(vault_resolved)):
|
|
52
|
+
return f"Error: Access denied. Path '{subfolder}' resolves outside the ThutaCortex vault boundary."
|
|
53
|
+
|
|
54
|
+
if not target_dir.exists():
|
|
55
|
+
return f"Error: Target directory {target_dir} does not exist."
|
|
56
|
+
|
|
57
|
+
matches = []
|
|
58
|
+
pattern = re.compile(re.escape(query), re.IGNORECASE)
|
|
59
|
+
|
|
60
|
+
for root, dirs, files in os.walk(target_dir):
|
|
61
|
+
if ".obsidian" in root or ".git" in root:
|
|
62
|
+
continue
|
|
63
|
+
for f in files:
|
|
64
|
+
if f.endswith(".md"):
|
|
65
|
+
file_path = Path(root) / f
|
|
66
|
+
try:
|
|
67
|
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as fp:
|
|
68
|
+
content = fp.read()
|
|
69
|
+
if pattern.search(content) or pattern.search(f):
|
|
70
|
+
rel_path = file_path.relative_to(VAULT_DIR)
|
|
71
|
+
# Extract first matching line excerpt
|
|
72
|
+
excerpt = ""
|
|
73
|
+
for line in content.splitlines():
|
|
74
|
+
if pattern.search(line) and not line.startswith("---") and not line.startswith("tags:"):
|
|
75
|
+
excerpt = line.strip()[:140]
|
|
76
|
+
break
|
|
77
|
+
matches.append(f"- [[{rel_path.stem}]] ({rel_path})\n Excerpt: {excerpt or 'Matched in note title'}")
|
|
78
|
+
except Exception as e:
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
if not matches:
|
|
82
|
+
return f"No notes found matching query: '{query}' in ThutaCortex."
|
|
83
|
+
|
|
84
|
+
result = f"ThutaCortex Search Results for '{query}' ({len(matches)} notes found):\n\n"
|
|
85
|
+
result += "\n".join(matches[:25])
|
|
86
|
+
return result
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def read_cortex_note(relative_path: str) -> str:
|
|
90
|
+
"""Reads a note from the ThutaCortex second brain.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
relative_path: Relative path to note inside vault (e.g. 'Projects/Specimen-X.md', 'Areas/Thea-Solutions/Overview.md').
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Full content of the note.
|
|
97
|
+
"""
|
|
98
|
+
if not VAULT_DIR.exists():
|
|
99
|
+
return f"Error: ThutaCortex vault not found at {VAULT_DIR}."
|
|
100
|
+
|
|
101
|
+
vault_resolved = VAULT_DIR.resolve()
|
|
102
|
+
note_path = (VAULT_DIR / relative_path).resolve()
|
|
103
|
+
if not note_path.suffix:
|
|
104
|
+
note_path = note_path.with_suffix(".md")
|
|
105
|
+
|
|
106
|
+
if not str(note_path).startswith(str(vault_resolved)):
|
|
107
|
+
return f"Error: Access denied. Path '{relative_path}' resolves outside the ThutaCortex vault boundary."
|
|
108
|
+
|
|
109
|
+
if not note_path.exists():
|
|
110
|
+
return f"Error: Note not found at {note_path}."
|
|
111
|
+
|
|
112
|
+
try:
|
|
113
|
+
with open(note_path, "r", encoding="utf-8") as f:
|
|
114
|
+
return f.read()
|
|
115
|
+
except Exception as e:
|
|
116
|
+
return f"Error reading note {relative_path}: {str(e)}"
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def ingest_concept_to_cortex(
|
|
120
|
+
title: str,
|
|
121
|
+
content: str,
|
|
122
|
+
domain_tag: str,
|
|
123
|
+
up_link: str = "Distributed-Systems-MOC",
|
|
124
|
+
related: list[str] = None,
|
|
125
|
+
) -> str:
|
|
126
|
+
"""Ingests an atomic Zettelkasten concept note into ThutaCortex (Resources/Concepts/).
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
title: Note title (e.g., 'Anti-Poisoning-Streaming-POT' or 'Deterministic-State-Verification').
|
|
130
|
+
content: The technical body (markdown, single mechanism, equations/diagrams, trade-offs).
|
|
131
|
+
domain_tag: Hierarchical tag (e.g., 'architecture/patterns', 'ai/eval', 'database/concurrency').
|
|
132
|
+
up_link: Parent Map of Content (MOC) note name.
|
|
133
|
+
related: List of related wikilink note names (e.g., ['Thea-Engineering-Team', 'Specimen-X']).
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
Confirmation message with file path.
|
|
137
|
+
"""
|
|
138
|
+
if not VAULT_DIR.exists():
|
|
139
|
+
return f"Error: ThutaCortex vault not found at {VAULT_DIR}."
|
|
140
|
+
|
|
141
|
+
# Validate zero-emoji rule
|
|
142
|
+
if _has_emoji(title) or _has_emoji(content):
|
|
143
|
+
return "Error: Content violates the strict ThutaCortex zero-emoji invariant."
|
|
144
|
+
|
|
145
|
+
clean_title = re.sub(r"[^\w\s-]", "", title).strip().replace(" ", "-")
|
|
146
|
+
file_path = VAULT_DIR / "Resources" / "Concepts" / f"{clean_title}.md"
|
|
147
|
+
file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
148
|
+
|
|
149
|
+
rel_tags = [f" - {domain_tag}"] if domain_tag else [" - concept"]
|
|
150
|
+
rel_links = [f' - "[[{r}]]"' for r in (related or [])]
|
|
151
|
+
|
|
152
|
+
from datetime import date
|
|
153
|
+
created_date = date.today().isoformat()
|
|
154
|
+
|
|
155
|
+
frontmatter = f"""---
|
|
156
|
+
title: "{title}"
|
|
157
|
+
type: concept
|
|
158
|
+
created: {created_date}
|
|
159
|
+
tags:
|
|
160
|
+
- concept
|
|
161
|
+
{chr(10).join(rel_tags)}
|
|
162
|
+
up: "[[{up_link}]]"
|
|
163
|
+
related:
|
|
164
|
+
{chr(10).join(rel_links) if rel_links else ' - "[[Projects-MOC]]"'}
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
# {title}
|
|
168
|
+
|
|
169
|
+
{content.strip()}
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
173
|
+
f.write(frontmatter)
|
|
174
|
+
|
|
175
|
+
return f"Successfully ingested atomic concept note: Resources/Concepts/{clean_title}.md"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Deterministic Test Runner & Compiler Verification Tool."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
def run_command(command: str, cwd: str = None, timeout: int = 60) -> str:
|
|
7
|
+
"""Executes a shell command (compilers, linters, test suites, git commands) in a specified workspace.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
command: The shell command to execute (e.g. 'go test -v ./...', 'npm test', 'tsc --noEmit').
|
|
11
|
+
cwd: Directory path to execute within. If omitted, uses current workspace.
|
|
12
|
+
timeout: Execution timeout in seconds (default: 60).
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
Structured output containing Exit Code, Stdout, and Stderr.
|
|
16
|
+
"""
|
|
17
|
+
workdir = cwd or os.getcwd()
|
|
18
|
+
try:
|
|
19
|
+
proc = subprocess.run(
|
|
20
|
+
command,
|
|
21
|
+
shell=True,
|
|
22
|
+
cwd=workdir,
|
|
23
|
+
capture_output=True,
|
|
24
|
+
text=True,
|
|
25
|
+
timeout=timeout
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
status = "SUCCESS" if proc.returncode == 0 else f"FAILED (Exit Code {proc.returncode})"
|
|
29
|
+
output = [
|
|
30
|
+
f"=== COMMAND RESULT: {status} ===",
|
|
31
|
+
f"Command: {command}",
|
|
32
|
+
f"Directory: {workdir}",
|
|
33
|
+
f"Exit Code: {proc.returncode}\n"
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
if proc.stdout:
|
|
37
|
+
output.append(f"--- STDOUT ---\n{proc.stdout}")
|
|
38
|
+
if proc.stderr:
|
|
39
|
+
output.append(f"--- STDERR ---\n{proc.stderr}")
|
|
40
|
+
|
|
41
|
+
return "\n".join(output)
|
|
42
|
+
except subprocess.TimeoutExpired:
|
|
43
|
+
return f"ERROR: Command '{command}' timed out after {timeout} seconds."
|
|
44
|
+
except Exception as e:
|
|
45
|
+
return f"ERROR: Failed to execute command '{command}': {str(e)}"
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Technical Web & Blog Research Tools."""
|
|
2
|
+
|
|
3
|
+
import urllib.request
|
|
4
|
+
import urllib.parse
|
|
5
|
+
import ipaddress
|
|
6
|
+
from bs4 import BeautifulSoup
|
|
7
|
+
import re
|
|
8
|
+
|
|
9
|
+
def search_web(query: str, max_results: int = 5) -> str:
|
|
10
|
+
"""Searches the web for technical documentation, engineering blogs, and GitHub repositories.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
query: Technical search query (e.g. 'go goroutine worker pool graceful shutdown pattern').
|
|
14
|
+
max_results: Max search results to retrieve (default: 5).
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
Summary of relevant links, titles, and snippets.
|
|
18
|
+
"""
|
|
19
|
+
clean_query = query.strip()
|
|
20
|
+
encoded = urllib.parse.quote(clean_query)
|
|
21
|
+
# Use DuckDuckGo HTML search for direct, dependency-free technical search
|
|
22
|
+
url = f"https://html.duckduckgo.com/html/?q={encoded}"
|
|
23
|
+
|
|
24
|
+
req = urllib.request.Request(
|
|
25
|
+
url,
|
|
26
|
+
headers={
|
|
27
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
33
|
+
html = resp.read().decode("utf-8", errors="ignore")
|
|
34
|
+
|
|
35
|
+
soup = BeautifulSoup(html, "html.parser")
|
|
36
|
+
results = []
|
|
37
|
+
for result in soup.find_all("div", class_="result__body")[:max_results]:
|
|
38
|
+
title_tag = result.find("a", class_="result__url")
|
|
39
|
+
snippet_tag = result.find("a", class_="result__snippet")
|
|
40
|
+
|
|
41
|
+
if title_tag:
|
|
42
|
+
raw_url = title_tag.get("href", "")
|
|
43
|
+
# Clean URL redirect if present
|
|
44
|
+
if "uddg=" in raw_url:
|
|
45
|
+
parsed_url = urllib.parse.unquote(raw_url.split("uddg=")[1].split("&")[0])
|
|
46
|
+
else:
|
|
47
|
+
parsed_url = raw_url
|
|
48
|
+
title = title_tag.get_text(strip=True)
|
|
49
|
+
snippet = snippet_tag.get_text(strip=True) if snippet_tag else ""
|
|
50
|
+
results.append(f"Title: {title}\nURL: {parsed_url}\nSnippet: {snippet}\n")
|
|
51
|
+
|
|
52
|
+
if not results:
|
|
53
|
+
return f"No web results found for '{clean_query}'."
|
|
54
|
+
|
|
55
|
+
return "\n".join(results)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
return f"Error executing web search: {str(e)}"
|
|
58
|
+
|
|
59
|
+
def read_web_page(url: str, max_chars: int = 8000) -> str:
|
|
60
|
+
"""Fetches a web page or technical documentation and converts it into clean readable text.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
url: The web URL to inspect.
|
|
64
|
+
max_chars: Character limit to avoid context blowout (default: 8000).
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Cleaned plain text of the article/documentation.
|
|
68
|
+
"""
|
|
69
|
+
parsed = urllib.parse.urlparse(url.strip())
|
|
70
|
+
if parsed.scheme not in ("http", "https"):
|
|
71
|
+
return f"ERROR: Blocked unsupported scheme '{parsed.scheme}'. Only HTTP and HTTPS are permitted."
|
|
72
|
+
|
|
73
|
+
hostname = parsed.hostname or ""
|
|
74
|
+
if hostname in ("localhost", "127.0.0.1", "::1", "169.254.169.254"):
|
|
75
|
+
return "ERROR: Access to loopback or cloud metadata services is prohibited."
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
ip = ipaddress.ip_address(hostname)
|
|
79
|
+
if ip.is_private or ip.is_loopback or ip.is_link_local:
|
|
80
|
+
return f"ERROR: Access to private network destination '{hostname}' is prohibited."
|
|
81
|
+
except ValueError:
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
req = urllib.request.Request(
|
|
85
|
+
url,
|
|
86
|
+
headers={
|
|
87
|
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
try:
|
|
91
|
+
with urllib.request.urlopen(req, timeout=20) as resp:
|
|
92
|
+
html = resp.read().decode("utf-8", errors="ignore")
|
|
93
|
+
|
|
94
|
+
soup = BeautifulSoup(html, "html.parser")
|
|
95
|
+
for tag in soup(["script", "style", "nav", "footer", "header", "noscript"]):
|
|
96
|
+
tag.extract()
|
|
97
|
+
|
|
98
|
+
text = soup.get_text(separator="\n")
|
|
99
|
+
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
|
100
|
+
clean_text = "\n".join(lines)
|
|
101
|
+
|
|
102
|
+
if len(clean_text) > max_chars:
|
|
103
|
+
return clean_text[:max_chars] + f"\n... [Truncated to {max_chars} chars]"
|
|
104
|
+
return clean_text
|
|
105
|
+
except Exception as e:
|
|
106
|
+
return f"Error reading web page {url}: {str(e)}"
|
package/verify_agents.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Portable verification script for CortexOps Multi-Agent Framework subagents."""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
BASE_DIR = Path(__file__).resolve().parent
|
|
8
|
+
PLUGIN_AGENTS_DIR = BASE_DIR / "plugin" / "agents"
|
|
9
|
+
GLOBAL_PLUGIN_DIR = Path.home() / ".gemini" / "config" / "plugins" / "cortexops"
|
|
10
|
+
LEGACY_PLUGIN_DIR = Path.home() / ".gemini" / "config" / "plugins" / "thea-engineering-team"
|
|
11
|
+
|
|
12
|
+
print("=" * 80)
|
|
13
|
+
print("CORTEXOPS MULTI-AGENT FRAMEWORK - PORTABLE AGENT VERIFICATION")
|
|
14
|
+
print("=" * 80)
|
|
15
|
+
|
|
16
|
+
# Verify Declarative Plugin Agents
|
|
17
|
+
print("[1] Declarative Plugin Definitions:")
|
|
18
|
+
if not PLUGIN_AGENTS_DIR.exists():
|
|
19
|
+
print(f" Missing plugin directory: {PLUGIN_AGENTS_DIR}")
|
|
20
|
+
else:
|
|
21
|
+
agent_files = sorted(PLUGIN_AGENTS_DIR.glob("*.md"))
|
|
22
|
+
print(f" Found {len(agent_files)} agent definitions in repository:")
|
|
23
|
+
for f in agent_files:
|
|
24
|
+
name = f.stem
|
|
25
|
+
desc = "No description"
|
|
26
|
+
try:
|
|
27
|
+
with open(f, "r", encoding="utf-8") as af:
|
|
28
|
+
lines = af.readlines()
|
|
29
|
+
for line in lines:
|
|
30
|
+
if line.startswith("description:"):
|
|
31
|
+
desc = line.replace("description:", "").strip()
|
|
32
|
+
break
|
|
33
|
+
except Exception:
|
|
34
|
+
pass
|
|
35
|
+
print(f" - {name:20s} -> {desc[:65]}...")
|
|
36
|
+
|
|
37
|
+
# Verify Global Antigravity Plugin Link
|
|
38
|
+
print("\n[2] Antigravity Global Plugin Link:")
|
|
39
|
+
active_link = GLOBAL_PLUGIN_DIR if GLOBAL_PLUGIN_DIR.exists() else (LEGACY_PLUGIN_DIR if LEGACY_PLUGIN_DIR.exists() else None)
|
|
40
|
+
if active_link:
|
|
41
|
+
print(f" Active link at: {active_link}")
|
|
42
|
+
print(f" Status: ENABLED (Available to Antigravity sessions globally)")
|
|
43
|
+
else:
|
|
44
|
+
print(f" Link not found at: {GLOBAL_PLUGIN_DIR}")
|
|
45
|
+
print(f" Run ./cx install to link the plugin globally.")
|
|
46
|
+
|
|
47
|
+
# Verify Python Standalone Framework Tools
|
|
48
|
+
print("\n[3] Python Agent Framework Modules:")
|
|
49
|
+
tools_dir = BASE_DIR / "src" / "tools"
|
|
50
|
+
agents_dir = BASE_DIR / "src" / "agents"
|
|
51
|
+
if tools_dir.exists() and agents_dir.exists():
|
|
52
|
+
tools = [t.stem for t in tools_dir.glob("*.py") if not t.name.startswith("__")]
|
|
53
|
+
print(f" Available Custom Tools: {', '.join(tools)}")
|
|
54
|
+
print(f" Framework Personas: Available in src/agents/personas.py")
|
|
55
|
+
print(f" Status: OPERATIONAL")
|
|
56
|
+
else:
|
|
57
|
+
print(" Framework modules missing or incomplete.")
|
|
58
|
+
|
|
59
|
+
print("=" * 80)
|
|
60
|
+
print("Verification complete. All agents are cross-laptop portable via Git.")
|
|
61
|
+
print("=" * 80)
|