lorewell 0.4.0__tar.gz → 0.4.2__tar.gz

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.
Files changed (30) hide show
  1. {lorewell-0.4.0 → lorewell-0.4.2}/PKG-INFO +1 -1
  2. {lorewell-0.4.0 → lorewell-0.4.2}/lorewell.py +47 -9
  3. {lorewell-0.4.0 → lorewell-0.4.2}/tests/test_lorewell.py +3 -2
  4. {lorewell-0.4.0 → lorewell-0.4.2}/LICENSE +0 -0
  5. {lorewell-0.4.0 → lorewell-0.4.2}/README.md +0 -0
  6. {lorewell-0.4.0 → lorewell-0.4.2}/docs/RUNBOOK.md +0 -0
  7. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/cheatsheet.md +0 -0
  8. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/examples.jsonl +0 -0
  9. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/pack.json +0 -0
  10. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/sections.jsonl +0 -0
  11. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/skill.md +0 -0
  12. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/symbols.jsonl +0 -0
  13. {lorewell-0.4.0 → lorewell-0.4.2}/packs/jq/tools.jsonl +0 -0
  14. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/cheatsheet.md +0 -0
  15. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/examples.jsonl +0 -0
  16. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/files/fixture/content.html +0 -0
  17. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/files/fixture/homepage.html +0 -0
  18. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/files/fixture/portal.html +0 -0
  19. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/files/fixture/signon.html +0 -0
  20. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/files/run_snippet.py +0 -0
  21. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/pack.json +0 -0
  22. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/sections.jsonl +0 -0
  23. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/skill.md +0 -0
  24. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/symbols.jsonl +0 -0
  25. {lorewell-0.4.0 → lorewell-0.4.2}/packs/peoplesoft-pia/tools.jsonl +0 -0
  26. {lorewell-0.4.0 → lorewell-0.4.2}/pyproject.toml +0 -0
  27. {lorewell-0.4.0 → lorewell-0.4.2}/tests/fake_model.py +0 -0
  28. {lorewell-0.4.0 → lorewell-0.4.2}/tests/fakeps.py +0 -0
  29. {lorewell-0.4.0 → lorewell-0.4.2}/tests/test_build.py +0 -0
  30. {lorewell-0.4.0 → lorewell-0.4.2}/tests/test_workspace.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lorewell
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Reference packs for languages and their tools, that an agent looks things up in instead of holding them in context: one SQLite file each, installed as a skill any skill-reading agent can use (designed for hobkin; Claude Code reads it as it is).
5
5
  Keywords: agent,llm,ai,skills,reference,documentation,rag,sqlite,mcp,hobkin,claude-code
6
6
  Author: Frank Lynam
@@ -49,7 +49,7 @@ Standard library only; Python 3.9+. See README.md for the pack source format.
49
49
 
50
50
  from __future__ import annotations
51
51
 
52
- __version__ = "0.4.0"
52
+ __version__ = "0.4.2"
53
53
 
54
54
  import argparse
55
55
  import base64
@@ -738,10 +738,11 @@ REDACT = [
738
738
  (r"\bxox[abprs]-[A-Za-z0-9-]{10,}", "<redacted>"), # Slack tokens
739
739
  (r"\beyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]{8,}", "<redacted>"), # JWTs
740
740
  (r"(?i)\b(bearer|basic)\s+[\w.~+/=-]{8,}", r"\1 <redacted>"), # Authorization: Bearer ...
741
- (r"(?i)\b(password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|"
742
- r"aws_secret_access_key|authorization)([\"']?\s*[:=]\s*[\"']?)(?!<redacted)[^\s&\"',;]+", r"\1\2<redacted>"),
741
+ (r"(?i)(\b[\w.-]*?(?:password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|"
742
+ r"aws_secret_access_key|authorization))([\"']?\s*[:=]\s*[\"']?)(?!<redacted)[^\s&\"',;]+", r"\1\2<redacted>"),
743
743
  (r"(://[^/\s:@]+):[^/\s@]+@", r"\1:<redacted>@"), # user:pass@ in URLs
744
- (r"(?<![\w/+=])[A-Za-z0-9+/]{40,}={0,2}(?![\w/+=])", "<redacted blob>"), # long base64: keys, tokens
744
+ (r"(?<![\w/+=])(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*[0-9])[A-Za-z0-9+/]{40,}={0,2}"
745
+ r"(?![\w/+=])", "<redacted blob>"), # long base64 (keys, tokens): mixed case and digits, so not hashes or paths
745
746
  ]
746
747
  _REDACT = [(re.compile(p, re.S), r) for p, r in REDACT]
747
748
  STOPWORDS = set("""a an and are as at be but by can could did do does doing for from had has have how i if in into is
@@ -2547,12 +2548,49 @@ LOOKUPS = {"info": cmd_info, "cheatsheet": cmd_cheatsheet, "toc": cmd_toc, "sear
2547
2548
  "note": cmd_note, "notes": cmd_notes}
2548
2549
 
2549
2550
 
2551
+ class HelpFormat(argparse.RawDescriptionHelpFormatter):
2552
+ """--help laid out the way hobkin, lorewell, eaveswatch, atone and hearthboard all do it: a short usage line,
2553
+ then each command and option on one line with what it does (argparse's {a,b,c} list of choices left out)."""
2554
+
2555
+ def __init__(self, prog):
2556
+ super().__init__(prog, max_help_position=26, width=min(100, shutil.get_terminal_size((100, 24)).columns))
2557
+
2558
+ def _format_action(self, action):
2559
+ if isinstance(action, argparse._SubParsersAction):
2560
+ return "".join(self._format_action(a) for a in action._get_subactions())
2561
+ return super()._format_action(action)
2562
+
2563
+ @classmethod
2564
+ def everywhere(cls, parser, prog=None):
2565
+ """This layout for a parser and all its commands, at every level: commands shown as COMMAND, and listed
2566
+ under "commands" (or "arguments", where there are others too)."""
2567
+ parser.formatter_class = cls
2568
+ subs = [a for a in parser._positionals._group_actions if isinstance(a, argparse._SubParsersAction)]
2569
+ for action in subs:
2570
+ action.metavar = action.metavar or "COMMAND"
2571
+ for each in action.choices.values():
2572
+ cls.everywhere(each)
2573
+ if subs:
2574
+ parser._positionals.title = "commands" if len(subs) == len(parser._positionals._group_actions) else "arguments"
2575
+ return parser
2576
+
2577
+
2550
2578
  def parser() -> argparse.ArgumentParser:
2551
- ap = argparse.ArgumentParser(prog="lorewell" if Path(sys.argv[0]).name != "lore.py" else "lore.py",
2552
- description="Reference packs (lores) for languages and their tools.")
2553
- ap.add_argument("--version", action="version", version=f"lorewell {__version__}")
2579
+ prog = "lorewell" if Path(sys.argv[0]).name != "lore.py" else "lore.py"
2580
+ ap = argparse.ArgumentParser(
2581
+ prog=prog, usage=f"{prog} COMMAND [options]",
2582
+ description="lorewell: reference packs (lores) for languages and their tools, one SQLite file each: ranked\n"
2583
+ "search, symbols, checked examples and tool docs, installed as a skill any agent reads. And\n"
2584
+ "living lores, which agents write as they learn (hobkin's field lore is one).",
2585
+ epilog="examples:\n"
2586
+ f" {prog} install jq.lore.db a lore, as a skill for the agent here\n"
2587
+ f" {prog} --lore jq.lore.db search 'select by key' ranked hits\n"
2588
+ f" {prog} build mytool docs/ --base-url URL --model M\n"
2589
+ f" {prog} living field.lore.db topics what a living lore holds\n\n"
2590
+ f"{prog} COMMAND --help: that command's options. More: https://github.com/frank-lynam/lorewell")
2591
+ ap.add_argument("--version", action="version", version=f"lorewell {__version__}", help="show the version and exit")
2554
2592
  ap.add_argument("--lore", help="the .lore.db to read (default: $LORE, or the one beside lore.py)")
2555
- sub = ap.add_subparsers(dest="cmd")
2593
+ sub = ap.add_subparsers(dest="cmd", metavar="COMMAND", prog=prog)
2556
2594
  c = sub.add_parser("compile", help="compile a pack source folder into a lore")
2557
2595
  c.add_argument("src")
2558
2596
  c.add_argument("-o", "--out", help="where to write it (default: NAME.lore.db here)")
@@ -2677,7 +2715,7 @@ def parser() -> argparse.ArgumentParser:
2677
2715
  x.add_argument("days", type=float, nargs="?", default=90)
2678
2716
  x = lsub.add_parser("merge", help="bring another living lore in (newest wins, nothing lost)")
2679
2717
  x.add_argument("other")
2680
- return ap
2718
+ return HelpFormat.everywhere(ap)
2681
2719
 
2682
2720
 
2683
2721
  def cmd_ws(args) -> int:
@@ -355,9 +355,10 @@ class LivingTest(unittest.TestCase):
355
355
  self.assertEqual(self.lv.search("bazel"), [])
356
356
 
357
357
  def test_secrets_never_get_in(self):
358
- self.lv.remember("env/prod", "Deploys use token=hunter2xyz and key AKIAABCDEFGHIJKLMNOP via https://u:pw@h/x")
358
+ self.lv.remember("env/prod", "Deploys use token=hunter2xyz and key AKIAABCDEFGHIJKLMNOP via https://u:pw@h/x"
359
+ " with db_password=dbpw42")
359
360
  body = self.lv.get("env/prod")["body"]
360
- for secret in ("hunter2xyz", "AKIAABCDEFGHIJKLMNOP", "u:pw@"):
361
+ for secret in ("hunter2xyz", "AKIAABCDEFGHIJKLMNOP", "u:pw@", "dbpw42"):
361
362
  self.assertNotIn(secret, body)
362
363
 
363
364
  def test_aliases_join_names(self):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes