cto-legends 0.2.9__py3-none-any.whl
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.
- cto_legends/SKILL.md +178 -0
- cto_legends/__init__.py +2 -0
- cto_legends/__main__.py +2 -0
- cto_legends/agents.py +172 -0
- cto_legends/catalog.json +1976 -0
- cto_legends/cli.py +255 -0
- cto_legends/discovery.py +265 -0
- cto_legends/manager.py +869 -0
- cto_legends/readiness.py +87 -0
- cto_legends/startup.py +352 -0
- cto_legends-0.2.9.dist-info/METADATA +358 -0
- cto_legends-0.2.9.dist-info/RECORD +19 -0
- cto_legends-0.2.9.dist-info/WHEEL +5 -0
- cto_legends-0.2.9.dist-info/entry_points.txt +3 -0
- cto_legends-0.2.9.dist-info/licenses/LICENSE +21 -0
- cto_legends-0.2.9.dist-info/licenses/NOTICE +8 -0
- cto_legends-0.2.9.dist-info/top_level.txt +2 -0
- ctolegends/__init__.py +4 -0
- ctolegends/__main__.py +3 -0
cto_legends/SKILL.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cto-legends
|
|
3
|
+
description: Route ordinary requests to the matching Legends module without per-module skills. Discover the live capability index, preview installs, and keep modules updated through the cto-legends CLI. Also use for Legends setup and updates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cto-legends
|
|
7
|
+
|
|
8
|
+
This is the single registered skill for the Legends ecosystem. It routes a
|
|
9
|
+
user goal to the right module and loads that module recipe on demand. No
|
|
10
|
+
module registers its own skill. This file is canonical in the router repo;
|
|
11
|
+
every module repo vendors a byte-exact copy. The text below names no
|
|
12
|
+
modules: the live module set comes from the CLI, so new and updated modules
|
|
13
|
+
work here with no skill change.
|
|
14
|
+
|
|
15
|
+
Install the router from source:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
git clone https://github.com/avalonreset/cto-legends.git
|
|
19
|
+
cd cto-legends
|
|
20
|
+
python -m pip install .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Start with the user's request, including in an empty working directory. A chat
|
|
24
|
+
request is a task specification; do not require a project manifest or a
|
|
25
|
+
separate task file to run catalog, status, or readiness. Read this entry point
|
|
26
|
+
before unrelated desktop, browser, or community skills for matching Legends
|
|
27
|
+
goals.
|
|
28
|
+
|
|
29
|
+
## Intent first, one registered skill
|
|
30
|
+
|
|
31
|
+
Do not ask users to name a module or install its skill: this recipe is the
|
|
32
|
+
single-skill router. Run `cto-legends capabilities --markdown` and select the
|
|
33
|
+
narrowest capability that fits the requested outcome. Module recipes are
|
|
34
|
+
ordinary Markdown loaded from their installed source, not separately
|
|
35
|
+
registered skills. A question in chat is sufficient context to begin
|
|
36
|
+
discovery.
|
|
37
|
+
|
|
38
|
+
Use `cto-legends capabilities` for examples, boundaries, and setup.
|
|
39
|
+
`cto-legends route "<user goal>"` offers offline lexical hints, not semantic
|
|
40
|
+
judgment. No lexical match is not proof that no capability fits: read the
|
|
41
|
+
index. For several outcomes, choose a small ordered set of modules. Do not
|
|
42
|
+
install all matches. Clarify only a meaningful ambiguity, not the user's
|
|
43
|
+
choice of tool.
|
|
44
|
+
|
|
45
|
+
Run `cto-legends handoff <module>` to resolve the active recipe paths. If
|
|
46
|
+
missing, preview and perform authorized setup, then repeat the handoff. Read
|
|
47
|
+
returned files in order and use `status` for the isolated runtime. A missing
|
|
48
|
+
recipe is a setup defect, not permission to substitute unrelated installed
|
|
49
|
+
global skills. Read only the selected workflow and references; do not preload
|
|
50
|
+
every module. When the handoff names a readiness command, run it before
|
|
51
|
+
promising live results.
|
|
52
|
+
|
|
53
|
+
Only cataloged public modules and explicitly registered local guides are
|
|
54
|
+
known. Unsupported requests must remain unsupported rather than being forced
|
|
55
|
+
into a nearby match. Discovery never grants paid, destructive, or publishing
|
|
56
|
+
authority.
|
|
57
|
+
|
|
58
|
+
`status` may also list explicitly registered `local_guides`. These are
|
|
59
|
+
existing user-selected Markdown instructions, not catalog installs or proof
|
|
60
|
+
of readiness. Read a matching guide when the user requests that capability;
|
|
61
|
+
follow its own prerequisites. Never execute a guide path as a command or
|
|
62
|
+
automatically publish its contents. The manager does not update or roll back
|
|
63
|
+
these local products.
|
|
64
|
+
|
|
65
|
+
One central skill is sufficient: read only the selected product's
|
|
66
|
+
instructions on demand, without installing all its subskills into every host.
|
|
67
|
+
Use `agent-setup codex|gemini|claude|cursor|grok|muse|windsurf|aider` to
|
|
68
|
+
preview host registration, then `--apply` when authorized. `--directory`
|
|
69
|
+
overrides the skill root. Registration is not live discovery proof; reload
|
|
70
|
+
the host and invoke doctor.
|
|
71
|
+
|
|
72
|
+
Run `agent-audit <host>` in the actual execution environment. Windows, WSL,
|
|
73
|
+
remote Linux and temporary agent homes are separate discovery environments.
|
|
74
|
+
When explicitly consolidating registrations, preview `isolate-skills <host>`,
|
|
75
|
+
then apply it. It moves only known replaced registrations to a restorable
|
|
76
|
+
backup. Host plugins and injected tool catalogs may remain; inspect the fresh
|
|
77
|
+
session's advertised skills before declaring a central-only test. Never
|
|
78
|
+
confuse an empty `local_guides` object with evidence that standalone skills
|
|
79
|
+
are absent.
|
|
80
|
+
|
|
81
|
+
Run `task-readiness` before describing the complete workflow as ready. It
|
|
82
|
+
checks report, provider, evidence, and artwork prerequisites separately. A
|
|
83
|
+
missing selected vault or target repository is an input requirement, not a
|
|
84
|
+
failure to discover the installed tools. For an offline acceptance task,
|
|
85
|
+
perform the available checks and write the requested receipt, including
|
|
86
|
+
blockers; do not stop because the workspace is empty.
|
|
87
|
+
|
|
88
|
+
## Install law: suggest, never seize
|
|
89
|
+
|
|
90
|
+
1. The router may propose a module install. Every install is explicit per
|
|
91
|
+
module: `cto-legends install <module>` previews, and nothing is written
|
|
92
|
+
until the user runs with `--apply` (or otherwise explicitly authorizes
|
|
93
|
+
that module).
|
|
94
|
+
2. No bundles: never install all matches, never install a second module as a
|
|
95
|
+
side effect of the first.
|
|
96
|
+
3. No background or silent installs. Native applications use their own
|
|
97
|
+
installers after platform and user intent checks; manager rollback does
|
|
98
|
+
not cover native apps or scene changes. Close recording tools and preserve
|
|
99
|
+
scene backups before applying their extras.
|
|
100
|
+
4. Spending and publishing modules keep their own preview and spending
|
|
101
|
+
gates; installation never grants paid, destructive, or publishing
|
|
102
|
+
authority.
|
|
103
|
+
|
|
104
|
+
## Install what the task needs
|
|
105
|
+
|
|
106
|
+
1. Match the goal using the live capability index.
|
|
107
|
+
2. Preview: `cto-legends install <module>`.
|
|
108
|
+
3. When installation is within the user's request, run the same command with
|
|
109
|
+
`--apply`. Otherwise explain the proposed install and ask before doing it.
|
|
110
|
+
4. Run `cto-legends doctor`, then read that module's recipe paths returned by
|
|
111
|
+
`cto-legends handoff <module>` at the source path returned by `status`.
|
|
112
|
+
Follow its workflow and credential rules.
|
|
113
|
+
5. Use `cto-legends run <module> -- <arguments>` or the exact isolated Python
|
|
114
|
+
path from `status`. Do not use a global Python for managed module
|
|
115
|
+
commands.
|
|
116
|
+
|
|
117
|
+
For guided native products, `install` returns a guided setup handoff. Use
|
|
118
|
+
`guide <module>` to read the pinned README, release assets, platform
|
|
119
|
+
support, and checksums. Do not call these native applications installed
|
|
120
|
+
merely because the guide was returned. Native installation and upgrades use
|
|
121
|
+
their own installers after platform and user intent checks; manager rollback
|
|
122
|
+
does not roll back native applications.
|
|
123
|
+
|
|
124
|
+
Managed installs may need runtimes, credentials, or services beyond the CLI
|
|
125
|
+
itself. Read the module recipe for its access, hardware, license, and
|
|
126
|
+
paid-generation rules, and follow the module's own doctor and setup before
|
|
127
|
+
promising live operation. Do not claim runtimes, model weights, or a working
|
|
128
|
+
generator merely because the planning CLI is installed.
|
|
129
|
+
|
|
130
|
+
## Startup and host registration
|
|
131
|
+
|
|
132
|
+
For dependable discovery, connect the central index to startup instructions
|
|
133
|
+
as well as registering its skill:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
cto-legends startup-setup codex
|
|
137
|
+
cto-legends startup-setup codex --apply
|
|
138
|
+
cto-legends startup-status codex
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This preserves existing instructions and provides a checked restoration
|
|
142
|
+
manifest. Use `gemini` or `claude` for their documented user instruction
|
|
143
|
+
files. Registration alone does not prove that a fresh agent loads or follows
|
|
144
|
+
the instructions.
|
|
145
|
+
|
|
146
|
+
## Update and recover
|
|
147
|
+
|
|
148
|
+
When the user asks about updates, run `cto-legends check-updates`. It
|
|
149
|
+
compares installed versions, the active catalog, and upstream releases, and
|
|
150
|
+
names the next command for each drift. To adopt a refreshed catalog, preview
|
|
151
|
+
`cto-legends sync`, then run `cto-legends sync --apply` when authorized;
|
|
152
|
+
afterward `cto-legends update --apply` refreshes installed modules to the
|
|
153
|
+
new pins. New catalog versions arrive without a router release: the skill
|
|
154
|
+
text stays frozen while modules come and go. If a catalog refresh
|
|
155
|
+
misbehaves, preview `cto-legends sync --rollback` and apply it when
|
|
156
|
+
authorized.
|
|
157
|
+
|
|
158
|
+
If needed, preview `cto-legends rollback <module>` and apply it with
|
|
159
|
+
`--apply`. Previous environments remain on disk. Never erase user reports or
|
|
160
|
+
credentials to fix an installation. Do not modify managed source checkouts;
|
|
161
|
+
save outputs outside them. Managed installs live under the manager home
|
|
162
|
+
(`~/.cto-legends` by default, or `CTO_LEGENDS_HOME` / `--home PATH`): keep
|
|
163
|
+
that home at its original path because Python environments are not
|
|
164
|
+
relocatable.
|
|
165
|
+
|
|
166
|
+
## Research and credentials
|
|
167
|
+
|
|
168
|
+
Installation and doctor do not call paid provider endpoints. Module execution
|
|
169
|
+
can: retain each module's preview, execute and spending gates. Credentials
|
|
170
|
+
stay in user-provided environment variables. Never print or persist secret
|
|
171
|
+
values. Do not subscribe to an MCP server just to discover these modules. No
|
|
172
|
+
background service is required. Route matching is a hint, not an
|
|
173
|
+
authoritative judgment.
|
|
174
|
+
|
|
175
|
+
## Writing style
|
|
176
|
+
|
|
177
|
+
Use plain punctuation. Do not use em dashes in generated copy,
|
|
178
|
+
documentation, or release titles.
|
cto_legends/__init__.py
ADDED
cto_legends/__main__.py
ADDED
cto_legends/agents.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""Small discovery adapters; all hosts read the same canonical skill."""
|
|
2
|
+
import hashlib
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import sys
|
|
6
|
+
import os
|
|
7
|
+
import platform
|
|
8
|
+
import uuid
|
|
9
|
+
|
|
10
|
+
ROOTS = {
|
|
11
|
+
"codex": ".codex/skills", "antigravity": ".gemini/config/skills",
|
|
12
|
+
"gemini": ".gemini/skills",
|
|
13
|
+
"claude": ".claude/skills", "cursor": ".cursor/skills",
|
|
14
|
+
"grok": ".grok/skills", "muse": ".agents/skills",
|
|
15
|
+
"windsurf": ".windsurf/skills", "aider": ".aider/skills",
|
|
16
|
+
}
|
|
17
|
+
ALIASES = {"agy": "antigravity"}
|
|
18
|
+
COMPANION_ROOTS = {"gemini": (".gemini/config/skills",)}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def resolve_host(host):
|
|
22
|
+
host = ALIASES.get(host, host)
|
|
23
|
+
if host not in ROOTS:
|
|
24
|
+
raise ValueError('Unsupported agent host')
|
|
25
|
+
return host
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Only suites actually replaced by the four central catalog workflows.
|
|
29
|
+
# Desktop-control and GitHub's gh wrapper are different products.
|
|
30
|
+
REPLACED = frozenset(('cto-legends-library legends-geogrid legends-dataforseo legends-dataforseo-kit '
|
|
31
|
+
'legends-github legends-empire autoresearch canvas defuddle obsidian-bases '
|
|
32
|
+
'obsidian-markdown save think wiki wiki-cli wiki-fold wiki-ingest wiki-lint '
|
|
33
|
+
'wiki-mode wiki-query wiki-retrieve github github-audit github-community '
|
|
34
|
+
'github-dataforseo github-empire github-legal github-meta github-readme '
|
|
35
|
+
'github-release github-seo').split())
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def audit(host, *, directories=None, user_home=None):
|
|
39
|
+
host = resolve_host(host)
|
|
40
|
+
base = Path(user_home or Path.home())
|
|
41
|
+
if directories:
|
|
42
|
+
roots = list(directories)
|
|
43
|
+
else:
|
|
44
|
+
roots = [base / ROOTS[host]]
|
|
45
|
+
if host in ('gemini', 'antigravity'):
|
|
46
|
+
roots.extend([base / '.gemini/skills', base / '.gemini/config/skills'])
|
|
47
|
+
roots.append(base / '.agents/skills')
|
|
48
|
+
if not directories and host == 'codex' and os.environ.get('CODEX_HOME'):
|
|
49
|
+
roots.append(Path(os.environ['CODEX_HOME']) / 'skills')
|
|
50
|
+
roots = list(dict.fromkeys(str(Path(x).expanduser().absolute()) for x in roots))
|
|
51
|
+
entries = []
|
|
52
|
+
for root in roots:
|
|
53
|
+
directory = Path(root)
|
|
54
|
+
if not directory.is_dir():
|
|
55
|
+
continue
|
|
56
|
+
for item in sorted(directory.iterdir()):
|
|
57
|
+
if item.name in REPLACED or item.name == 'cto-legends':
|
|
58
|
+
entries.append({'name': item.name, 'path': str(item),
|
|
59
|
+
'standalone': item.name in REPLACED, 'linked': item.is_symlink(),
|
|
60
|
+
'instructions_present': (item / 'SKILL.md').is_file()})
|
|
61
|
+
return {'host': host, 'execution_platform': platform.system(),
|
|
62
|
+
'wsl': 'microsoft' in platform.release().lower(), 'python': sys.executable,
|
|
63
|
+
'roots': roots, 'entries': entries, 'discovery': 'unverified',
|
|
64
|
+
'standalone_count': sum(x['standalone'] for x in entries),
|
|
65
|
+
'limit': 'Filesystem inventory only. Host plugins, cached snapshots and tool-provided skill catalogs may inject other instructions. Inspect a fresh session before claiming isolation.'}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def isolate(host, *, directories=None, user_home=None, apply=False):
|
|
69
|
+
inventory = audit(host, directories=directories, user_home=user_home)
|
|
70
|
+
sources = [Path(x['path']) for x in inventory['entries'] if x['standalone']]
|
|
71
|
+
result = {'preview': not apply, 'sources': [str(x) for x in sources],
|
|
72
|
+
'limit': inventory['limit']}
|
|
73
|
+
if not apply or not sources:
|
|
74
|
+
return result
|
|
75
|
+
backup_root = Path(user_home or Path.home()) / '.cto-legends-skill-backups'
|
|
76
|
+
if backup_root.is_symlink():
|
|
77
|
+
raise ValueError('Backup directory is linked; preserved')
|
|
78
|
+
backup = backup_root / uuid.uuid4().hex
|
|
79
|
+
backup.mkdir(parents=True)
|
|
80
|
+
manifest = backup / 'manifest.json'
|
|
81
|
+
rows = []
|
|
82
|
+
for index, source in enumerate(sources):
|
|
83
|
+
# Move the registration itself, never its symlink destination.
|
|
84
|
+
destination = backup / str(index) / source.name
|
|
85
|
+
destination.parent.mkdir()
|
|
86
|
+
row = {'source': str(source), 'backup': str(destination), 'moved': False}
|
|
87
|
+
rows.append(row)
|
|
88
|
+
manifest.write_text(json.dumps({'schema': 1, 'entries': rows}, indent=2), encoding='utf-8')
|
|
89
|
+
source.rename(destination)
|
|
90
|
+
row['moved'] = True
|
|
91
|
+
manifest.write_text(json.dumps({'schema': 1, 'entries': rows}, indent=2), encoding='utf-8')
|
|
92
|
+
return {**result, 'manifest': str(manifest), 'moved': len(rows),
|
|
93
|
+
'next': 'Reload the host. Verify its advertised skills; external injected catalogs are unchanged.'}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def restore(manifest, *, apply=False):
|
|
97
|
+
manifest = Path(manifest).expanduser().absolute()
|
|
98
|
+
data = json.loads(manifest.read_text(encoding='utf-8'))
|
|
99
|
+
if data.get('schema') != 1:
|
|
100
|
+
raise ValueError('Unsupported restoration manifest')
|
|
101
|
+
moves = []
|
|
102
|
+
for row in data['entries']:
|
|
103
|
+
source, backup = Path(row['source']), Path(row['backup'])
|
|
104
|
+
# Validate lexical backup containment without following moved symlinks.
|
|
105
|
+
if (not source.is_absolute() or not backup.is_absolute()
|
|
106
|
+
or manifest.parent.resolve() not in backup.parent.resolve().parents
|
|
107
|
+
or source.name not in REPLACED):
|
|
108
|
+
raise ValueError('Invalid restoration path')
|
|
109
|
+
if not backup.exists() and not backup.is_symlink():
|
|
110
|
+
if source.exists() or source.is_symlink():
|
|
111
|
+
continue # already restored (also tolerates interrupted manifest update)
|
|
112
|
+
if row.get('moved'):
|
|
113
|
+
raise ValueError('Both original and backup are missing')
|
|
114
|
+
continue
|
|
115
|
+
if source.exists() or source.is_symlink():
|
|
116
|
+
raise ValueError('Restoration destination exists; preserved')
|
|
117
|
+
moves.append((backup, source))
|
|
118
|
+
if apply:
|
|
119
|
+
for backup, source in moves:
|
|
120
|
+
source.parent.mkdir(parents=True, exist_ok=True)
|
|
121
|
+
backup.rename(source)
|
|
122
|
+
return {'preview': not apply, 'restored' if apply else 'planned': len(moves)}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _validate_target(target):
|
|
126
|
+
if target.is_symlink():
|
|
127
|
+
raise ValueError("Existing linked skill is user-owned; choose another directory")
|
|
128
|
+
skill = target / "SKILL.md"
|
|
129
|
+
receipt = target / "installation.json"
|
|
130
|
+
if target.exists():
|
|
131
|
+
if not receipt.is_file() or not skill.is_file() or skill.is_symlink() or receipt.is_symlink():
|
|
132
|
+
raise ValueError("Existing skill is unmanaged; preserved")
|
|
133
|
+
old = json.loads(receipt.read_text(encoding="utf-8"))
|
|
134
|
+
if hashlib.sha256(skill.read_bytes()).hexdigest() != old.get("sha256"):
|
|
135
|
+
raise ValueError("Existing skill was edited; preserved")
|
|
136
|
+
return skill, receipt
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def configure(host, managed_home, *, user_home=None, directory=None, apply=False):
|
|
140
|
+
host = resolve_host(host)
|
|
141
|
+
base = Path(user_home or Path.home())
|
|
142
|
+
target = Path(directory).expanduser() if directory else base / ROOTS[host]
|
|
143
|
+
target = target / "cto-legends"
|
|
144
|
+
companions = [] if directory else [base / rel / "cto-legends" for rel in COMPANION_ROOTS.get(host, ())]
|
|
145
|
+
targets = [target, *companions]
|
|
146
|
+
validated = [_validate_target(item) for item in targets]
|
|
147
|
+
skill, _ = validated[0]
|
|
148
|
+
canonical = (Path(__file__).parent / "SKILL.md").read_text(encoding="utf-8")
|
|
149
|
+
content = canonical + (f"\n## Installed manager\n\nUse Python `{sys.executable}` with "
|
|
150
|
+
f"`-m cto_legends --home \"{Path(managed_home).resolve()}\"`.\n"
|
|
151
|
+
"Read only the chosen module's instructions returned by status. "
|
|
152
|
+
"Registration does not prove live discovery or task readiness.\n")
|
|
153
|
+
overlay_path = Path(managed_home).resolve() / "skill-local.md"
|
|
154
|
+
overlay_text = overlay_path.read_text(encoding="utf-8").strip() if overlay_path.is_file() else ""
|
|
155
|
+
if overlay_text:
|
|
156
|
+
content = content.rstrip("\n") + "\n\n" + overlay_text + "\n"
|
|
157
|
+
digest = hashlib.sha256(content.encode()).hexdigest()
|
|
158
|
+
result = {"host": host, "skill": str(skill), "preview": not apply,
|
|
159
|
+
"discovery": "unverified", "next": "Reload host skills and invoke cto-legends doctor"}
|
|
160
|
+
if companions:
|
|
161
|
+
result["companion_skills"] = [str(item / "SKILL.md") for item in companions]
|
|
162
|
+
if apply:
|
|
163
|
+
receipt_text = json.dumps({"host": host, "sha256": digest,
|
|
164
|
+
"python": sys.executable, "managed_home": str(Path(managed_home).resolve()),
|
|
165
|
+
"overlay": overlay_path.name if overlay_text else None,
|
|
166
|
+
"overlay_sha256": hashlib.sha256(overlay_text.encode()).hexdigest() if overlay_text else None}, indent=2)
|
|
167
|
+
for item, (item_skill, item_receipt) in zip(targets, validated):
|
|
168
|
+
item.mkdir(parents=True, exist_ok=True)
|
|
169
|
+
item_skill.write_bytes(content.encode())
|
|
170
|
+
item_receipt.write_text(receipt_text, encoding="utf-8")
|
|
171
|
+
result["registration"] = "installed"
|
|
172
|
+
return result
|