Skills
dotagents._skills
Publish an overlay's skills into a scope's shared skills/ dir, so every
agent that reads that dir sees the same skills (the "skills synced between agents"
behavior).
An overlay may ship skills/<skill-name>/ directories. Publishing symlinks (or,
where symlinks aren't available, copies) each into <scope>/skills/<skill-name>/.
Removing an overlay unpublishes only the skills it published (matched against
its own skills/ source), never a skill another overlay or the user placed there,
then sweeps any now-broken symlinks.
Pure stdlib (os/shutil) -- no pathapi -- so it works in a plain
pip install and inside the .pyz. Symlink-preferred with a copy fallback is
the contract (on Windows a directory junction is tried between the two: it
needs no privilege and, like a symlink, is always current); --copy forces
the copy path up front (Windows / no-symlink).
:func:link_skills_into is the second hop: a store's skills/ linked per
skill into an agent's OWN skills dir (Claude's <config>/skills/), with an
ownership record there so a copy can be refreshed and a skill the store no
longer has can be removed -- never a same-named skill the user placed.
LINKED_RECORD = '.dotagents-linked.json'
module-attribute
PUBLISHED_RECORD = '.dotagents-published.json'
module-attribute
LinkResult()
What :func:link_skills_into did (or, in a dry run, would do), by
skill name: linked (a symlink/junction made or re-pointed),
copied (a copy made or refreshed), removed and kept (left
alone: someone else's, or edited since it was copied). owned is every
name dotagents holds in the target afterwards.
Source code in src/dotagents/_skills.py
452 453 454 455 456 457 | |
__slots__ = ('linked', 'copied', 'removed', 'kept', 'owned')
class-attribute
instance-attribute
copied = []
instance-attribute
kept = []
instance-attribute
linked = []
instance-attribute
owned = []
instance-attribute
removed = []
instance-attribute
SyncResult(success, mode, message='')
Source code in src/dotagents/_skills.py
72 73 74 75 | |
__slots__ = ('success', 'mode', 'message')
class-attribute
instance-attribute
message = message
instance-attribute
mode = mode
instance-attribute
success = success
instance-attribute
__bool__()
Source code in src/dotagents/_skills.py
77 78 | |
clean_broken_syncs(shared_skills, logger=None)
Drop symlinks under shared_skills whose target no longer exists (an
overlay's skills/ went away), then remove the dir if it emptied.
Source code in src/dotagents/_skills.py
277 278 279 280 281 282 283 284 285 286 287 288 289 | |
link_skills_into(shared_skills, target_dir, *, dry_run=False, logger=None)
Link each shared_skills/<name>/ into target_dir/<name> (an
agent's own skills dir), per skill, and drop the entries a skill the
store no longer has left behind.
A symlink where the OS allows one, else (Windows) a junction, else a
copy. Ownership is recorded in target_dir/.dotagents-linked.json
(per store): a link is dotagents' when the record says so or it points
into shared_skills; a copy only while it is byte-for-byte what was
copied (its recorded digest). An owned copy that went stale is refreshed
(re-linked when links work now); an owned entry whose skill is gone is
removed. Anything else of the same name -- a skill the user placed, or a
copy edited in place -- is kept and reported in kept, never replaced.
Source code in src/dotagents/_skills.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | |
linked_names(shared_skills, target_dir)
The names the linked record says shared_skills owns in target_dir.
Source code in src/dotagents/_skills.py
497 498 499 | |
owned_overlay_skills(overlay_dir, shared_skills, *, logger=None)
The names under shared_skills that are THIS overlay's publications
(a symlink to its skill, or a copy matching it) -- decided while the
overlay still exists, so overlays remove can delete the overlay first
and unpublish only once that succeeded (:func:unpublish_skills). A
same-named skill that is someone else's is reported and left out.
Source code in src/dotagents/_skills.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
publish_overlay_skills(overlay_dir, shared_skills, *, copy=False, logger=None)
Publish each overlay_dir/skills/<name>/ into shared_skills.
Symlink-preferred unless copy forces copies. A target that already
holds something else (a skill the user placed or edited) is kept and
reported, never replaced. Returns the count published. Sweeps broken syncs
first so a stale symlink can't block a re-publish.
Source code in src/dotagents/_skills.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
remove_overlay_skills(overlay_dir, shared_skills, *, logger=None)
Unpublish only the skills this overlay published (matched to its source), then sweep broken syncs. Returns the count removed.
Source code in src/dotagents/_skills.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
resync_overlay_skills(overlay_dir, shared_skills, *, copy=False, overwrite=False, logger=None)
Refresh already-published skills of this overlay (copy-mode drift). New
skills are published (as copies with copy, the sync --copy form);
symlinks are inherently current. A copy edited since it was published is
kept unless overwrite (sync --overwrite).
Source code in src/dotagents/_skills.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
resync_path(source, target, *, prefer_symlink=True, published_digest=None, overwrite=False)
Refresh a published skill from its overlay source. A symlink is inherently
current; an unpublished skill is published (symlink-preferred unless
prefer_symlink is False). A copy that differs from the source is
re-copied only when it is still exactly what was published
(published_digest) or overwrite is set -- otherwise it was edited
in place (or placed by hand) and is kept, reported as a conflict.
Source code in src/dotagents/_skills.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
sync_path(source, target, *, prefer_symlink=True, force=False)
Publish source at target -- symlink if possible, else copy.
An existing correct symlink / matching copy is a no-op success. A conflicting
target is only replaced with force=True; otherwise it is reported as a
conflict so the caller can decide (the publish path retries once with force).
Source code in src/dotagents/_skills.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
unpublish_skills(shared_skills, names, *, logger=None)
Remove names from shared_skills (see :func:owned_overlay_skills),
drop their published-copy records, then sweep broken syncs. Returns the
count removed.
Source code in src/dotagents/_skills.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
unsync_path(target, source)
Unpublish target -- but only if it is this overlay's (a symlink to
source, or a copy matching it). A symlink pointing elsewhere, or a copy whose
content differs, is left untouched (it is someone else's).
Source code in src/dotagents/_skills.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |