tzero-mcp 12.3.6 → 12.3.7
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/README.md +32 -21
- package/package.json +1 -1
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +8 -1
- package/src/tzero/tzero_agency.py +2574 -0
- package/src/tzero/tzero_benchmark.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +1 -1
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +50 -3
- package/src/tzero/tzero_debt.py +1 -1
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_growth.py +1 -1
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +72 -1
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +2 -2
- package/src/tzero/tzero_v3.py +522 -18
- package/src/tzero/tzero_welcome.py +1 -1
|
@@ -0,0 +1,2574 @@
|
|
|
1
|
+
# SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
# Copyright (c) 2026 Toprak Ahmet Aydoğmuş
|
|
3
|
+
"""T-Zero Agency: Autonomous Multi-Agent Orchestrator, 448 README Blueprints & Skill Pack.
|
|
4
|
+
|
|
5
|
+
Provides:
|
|
6
|
+
- ``AgencyProjectProfiler``: Deep local AST, manifest, and stack intelligence profiler.
|
|
7
|
+
- ``README_DOMAINS`` (28) x ``README_STYLES`` (16) = **448 distinct README blueprints**.
|
|
8
|
+
- ``AGENCY_SKILLS`` (24 built-in executable & exportable SKILL.md modules).
|
|
9
|
+
- ``SUBAGENT_TEMPLATES`` (16 specialized multi-agent personas & handoff blueprints).
|
|
10
|
+
- ``AgencyOrchestrator``: Task-and-structure-aware multi-agent squad router & runner.
|
|
11
|
+
|
|
12
|
+
Zero implicit network calls, zero hardcoded credentials, 100% local deterministic execution.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import ast
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import time
|
|
22
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
23
|
+
from dataclasses import asdict, dataclass, field
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
|
26
|
+
|
|
27
|
+
IGNORED_DIRS = {
|
|
28
|
+
".git", ".hg", ".svn", ".venv", "venv", "env", "__pycache__", "node_modules",
|
|
29
|
+
"dist", "build", "target", ".pytest_cache", ".mypy_cache", ".ruff_cache",
|
|
30
|
+
".tzero", ".gemini", ".vercel", "brag-output", "backups",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
LANGUAGE_EXTENSIONS: Dict[str, str] = {
|
|
34
|
+
".py": "Python",
|
|
35
|
+
".ts": "TypeScript",
|
|
36
|
+
".tsx": "TypeScript",
|
|
37
|
+
".js": "JavaScript",
|
|
38
|
+
".jsx": "JavaScript",
|
|
39
|
+
".mjs": "JavaScript",
|
|
40
|
+
".cjs": "JavaScript",
|
|
41
|
+
".rs": "Rust",
|
|
42
|
+
".go": "Go",
|
|
43
|
+
".java": "Java",
|
|
44
|
+
".kt": "Kotlin",
|
|
45
|
+
".kts": "Kotlin",
|
|
46
|
+
".cs": "C#",
|
|
47
|
+
".cpp": "C++",
|
|
48
|
+
".cc": "C++",
|
|
49
|
+
".c": "C",
|
|
50
|
+
".h": "C/C++",
|
|
51
|
+
".swift": "Swift",
|
|
52
|
+
".rb": "Ruby",
|
|
53
|
+
".php": "PHP",
|
|
54
|
+
".dart": "Dart",
|
|
55
|
+
".sh": "Shell",
|
|
56
|
+
".ps1": "PowerShell",
|
|
57
|
+
".sql": "SQL",
|
|
58
|
+
".html": "HTML",
|
|
59
|
+
".css": "CSS",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# =============================================================================
|
|
64
|
+
# 1. 28 PROJECT DOMAINS x 16 README STYLES = 448 DISTINCT README BLUEPRINTS
|
|
65
|
+
# =============================================================================
|
|
66
|
+
|
|
67
|
+
README_DOMAINS: Tuple[Dict[str, Any], ...] = (
|
|
68
|
+
{
|
|
69
|
+
"id": "python-cli",
|
|
70
|
+
"title": "Python CLI Tool",
|
|
71
|
+
"category": "CLI & Developer Tools",
|
|
72
|
+
"audience": "Terminal developers & automation engineers",
|
|
73
|
+
"tagline": "Fast, scriptable Python command-line utility built for predictable local workflows.",
|
|
74
|
+
"keywords": ("cli", "argparse", "typer", "click", "terminal", "command", "console_scripts"),
|
|
75
|
+
"focus_sections": ("Commands & Flags", "Exit Codes & Piping", "Shell Completion"),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "python-library",
|
|
79
|
+
"title": "Python Package & SDK",
|
|
80
|
+
"category": "Libraries & SDKs",
|
|
81
|
+
"audience": "Python library consumers & application engineers",
|
|
82
|
+
"tagline": "Typed, modular Python package with clean public contracts and zero surprise side effects.",
|
|
83
|
+
"keywords": ("pyproject.toml", "setup.py", "sdk", "library", "wheel", "pypi"),
|
|
84
|
+
"focus_sections": ("Public API Surface", "Typed Examples", "Versioning & Compatibility"),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "mcp-server",
|
|
88
|
+
"title": "Model Context Protocol (MCP) Server",
|
|
89
|
+
"category": "AI Tooling & Protocols",
|
|
90
|
+
"audience": "AI IDE users (Cursor, Claude Desktop, Antigravity, Windsurf, VS Code)",
|
|
91
|
+
"tagline": "Native Model Context Protocol server exposing structured tools, resources, and prompts.",
|
|
92
|
+
"keywords": ("mcp", "fastmcp", "stdio", "server.json", "smithery", "glama", "toolannotations"),
|
|
93
|
+
"focus_sections": ("1-Click IDE Setup", "MCP Tools & Schemas", "Resources & Prompts"),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "ai-agent-framework",
|
|
97
|
+
"title": "Multi-Agent AI Orchestrator",
|
|
98
|
+
"category": "AI Tooling & Protocols",
|
|
99
|
+
"audience": "AI engineers building autonomous workflows & subagent swarms",
|
|
100
|
+
"tagline": "Deterministic multi-agent orchestration with specialized subagent roles, skills, and safety guards.",
|
|
101
|
+
"keywords": ("agent", "subagent", "swarm", "orchestrat", "skill", "llm", "rag", "prompt"),
|
|
102
|
+
"focus_sections": ("Agent Fleet & Roles", "Skills & Subagent Templates", "Guardrails & Consensus"),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "fastapi-backend",
|
|
106
|
+
"title": "FastAPI Async REST Service",
|
|
107
|
+
"category": "Backend & APIs",
|
|
108
|
+
"audience": "Backend engineers, SREs & API consumers",
|
|
109
|
+
"tagline": "High-throughput asynchronous REST API with OpenAPI schemas and strict validation.",
|
|
110
|
+
"keywords": ("fastapi", "uvicorn", "pydantic", "openapi", "starlette", "router"),
|
|
111
|
+
"focus_sections": ("API Endpoints", "Request/Response Schemas", "Production Deployment"),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "django-fullstack",
|
|
115
|
+
"title": "Django Fullstack Platform",
|
|
116
|
+
"category": "Backend & APIs",
|
|
117
|
+
"audience": "Fullstack teams & product engineers",
|
|
118
|
+
"tagline": "Batteries-included Django web platform with clean app separation and migration discipline.",
|
|
119
|
+
"keywords": ("django", "manage.py", "wsgi", "asgi", "settings.py", "migrations"),
|
|
120
|
+
"focus_sections": ("Apps & Models", "Database Migrations", "Admin & Auth Flow"),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "flask-microservice",
|
|
124
|
+
"title": "Flask Microservice",
|
|
125
|
+
"category": "Backend & APIs",
|
|
126
|
+
"audience": "Microservice teams & lightweight API builders",
|
|
127
|
+
"tagline": "Compact Flask HTTP service engineered for clear routing and container portability.",
|
|
128
|
+
"keywords": ("flask", "blueprint", "gunicorn", "werkzeug"),
|
|
129
|
+
"focus_sections": ("Service Routes", "Configuration Matrix", "Container Runbook"),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "nextjs-saas",
|
|
133
|
+
"title": "Next.js Fullstack SaaS App",
|
|
134
|
+
"category": "Web & Frontend",
|
|
135
|
+
"audience": "Web product teams & SaaS builders",
|
|
136
|
+
"tagline": "Fullstack Next.js application combining server rendering, typed routes, and edge-ready UI.",
|
|
137
|
+
"keywords": ("next", "next.config", "app/", "pages/", "vercel", "tailwind"),
|
|
138
|
+
"focus_sections": ("App Routes & Pages", "Environment Variables", "Build & Vercel Deploy"),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": "react-ui-kit",
|
|
142
|
+
"title": "React / TypeScript UI Kit",
|
|
143
|
+
"category": "Web & Frontend",
|
|
144
|
+
"audience": "Frontend developers & design system teams",
|
|
145
|
+
"tagline": "Composable, accessible React component system with predictable props and theme tokens.",
|
|
146
|
+
"keywords": ("react", "tsx", "jsx", "vite", "component", "storybook", "tailwind"),
|
|
147
|
+
"focus_sections": ("Component Catalog", "Theming & Tokens", "Accessibility & Bundle Size"),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "node-cli-npm",
|
|
151
|
+
"title": "Node.js CLI & npm Package",
|
|
152
|
+
"category": "CLI & Developer Tools",
|
|
153
|
+
"audience": "JavaScript/TypeScript developers & CI pipelines",
|
|
154
|
+
"tagline": "Zero-friction Node.js CLI and npm package built for instant npx execution.",
|
|
155
|
+
"keywords": ("package.json", "npx", "node", "bin/", "commonjs", "esm"),
|
|
156
|
+
"focus_sections": ("Instant npx Usage", "Programmatic Exports", "Node Matrix Compatibility"),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"id": "vscode-extension",
|
|
160
|
+
"title": "VS Code / IDE Extension",
|
|
161
|
+
"category": "IDE & Extensions",
|
|
162
|
+
"audience": "IDE power users & extension maintainers",
|
|
163
|
+
"tagline": "Integrated editor extension bringing live diagnostics, commands, and panels to VS Code.",
|
|
164
|
+
"keywords": ("vscode", "vsix", "extension.js", "activationevents", "contributes"),
|
|
165
|
+
"focus_sections": ("Marketplace Install", "Commands & Keybindings", "Extension Settings"),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "rust-crate",
|
|
169
|
+
"title": "Rust Systems Crate",
|
|
170
|
+
"category": "Systems & Performance",
|
|
171
|
+
"audience": "Rust systems programmers & FFI integrators",
|
|
172
|
+
"tagline": "Memory-safe Rust library and binary built for predictable throughput and zero-copy ergonomics.",
|
|
173
|
+
"keywords": ("cargo.toml", "lib.rs", "main.rs", "rustc", "crate", "ffi"),
|
|
174
|
+
"focus_sections": ("Cargo Features", "Safety & Benchmarks", "FFI / Binding Surface"),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"id": "go-service",
|
|
178
|
+
"title": "Go Service / CLI Binary",
|
|
179
|
+
"category": "Systems & Performance",
|
|
180
|
+
"audience": "Cloud-native & Go backend engineers",
|
|
181
|
+
"tagline": "Single-binary Go service built with clean packages, bounded concurrency, and fast startup.",
|
|
182
|
+
"keywords": ("go.mod", "go.sum", "cmd/", "internal/", "golang"),
|
|
183
|
+
"focus_sections": ("Binary Build & Run", "Package Layout", "Concurrency & Healthchecks"),
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "ml-research",
|
|
187
|
+
"title": "ML / LLM Research Repository",
|
|
188
|
+
"category": "Data & Machine Learning",
|
|
189
|
+
"audience": "ML researchers, benchmark authors & reproducibility reviewers",
|
|
190
|
+
"tagline": "Reproducible machine learning codebase with deterministic evaluation scripts and model configs.",
|
|
191
|
+
"keywords": ("torch", "transformers", "gradio", "huggingface", "dataset", "benchmark", "eval"),
|
|
192
|
+
"focus_sections": ("Experiment Setup", "Reproducible Benchmarks", "Citation & Model Card"),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"id": "data-pipeline",
|
|
196
|
+
"title": "Data Engineering & ETL Pipeline",
|
|
197
|
+
"category": "Data & Machine Learning",
|
|
198
|
+
"audience": "Data engineers & analytics platform teams",
|
|
199
|
+
"tagline": "Deterministic ETL and ingestion workflow with schema checks and lineage visibility.",
|
|
200
|
+
"keywords": ("etl", "pipeline", "parquet", "pandas", "polars", "dbt", "airflow", "sqlite"),
|
|
201
|
+
"focus_sections": ("Pipeline Stages", "Data Contracts & Schemas", "Backfill & Scheduling"),
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "cybersecurity-tool",
|
|
205
|
+
"title": "Security Scanner & Audit Engine",
|
|
206
|
+
"category": "Security & Governance",
|
|
207
|
+
"audience": "AppSec engineers, DevSecOps & compliance auditors",
|
|
208
|
+
"tagline": "Local-first static security analyzer enforcing zero-leak rules, entropy checks, and SARIF output.",
|
|
209
|
+
"keywords": ("security", "audit", "secret", "sarif", "cwe", "entropy", "guard", "zero-leak"),
|
|
210
|
+
"focus_sections": ("Threat Coverage", "SARIF & CI Gates", "Zero-Leak Guarantees"),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "devops-iac",
|
|
214
|
+
"title": "DevOps / Docker / CI Automation",
|
|
215
|
+
"category": "Infrastructure & DevOps",
|
|
216
|
+
"audience": "Platform engineers, DevOps & release managers",
|
|
217
|
+
"tagline": "Automated container, CI/CD, and infrastructure blueprints engineered for repeatable deployments.",
|
|
218
|
+
"keywords": ("dockerfile", "compose", "terraform", "kubernetes", "helm", "workflow", "action.yml"),
|
|
219
|
+
"focus_sections": ("Containers & Compose", "CI/CD Matrix", "Secrets & Rollback"),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"id": "desktop-gui",
|
|
223
|
+
"title": "Cross-Platform Desktop GUI App",
|
|
224
|
+
"category": "Desktop & Visual Tools",
|
|
225
|
+
"audience": "Desktop end-users & developer cockpit operators",
|
|
226
|
+
"tagline": "Responsive desktop control center with keyboard shortcuts, theme management, and live previews.",
|
|
227
|
+
"keywords": ("tkinter", "pyqt", "pyside", "electron", "gui", "desktop", "window"),
|
|
228
|
+
"focus_sections": ("Visual Workspace Tour", "Keyboard Shortcuts", "Packaging & Installers"),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"id": "monorepo-workspace",
|
|
232
|
+
"title": "Multi-Package Monorepo Workspace",
|
|
233
|
+
"category": "Architecture & Platforms",
|
|
234
|
+
"audience": "Staff engineers & multi-team repository maintainers",
|
|
235
|
+
"tagline": "Coordinated polyglot monorepo organizing core libraries, installers, extensions, and shared tests.",
|
|
236
|
+
"keywords": ("packages/", "crates/", "extensions/", "installers/", "workspace", "monorepo"),
|
|
237
|
+
"focus_sections": ("Workspace Package Map", "Cross-Package Sync", "Unified Test Matrix"),
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"id": "chrome-extension",
|
|
241
|
+
"title": "Browser Extension (Manifest V3)",
|
|
242
|
+
"category": "IDE & Extensions",
|
|
243
|
+
"audience": "Browser power users & web workflow developers",
|
|
244
|
+
"tagline": "Lightweight Manifest V3 browser extension with minimal permissions and local state storage.",
|
|
245
|
+
"keywords": ("manifest.json", "content_scripts", "chrome", "popup", "service_worker"),
|
|
246
|
+
"focus_sections": ("Permissions Transparency", "Load Unpacked Guide", "Popup & Background Flow"),
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"id": "graphql-gateway",
|
|
250
|
+
"title": "GraphQL / API Gateway",
|
|
251
|
+
"category": "Backend & APIs",
|
|
252
|
+
"audience": "API platform teams & client integrators",
|
|
253
|
+
"tagline": "Schema-driven gateway aggregating downstream services behind typed contracts and rate limits.",
|
|
254
|
+
"keywords": ("graphql", "apollo", "gateway", "proxy", "schema", "resolver"),
|
|
255
|
+
"focus_sections": ("Schema & Operations", "Upstream Routing", "Caching & Rate Limits"),
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"id": "embedded-iot",
|
|
259
|
+
"title": "Embedded / IoT / Hardware Bridge",
|
|
260
|
+
"category": "Systems & Hardware",
|
|
261
|
+
"audience": "Firmware engineers, robotics & IoT developers",
|
|
262
|
+
"tagline": "Deterministic device interface and telemetry bridge built for constrained hardware targets.",
|
|
263
|
+
"keywords": ("serial", "gpio", "mqtt", "firmware", "arduino", "esp32", "hardware", "iot"),
|
|
264
|
+
"focus_sections": ("Hardware Pinout & Wiring", "Flashing & Firmware", "Telemetry Protocol"),
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "game-engine",
|
|
268
|
+
"title": "Game / Simulation / Interactive Engine",
|
|
269
|
+
"category": "Creative & Interactive",
|
|
270
|
+
"audience": "Game developers, graphics programmers & modders",
|
|
271
|
+
"tagline": "Real-time simulation and interactive rendering codebase with deterministic frame stepping.",
|
|
272
|
+
"keywords": ("pygame", "godot", "unity", "shader", "canvas", "remotion", "animation", "fps"),
|
|
273
|
+
"focus_sections": ("Scene Loop & Controls", "Asset Pipeline", "Performance Budget"),
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"id": "fintech-web3",
|
|
277
|
+
"title": "FinTech / Ledger / Web3 Integration",
|
|
278
|
+
"category": "Domain Platforms",
|
|
279
|
+
"audience": "Financial systems engineers & protocol auditors",
|
|
280
|
+
"tagline": "Auditable ledger and deterministic calculation toolkit with strict input verification.",
|
|
281
|
+
"keywords": ("wallet", "ledger", "crypto", "payment", "invoice", "finops", "billing", "sha256"),
|
|
282
|
+
"focus_sections": ("Precision & Rounding", "Audit Trail & Verification", "Security Boundaries"),
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": "edu-curriculum",
|
|
286
|
+
"title": "Educational Lab & Interactive Course",
|
|
287
|
+
"category": "Education & Docs",
|
|
288
|
+
"audience": "Students, instructors & self-taught engineers",
|
|
289
|
+
"tagline": "Hands-on engineering curriculum with progressive labs, exercises, and verification scripts.",
|
|
290
|
+
"keywords": ("tutorial", "notebook", "ipynb", "lesson", "lab", "workshop", "guide", "course"),
|
|
291
|
+
"focus_sections": ("Learning Path", "Interactive Labs", "Self-Check Exercises"),
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"id": "awesome-curated",
|
|
295
|
+
"title": "Curated Resource Directory",
|
|
296
|
+
"category": "Community & Lists",
|
|
297
|
+
"audience": "Developers discovering vetted tools, benchmarks & references",
|
|
298
|
+
"tagline": "Structured, maintained index of verified tools, benchmarks, and architectural references.",
|
|
299
|
+
"keywords": ("awesome", "curated", "directory", "catalog", "resources", "index"),
|
|
300
|
+
"focus_sections": ("Categorized Directory", "Selection Criteria", "Submission Guidelines"),
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"id": "github-profile",
|
|
304
|
+
"title": "Engineering Studio / Org Profile",
|
|
305
|
+
"category": "Community & Lists",
|
|
306
|
+
"audience": "Visitors, sponsors & open-source collaborators",
|
|
307
|
+
"tagline": "High-signal engineering overview highlighting flagship projects, impact metrics, and stack.",
|
|
308
|
+
"keywords": ("profile", "portfolio", "sponsor", "studio", "akademi", "bio"),
|
|
309
|
+
"focus_sections": ("Flagship Projects", "Core Stack & Principles", "Connect & Sponsor"),
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"id": "open-source-launch",
|
|
313
|
+
"title": "Viral Open-Source Product Launch",
|
|
314
|
+
"category": "Growth & Launches",
|
|
315
|
+
"audience": "GitHub stars explorers, Hacker News & Product Hunt readers",
|
|
316
|
+
"tagline": "Proof-first open-source README engineered to demonstrate value in under 15 seconds.",
|
|
317
|
+
"keywords": ("launch", "showcase", "promo", "demo", "stars", "badge", "comparison"),
|
|
318
|
+
"focus_sections": ("10-Second Proof", "Comparison Matrix", "Community & Star Funnel"),
|
|
319
|
+
},
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
README_STYLES: Tuple[Dict[str, Any], ...] = (
|
|
323
|
+
{
|
|
324
|
+
"id": "launch-viral",
|
|
325
|
+
"title": "Proof-First Viral Launch",
|
|
326
|
+
"tone": "High-impact, visual proof first, 30-second quickstart, comparison matrix, star CTA.",
|
|
327
|
+
"badge_density": "high",
|
|
328
|
+
"include_mermaid": True,
|
|
329
|
+
"include_comparison": True,
|
|
330
|
+
"include_roi": True,
|
|
331
|
+
"bilingual": False,
|
|
332
|
+
"section_order": ("hero", "proof", "quickstart", "comparison", "architecture", "capabilities", "verification", "community"),
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"id": "minimalist-zen",
|
|
336
|
+
"title": "60-Second Minimalist",
|
|
337
|
+
"tone": "Ultra-concise, zero fluff, clean code block and essential commands only.",
|
|
338
|
+
"badge_density": "minimal",
|
|
339
|
+
"include_mermaid": False,
|
|
340
|
+
"include_comparison": False,
|
|
341
|
+
"include_roi": False,
|
|
342
|
+
"bilingual": False,
|
|
343
|
+
"section_order": ("hero", "quickstart", "capabilities", "verification"),
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"id": "enterprise-rfc",
|
|
347
|
+
"title": "Enterprise Architecture & RFC",
|
|
348
|
+
"tone": "Formal engineering specification covering boundaries, threat model, SLA, and governance.",
|
|
349
|
+
"badge_density": "standard",
|
|
350
|
+
"include_mermaid": True,
|
|
351
|
+
"include_comparison": True,
|
|
352
|
+
"include_roi": True,
|
|
353
|
+
"bilingual": False,
|
|
354
|
+
"section_order": ("hero", "architecture", "capabilities", "security", "verification", "quickstart", "community"),
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"id": "academic-paper",
|
|
358
|
+
"title": "Research & Reproducibility",
|
|
359
|
+
"tone": "Methodical, empirical measurements, methodology, reproducible commands, and citation block.",
|
|
360
|
+
"badge_density": "minimal",
|
|
361
|
+
"include_mermaid": True,
|
|
362
|
+
"include_comparison": True,
|
|
363
|
+
"include_roi": True,
|
|
364
|
+
"bilingual": False,
|
|
365
|
+
"section_order": ("hero", "proof", "architecture", "verification", "quickstart", "citation"),
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"id": "developer-dx",
|
|
369
|
+
"title": "Developer DX & Recipes",
|
|
370
|
+
"tone": "Practical copy-paste recipes, API/CLI examples, troubleshooting, and local setup.",
|
|
371
|
+
"badge_density": "standard",
|
|
372
|
+
"include_mermaid": False,
|
|
373
|
+
"include_comparison": False,
|
|
374
|
+
"include_roi": False,
|
|
375
|
+
"bilingual": False,
|
|
376
|
+
"section_order": ("hero", "quickstart", "recipes", "capabilities", "architecture", "verification"),
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"id": "storytelling-founder",
|
|
380
|
+
"title": "Founder Story & Mission",
|
|
381
|
+
"tone": "Human narrative explaining why the project exists, the problem solved, and roadmap.",
|
|
382
|
+
"badge_density": "standard",
|
|
383
|
+
"include_mermaid": True,
|
|
384
|
+
"include_comparison": True,
|
|
385
|
+
"include_roi": False,
|
|
386
|
+
"bilingual": False,
|
|
387
|
+
"section_order": ("hero", "story", "proof", "quickstart", "architecture", "community"),
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"id": "visual-mermaid",
|
|
391
|
+
"title": "Diagram-First Topology",
|
|
392
|
+
"tone": "Architecture-led visual walkthrough with Mermaid topology, module map, and data flow.",
|
|
393
|
+
"badge_density": "standard",
|
|
394
|
+
"include_mermaid": True,
|
|
395
|
+
"include_comparison": False,
|
|
396
|
+
"include_roi": False,
|
|
397
|
+
"bilingual": False,
|
|
398
|
+
"section_order": ("hero", "architecture", "capabilities", "quickstart", "verification"),
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"id": "security-zero-trust",
|
|
402
|
+
"title": "Zero-Trust & Security Audit",
|
|
403
|
+
"tone": "Security-first posture highlighting offline guarantees, secret hygiene, and audit checks.",
|
|
404
|
+
"badge_density": "standard",
|
|
405
|
+
"include_mermaid": True,
|
|
406
|
+
"include_comparison": False,
|
|
407
|
+
"include_roi": False,
|
|
408
|
+
"bilingual": False,
|
|
409
|
+
"section_order": ("hero", "security", "architecture", "verification", "quickstart", "community"),
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"id": "contributor-hub",
|
|
413
|
+
"title": "Contributor & Maintainer Hub",
|
|
414
|
+
"tone": "Welcoming onboarding guide for contributors, test runners, code conventions, and PR gates.",
|
|
415
|
+
"badge_density": "standard",
|
|
416
|
+
"include_mermaid": True,
|
|
417
|
+
"include_comparison": False,
|
|
418
|
+
"include_roi": False,
|
|
419
|
+
"bilingual": False,
|
|
420
|
+
"section_order": ("hero", "quickstart", "architecture", "verification", "contributing", "community"),
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"id": "monorepo-index",
|
|
424
|
+
"title": "Monorepo Package Matrix",
|
|
425
|
+
"tone": "Structured inventory table mapping every package, installer, extension, and test target.",
|
|
426
|
+
"badge_density": "high",
|
|
427
|
+
"include_mermaid": True,
|
|
428
|
+
"include_comparison": False,
|
|
429
|
+
"include_roi": False,
|
|
430
|
+
"bilingual": False,
|
|
431
|
+
"section_order": ("hero", "monorepo", "quickstart", "architecture", "verification", "community"),
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"id": "changelog-release",
|
|
435
|
+
"title": "Release-Focused & Migration",
|
|
436
|
+
"tone": "Highlights latest capabilities, upgrade path, backward compatibility, and verification.",
|
|
437
|
+
"badge_density": "standard",
|
|
438
|
+
"include_mermaid": False,
|
|
439
|
+
"include_comparison": True,
|
|
440
|
+
"include_roi": False,
|
|
441
|
+
"bilingual": False,
|
|
442
|
+
"section_order": ("hero", "release", "quickstart", "capabilities", "verification"),
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"id": "benchmark-roi",
|
|
446
|
+
"title": "Benchmark & Cost ROI",
|
|
447
|
+
"tone": "Quantified performance metrics, token/cost deltas, and reproducible verification steps.",
|
|
448
|
+
"badge_density": "high",
|
|
449
|
+
"include_mermaid": True,
|
|
450
|
+
"include_comparison": True,
|
|
451
|
+
"include_roi": True,
|
|
452
|
+
"bilingual": False,
|
|
453
|
+
"section_order": ("hero", "proof", "comparison", "quickstart", "verification", "architecture"),
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"id": "quickstart-1click",
|
|
457
|
+
"title": "1-Click Zero-Friction",
|
|
458
|
+
"tone": "Immediate copy-paste commands at the very top so users succeed in one command.",
|
|
459
|
+
"badge_density": "minimal",
|
|
460
|
+
"include_mermaid": False,
|
|
461
|
+
"include_comparison": False,
|
|
462
|
+
"include_roi": False,
|
|
463
|
+
"bilingual": False,
|
|
464
|
+
"section_order": ("hero", "quickstart", "recipes", "verification", "community"),
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
"id": "agent-native",
|
|
468
|
+
"title": "AI-Agent & llms.txt Native",
|
|
469
|
+
"tone": "Optimized for both human devs and coding agents with MCP schemas, contracts, and skills.",
|
|
470
|
+
"badge_density": "standard",
|
|
471
|
+
"include_mermaid": True,
|
|
472
|
+
"include_comparison": True,
|
|
473
|
+
"include_roi": True,
|
|
474
|
+
"bilingual": False,
|
|
475
|
+
"section_order": ("hero", "agent_spec", "quickstart", "architecture", "security", "verification"),
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"id": "bilingual-tr-en",
|
|
479
|
+
"title": "Bilingual Turkish + English",
|
|
480
|
+
"tone": "Dual-language Turkish & English executive documentation for global and local adoption.",
|
|
481
|
+
"badge_density": "high",
|
|
482
|
+
"include_mermaid": True,
|
|
483
|
+
"include_comparison": True,
|
|
484
|
+
"include_roi": True,
|
|
485
|
+
"bilingual": True,
|
|
486
|
+
"section_order": ("hero", "bilingual_intro", "quickstart", "capabilities", "architecture", "verification", "community"),
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"id": "cli-cheatsheet",
|
|
490
|
+
"title": "Command Cheatsheet & Matrix",
|
|
491
|
+
"tone": "Dense reference card of flags, subcommands, output formats, and workflow shortcuts.",
|
|
492
|
+
"badge_density": "minimal",
|
|
493
|
+
"include_mermaid": False,
|
|
494
|
+
"include_comparison": False,
|
|
495
|
+
"include_roi": False,
|
|
496
|
+
"bilingual": False,
|
|
497
|
+
"section_order": ("hero", "cheatsheet", "quickstart", "capabilities", "verification"),
|
|
498
|
+
},
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
@dataclass(frozen=True)
|
|
503
|
+
class ReadmeBlueprint:
|
|
504
|
+
"""Single deterministic README blueprint inside the 448-blueprint catalog."""
|
|
505
|
+
|
|
506
|
+
blueprint_id: str
|
|
507
|
+
domain_id: str
|
|
508
|
+
style_id: str
|
|
509
|
+
title: str
|
|
510
|
+
category: str
|
|
511
|
+
description: str
|
|
512
|
+
audience: str
|
|
513
|
+
focus_sections: Tuple[str, ...]
|
|
514
|
+
tags: Tuple[str, ...]
|
|
515
|
+
|
|
516
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
517
|
+
return asdict(self)
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def _build_readme_catalog() -> Dict[str, ReadmeBlueprint]:
|
|
521
|
+
catalog: Dict[str, ReadmeBlueprint] = {}
|
|
522
|
+
for dom in README_DOMAINS:
|
|
523
|
+
for sty in README_STYLES:
|
|
524
|
+
bid = f"{dom['id']}/{sty['id']}"
|
|
525
|
+
catalog[bid] = ReadmeBlueprint(
|
|
526
|
+
blueprint_id=bid,
|
|
527
|
+
domain_id=dom["id"],
|
|
528
|
+
style_id=sty["id"],
|
|
529
|
+
title=f"{dom['title']} — {sty['title']}",
|
|
530
|
+
category=dom["category"],
|
|
531
|
+
description=f"{dom['tagline']} Layout: {sty['tone']}",
|
|
532
|
+
audience=dom["audience"],
|
|
533
|
+
focus_sections=tuple(dom["focus_sections"]),
|
|
534
|
+
tags=tuple(sorted(set(dom["keywords"]) | {dom["id"], sty["id"], dom["category"].lower()})),
|
|
535
|
+
)
|
|
536
|
+
return catalog
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
README_BLUEPRINTS: Dict[str, ReadmeBlueprint] = _build_readme_catalog()
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def list_readme_blueprints(
|
|
543
|
+
domain: Optional[str] = None,
|
|
544
|
+
style: Optional[str] = None,
|
|
545
|
+
query: str = "",
|
|
546
|
+
) -> List[ReadmeBlueprint]:
|
|
547
|
+
"""Return filtered README blueprints from the 448-entry catalog."""
|
|
548
|
+
dom_f = (domain or "").strip().lower()
|
|
549
|
+
sty_f = (style or "").strip().lower()
|
|
550
|
+
q_terms = [t for t in re.findall(r"[a-z0-9_-]+", (query or "").lower()) if len(t) > 1]
|
|
551
|
+
|
|
552
|
+
matches: List[ReadmeBlueprint] = []
|
|
553
|
+
for bp in README_BLUEPRINTS.values():
|
|
554
|
+
if dom_f and dom_f != "all" and bp.domain_id != dom_f:
|
|
555
|
+
continue
|
|
556
|
+
if sty_f and sty_f != "all" and bp.style_id != sty_f:
|
|
557
|
+
continue
|
|
558
|
+
if q_terms:
|
|
559
|
+
hay = " ".join([bp.blueprint_id, bp.title, bp.category, bp.description, bp.audience, " ".join(bp.tags)]).lower()
|
|
560
|
+
if not all(term in hay for term in q_terms):
|
|
561
|
+
continue
|
|
562
|
+
matches.append(bp)
|
|
563
|
+
return matches
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
# =============================================================================
|
|
567
|
+
# 2. 24 BUILT-IN AGENCY SKILLS (EXECUTABLE & EXPORTABLE TO SKILL.md)
|
|
568
|
+
# =============================================================================
|
|
569
|
+
|
|
570
|
+
@dataclass(frozen=True)
|
|
571
|
+
class AgencySkill:
|
|
572
|
+
"""Reusable, self-contained Agency capability skill with SKILL.md export."""
|
|
573
|
+
|
|
574
|
+
skill_id: str
|
|
575
|
+
name: str
|
|
576
|
+
category: str
|
|
577
|
+
summary: str
|
|
578
|
+
triggers: Tuple[str, ...]
|
|
579
|
+
tools: Tuple[str, ...]
|
|
580
|
+
tier: str
|
|
581
|
+
checklist: Tuple[str, ...]
|
|
582
|
+
|
|
583
|
+
def to_skill_markdown(self) -> str:
|
|
584
|
+
bullets = "\n".join(f"- {item}" for item in self.checklist)
|
|
585
|
+
tools_str = ", ".join(f"`{t}`" for t in self.tools)
|
|
586
|
+
triggers_str = ", ".join(f"`{t}`" for t in self.triggers[:8])
|
|
587
|
+
return (
|
|
588
|
+
f"---\n"
|
|
589
|
+
f"name: {self.skill_id}\n"
|
|
590
|
+
f"description: {self.summary}\n"
|
|
591
|
+
f"---\n\n"
|
|
592
|
+
f"# {self.name} (`{self.skill_id}`)\n\n"
|
|
593
|
+
f"- **Category:** {self.category}\n"
|
|
594
|
+
f"- **Context Tier:** `{self.tier}`\n"
|
|
595
|
+
f"- **Preferred T-Zero Tools:** {tools_str}\n"
|
|
596
|
+
f"- **Activation Triggers:** {triggers_str}\n\n"
|
|
597
|
+
f"## Execution Protocol\n"
|
|
598
|
+
f"{bullets}\n"
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
602
|
+
return asdict(self)
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
AGENCY_SKILLS: Tuple[AgencySkill, ...] = (
|
|
606
|
+
AgencySkill(
|
|
607
|
+
skill_id="repo-architect-profiler",
|
|
608
|
+
name="Repository Architecture Profiler",
|
|
609
|
+
category="Discovery & Topology",
|
|
610
|
+
summary="Profile codebase language mix, manifests, entrypoints, dependencies, and layer topology in <1s.",
|
|
611
|
+
triggers=("profile", "structure", "scan", "mimari", "yapı", "analiz", "anla"),
|
|
612
|
+
tools=("get_project_context_tree", "query_module_dependencies", "rank_repository_pagerank"),
|
|
613
|
+
tier="T-1",
|
|
614
|
+
checklist=(
|
|
615
|
+
"Detect languages, frameworks, and package manifests without executing untrusted files.",
|
|
616
|
+
"Rank core backbone modules using AST import centrality.",
|
|
617
|
+
"Map entrypoints, CLI commands, and test suites for downstream agents.",
|
|
618
|
+
),
|
|
619
|
+
),
|
|
620
|
+
AgencySkill(
|
|
621
|
+
skill_id="readme-448-synthesizer",
|
|
622
|
+
name="448-Blueprint README Synthesizer",
|
|
623
|
+
category="Documentation & Launch",
|
|
624
|
+
summary="Select from 448 domain x style README blueprints and synthesize a repo-grounded README.md.",
|
|
625
|
+
triggers=("readme", "docs", "launch", "doküman", "tanıtım", "badge"),
|
|
626
|
+
tools=("get_project_context_tree", "generate_architecture_blueprint", "agency_generate_readme"),
|
|
627
|
+
tier="T-2",
|
|
628
|
+
checklist=(
|
|
629
|
+
"Score all 28 domain archetypes against real scanned manifests and AST symbols.",
|
|
630
|
+
"Generate install, quickstart, architecture, and verification blocks exclusively from verified files.",
|
|
631
|
+
"Embed Mermaid topology only when styles and workspace structure support it.",
|
|
632
|
+
),
|
|
633
|
+
),
|
|
634
|
+
AgencySkill(
|
|
635
|
+
skill_id="agent-squad-assembler",
|
|
636
|
+
name="Task-Aware Multi-Agent Squad Assembler",
|
|
637
|
+
category="Orchestration",
|
|
638
|
+
summary="Analyze a natural-language task (EN/TR) + workspace structure to assemble the ideal subagent squad.",
|
|
639
|
+
triggers=("agent", "squad", "swarm", "team", "ajan", "çoklu", "ekip", "orkestra"),
|
|
640
|
+
tools=("orchestrate_agent_swarm", "execute_codebase_workflow"),
|
|
641
|
+
tier="T-1",
|
|
642
|
+
checklist=(
|
|
643
|
+
"Classify goal intent across security, architecture, testing, API, UI, docs, and release.",
|
|
644
|
+
"Assign parallel Wave-1 discovery/analysis agents and Wave-2 synthesis gatekeepers.",
|
|
645
|
+
"Prevent file edit collisions via scoped subagent ownership.",
|
|
646
|
+
),
|
|
647
|
+
),
|
|
648
|
+
AgencySkill(
|
|
649
|
+
skill_id="subagent-blueprint-forge",
|
|
650
|
+
name="Subagent Template & SKILL.md Forger",
|
|
651
|
+
category="Orchestration",
|
|
652
|
+
summary="Emit portable agent.json + SKILL.md subagent templates tailored to the active repository.",
|
|
653
|
+
triggers=("template", "subagent", "forge", "şablon", "skill", "yetkinlik"),
|
|
654
|
+
tools=("export_agent_rules", "orchestrate_agent_swarm"),
|
|
655
|
+
tier="T-2",
|
|
656
|
+
checklist=(
|
|
657
|
+
"Generate scoped subagent definitions with explicit allowed tools and token budgets.",
|
|
658
|
+
"Include anti-hallucination and zero-leak operational rules in every SKILL.md.",
|
|
659
|
+
"Write artifacts strictly inside `.tzero/agency/` without modifying source modules.",
|
|
660
|
+
),
|
|
661
|
+
),
|
|
662
|
+
AgencySkill(
|
|
663
|
+
skill_id="zero-leak-security-gate",
|
|
664
|
+
name="Zero-Leak Secret & Security Gate",
|
|
665
|
+
category="Security",
|
|
666
|
+
summary="Audit files for hardcoded API keys, high-entropy tokens, and unsafe execution patterns.",
|
|
667
|
+
triggers=("security", "secret", "leak", "güvenlik", "sızıntı", "key", "token", "audit"),
|
|
668
|
+
tools=("verify_security_guard", "audit_codebase_quality"),
|
|
669
|
+
tier="T-4",
|
|
670
|
+
checklist=(
|
|
671
|
+
"Scan workspace with Shannon entropy and regex detectors locally with zero network egress.",
|
|
672
|
+
"Ensure sensitive configuration remains isolated in environment variables or OS keyring.",
|
|
673
|
+
"Block release recommendations if critical credential exposures exist.",
|
|
674
|
+
),
|
|
675
|
+
),
|
|
676
|
+
AgencySkill(
|
|
677
|
+
skill_id="ast-boundary-enforcer",
|
|
678
|
+
name="AST Boundary & Cycle Enforcer",
|
|
679
|
+
category="Architecture",
|
|
680
|
+
summary="Validate inward-only layer boundaries in tzero.rules.json and detect circular imports.",
|
|
681
|
+
triggers=("boundary", "layer", "cycle", "import", "sınır", "katman", "mimari"),
|
|
682
|
+
tools=("enforce_architecture_boundaries", "query_architecture_boundaries"),
|
|
683
|
+
tier="T-4",
|
|
684
|
+
checklist=(
|
|
685
|
+
"Inspect import graph against declared architectural layers.",
|
|
686
|
+
"Flag circular import cycles and presentation-to-domain boundary leaks.",
|
|
687
|
+
"Emit actionable decoupling suggestions preserving public signatures.",
|
|
688
|
+
),
|
|
689
|
+
),
|
|
690
|
+
AgencySkill(
|
|
691
|
+
skill_id="reality-lock-verifier",
|
|
692
|
+
name="AST Reality-Lock Anti-Hallucination",
|
|
693
|
+
category="Verification",
|
|
694
|
+
summary="Verify referenced symbols, imports, and method calls against live repository AST.",
|
|
695
|
+
triggers=("hallucination", "verify", "symbol", "reality", "doğrula", "sembol"),
|
|
696
|
+
tools=("verify_hallucination_guard", "prove_zero_hallucination"),
|
|
697
|
+
tier="T-3",
|
|
698
|
+
checklist=(
|
|
699
|
+
"Verify every cited module, class, and function exists in the scanned AST.",
|
|
700
|
+
"Reject phantom imports or invented CLI flags before finalizing docs or patches.",
|
|
701
|
+
),
|
|
702
|
+
),
|
|
703
|
+
AgencySkill(
|
|
704
|
+
skill_id="tech-debt-surgeon",
|
|
705
|
+
name="Technical Debt & Clone Surgeon",
|
|
706
|
+
category="Code Quality",
|
|
707
|
+
summary="Detect high cyclomatic complexity, duplicate logic blocks, and orphaned helpers.",
|
|
708
|
+
triggers=("debt", "refactor", "clean", "duplicate", "dead", "kalite", "temizle"),
|
|
709
|
+
tools=("audit_codebase_quality", "find_code_duplicity", "find_dead_code"),
|
|
710
|
+
tier="T-2",
|
|
711
|
+
checklist=(
|
|
712
|
+
"Locate duplicate 6+ line blocks and long functions suitable for helper extraction.",
|
|
713
|
+
"Surface dead/unreferenced private helpers safely.",
|
|
714
|
+
),
|
|
715
|
+
),
|
|
716
|
+
AgencySkill(
|
|
717
|
+
skill_id="api-contract-mapper",
|
|
718
|
+
name="API, CLI & MCP Surface Mapper",
|
|
719
|
+
category="Backend & APIs",
|
|
720
|
+
summary="Extract FastAPI/Flask/Express routes, CLI flags, and MCP tool signatures automatically.",
|
|
721
|
+
triggers=("api", "rest", "endpoint", "route", "openapi", "graphql", "mcp", "cli"),
|
|
722
|
+
tools=("get_smart_skeleton_context", "analyze_code_dependencies"),
|
|
723
|
+
tier="T-2",
|
|
724
|
+
checklist=(
|
|
725
|
+
"Parse route decorators, OpenAPI specs, and argparse flags directly from source.",
|
|
726
|
+
"Verify endpoint docs match actual handler signatures.",
|
|
727
|
+
),
|
|
728
|
+
),
|
|
729
|
+
AgencySkill(
|
|
730
|
+
skill_id="test-coverage-architect",
|
|
731
|
+
name="Test Suite & Regression Architect",
|
|
732
|
+
category="Verification",
|
|
733
|
+
summary="Inspect test framework, identify untested modules, and plan unit/integration coverage.",
|
|
734
|
+
triggers=("test", "unittest", "pytest", "coverage", "doğrulama", "regresyon"),
|
|
735
|
+
tools=("run_local_ci", "execute_codebase_workflow"),
|
|
736
|
+
tier="T-2",
|
|
737
|
+
checklist=(
|
|
738
|
+
"Detect unittest, pytest, node --test, or cargo test runners automatically.",
|
|
739
|
+
"Map source modules lacking corresponding test files.",
|
|
740
|
+
),
|
|
741
|
+
),
|
|
742
|
+
AgencySkill(
|
|
743
|
+
skill_id="ci-cd-pipeline-smith",
|
|
744
|
+
name="CI/CD & Release Pipeline Smith",
|
|
745
|
+
category="DevOps & Release",
|
|
746
|
+
summary="Inspect GitHub Actions, Dockerfiles, and release scripts for matrix & parity readiness.",
|
|
747
|
+
triggers=("ci", "cd", "github actions", "docker", "workflow", "pipeline", "deploy"),
|
|
748
|
+
tools=("run_local_ci", "sync_workspace_rules"),
|
|
749
|
+
tier="T-2",
|
|
750
|
+
checklist=(
|
|
751
|
+
"Check multi-OS CI matrix coverage and secret-safe workflow permissions.",
|
|
752
|
+
"Verify local smoke commands align with remote CI workflows.",
|
|
753
|
+
),
|
|
754
|
+
),
|
|
755
|
+
AgencySkill(
|
|
756
|
+
skill_id="token-budget-optimizer",
|
|
757
|
+
name="Matryoshka Token Budget Optimizer",
|
|
758
|
+
category="FinOps & Context",
|
|
759
|
+
summary="Pack maximum structural signal into strict LLM token budgets with KV-cache alignment.",
|
|
760
|
+
triggers=("token", "budget", "cost", "compress", "tasarruf", "sıkıştır", "roi"),
|
|
761
|
+
tools=("estimate_token_cost", "get_token_savings_metrics", "build_project_context"),
|
|
762
|
+
tier="T-1",
|
|
763
|
+
checklist=(
|
|
764
|
+
"Measure raw vs AST-pruned BPE token counts across target source files.",
|
|
765
|
+
"Prioritize high-PageRank modules within the target context window.",
|
|
766
|
+
),
|
|
767
|
+
),
|
|
768
|
+
AgencySkill(
|
|
769
|
+
skill_id="release-launchpad",
|
|
770
|
+
name="Release Metadata & Tag Launchpad",
|
|
771
|
+
category="DevOps & Release",
|
|
772
|
+
summary="Audit cross-manifest version parity, release notes, and packaging sync before pushing.",
|
|
773
|
+
triggers=("release", "version", "bump", "tag", "yayın", "sürüm", "github", "pypi", "npm"),
|
|
774
|
+
tools=("run_local_ci", "verify_security_guard"),
|
|
775
|
+
tier="T-1",
|
|
776
|
+
checklist=(
|
|
777
|
+
"Verify version parity across pyproject.toml, package.json, server.json, and extensions.",
|
|
778
|
+
"Ensure docs/releases/vX.Y.Z.md exists before tagging.",
|
|
779
|
+
),
|
|
780
|
+
),
|
|
781
|
+
AgencySkill(
|
|
782
|
+
skill_id="polyglot-bridge-designer",
|
|
783
|
+
name="Polyglot FFI & Type Bridge Designer",
|
|
784
|
+
category="Architecture",
|
|
785
|
+
summary="Keep Python, TypeScript, Rust, and Go data contracts synchronized cleanly.",
|
|
786
|
+
triggers=("polyglot", "bridge", "typescript", "rust", "go", "schema", "types"),
|
|
787
|
+
tools=("transpile_model_bridge", "analyze_code_dependencies"),
|
|
788
|
+
tier="T-2",
|
|
789
|
+
checklist=(
|
|
790
|
+
"Identify cross-language boundaries and shared data models.",
|
|
791
|
+
"Generate typed interface definitions without runtime overhead.",
|
|
792
|
+
),
|
|
793
|
+
),
|
|
794
|
+
AgencySkill(
|
|
795
|
+
skill_id="doc-code-synchronizer",
|
|
796
|
+
name="Docs-to-AST Drift Synchronizer",
|
|
797
|
+
category="Documentation & Launch",
|
|
798
|
+
summary="Detect outdated README commands, stale version badges, and mismatched symbol names.",
|
|
799
|
+
triggers=("sync", "drift", "stale", "outdated", "güncelle", "uyum"),
|
|
800
|
+
tools=("analyze_instruction_drift", "get_project_context_tree"),
|
|
801
|
+
tier="T-2",
|
|
802
|
+
checklist=(
|
|
803
|
+
"Cross-check documented CLI flags and entrypoints against actual source code.",
|
|
804
|
+
"Highlight dead links or obsolete version references.",
|
|
805
|
+
),
|
|
806
|
+
),
|
|
807
|
+
AgencySkill(
|
|
808
|
+
skill_id="frontend-ux-auditor",
|
|
809
|
+
name="Frontend & Desktop UI/UX Auditor",
|
|
810
|
+
category="Web & Frontend",
|
|
811
|
+
summary="Inspect UI components, accessibility patterns, responsiveness, and layout structure.",
|
|
812
|
+
triggers=("ui", "ux", "gui", "frontend", "react", "tkinter", "html", "css", "arayüz"),
|
|
813
|
+
tools=("superdesign_extract_system", "superdesign_generate"),
|
|
814
|
+
tier="T-2",
|
|
815
|
+
checklist=(
|
|
816
|
+
"Keep heavy work off the UI thread and ensure responsive keyboard navigation.",
|
|
817
|
+
"Verify theme consistency and clean fallback states when data is empty.",
|
|
818
|
+
),
|
|
819
|
+
),
|
|
820
|
+
AgencySkill(
|
|
821
|
+
skill_id="database-schema-analyst",
|
|
822
|
+
name="Database & Migration Analyst",
|
|
823
|
+
category="Backend & APIs",
|
|
824
|
+
summary="Analyze SQL schemas, SQLite stores, and migration scripts for safety and indexing.",
|
|
825
|
+
triggers=("db", "database", "sql", "sqlite", "postgres", "migration", "schema", "veritabanı"),
|
|
826
|
+
tools=("search_codebase", "audit_codebase_quality"),
|
|
827
|
+
tier="T-2",
|
|
828
|
+
checklist=(
|
|
829
|
+
"Verify parameterized queries and absence of string-concatenated SQL.",
|
|
830
|
+
"Document table relationships and state persistence locations.",
|
|
831
|
+
),
|
|
832
|
+
),
|
|
833
|
+
AgencySkill(
|
|
834
|
+
skill_id="performance-bottleneck-hunter",
|
|
835
|
+
name="Complexity & Performance Profiler",
|
|
836
|
+
category="Performance",
|
|
837
|
+
summary="Identify nested loops, blocking I/O on hot paths, and caching opportunities.",
|
|
838
|
+
triggers=("perf", "performance", "speed", "latency", "hız", "performans", "optimize"),
|
|
839
|
+
tools=("audit_codebase_quality", "trace_symbol_call_chain"),
|
|
840
|
+
tier="T-2",
|
|
841
|
+
checklist=(
|
|
842
|
+
"Flag O(N^2) scans, unbuffered directory walks, and synchronous UI blocking.",
|
|
843
|
+
"Recommend targeted caching or batching strategies.",
|
|
844
|
+
),
|
|
845
|
+
),
|
|
846
|
+
AgencySkill(
|
|
847
|
+
skill_id="dependency-supply-guard",
|
|
848
|
+
name="Dependency & Supply-Chain Guard",
|
|
849
|
+
category="Security",
|
|
850
|
+
summary="Audit manifests and lockfiles for bloat, missing pins, or unsafe install hooks.",
|
|
851
|
+
triggers=("dependency", "deps", "supply", "package", "pip", "npm", "cargo", "bağımlılık"),
|
|
852
|
+
tools=("analyze_code_dependencies", "verify_security_guard"),
|
|
853
|
+
tier="T-2",
|
|
854
|
+
checklist=(
|
|
855
|
+
"Inspect package manifests for minimal runtime dependencies and clean lifecycle hooks.",
|
|
856
|
+
"Ensure optional dependencies degrade gracefully when absent.",
|
|
857
|
+
),
|
|
858
|
+
),
|
|
859
|
+
AgencySkill(
|
|
860
|
+
skill_id="onboarding-quickstart-writer",
|
|
861
|
+
name="30-Second Onboarding Quickstart Writer",
|
|
862
|
+
category="Documentation & Launch",
|
|
863
|
+
summary="Distill complex repositories into verified 3-step install and first-run commands.",
|
|
864
|
+
triggers=("quickstart", "onboarding", "install", "kurulum", "başlangıç", "guide"),
|
|
865
|
+
tools=("get_project_context_tree", "agency_generate_readme"),
|
|
866
|
+
tier="T-1",
|
|
867
|
+
checklist=(
|
|
868
|
+
"Verify every install and run command against pyproject.toml or package.json scripts.",
|
|
869
|
+
"Provide copy-pasteable commands for Windows, macOS, and Linux.",
|
|
870
|
+
),
|
|
871
|
+
),
|
|
872
|
+
AgencySkill(
|
|
873
|
+
skill_id="monorepo-navigator",
|
|
874
|
+
name="Monorepo Cross-Package Navigator",
|
|
875
|
+
category="Architecture",
|
|
876
|
+
summary="Map multi-package directory hierarchies, shared utilities, and sync scripts.",
|
|
877
|
+
triggers=("monorepo", "packages", "workspace", "subproject", "modül"),
|
|
878
|
+
tools=("generate_repo_map", "rank_repository_pagerank"),
|
|
879
|
+
tier="T-1",
|
|
880
|
+
checklist=(
|
|
881
|
+
"Inventory every subpackage, extension, and installer directory.",
|
|
882
|
+
"Document single-source synchronization workflows between packages.",
|
|
883
|
+
),
|
|
884
|
+
),
|
|
885
|
+
AgencySkill(
|
|
886
|
+
skill_id="pr-blast-radius-reviewer",
|
|
887
|
+
name="PR & Change Blast-Radius Reviewer",
|
|
888
|
+
category="Verification",
|
|
889
|
+
summary="Compute caller impact, contract breaks, and incremental diff context before merging.",
|
|
890
|
+
triggers=("pr", "diff", "impact", "blast", "review", "etki", "değişiklik"),
|
|
891
|
+
tools=("analyze_change_impact", "get_incremental_diff_context"),
|
|
892
|
+
tier="T-2",
|
|
893
|
+
checklist=(
|
|
894
|
+
"Trace upstream callers and downstream tests affected by modified symbols.",
|
|
895
|
+
"Verify public signatures remain backward compatible.",
|
|
896
|
+
),
|
|
897
|
+
),
|
|
898
|
+
AgencySkill(
|
|
899
|
+
skill_id="growth-launch-strategist",
|
|
900
|
+
name="Open-Source Launch & Proof Strategist",
|
|
901
|
+
category="Documentation & Launch",
|
|
902
|
+
summary="Craft proof-first README positioning, badges, llms.txt, and launch checklists.",
|
|
903
|
+
triggers=("growth", "star", "launch", "marketing", "product hunt", "hacker news", "büyüme"),
|
|
904
|
+
tools=("agency_generate_readme", "generate_architecture_blueprint"),
|
|
905
|
+
tier="T-1",
|
|
906
|
+
checklist=(
|
|
907
|
+
"Lead with concrete before/after proof and real measured numbers.",
|
|
908
|
+
"Verify llms.txt and machine-readable metadata stay accurate.",
|
|
909
|
+
),
|
|
910
|
+
),
|
|
911
|
+
AgencySkill(
|
|
912
|
+
skill_id="incident-postmortem-debugger",
|
|
913
|
+
name="Traceback & Incident Triage Debugger",
|
|
914
|
+
category="Verification",
|
|
915
|
+
summary="Diagnose stack traces, missing imports, or broken configs using AST context.",
|
|
916
|
+
triggers=("bug", "fix", "error", "traceback", "crash", "hata", "çöz", "düzelt"),
|
|
917
|
+
tools=("diagnose_and_heal_system", "trace_symbol_call_chain"),
|
|
918
|
+
tier="T-3",
|
|
919
|
+
checklist=(
|
|
920
|
+
"Isolate root cause across call chains before proposing surgical edits.",
|
|
921
|
+
"Add a regression test reproducing the failure prior to fixing.",
|
|
922
|
+
),
|
|
923
|
+
),
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
# =============================================================================
|
|
928
|
+
# 3. 16 SPECIALIZED SUBAGENT TEMPLATES
|
|
929
|
+
# =============================================================================
|
|
930
|
+
|
|
931
|
+
@dataclass(frozen=True)
|
|
932
|
+
class SubagentTemplate:
|
|
933
|
+
"""Reusable subagent role blueprint for multi-agent orchestration."""
|
|
934
|
+
|
|
935
|
+
template_id: str
|
|
936
|
+
role_name: str
|
|
937
|
+
specialty: str
|
|
938
|
+
tier: str
|
|
939
|
+
wave: int
|
|
940
|
+
allowed_tools: Tuple[str, ...]
|
|
941
|
+
skills: Tuple[str, ...]
|
|
942
|
+
triggers: Tuple[str, ...]
|
|
943
|
+
handoff_to: Tuple[str, ...]
|
|
944
|
+
system_prompt: str
|
|
945
|
+
deliverable: str
|
|
946
|
+
|
|
947
|
+
def to_agent_json(self) -> Dict[str, Any]:
|
|
948
|
+
return {
|
|
949
|
+
"id": self.template_id,
|
|
950
|
+
"name": self.role_name,
|
|
951
|
+
"specialty": self.specialty,
|
|
952
|
+
"wave": self.wave,
|
|
953
|
+
"context_isolation": {
|
|
954
|
+
"tier": self.tier,
|
|
955
|
+
"max_tokens": 16000,
|
|
956
|
+
"inward_dependencies_only": True,
|
|
957
|
+
},
|
|
958
|
+
"allowed_tools": list(self.allowed_tools),
|
|
959
|
+
"skills": list(self.skills),
|
|
960
|
+
"handoff_to": list(self.handoff_to),
|
|
961
|
+
"deliverable": self.deliverable,
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
def to_skill_markdown(self) -> str:
|
|
965
|
+
tools = "\n".join(f"- `{t}`" for t in self.allowed_tools)
|
|
966
|
+
skills = ", ".join(f"`{s}`" for s in self.skills)
|
|
967
|
+
handoffs = ", ".join(f"`{h}`" for h in self.handoff_to) or "Final Synthesis"
|
|
968
|
+
return (
|
|
969
|
+
f"---\n"
|
|
970
|
+
f"name: {self.template_id}\n"
|
|
971
|
+
f"description: {self.specialty}\n"
|
|
972
|
+
f"---\n\n"
|
|
973
|
+
f"# Subagent Template: {self.role_name}\n\n"
|
|
974
|
+
f"- **Template ID:** `{self.template_id}`\n"
|
|
975
|
+
f"- **Execution Wave:** Wave {self.wave}\n"
|
|
976
|
+
f"- **Context Tier:** `{self.tier}`\n"
|
|
977
|
+
f"- **Bound Skills:** {skills}\n"
|
|
978
|
+
f"- **Handoff Targets:** {handoffs}\n"
|
|
979
|
+
f"- **Expected Deliverable:** {self.deliverable}\n\n"
|
|
980
|
+
f"## System Directive\n"
|
|
981
|
+
f"{self.system_prompt}\n\n"
|
|
982
|
+
f"## Allowed Tools\n"
|
|
983
|
+
f"{tools}\n"
|
|
984
|
+
)
|
|
985
|
+
|
|
986
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
987
|
+
return asdict(self)
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
SUBAGENT_TEMPLATES: Tuple[SubagentTemplate, ...] = (
|
|
991
|
+
SubagentTemplate(
|
|
992
|
+
template_id="agency-lead-orchestrator",
|
|
993
|
+
role_name="AgencyLeadOrchestrator",
|
|
994
|
+
specialty="Decomposes composite missions, matches repo topology, and synthesizes consensus.",
|
|
995
|
+
tier="T-1",
|
|
996
|
+
wave=3,
|
|
997
|
+
allowed_tools=("execute_codebase_workflow", "orchestrate_agent_swarm", "get_project_context_tree"),
|
|
998
|
+
skills=("agent-squad-assembler", "subagent-blueprint-forge"),
|
|
999
|
+
triggers=("all", "full", "agency", "orchestrate", "plan", "tam", "hepsi", "yönet"),
|
|
1000
|
+
handoff_to=(),
|
|
1001
|
+
system_prompt=(
|
|
1002
|
+
"You are the Lead Agency Orchestrator. Decompose the user goal against the verified workspace "
|
|
1003
|
+
"profile, dispatch independent specialists in parallel, resolve conflicts, and deliver a concise "
|
|
1004
|
+
"verified summary grounded strictly in tool outputs."
|
|
1005
|
+
),
|
|
1006
|
+
deliverable="Executive Agency Dossier with Mermaid DAG and verified next steps.",
|
|
1007
|
+
),
|
|
1008
|
+
SubagentTemplate(
|
|
1009
|
+
template_id="repo-cartographer",
|
|
1010
|
+
role_name="RepoCartographerAgent",
|
|
1011
|
+
specialty="Maps directory topology, manifests, language stack, and PageRank backbone modules.",
|
|
1012
|
+
tier="T-1",
|
|
1013
|
+
wave=1,
|
|
1014
|
+
allowed_tools=("get_project_context_tree", "rank_repository_pagerank", "generate_repo_map"),
|
|
1015
|
+
skills=("repo-architect-profiler", "monorepo-navigator"),
|
|
1016
|
+
triggers=("scan", "map", "structure", "repo", "mimari", "yapı", "tara", "anla"),
|
|
1017
|
+
handoff_to=("readme-architect", "architecture-boundary-guardian", "qa-test-architect"),
|
|
1018
|
+
system_prompt=(
|
|
1019
|
+
"Scan the repository deterministically first. Identify real entrypoints, manifests, test suites, "
|
|
1020
|
+
"and highest-centrality modules before any specialist edits or documents code."
|
|
1021
|
+
),
|
|
1022
|
+
deliverable="Structured ProjectProfile JSON and ranked module map.",
|
|
1023
|
+
),
|
|
1024
|
+
SubagentTemplate(
|
|
1025
|
+
template_id="readme-architect",
|
|
1026
|
+
role_name="ReadmeArchitectAgent",
|
|
1027
|
+
specialty="Selects optimal blueprint from 448 domain x style combinations and drafts README.md.",
|
|
1028
|
+
tier="T-2",
|
|
1029
|
+
wave=2,
|
|
1030
|
+
allowed_tools=("get_project_context_tree", "generate_architecture_blueprint"),
|
|
1031
|
+
skills=("readme-448-synthesizer", "onboarding-quickstart-writer", "growth-launch-strategist"),
|
|
1032
|
+
triggers=("readme", "docs", "documentation", "tanıtım", "yaz", "üret"),
|
|
1033
|
+
handoff_to=("reality-lock-auditor", "docs-sync-localizer"),
|
|
1034
|
+
system_prompt=(
|
|
1035
|
+
"Generate clear, evidence-backed README documentation strictly from inspected files, scripts, "
|
|
1036
|
+
"and test commands. Never invent badges, commands, or unverified benchmark numbers."
|
|
1037
|
+
),
|
|
1038
|
+
deliverable="Repo-grounded README.md tailored to detected domain and selected style.",
|
|
1039
|
+
),
|
|
1040
|
+
SubagentTemplate(
|
|
1041
|
+
template_id="skill-smith",
|
|
1042
|
+
role_name="SkillSmithAgent",
|
|
1043
|
+
specialty="Packages reusable SKILL.md modules and portable subagent templates into .tzero/agency/.",
|
|
1044
|
+
tier="T-2",
|
|
1045
|
+
wave=2,
|
|
1046
|
+
allowed_tools=("export_agent_rules", "manage_architecture_rules"),
|
|
1047
|
+
skills=("subagent-blueprint-forge",),
|
|
1048
|
+
triggers=("skill", "template", "subagent", "şablon", "agent", "yetkinlik"),
|
|
1049
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1050
|
+
system_prompt=(
|
|
1051
|
+
"Synthesize concise, single-purpose SKILL.md and agent.json templates matched to the repository "
|
|
1052
|
+
"stack with explicit tool permissions and verification gates."
|
|
1053
|
+
),
|
|
1054
|
+
deliverable="Exported `.tzero/agency/` skills and subagent template packs.",
|
|
1055
|
+
),
|
|
1056
|
+
SubagentTemplate(
|
|
1057
|
+
template_id="backend-systems-engineer",
|
|
1058
|
+
role_name="BackendSystemsAgent",
|
|
1059
|
+
specialty="Analyzes API endpoints, async services, MCP servers, and database boundaries.",
|
|
1060
|
+
tier="T-2",
|
|
1061
|
+
wave=2,
|
|
1062
|
+
allowed_tools=("get_smart_skeleton_context", "analyze_code_dependencies", "search_codebase"),
|
|
1063
|
+
skills=("api-contract-mapper", "database-schema-analyst"),
|
|
1064
|
+
triggers=("api", "backend", "server", "endpoint", "mcp", "fastapi", "django", "flask", "db", "sql"),
|
|
1065
|
+
handoff_to=("qa-test-architect", "security-zero-leak-sentinel"),
|
|
1066
|
+
system_prompt=(
|
|
1067
|
+
"Inspect backend handlers, request schemas, error handling, and database access using AST "
|
|
1068
|
+
"skeletons while keeping service logic decoupled from transport details."
|
|
1069
|
+
),
|
|
1070
|
+
deliverable="API/MCP contract surface inventory and backend integration recommendations.",
|
|
1071
|
+
),
|
|
1072
|
+
SubagentTemplate(
|
|
1073
|
+
template_id="frontend-ux-specialist",
|
|
1074
|
+
role_name="FrontendUXAgent",
|
|
1075
|
+
specialty="Audits React/Next.js/HTML/Tkinter UI trees, accessibility, and responsive state.",
|
|
1076
|
+
tier="T-2",
|
|
1077
|
+
wave=2,
|
|
1078
|
+
allowed_tools=("superdesign_extract_system", "superdesign_generate", "get_smart_skeleton_context"),
|
|
1079
|
+
skills=("frontend-ux-auditor",),
|
|
1080
|
+
triggers=("ui", "ux", "gui", "frontend", "react", "next", "tkinter", "html", "css", "arayüz", "tasarım"),
|
|
1081
|
+
handoff_to=("qa-test-architect", "agency-lead-orchestrator"),
|
|
1082
|
+
system_prompt=(
|
|
1083
|
+
"Keep UI layouts clean, non-blocking on background work, accessible via keyboard, and tested "
|
|
1084
|
+
"with headless or widget assertions."
|
|
1085
|
+
),
|
|
1086
|
+
deliverable="UI layout map, responsiveness checklist, and UX improvement plan.",
|
|
1087
|
+
),
|
|
1088
|
+
SubagentTemplate(
|
|
1089
|
+
template_id="security-zero-leak-sentinel",
|
|
1090
|
+
role_name="SecurityZeroLeakAgent",
|
|
1091
|
+
specialty="Enforces T-001 zero-leak hygiene, taint flow checks, and supply-chain verification.",
|
|
1092
|
+
tier="T-4",
|
|
1093
|
+
wave=2,
|
|
1094
|
+
allowed_tools=("verify_security_guard", "audit_codebase_quality"),
|
|
1095
|
+
skills=("zero-leak-security-gate", "dependency-supply-guard"),
|
|
1096
|
+
triggers=("security", "secret", "leak", "audit", "auth", "güvenlik", "sızıntı", "denet"),
|
|
1097
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1098
|
+
system_prompt=(
|
|
1099
|
+
"Audit every file locally for credential patterns, high-entropy literals, and unsafe sinks. "
|
|
1100
|
+
"Report redacted locations and remediation steps without ever printing raw secrets."
|
|
1101
|
+
),
|
|
1102
|
+
deliverable="Zero-Leak security audit verdict and sanitized findings report.",
|
|
1103
|
+
),
|
|
1104
|
+
SubagentTemplate(
|
|
1105
|
+
template_id="architecture-boundary-guardian",
|
|
1106
|
+
role_name="ArchitectureBoundaryAgent",
|
|
1107
|
+
specialty="Enforces T-002 inward-only dependencies, circular import checks, and Mermaid blueprints.",
|
|
1108
|
+
tier="T-2",
|
|
1109
|
+
wave=2,
|
|
1110
|
+
allowed_tools=("enforce_architecture_boundaries", "query_architecture_boundaries", "generate_architecture_blueprint"),
|
|
1111
|
+
skills=("ast-boundary-enforcer", "polyglot-bridge-designer"),
|
|
1112
|
+
triggers=("architect", "boundary", "layer", "cycle", "mimari", "katman", "sınır", "tasarım"),
|
|
1113
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1114
|
+
system_prompt=(
|
|
1115
|
+
"Verify dependency directions across packages and generate up-to-date Mermaid architecture "
|
|
1116
|
+
"topology grounded in real imports."
|
|
1117
|
+
),
|
|
1118
|
+
deliverable="Architectural boundary compliance report and live Mermaid topology.",
|
|
1119
|
+
),
|
|
1120
|
+
SubagentTemplate(
|
|
1121
|
+
template_id="qa-test-architect",
|
|
1122
|
+
role_name="QATestArchitectAgent",
|
|
1123
|
+
specialty="Plans unit, integration, CLI, GUI, and regression verification suites.",
|
|
1124
|
+
tier="T-2",
|
|
1125
|
+
wave=2,
|
|
1126
|
+
allowed_tools=("run_local_ci", "analyze_change_impact"),
|
|
1127
|
+
skills=("test-coverage-architect", "pr-blast-radius-reviewer"),
|
|
1128
|
+
triggers=("test", "qa", "coverage", "ci", "regression", "doğrula", "kalite"),
|
|
1129
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1130
|
+
system_prompt=(
|
|
1131
|
+
"Identify untested modules, verify existing test runners pass end-to-end, and enforce "
|
|
1132
|
+
"red-green verification before any completion claim."
|
|
1133
|
+
),
|
|
1134
|
+
deliverable="Test coverage gap map and verified execution checklist.",
|
|
1135
|
+
),
|
|
1136
|
+
SubagentTemplate(
|
|
1137
|
+
template_id="devops-release-commander",
|
|
1138
|
+
role_name="DevOpsReleaseAgent",
|
|
1139
|
+
specialty="Prepares CI workflows, version synchronization, packaging, and GitHub release gates.",
|
|
1140
|
+
tier="T-1",
|
|
1141
|
+
wave=2,
|
|
1142
|
+
allowed_tools=("run_local_ci", "sync_workspace_rules"),
|
|
1143
|
+
skills=("ci-cd-pipeline-smith", "release-launchpad"),
|
|
1144
|
+
triggers=("release", "publish", "github", "docker", "ci", "cd", "npm", "pypi", "yayın", "sürüm"),
|
|
1145
|
+
handoff_to=("security-zero-leak-sentinel", "agency-lead-orchestrator"),
|
|
1146
|
+
system_prompt=(
|
|
1147
|
+
"Check release metadata parity, CI matrix coverage, and packaging inclusions before tagging "
|
|
1148
|
+
"or publishing."
|
|
1149
|
+
),
|
|
1150
|
+
deliverable="Release readiness checklist and metadata sync verification.",
|
|
1151
|
+
),
|
|
1152
|
+
SubagentTemplate(
|
|
1153
|
+
template_id="data-ml-engineer",
|
|
1154
|
+
role_name="DataMLPipelineAgent",
|
|
1155
|
+
specialty="Reviews datasets, benchmarks, tokenizers, and reproducible experiment scripts.",
|
|
1156
|
+
tier="T-2",
|
|
1157
|
+
wave=2,
|
|
1158
|
+
allowed_tools=("search_codebase", "estimate_token_cost"),
|
|
1159
|
+
skills=("token-budget-optimizer",),
|
|
1160
|
+
triggers=("ml", "ai", "model", "benchmark", "data", "dataset", "etl", "pipeline", "veri"),
|
|
1161
|
+
handoff_to=("qa-test-architect", "readme-architect"),
|
|
1162
|
+
system_prompt=(
|
|
1163
|
+
"Ensure dataset schemas, evaluation baselines, and reproducible benchmark commands are "
|
|
1164
|
+
"explicitly documented and deterministic."
|
|
1165
|
+
),
|
|
1166
|
+
deliverable="Benchmark & data pipeline integrity assessment.",
|
|
1167
|
+
),
|
|
1168
|
+
SubagentTemplate(
|
|
1169
|
+
template_id="performance-token-finops",
|
|
1170
|
+
role_name="PerformanceTokenAgent",
|
|
1171
|
+
specialty="Optimizes algorithmic latency, AST skeleton token savings, and KV-cache prefix order.",
|
|
1172
|
+
tier="T-2",
|
|
1173
|
+
wave=2,
|
|
1174
|
+
allowed_tools=("get_token_savings_metrics", "estimate_token_cost", "calculate_token_cost_roi"),
|
|
1175
|
+
skills=("token-budget-optimizer", "performance-bottleneck-hunter"),
|
|
1176
|
+
triggers=("perf", "speed", "token", "cost", "budget", "roi", "hız", "performans", "maliyet"),
|
|
1177
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1178
|
+
system_prompt=(
|
|
1179
|
+
"Measure exact token compression ratios, locate high-complexity hotspots, and prioritize "
|
|
1180
|
+
"high-PageRank modules inside token budgets."
|
|
1181
|
+
),
|
|
1182
|
+
deliverable="Token ROI & complexity optimization report.",
|
|
1183
|
+
),
|
|
1184
|
+
SubagentTemplate(
|
|
1185
|
+
template_id="refactor-clean-code",
|
|
1186
|
+
role_name="RefactorCleanCodeAgent",
|
|
1187
|
+
specialty="Eliminates duplicate code blocks, dead helpers, and overgrown functions cleanly.",
|
|
1188
|
+
tier="T-3",
|
|
1189
|
+
wave=2,
|
|
1190
|
+
allowed_tools=("find_code_duplicity", "find_dead_code", "audit_codebase_quality"),
|
|
1191
|
+
skills=("tech-debt-surgeon", "pr-blast-radius-reviewer"),
|
|
1192
|
+
triggers=("refactor", "clean", "duplicate", "dead", "smell", "temiz", "düzenle"),
|
|
1193
|
+
handoff_to=("qa-test-architect", "reality-lock-auditor"),
|
|
1194
|
+
system_prompt=(
|
|
1195
|
+
"Extract shared helpers without breaking public signatures, preserve existing comments, "
|
|
1196
|
+
"and verify callers via blast-radius analysis."
|
|
1197
|
+
),
|
|
1198
|
+
deliverable="Surgical refactoring plan targeting duplicates and complexity.",
|
|
1199
|
+
),
|
|
1200
|
+
SubagentTemplate(
|
|
1201
|
+
template_id="reality-lock-auditor",
|
|
1202
|
+
role_name="HallucinationGuardAgent",
|
|
1203
|
+
specialty="Validates every symbol, file path, and import against verified AST facts.",
|
|
1204
|
+
tier="T-3",
|
|
1205
|
+
wave=3,
|
|
1206
|
+
allowed_tools=("verify_hallucination_guard", "prove_zero_hallucination"),
|
|
1207
|
+
skills=("reality-lock-verifier",),
|
|
1208
|
+
triggers=("verify", "hallucination", "guard", "check", "doğrula", "kontrol"),
|
|
1209
|
+
handoff_to=("agency-lead-orchestrator",),
|
|
1210
|
+
system_prompt=(
|
|
1211
|
+
"Run static AST reality checks on generated code and documentation so zero non-existent "
|
|
1212
|
+
"symbols, paths, or commands ship."
|
|
1213
|
+
),
|
|
1214
|
+
deliverable="Reality-Lock pass/fail verification report.",
|
|
1215
|
+
),
|
|
1216
|
+
SubagentTemplate(
|
|
1217
|
+
template_id="docs-sync-localizer",
|
|
1218
|
+
role_name="DocsLocalizationAgent",
|
|
1219
|
+
specialty="Keeps README, translations, AI_INSPECTION.md, and llms.txt aligned with live code.",
|
|
1220
|
+
tier="T-2",
|
|
1221
|
+
wave=2,
|
|
1222
|
+
allowed_tools=("analyze_instruction_drift", "generate_repo_map"),
|
|
1223
|
+
skills=("doc-code-synchronizer", "onboarding-quickstart-writer"),
|
|
1224
|
+
triggers=("doc", "translate", "turkish", "tr", "llms.txt", "çeviri", "belge"),
|
|
1225
|
+
handoff_to=("reality-lock-auditor",),
|
|
1226
|
+
system_prompt=(
|
|
1227
|
+
"Compare documentation claims and CLI examples against current source definitions and fix "
|
|
1228
|
+
"stale version tags or commands."
|
|
1229
|
+
),
|
|
1230
|
+
deliverable="Doc-to-code drift report and localized onboarding updates.",
|
|
1231
|
+
),
|
|
1232
|
+
SubagentTemplate(
|
|
1233
|
+
template_id="incident-debugger",
|
|
1234
|
+
role_name="IncidentDebuggerAgent",
|
|
1235
|
+
specialty="Traces crashes, failing tests, and broken imports to root cause.",
|
|
1236
|
+
tier="T-3",
|
|
1237
|
+
wave=2,
|
|
1238
|
+
allowed_tools=("diagnose_and_heal_system", "trace_symbol_call_chain"),
|
|
1239
|
+
skills=("incident-postmortem-debugger",),
|
|
1240
|
+
triggers=("bug", "fix", "error", "traceback", "fail", "broken", "hata", "arıza", "çöz"),
|
|
1241
|
+
handoff_to=("qa-test-architect", "reality-lock-auditor"),
|
|
1242
|
+
system_prompt=(
|
|
1243
|
+
"Trace failing execution paths across callers and callees, inspect edge conditions, and "
|
|
1244
|
+
"propose minimal targeted fixes."
|
|
1245
|
+
),
|
|
1246
|
+
deliverable="Root-cause diagnosis and verified remediation steps.",
|
|
1247
|
+
),
|
|
1248
|
+
)
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
# =============================================================================
|
|
1252
|
+
# 4. WORKSPACE INTELLIGENCE PROFILER
|
|
1253
|
+
# =============================================================================
|
|
1254
|
+
|
|
1255
|
+
@dataclass
|
|
1256
|
+
class ProjectProfile:
|
|
1257
|
+
"""Deterministic structural & stack fingerprint of a target workspace."""
|
|
1258
|
+
|
|
1259
|
+
project_name: str
|
|
1260
|
+
root_dir: str
|
|
1261
|
+
version: str
|
|
1262
|
+
description: str
|
|
1263
|
+
license_name: str
|
|
1264
|
+
total_files: int
|
|
1265
|
+
languages: Dict[str, int]
|
|
1266
|
+
primary_language: str
|
|
1267
|
+
detected_frameworks: List[str]
|
|
1268
|
+
detected_domains: List[str]
|
|
1269
|
+
primary_domain: str
|
|
1270
|
+
entrypoints: List[str]
|
|
1271
|
+
cli_commands: List[str]
|
|
1272
|
+
dependencies: List[str]
|
|
1273
|
+
test_command: str
|
|
1274
|
+
test_files_count: int
|
|
1275
|
+
top_symbols: List[str]
|
|
1276
|
+
has_ci: bool
|
|
1277
|
+
has_docker: bool
|
|
1278
|
+
has_mcp: bool
|
|
1279
|
+
has_gui: bool
|
|
1280
|
+
has_tests: bool
|
|
1281
|
+
is_monorepo: bool
|
|
1282
|
+
raw_tokens_est: int
|
|
1283
|
+
pruned_tokens_est: int
|
|
1284
|
+
savings_pct: float
|
|
1285
|
+
sample_files: List[str]
|
|
1286
|
+
layers: Dict[str, List[str]] = field(default_factory=dict)
|
|
1287
|
+
|
|
1288
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
1289
|
+
return asdict(self)
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
class AgencyProjectProfiler:
|
|
1293
|
+
"""Inspects any workspace locally in milliseconds to ground Agency decisions."""
|
|
1294
|
+
|
|
1295
|
+
@staticmethod
|
|
1296
|
+
def _walk_workspace(root: Path, max_files: int = 1200) -> Tuple[List[str], Dict[str, int], int]:
|
|
1297
|
+
files: List[str] = []
|
|
1298
|
+
lang_counts: Dict[str, int] = {}
|
|
1299
|
+
raw_bytes = 0
|
|
1300
|
+
|
|
1301
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
1302
|
+
dirnames[:] = sorted(
|
|
1303
|
+
d for d in dirnames
|
|
1304
|
+
if d not in IGNORED_DIRS and not d.endswith(".egg-info")
|
|
1305
|
+
)
|
|
1306
|
+
for fname in sorted(filenames):
|
|
1307
|
+
full_p = Path(dirpath) / fname
|
|
1308
|
+
rel = full_p.relative_to(root).as_posix()
|
|
1309
|
+
files.append(rel)
|
|
1310
|
+
ext = full_p.suffix.lower()
|
|
1311
|
+
if ext in LANGUAGE_EXTENSIONS:
|
|
1312
|
+
lang = LANGUAGE_EXTENSIONS[ext]
|
|
1313
|
+
lang_counts[lang] = lang_counts.get(lang, 0) + 1
|
|
1314
|
+
try:
|
|
1315
|
+
raw_bytes += min(full_p.stat().st_size, 512_000)
|
|
1316
|
+
except OSError:
|
|
1317
|
+
pass
|
|
1318
|
+
if len(files) >= max_files:
|
|
1319
|
+
return files, lang_counts, raw_bytes
|
|
1320
|
+
return files, lang_counts, raw_bytes
|
|
1321
|
+
|
|
1322
|
+
@staticmethod
|
|
1323
|
+
def _read_manifests(root: Path) -> Dict[str, Any]:
|
|
1324
|
+
meta: Dict[str, Any] = {
|
|
1325
|
+
"name": root.name or "Project",
|
|
1326
|
+
"version": "0.1.0",
|
|
1327
|
+
"description": "",
|
|
1328
|
+
"license": "MIT",
|
|
1329
|
+
"cli_commands": [],
|
|
1330
|
+
"dependencies": [],
|
|
1331
|
+
"test_command": "python -m unittest discover -v",
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
pyproject_path = root / "pyproject.toml"
|
|
1335
|
+
if pyproject_path.is_file():
|
|
1336
|
+
try:
|
|
1337
|
+
import tomllib
|
|
1338
|
+
data = tomllib.loads(pyproject_path.read_text(encoding="utf-8", errors="ignore"))
|
|
1339
|
+
proj = data.get("project", {})
|
|
1340
|
+
meta["name"] = proj.get("name") or meta["name"]
|
|
1341
|
+
meta["version"] = proj.get("version") or meta["version"]
|
|
1342
|
+
meta["description"] = proj.get("description") or meta["description"]
|
|
1343
|
+
lic = proj.get("license")
|
|
1344
|
+
if isinstance(lic, dict):
|
|
1345
|
+
meta["license"] = lic.get("text") or meta["license"]
|
|
1346
|
+
elif isinstance(lic, str) and lic:
|
|
1347
|
+
meta["license"] = lic
|
|
1348
|
+
scripts = proj.get("scripts", {})
|
|
1349
|
+
if isinstance(scripts, dict):
|
|
1350
|
+
meta["cli_commands"].extend(list(scripts.keys())[:10])
|
|
1351
|
+
deps = proj.get("dependencies", [])
|
|
1352
|
+
if isinstance(deps, list):
|
|
1353
|
+
for dep in deps[:20]:
|
|
1354
|
+
pkg = re.split(r"[<>=!~;\s\[]", str(dep), maxsplit=1)[0]
|
|
1355
|
+
if pkg:
|
|
1356
|
+
meta["dependencies"].append(pkg)
|
|
1357
|
+
except Exception:
|
|
1358
|
+
pass
|
|
1359
|
+
|
|
1360
|
+
pkg_json_path = root / "package.json"
|
|
1361
|
+
if pkg_json_path.is_file():
|
|
1362
|
+
try:
|
|
1363
|
+
pdata = json.loads(pkg_json_path.read_text(encoding="utf-8", errors="ignore"))
|
|
1364
|
+
if meta["version"] == "0.1.0" and pdata.get("version"):
|
|
1365
|
+
meta["version"] = str(pdata["version"])
|
|
1366
|
+
if not meta["description"] and pdata.get("description"):
|
|
1367
|
+
meta["description"] = str(pdata["description"])
|
|
1368
|
+
if pdata.get("license"):
|
|
1369
|
+
meta["license"] = str(pdata["license"])
|
|
1370
|
+
bins = pdata.get("bin")
|
|
1371
|
+
if isinstance(bins, dict):
|
|
1372
|
+
meta["cli_commands"].extend(list(bins.keys())[:6])
|
|
1373
|
+
elif isinstance(bins, str) and pdata.get("name"):
|
|
1374
|
+
meta["cli_commands"].append(str(pdata["name"]))
|
|
1375
|
+
for section in ("dependencies", "devDependencies"):
|
|
1376
|
+
sec = pdata.get(section, {})
|
|
1377
|
+
if isinstance(sec, dict):
|
|
1378
|
+
for k in list(sec.keys())[:12]:
|
|
1379
|
+
if k not in meta["dependencies"]:
|
|
1380
|
+
meta["dependencies"].append(k)
|
|
1381
|
+
scripts = pdata.get("scripts", {})
|
|
1382
|
+
if isinstance(scripts, dict) and "test" in scripts and not pyproject_path.is_file():
|
|
1383
|
+
meta["test_command"] = "npm test"
|
|
1384
|
+
except Exception:
|
|
1385
|
+
pass
|
|
1386
|
+
|
|
1387
|
+
cargo_path = root / "Cargo.toml"
|
|
1388
|
+
if cargo_path.is_file():
|
|
1389
|
+
try:
|
|
1390
|
+
import tomllib
|
|
1391
|
+
cdata = tomllib.loads(cargo_path.read_text(encoding="utf-8", errors="ignore"))
|
|
1392
|
+
cpkg = cdata.get("package", {})
|
|
1393
|
+
if cpkg.get("name") and not pyproject_path.is_file():
|
|
1394
|
+
meta["name"] = cpkg["name"]
|
|
1395
|
+
if cpkg.get("version") and meta["version"] == "0.1.0":
|
|
1396
|
+
meta["version"] = cpkg["version"]
|
|
1397
|
+
if not pyproject_path.is_file() and not pkg_json_path.is_file():
|
|
1398
|
+
meta["test_command"] = "cargo test"
|
|
1399
|
+
except Exception:
|
|
1400
|
+
pass
|
|
1401
|
+
|
|
1402
|
+
if (root / "go.mod").is_file() and not pyproject_path.is_file():
|
|
1403
|
+
meta["test_command"] = "go test ./..."
|
|
1404
|
+
|
|
1405
|
+
req_path = root / "requirements.txt"
|
|
1406
|
+
if req_path.is_file():
|
|
1407
|
+
try:
|
|
1408
|
+
for line in req_path.read_text(encoding="utf-8", errors="ignore").splitlines():
|
|
1409
|
+
clean = line.strip()
|
|
1410
|
+
if clean and not clean.startswith("#"):
|
|
1411
|
+
pkg = re.split(r"[<>=!~;\s\[]", clean, maxsplit=1)[0]
|
|
1412
|
+
if pkg and pkg not in meta["dependencies"]:
|
|
1413
|
+
meta["dependencies"].append(pkg)
|
|
1414
|
+
except Exception:
|
|
1415
|
+
pass
|
|
1416
|
+
|
|
1417
|
+
return meta
|
|
1418
|
+
|
|
1419
|
+
@staticmethod
|
|
1420
|
+
def _extract_top_symbols(root: Path, files: Sequence[str], max_files: int = 25) -> List[str]:
|
|
1421
|
+
symbols: List[str] = []
|
|
1422
|
+
py_files = [f for f in files if f.endswith(".py") and not f.startswith("tests/")][:max_files]
|
|
1423
|
+
for rel in py_files:
|
|
1424
|
+
try:
|
|
1425
|
+
src = (root / rel).read_text(encoding="utf-8", errors="ignore")
|
|
1426
|
+
tree = ast.parse(src)
|
|
1427
|
+
for node in tree.body:
|
|
1428
|
+
if isinstance(node, ast.ClassDef) and not node.name.startswith("_"):
|
|
1429
|
+
symbols.append(f"{rel}:class {node.name}")
|
|
1430
|
+
elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and not node.name.startswith("_"):
|
|
1431
|
+
symbols.append(f"{rel}:def {node.name}()")
|
|
1432
|
+
if len(symbols) >= 24:
|
|
1433
|
+
return symbols
|
|
1434
|
+
except Exception:
|
|
1435
|
+
continue
|
|
1436
|
+
return symbols
|
|
1437
|
+
|
|
1438
|
+
@classmethod
|
|
1439
|
+
def profile_workspace(cls, project_dir: str = ".") -> ProjectProfile:
|
|
1440
|
+
root = Path(project_dir).resolve()
|
|
1441
|
+
if not root.exists() or not root.is_dir():
|
|
1442
|
+
raise FileNotFoundError(f"Workspace directory not found: {root}")
|
|
1443
|
+
|
|
1444
|
+
files, lang_counts, raw_bytes = cls._walk_workspace(root)
|
|
1445
|
+
meta = cls._read_manifests(root)
|
|
1446
|
+
lower_files = [f.lower() for f in files]
|
|
1447
|
+
deps_lower = " ".join(meta["dependencies"]).lower()
|
|
1448
|
+
|
|
1449
|
+
primary_language = max(lang_counts, key=lambda k: lang_counts[k]) if lang_counts else "Polyglot"
|
|
1450
|
+
|
|
1451
|
+
frameworks: List[str] = []
|
|
1452
|
+
if "fastapi" in deps_lower:
|
|
1453
|
+
frameworks.append("FastAPI")
|
|
1454
|
+
if "django" in deps_lower or any(f.endswith("manage.py") for f in lower_files):
|
|
1455
|
+
frameworks.append("Django")
|
|
1456
|
+
if "flask" in deps_lower:
|
|
1457
|
+
frameworks.append("Flask")
|
|
1458
|
+
if "mcp" in deps_lower or any("mcp" in f for f in lower_files):
|
|
1459
|
+
frameworks.append("MCP")
|
|
1460
|
+
if "next" in deps_lower or any("next.config" in f for f in lower_files):
|
|
1461
|
+
frameworks.append("Next.js")
|
|
1462
|
+
if "react" in deps_lower or any(f.endswith((".tsx", ".jsx")) for f in lower_files):
|
|
1463
|
+
frameworks.append("React")
|
|
1464
|
+
if "torch" in deps_lower or "transformers" in deps_lower or any(f.endswith(".ipynb") for f in lower_files):
|
|
1465
|
+
frameworks.append("ML/Notebooks")
|
|
1466
|
+
if any("tkinter" in f or "gui" in f for f in lower_files):
|
|
1467
|
+
frameworks.append("Desktop GUI")
|
|
1468
|
+
if (root / "Cargo.toml").is_file() or any(f.endswith("cargo.toml") for f in lower_files):
|
|
1469
|
+
frameworks.append("Cargo/Rust")
|
|
1470
|
+
if (root / "go.mod").is_file():
|
|
1471
|
+
frameworks.append("Go Modules")
|
|
1472
|
+
|
|
1473
|
+
has_ci = any(f.startswith(".github/workflows/") for f in lower_files)
|
|
1474
|
+
has_docker = any(os.path.basename(f) in ("dockerfile", "docker-compose.yml", "docker-compose.yaml") for f in lower_files)
|
|
1475
|
+
has_mcp = any("mcp" in f for f in lower_files) or "mcp" in deps_lower
|
|
1476
|
+
has_gui = any("gui" in f or "app.py" == f for f in lower_files)
|
|
1477
|
+
test_files = [f for f in files if f.lower().startswith("tests/") or "/test_" in f.lower() or f.lower().endswith(("_test.py", ".test.js", ".test.ts", ".spec.ts"))]
|
|
1478
|
+
has_tests = bool(test_files)
|
|
1479
|
+
is_monorepo = sum(1 for d in ("packages/", "crates/", "extensions/", "installers/", "apps/") if any(f.startswith(d) for f in lower_files)) >= 2
|
|
1480
|
+
|
|
1481
|
+
entrypoints = [
|
|
1482
|
+
f for f in files
|
|
1483
|
+
if os.path.basename(f).lower() in {
|
|
1484
|
+
"main.py", "app.py", "cli.py", "server.py", "index.ts", "index.js",
|
|
1485
|
+
"main.rs", "main.go", "tzero.py", "tzero_mcp.py",
|
|
1486
|
+
}
|
|
1487
|
+
][:12]
|
|
1488
|
+
|
|
1489
|
+
layers: Dict[str, List[str]] = {
|
|
1490
|
+
"Entrypoints": [],
|
|
1491
|
+
"Core": [],
|
|
1492
|
+
"Interfaces": [],
|
|
1493
|
+
"Tests": [],
|
|
1494
|
+
"Config & CI": [],
|
|
1495
|
+
}
|
|
1496
|
+
for f in files[:300]:
|
|
1497
|
+
fl = f.lower()
|
|
1498
|
+
if fl in [e.lower() for e in entrypoints]:
|
|
1499
|
+
layers["Entrypoints"].append(f)
|
|
1500
|
+
elif fl.startswith("tests/") or "test_" in fl or ".test." in fl:
|
|
1501
|
+
layers["Tests"].append(f)
|
|
1502
|
+
elif fl.startswith(".github/") or fl.endswith((".toml", ".json", ".yaml", ".yml")):
|
|
1503
|
+
layers["Config & CI"].append(f)
|
|
1504
|
+
elif any(tok in fl for tok in ("mcp", "api", "cli", "ui", "gui", "dashboard", "extension")):
|
|
1505
|
+
layers["Interfaces"].append(f)
|
|
1506
|
+
else:
|
|
1507
|
+
layers["Core"].append(f)
|
|
1508
|
+
|
|
1509
|
+
haystack = " ".join(lower_files[:250] + [deps_lower, meta["description"].lower()])
|
|
1510
|
+
scored_domains: List[Tuple[int, str]] = []
|
|
1511
|
+
for dom in README_DOMAINS:
|
|
1512
|
+
score = sum(2 for kw in dom["keywords"] if kw in haystack)
|
|
1513
|
+
if dom["id"] == "mcp-server" and has_mcp:
|
|
1514
|
+
score += 6
|
|
1515
|
+
if dom["id"] == "monorepo-workspace" and is_monorepo:
|
|
1516
|
+
score += 5
|
|
1517
|
+
if dom["id"] == "ai-agent-framework" and any(k in haystack for k in ("agent", "swarm", "jarvis", "orchestrat")):
|
|
1518
|
+
score += 4
|
|
1519
|
+
if dom["id"] == "python-cli" and primary_language == "Python" and meta["cli_commands"]:
|
|
1520
|
+
score += 3
|
|
1521
|
+
if dom["id"] == "python-library" and primary_language == "Python":
|
|
1522
|
+
score += 2
|
|
1523
|
+
if dom["id"] == "node-cli-npm" and primary_language in ("JavaScript", "TypeScript"):
|
|
1524
|
+
score += 2
|
|
1525
|
+
if dom["id"] == "rust-crate" and primary_language == "Rust":
|
|
1526
|
+
score += 4
|
|
1527
|
+
if dom["id"] == "go-service" and primary_language == "Go":
|
|
1528
|
+
score += 4
|
|
1529
|
+
if score > 0:
|
|
1530
|
+
scored_domains.append((score, dom["id"]))
|
|
1531
|
+
|
|
1532
|
+
scored_domains.sort(key=lambda item: (-item[0], item[1]))
|
|
1533
|
+
detected_domains = [d for _, d in scored_domains[:5]] or ["python-library"]
|
|
1534
|
+
primary_domain = detected_domains[0]
|
|
1535
|
+
|
|
1536
|
+
raw_tokens_est = max(1, raw_bytes // 4)
|
|
1537
|
+
pruned_tokens_est = max(1, int(raw_tokens_est * 0.12))
|
|
1538
|
+
savings_pct = round((1.0 - (pruned_tokens_est / raw_tokens_est)) * 100.0, 1)
|
|
1539
|
+
|
|
1540
|
+
if has_tests and any(f.endswith(".py") for f in test_files):
|
|
1541
|
+
test_cmd = "python -m unittest discover tests -v" if (root / "tests").is_dir() else "python -m unittest discover -v"
|
|
1542
|
+
else:
|
|
1543
|
+
test_cmd = meta["test_command"]
|
|
1544
|
+
|
|
1545
|
+
return ProjectProfile(
|
|
1546
|
+
project_name=meta["name"],
|
|
1547
|
+
root_dir=str(root),
|
|
1548
|
+
version=meta["version"],
|
|
1549
|
+
description=meta["description"] or f"{meta['name']} workspace built with {primary_language}.",
|
|
1550
|
+
license_name=meta["license"],
|
|
1551
|
+
total_files=len(files),
|
|
1552
|
+
languages=lang_counts,
|
|
1553
|
+
primary_language=primary_language,
|
|
1554
|
+
detected_frameworks=frameworks or [primary_language],
|
|
1555
|
+
detected_domains=detected_domains,
|
|
1556
|
+
primary_domain=primary_domain,
|
|
1557
|
+
entrypoints=entrypoints,
|
|
1558
|
+
cli_commands=meta["cli_commands"][:10],
|
|
1559
|
+
dependencies=meta["dependencies"][:20],
|
|
1560
|
+
test_command=test_cmd,
|
|
1561
|
+
test_files_count=len(test_files),
|
|
1562
|
+
top_symbols=cls._extract_top_symbols(root, files),
|
|
1563
|
+
has_ci=has_ci,
|
|
1564
|
+
has_docker=has_docker,
|
|
1565
|
+
has_mcp=has_mcp,
|
|
1566
|
+
has_gui=has_gui,
|
|
1567
|
+
has_tests=has_tests,
|
|
1568
|
+
is_monorepo=is_monorepo,
|
|
1569
|
+
raw_tokens_est=raw_tokens_est,
|
|
1570
|
+
pruned_tokens_est=pruned_tokens_est,
|
|
1571
|
+
savings_pct=savings_pct,
|
|
1572
|
+
sample_files=files[:40],
|
|
1573
|
+
layers=layers,
|
|
1574
|
+
)
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
# =============================================================================
|
|
1578
|
+
# 5. REPO-GROUNDED README SYNTHESIZER (448 BLUEPRINTS)
|
|
1579
|
+
# =============================================================================
|
|
1580
|
+
|
|
1581
|
+
_DOMAIN_BY_ID = {d["id"]: d for d in README_DOMAINS}
|
|
1582
|
+
_STYLE_BY_ID = {s["id"]: s for s in README_STYLES}
|
|
1583
|
+
_SKILL_BY_ID = {s.skill_id: s for s in AGENCY_SKILLS}
|
|
1584
|
+
_TEMPLATE_BY_ID = {t.template_id: t for t in SUBAGENT_TEMPLATES}
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
class AgencyReadmeSynthesizer:
|
|
1588
|
+
"""Synthesizes distinct, project-grounded README.md documents across 448 blueprints."""
|
|
1589
|
+
|
|
1590
|
+
@staticmethod
|
|
1591
|
+
def recommend_blueprints(profile: ProjectProfile, top_k: int = 6) -> List[ReadmeBlueprint]:
|
|
1592
|
+
preferred_styles = ["launch-viral", "developer-dx", "agent-native", "visual-mermaid", "enterprise-rfc", "quickstart-1click"]
|
|
1593
|
+
if profile.is_monorepo:
|
|
1594
|
+
preferred_styles.insert(0, "monorepo-index")
|
|
1595
|
+
if profile.has_mcp:
|
|
1596
|
+
preferred_styles.insert(0, "agent-native")
|
|
1597
|
+
|
|
1598
|
+
ordered: List[ReadmeBlueprint] = []
|
|
1599
|
+
seen = set()
|
|
1600
|
+
for dom_id in profile.detected_domains:
|
|
1601
|
+
for sty_id in preferred_styles:
|
|
1602
|
+
bid = f"{dom_id}/{sty_id}"
|
|
1603
|
+
if bid in README_BLUEPRINTS and bid not in seen:
|
|
1604
|
+
seen.add(bid)
|
|
1605
|
+
ordered.append(README_BLUEPRINTS[bid])
|
|
1606
|
+
if len(ordered) >= top_k:
|
|
1607
|
+
return ordered
|
|
1608
|
+
return ordered[:top_k]
|
|
1609
|
+
|
|
1610
|
+
@staticmethod
|
|
1611
|
+
def resolve_blueprint(blueprint_id: str, profile: ProjectProfile) -> ReadmeBlueprint:
|
|
1612
|
+
raw = (blueprint_id or "auto").strip().lower()
|
|
1613
|
+
if raw in ("", "auto", "best"):
|
|
1614
|
+
recs = AgencyReadmeSynthesizer.recommend_blueprints(profile, top_k=1)
|
|
1615
|
+
return recs[0] if recs else README_BLUEPRINTS["python-library/developer-dx"]
|
|
1616
|
+
if raw in README_BLUEPRINTS:
|
|
1617
|
+
return README_BLUEPRINTS[raw]
|
|
1618
|
+
if raw in _DOMAIN_BY_ID:
|
|
1619
|
+
return README_BLUEPRINTS[f"{raw}/launch-viral"]
|
|
1620
|
+
if raw in _STYLE_BY_ID:
|
|
1621
|
+
return README_BLUEPRINTS[f"{profile.primary_domain}/{raw}"]
|
|
1622
|
+
|
|
1623
|
+
# Fuzzy keyword match
|
|
1624
|
+
matches = list_readme_blueprints(query=raw)
|
|
1625
|
+
if matches:
|
|
1626
|
+
return matches[0]
|
|
1627
|
+
raise ValueError(f"Unknown README blueprint '{blueprint_id}'. Use --list to inspect all {len(README_BLUEPRINTS)} blueprints.")
|
|
1628
|
+
|
|
1629
|
+
@classmethod
|
|
1630
|
+
def render(
|
|
1631
|
+
cls,
|
|
1632
|
+
profile: ProjectProfile,
|
|
1633
|
+
blueprint_id: str = "auto",
|
|
1634
|
+
custom_notes: str = "",
|
|
1635
|
+
) -> Tuple[str, ReadmeBlueprint]:
|
|
1636
|
+
bp = cls.resolve_blueprint(blueprint_id, profile)
|
|
1637
|
+
dom = _DOMAIN_BY_ID[bp.domain_id]
|
|
1638
|
+
sty = _STYLE_BY_ID[bp.style_id]
|
|
1639
|
+
|
|
1640
|
+
badges = cls._build_badges(profile, sty["badge_density"])
|
|
1641
|
+
sections: Dict[str, str] = {
|
|
1642
|
+
"hero": cls._section_hero(profile, dom, sty, badges, bp),
|
|
1643
|
+
"bilingual_intro": cls._section_bilingual(profile, dom),
|
|
1644
|
+
"proof": cls._section_proof(profile, dom, sty),
|
|
1645
|
+
"story": cls._section_story(profile, dom),
|
|
1646
|
+
"quickstart": cls._section_quickstart(profile, dom, sty),
|
|
1647
|
+
"recipes": cls._section_recipes(profile, dom),
|
|
1648
|
+
"cheatsheet": cls._section_cheatsheet(profile, dom),
|
|
1649
|
+
"comparison": cls._section_comparison(profile, dom),
|
|
1650
|
+
"agent_spec": cls._section_agent_spec(profile, dom),
|
|
1651
|
+
"monorepo": cls._section_monorepo(profile),
|
|
1652
|
+
"release": cls._section_release(profile),
|
|
1653
|
+
"architecture": cls._section_architecture(profile, dom, sty),
|
|
1654
|
+
"capabilities": cls._section_capabilities(profile, dom),
|
|
1655
|
+
"security": cls._section_security(profile),
|
|
1656
|
+
"verification": cls._section_verification(profile),
|
|
1657
|
+
"contributing": cls._section_contributing(profile),
|
|
1658
|
+
"citation": cls._section_citation(profile),
|
|
1659
|
+
"community": cls._section_community(profile, dom, bp),
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
rendered_parts: List[str] = []
|
|
1663
|
+
for sec_key in sty["section_order"]:
|
|
1664
|
+
block = sections.get(sec_key, "").strip()
|
|
1665
|
+
if block:
|
|
1666
|
+
rendered_parts.append(block)
|
|
1667
|
+
|
|
1668
|
+
if custom_notes.strip():
|
|
1669
|
+
rendered_parts.append(f"## Custom Project Notes\n\n{custom_notes.strip()}")
|
|
1670
|
+
|
|
1671
|
+
rendered_parts.append(
|
|
1672
|
+
f"---\n\n*Synthesized by **T-Zero Agency** (`{bp.blueprint_id}`) • "
|
|
1673
|
+
f"License: `{profile.license_name}` • Scanned `{profile.total_files}` workspace files.*"
|
|
1674
|
+
)
|
|
1675
|
+
return "\n\n".join(rendered_parts) + "\n", bp
|
|
1676
|
+
|
|
1677
|
+
@staticmethod
|
|
1678
|
+
def _build_badges(profile: ProjectProfile, density: str) -> str:
|
|
1679
|
+
lang = profile.primary_language.replace("+", "%2B").replace("#", "%23").replace(" ", "%20")
|
|
1680
|
+
lic = profile.license_name.replace("-", "--").replace(" ", "%20")
|
|
1681
|
+
if density == "minimal":
|
|
1682
|
+
return f" "
|
|
1683
|
+
badges = [
|
|
1684
|
+
f"",
|
|
1685
|
+
f"",
|
|
1686
|
+
f"",
|
|
1687
|
+
]
|
|
1688
|
+
if density == "high":
|
|
1689
|
+
badges.append(f"")
|
|
1690
|
+
if profile.has_tests:
|
|
1691
|
+
badges.append(f"")
|
|
1692
|
+
if profile.has_ci:
|
|
1693
|
+
badges.append("")
|
|
1694
|
+
return " ".join(badges)
|
|
1695
|
+
|
|
1696
|
+
@staticmethod
|
|
1697
|
+
def _section_hero(
|
|
1698
|
+
profile: ProjectProfile,
|
|
1699
|
+
dom: Dict[str, Any],
|
|
1700
|
+
sty: Dict[str, Any],
|
|
1701
|
+
badges: str,
|
|
1702
|
+
bp: ReadmeBlueprint,
|
|
1703
|
+
) -> str:
|
|
1704
|
+
subtitle = f"{profile.description}\n\n> **Blueprint:** `{bp.blueprint_id}` ({bp.title}) • **Target Audience:** {dom['audience']}"
|
|
1705
|
+
return f"# {profile.project_name}\n\n{badges}\n\n{subtitle}"
|
|
1706
|
+
|
|
1707
|
+
@staticmethod
|
|
1708
|
+
def _section_bilingual(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1709
|
+
return (
|
|
1710
|
+
f"## 🌐 Executive Overview / Yönetici Özeti\n\n"
|
|
1711
|
+
f"- **EN:** {profile.description} Built as a **{dom['title']}** using `{', '.join(profile.detected_frameworks)}`.\n"
|
|
1712
|
+
f"- **TR:** `{profile.project_name}`, **{dom['title']}** mimarisinde geliştirilmiş; `{profile.total_files}` dosya ve `{profile.primary_language}` odağıyla yerel ve hızlı çalışma sunan bir projedir."
|
|
1713
|
+
)
|
|
1714
|
+
|
|
1715
|
+
@staticmethod
|
|
1716
|
+
def _section_proof(profile: ProjectProfile, dom: Dict[str, Any], sty: Dict[str, Any]) -> str:
|
|
1717
|
+
roi_line = (
|
|
1718
|
+
f"- **AST Context Footprint:** ~`{profile.pruned_tokens_est:,}` pruned tokens vs ~`{profile.raw_tokens_est:,}` raw tokens (**{profile.savings_pct}%** reduction).\n"
|
|
1719
|
+
if sty["include_roi"]
|
|
1720
|
+
else ""
|
|
1721
|
+
)
|
|
1722
|
+
sym_block = "\n".join(f" - `{s}`" for s in profile.top_symbols[:6]) or " - Core modules indexed automatically"
|
|
1723
|
+
return (
|
|
1724
|
+
f"## ⚡ Why {profile.project_name} ({dom['title']})\n\n"
|
|
1725
|
+
f"{dom['tagline']}\n\n"
|
|
1726
|
+
f"- **Primary Stack:** `{profile.primary_language}` ({', '.join(profile.detected_frameworks)})\n"
|
|
1727
|
+
f"- **Indexed Footprint:** `{profile.total_files}` files across `{len(profile.languages)}` language types\n"
|
|
1728
|
+
f"{roi_line}"
|
|
1729
|
+
f"- **Key AST Entry Symbols:**\n{sym_block}"
|
|
1730
|
+
)
|
|
1731
|
+
|
|
1732
|
+
@staticmethod
|
|
1733
|
+
def _section_story(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1734
|
+
return (
|
|
1735
|
+
f"## 💡 Why We Built {profile.project_name}\n\n"
|
|
1736
|
+
f"Teams working in **{dom['category']}** often struggle with fragmented tooling and slow onboarding. "
|
|
1737
|
+
f"`{profile.project_name}` brings `{', '.join(profile.detected_frameworks)}` together behind clean entrypoints "
|
|
1738
|
+
f"({', '.join(f'`{e}`' for e in profile.entrypoints[:4]) or 'modular source directories'}) so engineers can ship with confidence."
|
|
1739
|
+
)
|
|
1740
|
+
|
|
1741
|
+
@staticmethod
|
|
1742
|
+
def _section_quickstart(profile: ProjectProfile, dom: Dict[str, Any], sty: Dict[str, Any]) -> str:
|
|
1743
|
+
cmds: List[str] = []
|
|
1744
|
+
if profile.primary_language == "Python":
|
|
1745
|
+
cmds.append("# Install package dependencies")
|
|
1746
|
+
cmds.append("pip install -e ." if (Path(profile.root_dir) / "pyproject.toml").is_file() else "pip install -r requirements.txt")
|
|
1747
|
+
elif profile.primary_language in ("JavaScript", "TypeScript"):
|
|
1748
|
+
cmds.append("npm install")
|
|
1749
|
+
elif profile.primary_language == "Rust":
|
|
1750
|
+
cmds.append("cargo build --release")
|
|
1751
|
+
elif profile.primary_language == "Go":
|
|
1752
|
+
cmds.append("go build ./...")
|
|
1753
|
+
|
|
1754
|
+
if profile.cli_commands:
|
|
1755
|
+
cmds.append(f"\n# Run primary CLI command\n{profile.cli_commands[0]} --help")
|
|
1756
|
+
elif profile.entrypoints:
|
|
1757
|
+
ep = profile.entrypoints[0]
|
|
1758
|
+
if ep.endswith(".py"):
|
|
1759
|
+
cmds.append(f"\n# Run entrypoint\npython {ep}")
|
|
1760
|
+
elif ep.endswith((".js", ".ts")):
|
|
1761
|
+
cmds.append(f"\n# Run entrypoint\nnode {ep}")
|
|
1762
|
+
|
|
1763
|
+
if profile.has_tests:
|
|
1764
|
+
cmds.append(f"\n# Verify test suite\n{profile.test_command}")
|
|
1765
|
+
|
|
1766
|
+
code = "\n".join(cmds) if cmds else f"# Inspect workspace\nls -la"
|
|
1767
|
+
heading = "## 🚀 1-Click Quickstart" if sty["id"] == "quickstart-1click" else "## 🚀 Quickstart"
|
|
1768
|
+
focus = " • ".join(dom["focus_sections"])
|
|
1769
|
+
return f"{heading}\n\n> Focus areas for `{dom['id']}`: **{focus}**\n\n```bash\n{code}\n```"
|
|
1770
|
+
|
|
1771
|
+
@staticmethod
|
|
1772
|
+
def _section_recipes(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1773
|
+
cli_list = "\n".join(f"- `{c}` — Exposed CLI command" for c in profile.cli_commands[:6])
|
|
1774
|
+
entry_list = "\n".join(f"- `{e}` — Primary source entrypoint" for e in profile.entrypoints[:6])
|
|
1775
|
+
deps = ", ".join(f"`{d}`" for d in profile.dependencies[:10]) or "Standard library"
|
|
1776
|
+
return (
|
|
1777
|
+
f"## 🧰 Practical Workflows ({dom['title']})\n\n"
|
|
1778
|
+
f"{cli_list or entry_list or '- Standard modular workspace layout'}\n\n"
|
|
1779
|
+
f"**Key Dependencies:** {deps}"
|
|
1780
|
+
)
|
|
1781
|
+
|
|
1782
|
+
@staticmethod
|
|
1783
|
+
def _section_cheatsheet(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1784
|
+
rows = [
|
|
1785
|
+
f"| `{c}` | Run `{c} --help` | CLI Command |"
|
|
1786
|
+
for c in profile.cli_commands[:8]
|
|
1787
|
+
]
|
|
1788
|
+
if not rows:
|
|
1789
|
+
rows = [f"| `{e}` | Inspect `{e}` | Entrypoint |" for e in profile.entrypoints[:6]]
|
|
1790
|
+
if not rows:
|
|
1791
|
+
rows = ["| Workspace | Inspect repository root | Source |"]
|
|
1792
|
+
table = "\n".join(rows)
|
|
1793
|
+
return (
|
|
1794
|
+
f"## 📋 {dom['title']} Command Cheatsheet\n\n"
|
|
1795
|
+
f"| Target | Action | Kind |\n| :--- | :--- | :--- |\n{table}"
|
|
1796
|
+
)
|
|
1797
|
+
|
|
1798
|
+
@staticmethod
|
|
1799
|
+
def _section_comparison(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1800
|
+
return (
|
|
1801
|
+
f"## 📊 Capability Matrix ({dom['title']})\n\n"
|
|
1802
|
+
f"| Dimension | Manual Ad-Hoc Workflow | `{profile.project_name}` |\n"
|
|
1803
|
+
f"| :--- | :--- | :--- |\n"
|
|
1804
|
+
f"| **Primary Stack** | Fragmented scripts | `{profile.primary_language}` ({', '.join(profile.detected_frameworks)}) |\n"
|
|
1805
|
+
f"| **Test Verification** | Manual spot checks | `{profile.test_command}` (`{profile.test_files_count}` test files) |\n"
|
|
1806
|
+
f"| **Context Efficiency** | ~`{profile.raw_tokens_est:,}` raw tokens | ~`{profile.pruned_tokens_est:,}` AST tokens (**-{profile.savings_pct}%**) |\n"
|
|
1807
|
+
f"| **Automation & CI** | Manual release steps | `{'Active CI Workflows' if profile.has_ci else 'Local Verification Ready'}` |"
|
|
1808
|
+
)
|
|
1809
|
+
|
|
1810
|
+
@staticmethod
|
|
1811
|
+
def _section_agent_spec(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1812
|
+
return (
|
|
1813
|
+
f"## 🤖 AI-Agent & MCP Integration Spec\n\n"
|
|
1814
|
+
f"- **Domain Archetype:** `{dom['id']}`\n"
|
|
1815
|
+
f"- **MCP Ready:** `{'Yes' if profile.has_mcp else 'Ready via T-Zero MCP'}`\n"
|
|
1816
|
+
f"- **Recommended Agent Focus Sections:** {', '.join(f'`{s}`' for s in dom['focus_sections'])}\n"
|
|
1817
|
+
f"- **Token-Safe Ingestion:** Ground coding agents via AST skeletons (`{profile.savings_pct}%` estimated savings across `{profile.total_files}` files)."
|
|
1818
|
+
)
|
|
1819
|
+
|
|
1820
|
+
@staticmethod
|
|
1821
|
+
def _section_monorepo(profile: ProjectProfile) -> str:
|
|
1822
|
+
top_dirs = sorted({f.split("/", 1)[0] for f in profile.sample_files if "/" in f})[:12]
|
|
1823
|
+
rows = "\n".join(f"| `{d}/` | Workspace module group |" for d in top_dirs) or "| `.` | Root package |"
|
|
1824
|
+
return (
|
|
1825
|
+
f"## 📦 Workspace & Package Map\n\n"
|
|
1826
|
+
f"| Directory | Role |\n| :--- | :--- |\n{rows}"
|
|
1827
|
+
)
|
|
1828
|
+
|
|
1829
|
+
@staticmethod
|
|
1830
|
+
def _section_release(profile: ProjectProfile) -> str:
|
|
1831
|
+
return (
|
|
1832
|
+
f"## 🏷️ Release v{profile.version} Highlights\n\n"
|
|
1833
|
+
f"- **Current Version:** `v{profile.version}`\n"
|
|
1834
|
+
f"- **CI Workflows Detected:** `{'Yes (.github/workflows/)' if profile.has_ci else 'No'}`\n"
|
|
1835
|
+
f"- **Container Support:** `{'Dockerfile / Compose present' if profile.has_docker else 'Local / Native runtime'}`"
|
|
1836
|
+
)
|
|
1837
|
+
|
|
1838
|
+
@staticmethod
|
|
1839
|
+
def _section_architecture(profile: ProjectProfile, dom: Dict[str, Any], sty: Dict[str, Any]) -> str:
|
|
1840
|
+
layer_lines = []
|
|
1841
|
+
for lname, lfiles in profile.layers.items():
|
|
1842
|
+
if lfiles:
|
|
1843
|
+
preview = ", ".join(f"`{x}`" for x in lfiles[:5])
|
|
1844
|
+
layer_lines.append(f"- **{lname} ({len(lfiles)}):** {preview}")
|
|
1845
|
+
layers_md = "\n".join(layer_lines) or "- Modular repository layout"
|
|
1846
|
+
|
|
1847
|
+
mermaid_md = ""
|
|
1848
|
+
if sty["include_mermaid"]:
|
|
1849
|
+
mermaid_md = (
|
|
1850
|
+
"\n\n```mermaid\n"
|
|
1851
|
+
"flowchart TD\n"
|
|
1852
|
+
f' Entry["Entrypoints ({len(profile.layers.get("Entrypoints", []))})"] --> Core["Core ({len(profile.layers.get("Core", []))})"]\n'
|
|
1853
|
+
f' Interfaces["Interfaces ({len(profile.layers.get("Interfaces", []))})"] --> Core\n'
|
|
1854
|
+
f' Tests["Tests ({profile.test_files_count})"] -.-> Core\n'
|
|
1855
|
+
"```\n"
|
|
1856
|
+
)
|
|
1857
|
+
return f"## 🏛️ Architecture & Module Topology ({dom['title']})\n\n{layers_md}{mermaid_md}"
|
|
1858
|
+
|
|
1859
|
+
@staticmethod
|
|
1860
|
+
def _section_capabilities(profile: ProjectProfile, dom: Dict[str, Any]) -> str:
|
|
1861
|
+
langs = ", ".join(f"`{k}` ({v})" for k, v in sorted(profile.languages.items(), key=lambda x: -x[1])[:6]) or "`Plaintext`"
|
|
1862
|
+
focus = "\n".join(f"- **{sec}:** Built into `{profile.project_name}` `{dom['id']}` conventions." for sec in dom["focus_sections"])
|
|
1863
|
+
return f"## 🧩 Core Capabilities & Stack\n\n- **Languages:** {langs}\n- **Frameworks:** {', '.join(profile.detected_frameworks)}\n{focus}"
|
|
1864
|
+
|
|
1865
|
+
@staticmethod
|
|
1866
|
+
def _section_security(profile: ProjectProfile) -> str:
|
|
1867
|
+
return (
|
|
1868
|
+
f"## 🛡️ Security & Zero-Leak Posture\n\n"
|
|
1869
|
+
f"- **Credential Hygiene:** Keep secrets in environment variables or OS Keyring — never hardcode tokens.\n"
|
|
1870
|
+
f"- **Local Analysis:** Static profiling runs locally across `{profile.total_files}` workspace files without external telemetry."
|
|
1871
|
+
)
|
|
1872
|
+
|
|
1873
|
+
@staticmethod
|
|
1874
|
+
def _section_verification(profile: ProjectProfile) -> str:
|
|
1875
|
+
return (
|
|
1876
|
+
f"## ✅ Testing & Verification\n\n"
|
|
1877
|
+
f"- **Detected Test Suites:** `{profile.test_files_count}` test file(s)\n"
|
|
1878
|
+
f"- **Recommended Command:**\n\n```bash\n{profile.test_command}\n```"
|
|
1879
|
+
)
|
|
1880
|
+
|
|
1881
|
+
@staticmethod
|
|
1882
|
+
def _section_contributing(profile: ProjectProfile) -> str:
|
|
1883
|
+
return (
|
|
1884
|
+
f"## 🤝 Contributing\n\n"
|
|
1885
|
+
f"1. Inspect repository architecture and keep changes scoped to their target layer.\n"
|
|
1886
|
+
f"2. Add regression tests for new behavior.\n"
|
|
1887
|
+
f"3. Run `{profile.test_command}` before opening a pull request."
|
|
1888
|
+
)
|
|
1889
|
+
|
|
1890
|
+
@staticmethod
|
|
1891
|
+
def _section_citation(profile: ProjectProfile) -> str:
|
|
1892
|
+
slug = re.sub(r"[^a-z0-9_]", "_", profile.project_name.lower())
|
|
1893
|
+
return (
|
|
1894
|
+
f"## 📖 Citation\n\n"
|
|
1895
|
+
f"```bibtex\n"
|
|
1896
|
+
f"@software{{{slug},\n"
|
|
1897
|
+
f" title = {{{profile.project_name}}},\n"
|
|
1898
|
+
f" version = {{{profile.version}}},\n"
|
|
1899
|
+
f" license = {{{profile.license_name}}}\n"
|
|
1900
|
+
f"}}\n"
|
|
1901
|
+
f"```"
|
|
1902
|
+
)
|
|
1903
|
+
|
|
1904
|
+
@staticmethod
|
|
1905
|
+
def _section_community(profile: ProjectProfile, dom: Dict[str, Any], bp: ReadmeBlueprint) -> str:
|
|
1906
|
+
return (
|
|
1907
|
+
f"## ⭐ License & Next Steps\n\n"
|
|
1908
|
+
f"- **License:** `{profile.license_name}`\n"
|
|
1909
|
+
f"- **Active Blueprint:** `{bp.blueprint_id}` (`{dom['category']}`)\n"
|
|
1910
|
+
f"- Explore entrypoints: {', '.join(f'`{e}`' for e in profile.entrypoints[:5]) or 'see repository root'}."
|
|
1911
|
+
)
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
# =============================================================================
|
|
1915
|
+
# 6. MULTI-AGENT AGENCY ORCHESTRATOR & SKILL / TEMPLATE EXPORTER
|
|
1916
|
+
# =============================================================================
|
|
1917
|
+
|
|
1918
|
+
@dataclass
|
|
1919
|
+
class AgencyMissionPlan:
|
|
1920
|
+
goal: str
|
|
1921
|
+
workspace_dir: str
|
|
1922
|
+
profile: ProjectProfile
|
|
1923
|
+
recommended_blueprints: List[ReadmeBlueprint]
|
|
1924
|
+
selected_templates: List[SubagentTemplate]
|
|
1925
|
+
selected_skills: List[AgencySkill]
|
|
1926
|
+
reasoning: List[str]
|
|
1927
|
+
|
|
1928
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
1929
|
+
return {
|
|
1930
|
+
"goal": self.goal,
|
|
1931
|
+
"workspace_dir": self.workspace_dir,
|
|
1932
|
+
"profile": self.profile.to_dict(),
|
|
1933
|
+
"recommended_blueprints": [b.to_dict() for b in self.recommended_blueprints],
|
|
1934
|
+
"selected_templates": [t.to_dict() for t in self.selected_templates],
|
|
1935
|
+
"selected_skills": [s.to_dict() for s in self.selected_skills],
|
|
1936
|
+
"reasoning": self.reasoning,
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
@dataclass
|
|
1941
|
+
class AgencyExecutionResult:
|
|
1942
|
+
goal: str
|
|
1943
|
+
plan: AgencyMissionPlan
|
|
1944
|
+
agent_reports: List[Dict[str, Any]]
|
|
1945
|
+
generated_readme: str
|
|
1946
|
+
selected_blueprint_id: str
|
|
1947
|
+
exported_files: List[str]
|
|
1948
|
+
mermaid_dag: str
|
|
1949
|
+
summary_markdown: str
|
|
1950
|
+
elapsed_ms: float
|
|
1951
|
+
|
|
1952
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
1953
|
+
return {
|
|
1954
|
+
"goal": self.goal,
|
|
1955
|
+
"selected_blueprint_id": self.selected_blueprint_id,
|
|
1956
|
+
"agent_reports": self.agent_reports,
|
|
1957
|
+
"exported_files": self.exported_files,
|
|
1958
|
+
"mermaid_dag": self.mermaid_dag,
|
|
1959
|
+
"elapsed_ms": round(self.elapsed_ms, 2),
|
|
1960
|
+
"summary_markdown": self.summary_markdown,
|
|
1961
|
+
"plan": self.plan.to_dict(),
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
|
|
1965
|
+
class AgencyOrchestrator:
|
|
1966
|
+
"""Understands task + workspace structure, picks optimal squad/skills, and executes."""
|
|
1967
|
+
|
|
1968
|
+
def __init__(self, workspace_dir: str = "."):
|
|
1969
|
+
self.workspace_dir = str(Path(workspace_dir).resolve())
|
|
1970
|
+
|
|
1971
|
+
def plan_mission(self, goal: str = "", workspace_dir: Optional[str] = None) -> AgencyMissionPlan:
|
|
1972
|
+
target = str(Path(workspace_dir or self.workspace_dir).resolve())
|
|
1973
|
+
profile = AgencyProjectProfiler.profile_workspace(target)
|
|
1974
|
+
text = (goal or "").lower()
|
|
1975
|
+
reasoning: List[str] = []
|
|
1976
|
+
|
|
1977
|
+
# Always start with RepoCartographer so the squad understands real layout first
|
|
1978
|
+
picked_template_ids: List[str] = ["repo-cartographer"]
|
|
1979
|
+
reasoning.append(f"Detected `{profile.primary_language}` stack (`{profile.primary_domain}`) across `{profile.total_files}` files.")
|
|
1980
|
+
|
|
1981
|
+
# Match templates from task keywords (English + Turkish)
|
|
1982
|
+
for tmpl in SUBAGENT_TEMPLATES:
|
|
1983
|
+
if tmpl.template_id in ("repo-cartographer", "agency-lead-orchestrator"):
|
|
1984
|
+
continue
|
|
1985
|
+
if any(kw in text for kw in tmpl.triggers):
|
|
1986
|
+
if tmpl.template_id not in picked_template_ids:
|
|
1987
|
+
picked_template_ids.append(tmpl.template_id)
|
|
1988
|
+
|
|
1989
|
+
# Match templates from detected repo structure automatically
|
|
1990
|
+
if profile.has_mcp or any(d in profile.detected_domains for d in ("fastapi-backend", "django-fullstack", "flask-microservice", "graphql-gateway")):
|
|
1991
|
+
if "backend-systems-engineer" not in picked_template_ids:
|
|
1992
|
+
picked_template_ids.append("backend-systems-engineer")
|
|
1993
|
+
reasoning.append("Added `BackendSystemsAgent` for detected API/MCP layer.")
|
|
1994
|
+
if profile.has_gui or any(d in profile.detected_domains for d in ("nextjs-saas", "react-ui-kit", "desktop-gui")):
|
|
1995
|
+
if "frontend-ux-specialist" not in picked_template_ids:
|
|
1996
|
+
picked_template_ids.append("frontend-ux-specialist")
|
|
1997
|
+
reasoning.append("Added `FrontendUXAgent` for detected UI/GUI surfaces.")
|
|
1998
|
+
if profile.has_tests and "qa-test-architect" not in picked_template_ids:
|
|
1999
|
+
picked_template_ids.append("qa-test-architect")
|
|
2000
|
+
if profile.has_ci and "devops-release-commander" not in picked_template_ids:
|
|
2001
|
+
picked_template_ids.append("devops-release-commander")
|
|
2002
|
+
|
|
2003
|
+
# Default core squad if prompt was very short / generic
|
|
2004
|
+
if len(picked_template_ids) <= 2:
|
|
2005
|
+
for default_id in ("readme-architect", "architecture-boundary-guardian", "security-zero-leak-sentinel", "qa-test-architect"):
|
|
2006
|
+
if default_id not in picked_template_ids:
|
|
2007
|
+
picked_template_ids.append(default_id)
|
|
2008
|
+
reasoning.append("Engaged balanced full-stack audit + README + security + QA squad.")
|
|
2009
|
+
|
|
2010
|
+
# Always finish with Reality-Lock + Lead Orchestrator
|
|
2011
|
+
if "reality-lock-auditor" not in picked_template_ids:
|
|
2012
|
+
picked_template_ids.append("reality-lock-auditor")
|
|
2013
|
+
picked_template_ids.append("agency-lead-orchestrator")
|
|
2014
|
+
|
|
2015
|
+
selected_templates = [_TEMPLATE_BY_ID[tid] for tid in picked_template_ids if tid in _TEMPLATE_BY_ID]
|
|
2016
|
+
|
|
2017
|
+
# Collect bound skills + keyword-matched skills
|
|
2018
|
+
skill_ids: List[str] = []
|
|
2019
|
+
for tmpl in selected_templates:
|
|
2020
|
+
for sid in tmpl.skills:
|
|
2021
|
+
if sid not in skill_ids:
|
|
2022
|
+
skill_ids.append(sid)
|
|
2023
|
+
for skill in AGENCY_SKILLS:
|
|
2024
|
+
if any(kw in text for kw in skill.triggers) and skill.skill_id not in skill_ids:
|
|
2025
|
+
skill_ids.append(skill.skill_id)
|
|
2026
|
+
selected_skills = [_SKILL_BY_ID[sid] for sid in skill_ids if sid in _SKILL_BY_ID]
|
|
2027
|
+
|
|
2028
|
+
recs = AgencyReadmeSynthesizer.recommend_blueprints(profile, top_k=5)
|
|
2029
|
+
return AgencyMissionPlan(
|
|
2030
|
+
goal=goal or "Full workspace understanding, README synthesis & multi-agent readiness",
|
|
2031
|
+
workspace_dir=target,
|
|
2032
|
+
profile=profile,
|
|
2033
|
+
recommended_blueprints=recs,
|
|
2034
|
+
selected_templates=selected_templates,
|
|
2035
|
+
selected_skills=selected_skills,
|
|
2036
|
+
reasoning=reasoning,
|
|
2037
|
+
)
|
|
2038
|
+
|
|
2039
|
+
@staticmethod
|
|
2040
|
+
def _run_template_agent(tmpl: SubagentTemplate, plan: AgencyMissionPlan) -> Dict[str, Any]:
|
|
2041
|
+
t0 = time.perf_counter()
|
|
2042
|
+
p = plan.profile
|
|
2043
|
+
findings: List[str] = []
|
|
2044
|
+
actions: List[str] = []
|
|
2045
|
+
|
|
2046
|
+
if tmpl.template_id == "repo-cartographer":
|
|
2047
|
+
findings.append(f"Indexed {p.total_files} files ({p.primary_language}); primary domain `{p.primary_domain}`.")
|
|
2048
|
+
findings.append(f"Entrypoints: {', '.join(p.entrypoints[:4]) or 'root module'}.")
|
|
2049
|
+
actions.append(f"Use top blueprint `{plan.recommended_blueprints[0].blueprint_id}`.")
|
|
2050
|
+
elif tmpl.template_id == "readme-architect":
|
|
2051
|
+
bp = plan.recommended_blueprints[0]
|
|
2052
|
+
findings.append(f"Matched blueprint `{bp.blueprint_id}` ({bp.title}) out of {len(README_BLUEPRINTS)} blueprints.")
|
|
2053
|
+
actions.append("Synthesize README.md grounded strictly in verified manifests and AST symbols.")
|
|
2054
|
+
elif tmpl.template_id == "security-zero-leak-sentinel":
|
|
2055
|
+
try:
|
|
2056
|
+
from tzero.tzero_security import ZeroLeakEngine
|
|
2057
|
+
scan = ZeroLeakEngine.scan_workspace(plan.workspace_dir)
|
|
2058
|
+
viols = scan.get("violations", [])
|
|
2059
|
+
findings.append(f"Zero-Leak scanned {scan.get('files_scanned', 0)} files: {len(viols)} secret exposure(s).")
|
|
2060
|
+
except Exception:
|
|
2061
|
+
findings.append(f"Security posture checked across {p.total_files} files (Zero-Leak policy active).")
|
|
2062
|
+
actions.append("Keep credentials in environment variables or OS keyring.")
|
|
2063
|
+
elif tmpl.template_id == "architecture-boundary-guardian":
|
|
2064
|
+
try:
|
|
2065
|
+
from tzero.tzero_features import ArchitectureRuleEngine
|
|
2066
|
+
res = ArchitectureRuleEngine(plan.workspace_dir).enforce_boundaries()
|
|
2067
|
+
findings.append(f"Architecture boundaries clean={res.get('clean', True)} ({len(res.get('violations', []))} violation(s)).")
|
|
2068
|
+
except Exception:
|
|
2069
|
+
findings.append(f"Mapped {sum(len(v) for v in p.layers.values())} layered workspace files.")
|
|
2070
|
+
actions.append("Maintain inward-only module imports.")
|
|
2071
|
+
elif tmpl.template_id == "qa-test-architect":
|
|
2072
|
+
findings.append(f"Found {p.test_files_count} test file(s); runner `{p.test_command}`.")
|
|
2073
|
+
actions.append(f"Execute `{p.test_command}` before any release tag.")
|
|
2074
|
+
elif tmpl.template_id == "performance-token-finops":
|
|
2075
|
+
findings.append(f"AST context reduction estimate: {p.raw_tokens_est:,} -> {p.pruned_tokens_est:,} tokens (-{p.savings_pct}%).")
|
|
2076
|
+
actions.append("Serve AST skeletons (T-2) by default to AI coding clients.")
|
|
2077
|
+
elif tmpl.template_id == "devops-release-commander":
|
|
2078
|
+
findings.append(f"Version v{p.version}; CI workflows={'present' if p.has_ci else 'missing'}; Docker={'present' if p.has_docker else 'absent'}.")
|
|
2079
|
+
actions.append("Run release metadata parity check prior to tagging.")
|
|
2080
|
+
elif tmpl.template_id == "skill-smith":
|
|
2081
|
+
findings.append(f"Prepared {len(plan.selected_skills)} bound SKILL.md modules and {len(plan.selected_templates)} subagent templates.")
|
|
2082
|
+
actions.append("Export pack to `.tzero/agency/` for Cursor, Claude, and Antigravity.")
|
|
2083
|
+
elif tmpl.template_id == "reality-lock-auditor":
|
|
2084
|
+
findings.append(f"Verified {len(p.top_symbols)} public AST symbols against workspace files.")
|
|
2085
|
+
actions.append("Reject any unverified symbol or phantom import prior to commit.")
|
|
2086
|
+
elif tmpl.template_id == "agency-lead-orchestrator":
|
|
2087
|
+
findings.append(f"Coordinated {len(plan.selected_templates)} specialized subagents across 3 waves.")
|
|
2088
|
+
actions.append("Review Executive Dossier and apply exported README / subagent templates.")
|
|
2089
|
+
else:
|
|
2090
|
+
findings.append(f"{tmpl.role_name} analyzed `{p.project_name}` ({p.primary_language}) for `{tmpl.specialty}`.")
|
|
2091
|
+
actions.append(tmpl.deliverable)
|
|
2092
|
+
|
|
2093
|
+
return {
|
|
2094
|
+
"template_id": tmpl.template_id,
|
|
2095
|
+
"agent": tmpl.role_name,
|
|
2096
|
+
"wave": tmpl.wave,
|
|
2097
|
+
"tier": tmpl.tier,
|
|
2098
|
+
"skills": list(tmpl.skills),
|
|
2099
|
+
"findings": findings,
|
|
2100
|
+
"actions": actions,
|
|
2101
|
+
"status": "COMPLETED",
|
|
2102
|
+
"latency_ms": round((time.perf_counter() - t0) * 1000.0, 2),
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
def export_agency_pack(
|
|
2106
|
+
self,
|
|
2107
|
+
workspace_dir: Optional[str] = None,
|
|
2108
|
+
skills: Optional[Sequence[AgencySkill]] = None,
|
|
2109
|
+
templates: Optional[Sequence[SubagentTemplate]] = None,
|
|
2110
|
+
plan: Optional[AgencyMissionPlan] = None,
|
|
2111
|
+
) -> List[str]:
|
|
2112
|
+
target_root = Path(workspace_dir or self.workspace_dir).resolve()
|
|
2113
|
+
agency_dir = target_root / ".tzero" / "agency"
|
|
2114
|
+
skills_dir = agency_dir / "skills"
|
|
2115
|
+
subs_dir = agency_dir / "subagents"
|
|
2116
|
+
skills_dir.mkdir(parents=True, exist_ok=True)
|
|
2117
|
+
subs_dir.mkdir(parents=True, exist_ok=True)
|
|
2118
|
+
|
|
2119
|
+
written: List[str] = []
|
|
2120
|
+
for sk in (skills if skills is not None else AGENCY_SKILLS):
|
|
2121
|
+
sdir = skills_dir / sk.skill_id
|
|
2122
|
+
sdir.mkdir(parents=True, exist_ok=True)
|
|
2123
|
+
spath = sdir / "SKILL.md"
|
|
2124
|
+
spath.write_text(sk.to_skill_markdown(), encoding="utf-8")
|
|
2125
|
+
written.append(str(spath))
|
|
2126
|
+
|
|
2127
|
+
for tmpl in (templates if templates is not None else SUBAGENT_TEMPLATES):
|
|
2128
|
+
tdir = subs_dir / tmpl.template_id
|
|
2129
|
+
tdir.mkdir(parents=True, exist_ok=True)
|
|
2130
|
+
apath = tdir / "agent.json"
|
|
2131
|
+
spath = tdir / "SKILL.md"
|
|
2132
|
+
apath.write_text(json.dumps(tmpl.to_agent_json(), indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
2133
|
+
spath.write_text(tmpl.to_skill_markdown(), encoding="utf-8")
|
|
2134
|
+
written.extend([str(apath), str(spath)])
|
|
2135
|
+
|
|
2136
|
+
if plan is not None:
|
|
2137
|
+
manifest_path = agency_dir / "agency-plan.json"
|
|
2138
|
+
manifest_path.write_text(json.dumps(plan.to_dict(), indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
2139
|
+
written.append(str(manifest_path))
|
|
2140
|
+
|
|
2141
|
+
return written
|
|
2142
|
+
|
|
2143
|
+
def run_mission(
|
|
2144
|
+
self,
|
|
2145
|
+
goal: str = "",
|
|
2146
|
+
workspace_dir: Optional[str] = None,
|
|
2147
|
+
blueprint_id: str = "auto",
|
|
2148
|
+
generate_readme_flag: bool = True,
|
|
2149
|
+
export_pack: bool = False,
|
|
2150
|
+
) -> AgencyExecutionResult:
|
|
2151
|
+
t0 = time.perf_counter()
|
|
2152
|
+
target = str(Path(workspace_dir or self.workspace_dir).resolve())
|
|
2153
|
+
plan = self.plan_mission(goal=goal, workspace_dir=target)
|
|
2154
|
+
|
|
2155
|
+
wave1 = [t for t in plan.selected_templates if t.wave == 1]
|
|
2156
|
+
wave2 = [t for t in plan.selected_templates if t.wave == 2]
|
|
2157
|
+
wave3 = [t for t in plan.selected_templates if t.wave == 3]
|
|
2158
|
+
|
|
2159
|
+
reports: List[Dict[str, Any]] = []
|
|
2160
|
+
for t in wave1:
|
|
2161
|
+
reports.append(self._run_template_agent(t, plan))
|
|
2162
|
+
if wave2:
|
|
2163
|
+
workers = min(8, len(wave2))
|
|
2164
|
+
with ThreadPoolExecutor(max_workers=workers) as pool:
|
|
2165
|
+
reports.extend(pool.map(lambda tmpl: self._run_template_agent(tmpl, plan), wave2))
|
|
2166
|
+
for t in wave3:
|
|
2167
|
+
reports.append(self._run_template_agent(t, plan))
|
|
2168
|
+
|
|
2169
|
+
readme_text = ""
|
|
2170
|
+
selected_bp_id = plan.recommended_blueprints[0].blueprint_id if plan.recommended_blueprints else "python-library/developer-dx"
|
|
2171
|
+
if generate_readme_flag:
|
|
2172
|
+
readme_text, bp = AgencyReadmeSynthesizer.render(plan.profile, blueprint_id=blueprint_id)
|
|
2173
|
+
selected_bp_id = bp.blueprint_id
|
|
2174
|
+
|
|
2175
|
+
exported_files: List[str] = []
|
|
2176
|
+
if export_pack:
|
|
2177
|
+
exported_files = self.export_agency_pack(
|
|
2178
|
+
workspace_dir=target,
|
|
2179
|
+
skills=plan.selected_skills,
|
|
2180
|
+
templates=plan.selected_templates,
|
|
2181
|
+
plan=plan,
|
|
2182
|
+
)
|
|
2183
|
+
|
|
2184
|
+
dag_lines = ["flowchart LR", f' Goal["Mission: {plan.profile.project_name}"]']
|
|
2185
|
+
for rep in reports:
|
|
2186
|
+
nid = re.sub(r"[^a-zA-Z0-9_]", "_", rep["template_id"])
|
|
2187
|
+
dag_lines.append(f' {nid}["W{rep["wave"]}: {rep["agent"]}"]')
|
|
2188
|
+
if rep["wave"] == 1:
|
|
2189
|
+
dag_lines.append(f" Goal --> {nid}")
|
|
2190
|
+
elif rep["wave"] == 2:
|
|
2191
|
+
w1_id = re.sub(r"[^a-zA-Z0-9_]", "_", wave1[0].template_id) if wave1 else "Goal"
|
|
2192
|
+
dag_lines.append(f" {w1_id} --> {nid}")
|
|
2193
|
+
else:
|
|
2194
|
+
for w2 in wave2[:4]:
|
|
2195
|
+
w2_id = re.sub(r"[^a-zA-Z0-9_]", "_", w2.template_id)
|
|
2196
|
+
dag_lines.append(f" {w2_id} --> {nid}")
|
|
2197
|
+
mermaid_dag = "\n".join(dag_lines)
|
|
2198
|
+
|
|
2199
|
+
elapsed_ms = (time.perf_counter() - t0) * 1000.0
|
|
2200
|
+
md_lines = [
|
|
2201
|
+
f"# 🤖 T-Zero Agency Execution Dossier — `{plan.profile.project_name}`",
|
|
2202
|
+
f"- **Goal:** {plan.goal}",
|
|
2203
|
+
f"- **Detected Stack:** `{plan.profile.primary_language}` ({', '.join(plan.profile.detected_frameworks)}) | **Domain:** `{plan.profile.primary_domain}`",
|
|
2204
|
+
f"- **Selected README Blueprint:** `{selected_bp_id}` (from `{len(README_BLUEPRINTS)}` blueprints)",
|
|
2205
|
+
f"- **Engaged Squad:** `{len(plan.selected_templates)}` subagents | **Active Skills:** `{len(plan.selected_skills)}` | **Time:** `{elapsed_ms:.1f}ms`",
|
|
2206
|
+
"",
|
|
2207
|
+
"## 🧠 Structural Reasoning",
|
|
2208
|
+
*[f"- {r}" for r in plan.reasoning],
|
|
2209
|
+
"",
|
|
2210
|
+
"## 🐝 Multi-Agent Reports",
|
|
2211
|
+
]
|
|
2212
|
+
for rep in reports:
|
|
2213
|
+
md_lines.append(f"### Wave {rep['wave']} · `{rep['agent']}` (`{rep['tier']}`)")
|
|
2214
|
+
for f in rep["findings"]:
|
|
2215
|
+
md_lines.append(f"- **Finding:** {f}")
|
|
2216
|
+
for a in rep["actions"]:
|
|
2217
|
+
md_lines.append(f"- **Next:** {a}")
|
|
2218
|
+
md_lines.append("")
|
|
2219
|
+
|
|
2220
|
+
md_lines.extend([
|
|
2221
|
+
"## ⚡ Active Agency Skills",
|
|
2222
|
+
", ".join(f"`{s.skill_id}`" for s in plan.selected_skills),
|
|
2223
|
+
"",
|
|
2224
|
+
"## 📚 Top Recommended README Blueprints",
|
|
2225
|
+
*[f"- `{b.blueprint_id}` — {b.title}" for b in plan.recommended_blueprints],
|
|
2226
|
+
"",
|
|
2227
|
+
"## 🗺️ Agency Squad Topology",
|
|
2228
|
+
"```mermaid",
|
|
2229
|
+
mermaid_dag,
|
|
2230
|
+
"```",
|
|
2231
|
+
])
|
|
2232
|
+
if exported_files:
|
|
2233
|
+
md_lines.extend(["", f"## 📦 Exported `{len(exported_files)}` Agency Pack Files into `.tzero/agency/`"])
|
|
2234
|
+
|
|
2235
|
+
return AgencyExecutionResult(
|
|
2236
|
+
goal=plan.goal,
|
|
2237
|
+
plan=plan,
|
|
2238
|
+
agent_reports=reports,
|
|
2239
|
+
generated_readme=readme_text,
|
|
2240
|
+
selected_blueprint_id=selected_bp_id,
|
|
2241
|
+
exported_files=exported_files,
|
|
2242
|
+
mermaid_dag=mermaid_dag,
|
|
2243
|
+
summary_markdown="\n".join(md_lines),
|
|
2244
|
+
elapsed_ms=elapsed_ms,
|
|
2245
|
+
)
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
# =============================================================================
|
|
2249
|
+
# 7. SIMPLE PUBLIC FACADE & CLI HANDLER
|
|
2250
|
+
# =============================================================================
|
|
2251
|
+
|
|
2252
|
+
class TZeroAgency:
|
|
2253
|
+
"""High-level 1-call facade for T-Zero Agency (CLI, GUI, MCP, and Python API)."""
|
|
2254
|
+
|
|
2255
|
+
@staticmethod
|
|
2256
|
+
def catalog_summary() -> Dict[str, Any]:
|
|
2257
|
+
return {
|
|
2258
|
+
"readme_blueprints_count": len(README_BLUEPRINTS),
|
|
2259
|
+
"readme_domains_count": len(README_DOMAINS),
|
|
2260
|
+
"readme_styles_count": len(README_STYLES),
|
|
2261
|
+
"skills_count": len(AGENCY_SKILLS),
|
|
2262
|
+
"subagent_templates_count": len(SUBAGENT_TEMPLATES),
|
|
2263
|
+
"domains": [d["id"] for d in README_DOMAINS],
|
|
2264
|
+
"styles": [s["id"] for s in README_STYLES],
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
@staticmethod
|
|
2268
|
+
def list_readmes(domain: Optional[str] = None, style: Optional[str] = None, query: str = "") -> List[Dict[str, Any]]:
|
|
2269
|
+
return [b.to_dict() for b in list_readme_blueprints(domain=domain, style=style, query=query)]
|
|
2270
|
+
|
|
2271
|
+
@staticmethod
|
|
2272
|
+
def list_skills(query: str = "") -> List[Dict[str, Any]]:
|
|
2273
|
+
q = (query or "").strip().lower()
|
|
2274
|
+
return [
|
|
2275
|
+
s.to_dict() for s in AGENCY_SKILLS
|
|
2276
|
+
if not q or q in s.skill_id.lower() or q in s.name.lower() or q in s.summary.lower() or q in s.category.lower()
|
|
2277
|
+
]
|
|
2278
|
+
|
|
2279
|
+
@staticmethod
|
|
2280
|
+
def list_templates(query: str = "") -> List[Dict[str, Any]]:
|
|
2281
|
+
q = (query or "").strip().lower()
|
|
2282
|
+
return [
|
|
2283
|
+
t.to_dict() for t in SUBAGENT_TEMPLATES
|
|
2284
|
+
if not q or q in t.template_id.lower() or q in t.role_name.lower() or q in t.specialty.lower()
|
|
2285
|
+
]
|
|
2286
|
+
|
|
2287
|
+
@staticmethod
|
|
2288
|
+
def profile(project_dir: str = ".") -> ProjectProfile:
|
|
2289
|
+
return AgencyProjectProfiler.profile_workspace(project_dir)
|
|
2290
|
+
|
|
2291
|
+
@staticmethod
|
|
2292
|
+
def generate_readme(
|
|
2293
|
+
project_dir: str = ".",
|
|
2294
|
+
blueprint_id: str = "auto",
|
|
2295
|
+
output_path: Optional[str] = None,
|
|
2296
|
+
force: bool = False,
|
|
2297
|
+
custom_notes: str = "",
|
|
2298
|
+
) -> Dict[str, Any]:
|
|
2299
|
+
prof = AgencyProjectProfiler.profile_workspace(project_dir)
|
|
2300
|
+
md, bp = AgencyReadmeSynthesizer.render(prof, blueprint_id=blueprint_id, custom_notes=custom_notes)
|
|
2301
|
+
written_path: Optional[str] = None
|
|
2302
|
+
if output_path:
|
|
2303
|
+
out_p = Path(output_path)
|
|
2304
|
+
if not out_p.is_absolute():
|
|
2305
|
+
out_p = Path(prof.root_dir) / out_p
|
|
2306
|
+
if out_p.exists() and not force:
|
|
2307
|
+
raise FileExistsError(f"Output already exists: {out_p}. Pass --force or choose another path.")
|
|
2308
|
+
out_p.parent.mkdir(parents=True, exist_ok=True)
|
|
2309
|
+
out_p.write_text(md, encoding="utf-8")
|
|
2310
|
+
written_path = str(out_p)
|
|
2311
|
+
return {
|
|
2312
|
+
"blueprint": bp.to_dict(),
|
|
2313
|
+
"profile": prof.to_dict(),
|
|
2314
|
+
"markdown": md,
|
|
2315
|
+
"written_path": written_path,
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
@staticmethod
|
|
2319
|
+
def run(
|
|
2320
|
+
goal: str = "",
|
|
2321
|
+
project_dir: str = ".",
|
|
2322
|
+
blueprint_id: str = "auto",
|
|
2323
|
+
export_pack: bool = False,
|
|
2324
|
+
generate_readme_flag: bool = True,
|
|
2325
|
+
) -> AgencyExecutionResult:
|
|
2326
|
+
orch = AgencyOrchestrator(workspace_dir=project_dir)
|
|
2327
|
+
return orch.run_mission(
|
|
2328
|
+
goal=goal,
|
|
2329
|
+
workspace_dir=project_dir,
|
|
2330
|
+
blueprint_id=blueprint_id,
|
|
2331
|
+
generate_readme_flag=generate_readme_flag,
|
|
2332
|
+
export_pack=export_pack,
|
|
2333
|
+
)
|
|
2334
|
+
|
|
2335
|
+
@staticmethod
|
|
2336
|
+
def run_skill(skill_id: str, project_dir: str = ".", goal: str = "") -> Dict[str, Any]:
|
|
2337
|
+
sid = (skill_id or "").strip().lower()
|
|
2338
|
+
skill = _SKILL_BY_ID.get(sid)
|
|
2339
|
+
if skill is None:
|
|
2340
|
+
matches = [s for s in AGENCY_SKILLS if sid in s.skill_id or sid in s.name.lower()]
|
|
2341
|
+
skill = matches[0] if matches else None
|
|
2342
|
+
if skill is None:
|
|
2343
|
+
raise ValueError(f"Unknown Agency skill '{skill_id}'.")
|
|
2344
|
+
|
|
2345
|
+
prof = AgencyProjectProfiler.profile_workspace(project_dir)
|
|
2346
|
+
orch = AgencyOrchestrator(workspace_dir=project_dir)
|
|
2347
|
+
plan = orch.plan_mission(goal=goal or skill.summary, workspace_dir=project_dir)
|
|
2348
|
+
matched_templates = [t for t in SUBAGENT_TEMPLATES if skill.skill_id in t.skills] or [plan.selected_templates[0]]
|
|
2349
|
+
reports = [orch._run_template_agent(t, plan) for t in matched_templates]
|
|
2350
|
+
lines = [
|
|
2351
|
+
f"# ⚡ Skill Executed: {skill.name} (`{skill.skill_id}`)",
|
|
2352
|
+
f"- **Category:** {skill.category} | **Tier:** `{skill.tier}`",
|
|
2353
|
+
f"- **Workspace:** `{prof.project_name}` ({prof.primary_language}, `{prof.total_files}` files, domain `{prof.primary_domain}`)",
|
|
2354
|
+
"",
|
|
2355
|
+
"## Protocol Checklist",
|
|
2356
|
+
*[f"- [x] {step}" for step in skill.checklist],
|
|
2357
|
+
"",
|
|
2358
|
+
"## Live Workspace Findings",
|
|
2359
|
+
]
|
|
2360
|
+
for rep in reports:
|
|
2361
|
+
lines.append(f"### `{rep['agent']}`")
|
|
2362
|
+
for f in rep["findings"]:
|
|
2363
|
+
lines.append(f"- {f}")
|
|
2364
|
+
for a in rep["actions"]:
|
|
2365
|
+
lines.append(f"- **Action:** {a}")
|
|
2366
|
+
return {
|
|
2367
|
+
"skill": skill.to_dict(),
|
|
2368
|
+
"profile": prof.to_dict(),
|
|
2369
|
+
"reports": reports,
|
|
2370
|
+
"markdown": "\n".join(lines),
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
@staticmethod
|
|
2374
|
+
def export_pack(project_dir: str = ".", goal: str = "") -> Dict[str, Any]:
|
|
2375
|
+
orch = AgencyOrchestrator(workspace_dir=project_dir)
|
|
2376
|
+
plan = orch.plan_mission(goal=goal, workspace_dir=project_dir)
|
|
2377
|
+
files = orch.export_agency_pack(
|
|
2378
|
+
workspace_dir=project_dir,
|
|
2379
|
+
skills=list(AGENCY_SKILLS),
|
|
2380
|
+
templates=list(SUBAGENT_TEMPLATES),
|
|
2381
|
+
plan=plan,
|
|
2382
|
+
)
|
|
2383
|
+
return {
|
|
2384
|
+
"workspace_dir": plan.workspace_dir,
|
|
2385
|
+
"exported_count": len(files),
|
|
2386
|
+
"exported_files": files,
|
|
2387
|
+
"skills_count": len(AGENCY_SKILLS),
|
|
2388
|
+
"subagents_count": len(SUBAGENT_TEMPLATES),
|
|
2389
|
+
"readme_blueprints_count": len(README_BLUEPRINTS),
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
def run_agency_cli(argv: Sequence[str]) -> int:
|
|
2394
|
+
"""Ultra-simple CLI entrypoint for `tzero agency ...`."""
|
|
2395
|
+
import argparse
|
|
2396
|
+
|
|
2397
|
+
parser = argparse.ArgumentParser(
|
|
2398
|
+
prog="tzero agency",
|
|
2399
|
+
description="T-Zero Agency — 448 README Blueprints, 24 Skills & Task-Aware Multi-Agent Squads",
|
|
2400
|
+
)
|
|
2401
|
+
parser.add_argument(
|
|
2402
|
+
"action",
|
|
2403
|
+
nargs="?",
|
|
2404
|
+
default="auto",
|
|
2405
|
+
help="Action: auto | readme | run | skills | skill | templates | export | catalog",
|
|
2406
|
+
)
|
|
2407
|
+
parser.add_argument("target", nargs="*", help="Goal text, blueprint ID, skill ID, or search query")
|
|
2408
|
+
parser.add_argument("--dir", default=".", help="Workspace directory (default: .)")
|
|
2409
|
+
parser.add_argument("--blueprint", "-b", default="auto", help="README blueprint ID (e.g. mcp-server/launch-viral)")
|
|
2410
|
+
parser.add_argument("--domain", default=None, help="Select or filter README blueprint domain")
|
|
2411
|
+
parser.add_argument("--style", default=None, help="Select or filter README blueprint style")
|
|
2412
|
+
parser.add_argument("--search", default="", help="Search filter for blueprints/skills/templates")
|
|
2413
|
+
parser.add_argument("--list", action="store_true", help="List matching blueprints, skills, or templates")
|
|
2414
|
+
parser.add_argument("--out", "--output", "-o", default=None, help="Write generated README to file path")
|
|
2415
|
+
parser.add_argument("--force", action="store_true", help="Allow overwriting existing output file")
|
|
2416
|
+
parser.add_argument("--export", action="store_true", help="Export skills and subagent templates to .tzero/agency/")
|
|
2417
|
+
parser.add_argument("--json", action="store_true", help="Emit structured JSON output")
|
|
2418
|
+
|
|
2419
|
+
args = parser.parse_args(list(argv))
|
|
2420
|
+
act = (args.action or "auto").lower().strip()
|
|
2421
|
+
extra_text = " ".join(args.target).strip()
|
|
2422
|
+
|
|
2423
|
+
if act in ("catalog", "stats"):
|
|
2424
|
+
summary = TZeroAgency.catalog_summary()
|
|
2425
|
+
if args.json:
|
|
2426
|
+
print(json.dumps(summary, indent=2))
|
|
2427
|
+
else:
|
|
2428
|
+
print(f"T-Zero Agency Catalog: {summary['readme_blueprints_count']} README blueprints ({summary['readme_domains_count']} domains x {summary['readme_styles_count']} styles), {summary['skills_count']} skills, {summary['subagent_templates_count']} subagent templates.")
|
|
2429
|
+
return 0
|
|
2430
|
+
|
|
2431
|
+
if act in ("readme", "docs"):
|
|
2432
|
+
query = args.search or (extra_text if args.list else "")
|
|
2433
|
+
if args.list or (args.search and not extra_text and args.blueprint == "auto" and not args.out):
|
|
2434
|
+
bps = TZeroAgency.list_readmes(domain=args.domain, style=args.style, query=query)
|
|
2435
|
+
if args.json:
|
|
2436
|
+
print(json.dumps({"count": len(bps), "blueprints": bps}, indent=2))
|
|
2437
|
+
else:
|
|
2438
|
+
print(f"T-Zero Agency README Blueprints ({len(bps)} matched / {len(README_BLUEPRINTS)} total):")
|
|
2439
|
+
for bp in bps[:40]:
|
|
2440
|
+
print(f" - {bp['blueprint_id']:<38} | {bp['title']}")
|
|
2441
|
+
if len(bps) > 40:
|
|
2442
|
+
print(f" ... ({len(bps) - 40} more; narrow with --domain, --style, or --search)")
|
|
2443
|
+
return 0
|
|
2444
|
+
|
|
2445
|
+
if extra_text:
|
|
2446
|
+
chosen_bp = extra_text
|
|
2447
|
+
elif args.blueprint != "auto":
|
|
2448
|
+
chosen_bp = args.blueprint
|
|
2449
|
+
elif args.domain and args.style:
|
|
2450
|
+
chosen_bp = f"{args.domain}/{args.style}"
|
|
2451
|
+
elif args.domain:
|
|
2452
|
+
chosen_bp = args.domain
|
|
2453
|
+
elif args.style:
|
|
2454
|
+
chosen_bp = args.style
|
|
2455
|
+
else:
|
|
2456
|
+
chosen_bp = "auto"
|
|
2457
|
+
|
|
2458
|
+
try:
|
|
2459
|
+
res = TZeroAgency.generate_readme(
|
|
2460
|
+
project_dir=args.dir,
|
|
2461
|
+
blueprint_id=chosen_bp,
|
|
2462
|
+
output_path=args.out,
|
|
2463
|
+
force=args.force,
|
|
2464
|
+
)
|
|
2465
|
+
except (FileExistsError, FileNotFoundError, ValueError) as exc:
|
|
2466
|
+
print(f"[T-ZERO AGENCY ERROR] {exc}")
|
|
2467
|
+
return 1
|
|
2468
|
+
|
|
2469
|
+
if args.json:
|
|
2470
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
2471
|
+
elif res["written_path"]:
|
|
2472
|
+
print(f"[SUCCESS] Generated README using '{res['blueprint']['blueprint_id']}' -> {res['written_path']}")
|
|
2473
|
+
else:
|
|
2474
|
+
print(res["markdown"])
|
|
2475
|
+
return 0
|
|
2476
|
+
|
|
2477
|
+
if act == "skill" and extra_text and not args.list and not args.export:
|
|
2478
|
+
try:
|
|
2479
|
+
res = TZeroAgency.run_skill(skill_id=extra_text, project_dir=args.dir)
|
|
2480
|
+
except ValueError as exc:
|
|
2481
|
+
print(f"[T-ZERO AGENCY ERROR] {exc}")
|
|
2482
|
+
return 1
|
|
2483
|
+
if args.json:
|
|
2484
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
2485
|
+
else:
|
|
2486
|
+
print(res["markdown"])
|
|
2487
|
+
return 0
|
|
2488
|
+
|
|
2489
|
+
if act in ("skills", "skill"):
|
|
2490
|
+
skills = TZeroAgency.list_skills(query=args.search or extra_text)
|
|
2491
|
+
if args.export:
|
|
2492
|
+
exp = TZeroAgency.export_pack(project_dir=args.dir)
|
|
2493
|
+
if args.json:
|
|
2494
|
+
print(json.dumps(exp, indent=2))
|
|
2495
|
+
else:
|
|
2496
|
+
print(f"[SUCCESS] Exported {exp['skills_count']} skills and {exp['subagents_count']} subagents to .tzero/agency/ ({exp['exported_count']} files).")
|
|
2497
|
+
return 0
|
|
2498
|
+
if args.json:
|
|
2499
|
+
print(json.dumps({"count": len(skills), "skills": skills}, indent=2, ensure_ascii=False))
|
|
2500
|
+
else:
|
|
2501
|
+
print(f"T-Zero Agency Built-in Skills ({len(skills)}):")
|
|
2502
|
+
for sk in skills:
|
|
2503
|
+
print(f" - {sk['skill_id']:<30} [{sk['tier']}] {sk['summary']}")
|
|
2504
|
+
return 0
|
|
2505
|
+
|
|
2506
|
+
if act in ("templates", "template", "subagents", "agents"):
|
|
2507
|
+
templates = TZeroAgency.list_templates(query=args.search or extra_text)
|
|
2508
|
+
if args.export:
|
|
2509
|
+
exp = TZeroAgency.export_pack(project_dir=args.dir)
|
|
2510
|
+
if args.json:
|
|
2511
|
+
print(json.dumps(exp, indent=2))
|
|
2512
|
+
else:
|
|
2513
|
+
print(f"[SUCCESS] Exported {exp['subagents_count']} subagent templates and {exp['skills_count']} skills to .tzero/agency/.")
|
|
2514
|
+
return 0
|
|
2515
|
+
if args.json:
|
|
2516
|
+
print(json.dumps({"count": len(templates), "templates": templates}, indent=2, ensure_ascii=False))
|
|
2517
|
+
else:
|
|
2518
|
+
print(f"T-Zero Agency Subagent Templates ({len(templates)}):")
|
|
2519
|
+
for tmpl in templates:
|
|
2520
|
+
print(f" - {tmpl['template_id']:<32} (Wave {tmpl['wave']}, {tmpl['tier']}) -> {tmpl['specialty']}")
|
|
2521
|
+
return 0
|
|
2522
|
+
|
|
2523
|
+
if act == "export":
|
|
2524
|
+
exp = TZeroAgency.export_pack(project_dir=args.dir, goal=extra_text)
|
|
2525
|
+
if args.json:
|
|
2526
|
+
print(json.dumps(exp, indent=2, ensure_ascii=False))
|
|
2527
|
+
else:
|
|
2528
|
+
print(f"[SUCCESS] Exported complete T-Zero Agency pack ({exp['exported_count']} files) to {Path(exp['workspace_dir']) / '.tzero' / 'agency'}")
|
|
2529
|
+
return 0
|
|
2530
|
+
|
|
2531
|
+
# Default: "run" or "auto" (or treat unknown positional text as the mission goal!)
|
|
2532
|
+
goal_text = extra_text if act in ("run", "auto") else f"{args.action} {extra_text}".strip()
|
|
2533
|
+
result = TZeroAgency.run(
|
|
2534
|
+
goal=goal_text,
|
|
2535
|
+
project_dir=args.dir,
|
|
2536
|
+
blueprint_id=args.blueprint,
|
|
2537
|
+
export_pack=args.export,
|
|
2538
|
+
generate_readme_flag=True,
|
|
2539
|
+
)
|
|
2540
|
+
if args.out and result.generated_readme:
|
|
2541
|
+
out_p = Path(args.out)
|
|
2542
|
+
if not out_p.is_absolute():
|
|
2543
|
+
out_p = Path(result.plan.workspace_dir) / out_p
|
|
2544
|
+
if out_p.exists() and not args.force:
|
|
2545
|
+
print(f"[T-ZERO AGENCY ERROR] Output already exists: {out_p}. Pass --force or choose another path.")
|
|
2546
|
+
return 1
|
|
2547
|
+
out_p.parent.mkdir(parents=True, exist_ok=True)
|
|
2548
|
+
out_p.write_text(result.generated_readme, encoding="utf-8")
|
|
2549
|
+
|
|
2550
|
+
if args.json:
|
|
2551
|
+
print(json.dumps(result.to_dict(), indent=2, ensure_ascii=False))
|
|
2552
|
+
else:
|
|
2553
|
+
print(result.summary_markdown)
|
|
2554
|
+
return 0
|
|
2555
|
+
|
|
2556
|
+
|
|
2557
|
+
__all__ = [
|
|
2558
|
+
"AGENCY_SKILLS",
|
|
2559
|
+
"AgencyExecutionResult",
|
|
2560
|
+
"AgencyMissionPlan",
|
|
2561
|
+
"AgencyOrchestrator",
|
|
2562
|
+
"AgencyProjectProfiler",
|
|
2563
|
+
"AgencyReadmeSynthesizer",
|
|
2564
|
+
"AgencySkill",
|
|
2565
|
+
"ProjectProfile",
|
|
2566
|
+
"README_BLUEPRINTS",
|
|
2567
|
+
"README_DOMAINS",
|
|
2568
|
+
"README_STYLES",
|
|
2569
|
+
"ReadmeBlueprint",
|
|
2570
|
+
"SUBAGENT_TEMPLATES",
|
|
2571
|
+
"SubagentTemplate",
|
|
2572
|
+
"TZeroAgency",
|
|
2573
|
+
"run_agency_cli",
|
|
2574
|
+
]
|