cribsheet 0.24.0.dev1__py3-none-any.whl → 0.24.0.dev2__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.
- crib/app.py +45 -6
- crib/cli.py +9 -4
- crib/designs.py +24 -2
- crib/facets.py +3 -0
- crib/learnings.py +13 -3
- {cribsheet-0.24.0.dev1.dist-info → cribsheet-0.24.0.dev2.dist-info}/METADATA +1 -1
- {cribsheet-0.24.0.dev1.dist-info → cribsheet-0.24.0.dev2.dist-info}/RECORD +9 -9
- {cribsheet-0.24.0.dev1.dist-info → cribsheet-0.24.0.dev2.dist-info}/WHEEL +0 -0
- {cribsheet-0.24.0.dev1.dist-info → cribsheet-0.24.0.dev2.dist-info}/entry_points.txt +0 -0
crib/app.py
CHANGED
|
@@ -489,12 +489,15 @@ class Crib:
|
|
|
489
489
|
found = self._stamped_ids(root, [r for r in scan(root, ".md", recursive=True)
|
|
490
490
|
if nloc.owns(r)]) \
|
|
491
491
|
if root is not None and nloc is not None and root.is_dir() else set()
|
|
492
|
-
if
|
|
493
|
-
continue
|
|
492
|
+
if ids <= found:
|
|
493
|
+
continue # every item is at the new home
|
|
494
494
|
what = "removed" if new is None else "moved"
|
|
495
495
|
where = link.root / ".crib" if link.root is not None else ".crib"
|
|
496
|
-
|
|
497
|
-
|
|
496
|
+
missing = len(ids - found)
|
|
497
|
+
state = ("the new home is empty" if not found else
|
|
498
|
+
f"the new home holds {len(found)} of the facet's items")
|
|
499
|
+
print(f"[crib] {where}: facets.{noun} was {what}, but {missing} of its "
|
|
500
|
+
f"item(s) are still in {loc.root} and {state} — "
|
|
498
501
|
f"keeping the mapping until they move: `crib project release` "
|
|
499
502
|
f"(back to crib's data dir), move the files"
|
|
500
503
|
f"{'' if new is None else ' to the new dir'}, or remove them if the "
|
|
@@ -1022,6 +1025,19 @@ class Crib:
|
|
|
1022
1025
|
"""True if `proj` has no notes dir yet (a write would create it)."""
|
|
1023
1026
|
return not self.project_paths(proj).notes_dir.exists()
|
|
1024
1027
|
|
|
1028
|
+
def _import_relpath(self, proj: str, facet: str, src: Path) -> str:
|
|
1029
|
+
"""Where an imported doc lands: `imported/<name>`, or under a mapped
|
|
1030
|
+
location, a name its glob takes (the glob's suffix; no `imported/` dir
|
|
1031
|
+
when the glob doesn't reach into subdirectories)."""
|
|
1032
|
+
store = self._facet_store(facet)
|
|
1033
|
+
loc = store.location(proj)
|
|
1034
|
+
rel = f"imported/{src.name}"
|
|
1035
|
+
if loc is None or loc.prefix is not None or loc.owns(rel):
|
|
1036
|
+
return rel
|
|
1037
|
+
stem = src.name[: -len(".md")] if src.name.endswith(".md") else src.stem
|
|
1038
|
+
nested = f"imported/{stem}{loc.suffix}"
|
|
1039
|
+
return nested if loc.owns(nested) else f"imported-{stem}{loc.suffix}"
|
|
1040
|
+
|
|
1025
1041
|
def _unique_relpath(self, proj: str, slug: str, facet: str = facets.HOME) -> str:
|
|
1026
1042
|
"""`<slug>.md`, with a numeric suffix only on collision — predictable and
|
|
1027
1043
|
hand-referenceable. Stable identity is the frontmatter `id`, not the path."""
|
|
@@ -2759,12 +2775,17 @@ class Crib:
|
|
|
2759
2775
|
import shutil
|
|
2760
2776
|
|
|
2761
2777
|
moved = 0
|
|
2778
|
+
kept = 0
|
|
2762
2779
|
for p, target in Crib._tree_pairs(src, dst):
|
|
2763
2780
|
if target.exists():
|
|
2781
|
+
kept += 1 # never overwritten; the source keeps it
|
|
2764
2782
|
continue
|
|
2765
2783
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
2766
2784
|
shutil.move(str(p), str(target))
|
|
2767
2785
|
moved += 1
|
|
2786
|
+
if kept:
|
|
2787
|
+
print(f"[crib] {kept} version stash(es) already in {dst} were kept; "
|
|
2788
|
+
f"the copies in {src} stay where they are", file=sys.stderr)
|
|
2768
2789
|
return moved
|
|
2769
2790
|
|
|
2770
2791
|
@staticmethod
|
|
@@ -2792,15 +2813,33 @@ class Crib:
|
|
|
2792
2813
|
f"({', '.join(taken[:3])}{', ...' if len(taken) > 3 else ''}): "
|
|
2793
2814
|
"nothing was moved. Move those aside and re-run")
|
|
2794
2815
|
done: list[tuple[Path, Path]] = []
|
|
2816
|
+
current: tuple[Path, Path] | None = None
|
|
2795
2817
|
try:
|
|
2796
2818
|
for src, dst in pairs:
|
|
2819
|
+
current = (src, dst)
|
|
2797
2820
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
2798
2821
|
shutil.move(str(src), str(dst))
|
|
2799
2822
|
done.append((src, dst))
|
|
2823
|
+
current = None
|
|
2800
2824
|
except OSError as e:
|
|
2801
|
-
|
|
2825
|
+
# across filesystems a move is copy + unlink: a copy that failed
|
|
2826
|
+
# part-way leaves a partial file at the destination; the source is
|
|
2827
|
+
# still whole, so the partial copy goes
|
|
2828
|
+
if current is not None and current[0].exists() and current[1].exists():
|
|
2802
2829
|
with contextlib.suppress(OSError):
|
|
2830
|
+
current[1].unlink()
|
|
2831
|
+
stuck: list[str] = []
|
|
2832
|
+
for src, dst in reversed(done):
|
|
2833
|
+
try:
|
|
2803
2834
|
shutil.move(str(dst), str(src))
|
|
2835
|
+
except OSError:
|
|
2836
|
+
stuck.append(str(dst))
|
|
2837
|
+
if stuck:
|
|
2838
|
+
raise CribUserError(
|
|
2839
|
+
f"moving {what} failed at {e.filename or '?'} ({e.strerror or e}), "
|
|
2840
|
+
f"and {len(stuck)} file(s) that had moved could not be put back: "
|
|
2841
|
+
f"{', '.join(stuck[:5])}{', ...' if len(stuck) > 5 else ''} "
|
|
2842
|
+
"(they are whole, at the destination)") from e
|
|
2804
2843
|
raise CribUserError(
|
|
2805
2844
|
f"moving {what} failed at {e.filename or '?'} ({e.strerror or e}); "
|
|
2806
2845
|
f"nothing was moved") from e
|
|
@@ -6426,7 +6465,7 @@ class Crib:
|
|
|
6426
6465
|
src = src.resolve()
|
|
6427
6466
|
if not src.is_file():
|
|
6428
6467
|
raise CribUserError(f"not a file: {p}")
|
|
6429
|
-
relpath =
|
|
6468
|
+
relpath = self._import_relpath(proj, facet, src)
|
|
6430
6469
|
sfm, sbody = notes.parse(src.read_text())
|
|
6431
6470
|
tgt = self.abspath(proj, relpath, facet)
|
|
6432
6471
|
prev = notes.load(tgt) if tgt.exists() else None
|
crib/cli.py
CHANGED
|
@@ -3980,13 +3980,18 @@ def _facets_cmd(args: Any) -> int:
|
|
|
3980
3980
|
"--apply --shared once their facets files agree")
|
|
3981
3981
|
return 1
|
|
3982
3982
|
crib.store.facet_sync(drop=args.drop, shared=args.shared)
|
|
3983
|
-
#
|
|
3983
|
+
# a facet whose store moved leaves its files in the old directories (unless
|
|
3984
|
+
# another facet now has that store): in crib's data dir, and in each project
|
|
3985
|
+
# adopted into a repo (`store:`)
|
|
3984
3986
|
for p in todo:
|
|
3985
3987
|
old = p.get("was_store")
|
|
3986
3988
|
spec = facets.get(p["facet"])
|
|
3987
|
-
if old and spec is not None and old != spec.store:
|
|
3988
|
-
|
|
3989
|
-
|
|
3989
|
+
if old and spec is not None and old != spec.store and facets.by_store(old) is None:
|
|
3990
|
+
roots = [crib.paths.projects_dir / n for n in crib.projects()]
|
|
3991
|
+
roots += [pp.data_root for n in crib.projects()
|
|
3992
|
+
if (pp := crib.project_paths(n)).in_repo and pp.available]
|
|
3993
|
+
left = sorted({d for r in roots if (d := r / old).is_dir()
|
|
3994
|
+
and any(d.rglob("*.md"))})
|
|
3990
3995
|
for d in left:
|
|
3991
3996
|
print(f" note: {p['facet']} items are still in {d}: move them to "
|
|
3992
3997
|
f"{d.parent / spec.store} (the store is now {spec.store!r})")
|
crib/designs.py
CHANGED
|
@@ -628,10 +628,15 @@ class Designs:
|
|
|
628
628
|
if (why := store.pending_move(proj)) is not None:
|
|
629
629
|
graph.pending[kind] = why
|
|
630
630
|
home = store.project_paths(proj).home_dir(store.spec.segment)
|
|
631
|
-
|
|
631
|
+
nodes = self._nodes_from_files(kind, home)
|
|
632
|
+
# and what is already in the mapping (a teammate's committed items)
|
|
633
|
+
loc = store.location(proj)
|
|
634
|
+
if loc is not None and loc.available:
|
|
635
|
+
nodes += self._nodes_owned(kind, loc)
|
|
636
|
+
for node in nodes:
|
|
632
637
|
for src in node.sources:
|
|
633
638
|
src["current"] = self._section_hash(proj, src, docs)
|
|
634
|
-
graph.nodes
|
|
639
|
+
graph.nodes.setdefault(node.id, node)
|
|
635
640
|
continue
|
|
636
641
|
try:
|
|
637
642
|
d = store.root(proj)
|
|
@@ -742,6 +747,23 @@ class Designs:
|
|
|
742
747
|
out.append(_node_from_file(kind, path.name, fm, body))
|
|
743
748
|
return out
|
|
744
749
|
|
|
750
|
+
@staticmethod
|
|
751
|
+
def _nodes_owned(kind: str, loc: Any) -> list[Node]:
|
|
752
|
+
"""`kind`'s nodes parsed from the files a mapped location owns (its
|
|
753
|
+
glob), relpaths relative to the mapping."""
|
|
754
|
+
out: list[Node] = []
|
|
755
|
+
for path in sorted(loc.root.rglob("*.md")):
|
|
756
|
+
rel = str(path.relative_to(loc.root))
|
|
757
|
+
if not loc.owns(rel):
|
|
758
|
+
continue
|
|
759
|
+
try:
|
|
760
|
+
fm, body = notes.parse(path.read_text(), path)
|
|
761
|
+
except (OSError, UnicodeDecodeError, notes.NoteParseError):
|
|
762
|
+
continue
|
|
763
|
+
if fm.get("id"):
|
|
764
|
+
out.append(_node_from_file(kind, rel, fm, body))
|
|
765
|
+
return out
|
|
766
|
+
|
|
745
767
|
def _note_nodes(self, proj: str, ids: set[str]) -> dict[str, Node]:
|
|
746
768
|
"""The plain notes among `ids`, as kind-"note" nodes with a body hash."""
|
|
747
769
|
out: dict[str, Node] = {}
|
crib/facets.py
CHANGED
|
@@ -822,6 +822,9 @@ def instructions(specs: Iterable[FacetSpec] | None = None,
|
|
|
822
822
|
line += (" Not ready in this store yet: it waits for "
|
|
823
823
|
"`crib facets sync --apply` (its tools refuse until then).")
|
|
824
824
|
out.append(line)
|
|
825
|
+
out += ["", "A tool of one of these that refuses with \"isn't ready in this store\" "
|
|
826
|
+
"is waiting for `crib facets sync --apply`: say so rather than work "
|
|
827
|
+
"around it."]
|
|
825
828
|
return "\n".join(out) + "\n"
|
|
826
829
|
|
|
827
830
|
|
crib/learnings.py
CHANGED
|
@@ -93,11 +93,21 @@ class Learnings:
|
|
|
93
93
|
return rel
|
|
94
94
|
# A note written before the case-hash slug keeps its old filename — those are
|
|
95
95
|
# deliberately never renamed, since a human may have the path in hand.
|
|
96
|
-
for cand in (
|
|
96
|
+
for cand in self._candidates(proj, binding):
|
|
97
97
|
if self.store.abspath(proj, cand).exists():
|
|
98
98
|
return cand
|
|
99
99
|
return None
|
|
100
100
|
|
|
101
|
+
def _candidates(self, proj: str, binding: str) -> tuple[str, ...]:
|
|
102
|
+
"""The filenames a learning for `binding` may already have: the
|
|
103
|
+
canonical and legacy slugs, with this location's suffix (a mapped
|
|
104
|
+
facet's glob suffix, `.md` otherwise) and, beside it, plain `.md`."""
|
|
105
|
+
sfx = self.store.suffix(proj)
|
|
106
|
+
names = [f"{ref_slug(binding)}{sfx}", f"{legacy_ref_slug(binding)}{sfx}"]
|
|
107
|
+
if sfx != ".md":
|
|
108
|
+
names += [f"{ref_slug(binding)}.md", f"{legacy_ref_slug(binding)}.md"]
|
|
109
|
+
return tuple(names)
|
|
110
|
+
|
|
101
111
|
def relpath(self, proj: str, entry: dict[str, Any]) -> str:
|
|
102
112
|
"""THE learning-note relpath for a symbol — the ONE function every verb uses.
|
|
103
113
|
|
|
@@ -111,7 +121,7 @@ class Learnings:
|
|
|
111
121
|
rel = by_binding.get(b)
|
|
112
122
|
if rel:
|
|
113
123
|
return rel
|
|
114
|
-
for cand in (
|
|
124
|
+
for cand in self._candidates(proj, b):
|
|
115
125
|
if self.store.abspath(proj, cand).exists():
|
|
116
126
|
return cand
|
|
117
127
|
# a new note's name ends as its location's glob wants (a mapped facet)
|
|
@@ -409,7 +419,7 @@ class Learnings:
|
|
|
409
419
|
rows["orphan"].append({"relpath": path.name, "binding": bound})
|
|
410
420
|
continue
|
|
411
421
|
ref = symbol_key(entry)
|
|
412
|
-
target = f"{ref_slug(ref)}.
|
|
422
|
+
target = f"{ref_slug(ref)}{self.store.suffix(proj)}"
|
|
413
423
|
if (
|
|
414
424
|
fm.get("symbol_ref") == ref
|
|
415
425
|
and "symbol" not in fm
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
crib/__init__.py,sha256=KzW14Xf3xyTCrmhsSbcFleJVCU6u6-WFidcrLB4YZSw,1001
|
|
2
2
|
crib/__main__.py,sha256=umIc03A2oA7s2oiL80Ts_QnS-0zj9fjV3IQ103AmNXg,232
|
|
3
|
-
crib/app.py,sha256=
|
|
3
|
+
crib/app.py,sha256=qY6A7F6KeRyC__trMZLaKSRP4b7IuvtWQcHAbrdAs8k,318150
|
|
4
4
|
crib/chunk.py,sha256=G5Ftt4zHQ0tx4__ecysFnW64otciPFcqpZ3Y-c_G6JE,15166
|
|
5
5
|
crib/claudemem.py,sha256=Xf4mVgTFbXHdhhqteTIRz2zirc4irf0wim8AeMybudI,4804
|
|
6
|
-
crib/cli.py,sha256=
|
|
6
|
+
crib/cli.py,sha256=OKqFdnC80gf8FSYTDABeLCEPrtwVxoWhJ5CnsKUFNy0,163109
|
|
7
7
|
crib/client.py,sha256=-PRVFFLjbI-D-libZ_wMdDFdcXkyHmc9AYikzxd9PmI,6605
|
|
8
8
|
crib/codeindex.py,sha256=HYavhLOEieD62iNQasC__kAaMEN6ld1uP2oHmoJjyEI,89916
|
|
9
9
|
crib/codeindexer.py,sha256=-eocU6ThZdNJar-cGaNJUgB5b6fd21QsjIRx56UFy-I,36737
|
|
@@ -11,14 +11,14 @@ crib/codequery.py,sha256=kJe1Mybwixydozjd8XOcxqnxgr9RodUiMFUnVnRsmyk,39191
|
|
|
11
11
|
crib/codestore.py,sha256=WgZCt3_ingKHNQgb-SuYNlS3Nkj3Meb6HQpVKkdKT1o,25357
|
|
12
12
|
crib/config.py,sha256=tVtj7py7ddgIcIWFxejetKOMMSIfGbu5Xpl-byEiNeE,42718
|
|
13
13
|
crib/describe_queue.py,sha256=orr6BTq9bch5dHTR_cAxEXr8PTqqVy7_a21yc94Amrk,6644
|
|
14
|
-
crib/designs.py,sha256=
|
|
14
|
+
crib/designs.py,sha256=IEEEmeIRVnsXVv_oWQV4u7P0nkJpjbjz79GD_syidkI,160545
|
|
15
15
|
crib/diag.py,sha256=0tB2PJ3Vow13FvCIkkTnjKzCbJ8RsgGAV5hEv-Z8i7Y,4805
|
|
16
16
|
crib/doctor.py,sha256=EFD2PUBuOw-PwVSZ34x5nNJACIquTZkBaIaHlJtVXzc,9969
|
|
17
17
|
crib/embed.py,sha256=aCI-3qULlKXx3fu8Q84o8b8IIP0GAtRcwBNSQZy-BOI,11108
|
|
18
18
|
crib/embedcache.py,sha256=x-4lV90Sw9jzbJWQ6NuxLULixKhFNr34owy9U8jLBXs,4896
|
|
19
19
|
crib/enrichments.py,sha256=R99rCJxGsiCVx2YgJuzogo80ZgjKTJnyjkO2TBNxq1A,6142
|
|
20
20
|
crib/errors.py,sha256=OBCUWM1vH1zbZUPB7DhAkOydBQFYYfSWsCC83XRbDeo,1363
|
|
21
|
-
crib/facets.py,sha256=
|
|
21
|
+
crib/facets.py,sha256=cCcYEJSmItiXt9T6AhF1mEWLHb-k02x0ZTxrE5RNdns,38684
|
|
22
22
|
crib/facets.toml,sha256=et3j0CHGKOWFa-anw3rNJAxDCFdHWYMmX1kaAylCP3Y,2762
|
|
23
23
|
crib/fields.py,sha256=cFsWKlycprLGX6U97ZMuXmTzisSixLrPWZcr823h_GQ,5297
|
|
24
24
|
crib/filesync.py,sha256=H8n2gf3HqSBf5ezW7oQWG7RrwchqLmL0kWzomVw91MY,3739
|
|
@@ -30,7 +30,7 @@ crib/graph_texts.py,sha256=yvcLJuQPYKVsItgsB4IQHxO4qFUWl1enfhin9IvvCBQ,23244
|
|
|
30
30
|
crib/inbound_auth.py,sha256=B2SbiKIMWP5o4pPQribkvtzbDTc_WVYV3MaDoOZ4uTE,4770
|
|
31
31
|
crib/indexer.py,sha256=75NTHA7W15tQbliIDN02BgotdKJak_ZeqW43DqCGGJ4,20150
|
|
32
32
|
crib/items.py,sha256=a0n2TlOLRYiCZomQ6wn4xvgqSJQLPbTOJiJs6HXeTvQ,14831
|
|
33
|
-
crib/learnings.py,sha256=
|
|
33
|
+
crib/learnings.py,sha256=1gxKZ6HY7ppVolkepcPTopna6hp276Xc_2Wo-2jXe7w,32185
|
|
34
34
|
crib/memmirror.py,sha256=DtDxPA9aHuznU5RWsU2Ud2hiz3CRPp9jSCObax1gnSU,5402
|
|
35
35
|
crib/merge.py,sha256=AE5wQJ7QT_S2hcHBPAGfh9PWVWvcWbP7B2mtyadcuJ8,6285
|
|
36
36
|
crib/notes.py,sha256=jd-Uf67FzdULtOnCh_bsR9-5Rnxsa6jWnnujNEyyj-k,6938
|
|
@@ -56,7 +56,7 @@ crib/util.py,sha256=EmDszxT0SIjIkgcppD6pDJxbkp3eU-7blYRwri5b_m4,3282
|
|
|
56
56
|
crib/verbs.py,sha256=o8686nxHUnGb6ceWTUbhrKDAUfQps5_6fZIVmbmc28I,53758
|
|
57
57
|
crib/versions.py,sha256=P517DveKCh2jKb3o5IOxkzki8ddwmc-QeuiYMvsBb88,3646
|
|
58
58
|
crib/watch.py,sha256=Uzy_BgvaTUCMzokTvgmX7vIEdGDh4Rb_M8MReYlAcCw,36361
|
|
59
|
-
cribsheet-0.24.0.
|
|
60
|
-
cribsheet-0.24.0.
|
|
61
|
-
cribsheet-0.24.0.
|
|
62
|
-
cribsheet-0.24.0.
|
|
59
|
+
cribsheet-0.24.0.dev2.dist-info/METADATA,sha256=vwLGkxSaODTHBIUuH7oS8MOF_YajAFpJRqY8Ymbz11Q,21224
|
|
60
|
+
cribsheet-0.24.0.dev2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
61
|
+
cribsheet-0.24.0.dev2.dist-info/entry_points.txt,sha256=CjLxgcZdPGI6U4VRZmrwQ2kL1gUkNykYNkLzT8EQkfQ,39
|
|
62
|
+
cribsheet-0.24.0.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|