youparle 0.1.0__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.
Files changed (182) hide show
  1. youparle/__init__.py +17 -0
  2. youparle/__main__.py +8 -0
  3. youparle/agents.py +151 -0
  4. youparle/agents_block.md +60 -0
  5. youparle/cli.py +511 -0
  6. youparle/commands/__init__.py +0 -0
  7. youparle/commands/build.py +59 -0
  8. youparle/commands/cards.py +49 -0
  9. youparle/commands/check.py +246 -0
  10. youparle/commands/exercise.py +65 -0
  11. youparle/commands/fetch.py +83 -0
  12. youparle/commands/guide.py +275 -0
  13. youparle/commands/html_reader.py +386 -0
  14. youparle/commands/init.py +243 -0
  15. youparle/commands/journal.py +20 -0
  16. youparle/commands/json_reader.py +260 -0
  17. youparle/commands/open_note.py +45 -0
  18. youparle/commands/publish.py +34 -0
  19. youparle/commands/server.py +87 -0
  20. youparle/commands/skill.py +91 -0
  21. youparle/commands/tmp.py +21 -0
  22. youparle/commands/tts.py +42 -0
  23. youparle/commands/voice.py +119 -0
  24. youparle/contract.py +237 -0
  25. youparle/documents/__init__.py +3 -0
  26. youparle/documents/cards.py +217 -0
  27. youparle/documents/embeds.py +33 -0
  28. youparle/documents/frontmatter.py +84 -0
  29. youparle/documents/lesson.py +41 -0
  30. youparle/documents/publish.py +122 -0
  31. youparle/documents/separators.py +108 -0
  32. youparle/documents/transient.py +142 -0
  33. youparle/errors.py +54 -0
  34. youparle/exercises/__init__.py +7 -0
  35. youparle/exercises/answers.py +289 -0
  36. youparle/exercises/format.py +24 -0
  37. youparle/exercises/render.py +155 -0
  38. youparle/exercises/rules.py +70 -0
  39. youparle/exercises/schema.py +49 -0
  40. youparle/exercises/shape.py +212 -0
  41. youparle/exercises/store.py +234 -0
  42. youparle/fields.py +279 -0
  43. youparle/file_naming.py +76 -0
  44. youparle/fs.py +65 -0
  45. youparle/harness.py +211 -0
  46. youparle/journal.py +92 -0
  47. youparle/media.py +793 -0
  48. youparle/memory.py +40 -0
  49. youparle/pages.py +68 -0
  50. youparle/proposal.py +338 -0
  51. youparle/reading/__init__.py +9 -0
  52. youparle/reading/display.py +94 -0
  53. youparle/reading/entries.py +72 -0
  54. youparle/reading/files.py +119 -0
  55. youparle/reading/outline.py +215 -0
  56. youparle/reading/page_outline.py +206 -0
  57. youparle/reading/page_text.py +196 -0
  58. youparle/reading/paths.py +636 -0
  59. youparle/reading/selectors.py +547 -0
  60. youparle/reading/tree.py +399 -0
  61. youparle/rules.py +69 -0
  62. youparle/server/__init__.py +3 -0
  63. youparle/server/__main__.py +28 -0
  64. youparle/server/app.py +100 -0
  65. youparle/server/control.py +243 -0
  66. youparle/server/filelock.py +46 -0
  67. youparle/server/handler.py +520 -0
  68. youparle/server/runtime.py +160 -0
  69. youparle/skills/card.md +64 -0
  70. youparle/skills/exercise-page.md +73 -0
  71. youparle/skills/exercise.md +61 -0
  72. youparle/skills/feedback.md +23 -0
  73. youparle/skills/harness.md +23 -0
  74. youparle/skills/lesson.md +45 -0
  75. youparle/skills/minimal-pairs.md +92 -0
  76. youparle/skills/onboarding.md +28 -0
  77. youparle/skills/remember.md +44 -0
  78. youparle/skills/resource-search.md +70 -0
  79. youparle/skills/resources.md +151 -0
  80. youparle/skills/session-start.md +46 -0
  81. youparle/skills/shadowing.md +80 -0
  82. youparle/skills/update.md +21 -0
  83. youparle/skills/voice.md +62 -0
  84. youparle/speech.py +311 -0
  85. youparle/static/base.css +350 -0
  86. youparle/static/beacon.js +17 -0
  87. youparle/static/cards.css +263 -0
  88. youparle/static/cards.js +340 -0
  89. youparle/static/dates.js +11 -0
  90. youparle/static/direction.js +30 -0
  91. youparle/static/exercise.css +705 -0
  92. youparle/static/exercise.js +472 -0
  93. youparle/static/fonts/Fredoka-OFL.txt +93 -0
  94. youparle/static/fonts/Ubuntu-UFL.txt +96 -0
  95. youparle/static/fonts/fonts.css +219 -0
  96. youparle/static/fonts/fredoka-hebrew.woff2 +0 -0
  97. youparle/static/fonts/fredoka-latin-ext.woff2 +0 -0
  98. youparle/static/fonts/fredoka-latin.woff2 +0 -0
  99. youparle/static/fonts/ubuntu-400-cyrillic-ext.woff2 +0 -0
  100. youparle/static/fonts/ubuntu-400-cyrillic.woff2 +0 -0
  101. youparle/static/fonts/ubuntu-400-greek-ext.woff2 +0 -0
  102. youparle/static/fonts/ubuntu-400-greek.woff2 +0 -0
  103. youparle/static/fonts/ubuntu-400-latin-ext.woff2 +0 -0
  104. youparle/static/fonts/ubuntu-400-latin.woff2 +0 -0
  105. youparle/static/fonts/ubuntu-500-cyrillic-ext.woff2 +0 -0
  106. youparle/static/fonts/ubuntu-500-cyrillic.woff2 +0 -0
  107. youparle/static/fonts/ubuntu-500-greek-ext.woff2 +0 -0
  108. youparle/static/fonts/ubuntu-500-greek.woff2 +0 -0
  109. youparle/static/fonts/ubuntu-500-latin-ext.woff2 +0 -0
  110. youparle/static/fonts/ubuntu-500-latin.woff2 +0 -0
  111. youparle/static/fonts/ubuntu-700-cyrillic-ext.woff2 +0 -0
  112. youparle/static/fonts/ubuntu-700-cyrillic.woff2 +0 -0
  113. youparle/static/fonts/ubuntu-700-greek-ext.woff2 +0 -0
  114. youparle/static/fonts/ubuntu-700-greek.woff2 +0 -0
  115. youparle/static/fonts/ubuntu-700-latin-ext.woff2 +0 -0
  116. youparle/static/fonts/ubuntu-700-latin.woff2 +0 -0
  117. youparle/static/logo.webp +0 -0
  118. youparle/static/matching.js +221 -0
  119. youparle/static/motion.js +273 -0
  120. youparle/static/ordering.js +195 -0
  121. youparle/static/player.js +191 -0
  122. youparle/static/shadowing.js +628 -0
  123. youparle/static/steps.js +90 -0
  124. youparle/static/stretch.js +104 -0
  125. youparle/templates/base.html +42 -0
  126. youparle/templates/card.html +61 -0
  127. youparle/templates/cards.html +44 -0
  128. youparle/templates/exercise.html +236 -0
  129. youparle/templates/icons.html +55 -0
  130. youparle/templates/media.html +11 -0
  131. youparle/templates/player.html +33 -0
  132. youparle/vault.py +128 -0
  133. youparle/vault_template/.claude/settings.json +24 -0
  134. youparle/vault_template/.codex/config.toml +8 -0
  135. youparle/vault_template/.codex/hooks.json +16 -0
  136. youparle/vault_template/.codex/rules/youparle.rules +3 -0
  137. youparle/vault_template/.obsidian/app.json +5 -0
  138. youparle/vault_template/.obsidian/appearance.json +1 -0
  139. youparle/vault_template/.obsidian/community-plugins.json +3 -0
  140. youparle/vault_template/.obsidian/core-plugins.json +33 -0
  141. youparle/vault_template/.obsidian/file-recovery.json +4 -0
  142. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/LICENSE +21 -0
  143. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/THIRD-PARTY-NOTICES.txt +288 -0
  144. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/data.json +91 -0
  145. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/main.js +37404 -0
  146. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/manifest.json +12 -0
  147. youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/styles.css +1202 -0
  148. youparle/vault_template/.obsidian/workspace.json +197 -0
  149. youparle/vault_template/.opencode/opencode.json +7 -0
  150. youparle/vault_template/.opencode/plugins/youparle.js +33 -0
  151. youparle/vault_template/AGENTS.md +2 -0
  152. youparle/vault_template/CLAUDE.md +1 -0
  153. youparle/vault_template/agent/exercises/.gitkeep +0 -0
  154. youparle/vault_template/agent/journal/.gitkeep +0 -0
  155. youparle/vault_template/agent/media/.gitkeep +0 -0
  156. youparle/vault_template/agent/preferences.md +0 -0
  157. youparle/vault_template/agent/progress.md +0 -0
  158. youparle/vault_template/agent/reports/.gitkeep +0 -0
  159. youparle/vault_template/agent/resources/index.md +17 -0
  160. youparle/vault_template/agent/resources/wiktionary-en.md +124 -0
  161. youparle/vault_template/agent/tmp/.gitkeep +0 -0
  162. youparle/vault_template/agent/user.md +0 -0
  163. youparle/vault_template/cards/.gitkeep +0 -0
  164. youparle/vault_template/lessons/.gitkeep +0 -0
  165. youparle/vault_template/library/.gitkeep +0 -0
  166. youparle/vault_template/notes/.gitkeep +0 -0
  167. youparle/voice/__init__.py +8 -0
  168. youparle/voice/install.py +256 -0
  169. youparle/voice/locales.py +51 -0
  170. youparle/voice/protocol.py +238 -0
  171. youparle/voice/providers.py +169 -0
  172. youparle/voice/scripts/speak_edge.py +50 -0
  173. youparle/voice/scripts/youparle_provider.py +55 -0
  174. youparle-0.1.0.dist-info/METADATA +162 -0
  175. youparle-0.1.0.dist-info/RECORD +182 -0
  176. youparle-0.1.0.dist-info/WHEEL +4 -0
  177. youparle-0.1.0.dist-info/entry_points.txt +2 -0
  178. youparle-0.1.0.dist-info/licenses/LICENSE +21 -0
  179. youparle-0.1.0.dist-info/licenses/src/youparle/static/fonts/Fredoka-OFL.txt +93 -0
  180. youparle-0.1.0.dist-info/licenses/src/youparle/static/fonts/Ubuntu-UFL.txt +96 -0
  181. youparle-0.1.0.dist-info/licenses/src/youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/LICENSE +21 -0
  182. youparle-0.1.0.dist-info/licenses/src/youparle/vault_template/.obsidian/plugins/obsidian-spaced-repetition/THIRD-PARTY-NOTICES.txt +288 -0
youparle/__init__.py ADDED
@@ -0,0 +1,17 @@
1
+ """YouParle: local tooling for a language learning vault.
2
+
3
+ The package takes on only what the harness cannot do or must not do: side
4
+ effects, validations that cannot be expressed as permissions, and differences
5
+ between operating systems. Reading and searching stay with the harness.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from importlib.metadata import PackageNotFoundError, version
11
+
12
+ try:
13
+ __version__ = version("youparle")
14
+ except PackageNotFoundError: # pragma: no cover - running from a source tree
15
+ __version__ = "0.0.0+unknown"
16
+
17
+ __all__ = ["__version__"]
youparle/__main__.py ADDED
@@ -0,0 +1,8 @@
1
+ """Support `python -m youparle`, which is how the tests drive the CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .cli import main
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(main())
youparle/agents.py ADDED
@@ -0,0 +1,151 @@
1
+ """The youparle block in `AGENTS.md`: the one part of the vault we rewrite.
2
+
3
+ The block runs from a begin marker to an end marker, each on a line of its
4
+ own. It belongs to the package, and `init` rewrites it from `agents_block.md`.
5
+ Everything outside it belongs to the student, who writes below it.
6
+
7
+ The begin marker carries the version that wrote the block, so the guide can
8
+ tell when it is older than the installed package. Markers that are missing,
9
+ out of order or doubled are refused, never guessed at: what lies outside the
10
+ block is the student's, and a wrong guess would rewrite it.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import re
16
+ from dataclasses import dataclass
17
+ from pathlib import Path
18
+ from typing import Final
19
+
20
+ from . import __version__, contract
21
+ from .errors import InvalidInput
22
+ from .fs import read_text, write_text_atomic
23
+
24
+ TEMPLATE: Final = Path(__file__).resolve().parent / "agents_block.md"
25
+
26
+ # Off until youparle is published on PyPI. An editable install keeps one
27
+ # version number while its code changes, so the number says nothing yet about
28
+ # which code wrote the block.
29
+ COMPARE_VERSIONS = False
30
+
31
+ BEGIN: Final = "youparle:begin"
32
+ END: Final = "youparle:end"
33
+ _MARKER: Final = re.compile(r"<!--\s*youparle:(begin|end)\b(.*?)-->")
34
+ _VERSION: Final = re.compile(r"\bversion=(\S+)")
35
+
36
+ # The two lines a block starts as, before `init` fills it.
37
+ EMPTY_BLOCK: Final = (f"<!-- {BEGIN} -->", f"<!-- {END} -->")
38
+
39
+
40
+ class BlockDamaged(InvalidInput):
41
+ """`AGENTS.md` has no block, or one that cannot be told apart from the rest."""
42
+
43
+
44
+ class NoBlock(BlockDamaged):
45
+ """`AGENTS.md` names no youparle marker at all: it may not be ours."""
46
+
47
+
48
+ @dataclass(frozen=True)
49
+ class Block:
50
+ version: str | None
51
+ first: int # the begin marker's line
52
+ last: int # the end marker's line
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class Problem:
57
+ said: str
58
+ damaged: bool # rather than written by another version
59
+
60
+
61
+ @dataclass(frozen=True)
62
+ class Rewrite:
63
+ text: str
64
+ changed: bool
65
+
66
+
67
+ def render() -> str:
68
+ """The block as this version writes it, markers included."""
69
+ from jinja2 import Environment, StrictUndefined
70
+
71
+ environment = Environment(undefined=StrictUndefined)
72
+ return environment.from_string(read_text(TEMPLATE)).render(version=__version__).strip()
73
+
74
+
75
+ def find(text: str) -> Block:
76
+ """Locate the one block in `text`, or refuse."""
77
+ begins, ends = [], []
78
+ for number, line in enumerate(text.split("\n")):
79
+ if BEGIN not in line and END not in line:
80
+ continue
81
+ marker = _MARKER.fullmatch(line.strip())
82
+ if marker is None:
83
+ raise BlockDamaged(
84
+ f"{contract.VAULT_SIGNATURE_FILE}, line {number + 1}, names a youparle "
85
+ f"marker but is not one: {line.strip()}",
86
+ f"Write it on a line of its own, as <!-- {BEGIN} --> or <!-- {END} -->.",
87
+ )
88
+ (begins if marker[1] == "begin" else ends).append((number, marker[2]))
89
+
90
+ if not begins and not ends:
91
+ raise NoBlock(
92
+ f"{contract.VAULT_SIGNATURE_FILE} has no youparle block.",
93
+ f"Add the line <!-- {BEGIN} --> and then the line <!-- {END} --> where "
94
+ "the block belongs, usually at the top, then run youparle init again. "
95
+ "It fills the block and leaves the rest of the file as it is.",
96
+ )
97
+ if len(begins) > 1 or len(ends) > 1:
98
+ raise BlockDamaged(
99
+ f"{contract.VAULT_SIGNATURE_FILE} has {len(begins)} begin and {len(ends)} "
100
+ "end youparle markers; it must have one of each.",
101
+ "Keep one block: delete the extra markers, and what lies between them if "
102
+ "youparle wrote it, then run youparle init again.",
103
+ )
104
+ if not begins or not ends or ends[0][0] < begins[0][0]:
105
+ missing = BEGIN if not begins else END if not ends else f"{BEGIN} before {END}"
106
+ raise BlockDamaged(
107
+ f"{contract.VAULT_SIGNATURE_FILE} has a youparle block without {missing}.",
108
+ f"Put <!-- {BEGIN} --> on the line where the block starts and "
109
+ f"<!-- {END} --> on the line where it ends, then run youparle init again.",
110
+ )
111
+
112
+ version = _VERSION.search(begins[0][1])
113
+ return Block(version[1] if version else None, begins[0][0], ends[0][0])
114
+
115
+
116
+ def rewrite(text: str) -> Rewrite:
117
+ """`text` with its block replaced by this version's, and the rest as it was."""
118
+ block = find(text)
119
+ lines = text.split("\n")
120
+ new = render().split("\n")
121
+ old = lines[block.first : block.last + 1]
122
+ lines[block.first : block.last + 1] = new
123
+ return Rewrite("\n".join(lines), changed=old != new)
124
+
125
+
126
+ def update(root: Path) -> bool:
127
+ """Rewrite the block of the vault at `root`; whether it changed."""
128
+ path = root / contract.VAULT_SIGNATURE_FILE
129
+ result = rewrite(read_text(path))
130
+ if result.changed:
131
+ write_text_atomic(path, result.text)
132
+ return result.changed
133
+
134
+
135
+ def problem(root: Path) -> Problem | None:
136
+ """What is wrong with the block, for `guide` and `check`, which repair nothing."""
137
+ path = root / contract.VAULT_SIGNATURE_FILE
138
+ try:
139
+ block = find(read_text(path))
140
+ except BlockDamaged as error:
141
+ return Problem(error.reason, damaged=True)
142
+ except (OSError, UnicodeDecodeError) as error:
143
+ return Problem(f"{contract.VAULT_SIGNATURE_FILE} is unreadable: {error}", damaged=True)
144
+ if not COMPARE_VERSIONS or block.version == __version__:
145
+ return None
146
+ written = f"youparle {block.version}" if block.version else "an unknown version"
147
+ return Problem(
148
+ f"the youparle block in {contract.VAULT_SIGNATURE_FILE} was written by "
149
+ f"{written}, and youparle {__version__} is installed",
150
+ damaged=False,
151
+ )
@@ -0,0 +1,60 @@
1
+ <!-- youparle:begin version={{ version }} · youparle init rewrites this block; write yours below it -->
2
+ # Tutor
3
+
4
+ You are a language tutor for one student. This folder is their Obsidian vault:
5
+ their lessons, cards and notes, and your memory in `agent/`.
6
+
7
+ ## The guide
8
+
9
+ The youparle guide starts with the line `# youparle guide`. It must always be
10
+ in your context: whenever it is not, run `youparle guide`. What it says holds.
11
+
12
+ ## In the chat
13
+
14
+ The student is learning a language, so every word you write costs them
15
+ attention. Be brief, and keep to one subject at a time.
16
+
17
+ - A lesson, cards or an exercise speak for themselves. Name them in one line,
18
+ and never repeat in the chat what they contain.
19
+ - Explain only what the student needs to go on. When more is needed, propose
20
+ a lesson.
21
+
22
+ ## Always
23
+
24
+ - Talk to the student in the language `agent/user.md` names.
25
+ - Decide what to do next yourself, from `agent/progress.md` and what the
26
+ student asks. Propose; they choose.
27
+ - Never correct the student while they are talking to you, not even in a
28
+ practice dialogue: answer what they mean, and use the right form in your
29
+ reply without pointing it out. Keep their mistakes for the end of the
30
+ activity, or for when they ask (`youparle skill feedback`). With no clear
31
+ end, ask whether they want them. Asking counts for that moment only.
32
+ - When they say something lasting about themselves or how they want to be
33
+ taught, write it down in the same turn (`youparle skill remember`).
34
+ - Your harness may have its own memory. Do not use it for the student: what
35
+ you learn about them goes in `agent/`, where they see it and every harness
36
+ reads it.
37
+ - Before moving on to another activity, add to the journal what was done and
38
+ what was hard, with `youparle journal add`. Never edit a journal file: the
39
+ journal only grows, and it holds everything that happened.
40
+ - The journal is your long memory: search `agent/journal/` whenever the past
41
+ can help.
42
+ - Write only inside `agent/`. Everything else goes through `youparle`.
43
+ - Before writing a lesson, exercise or card, check `agent/resources/index.md`:
44
+ word forms and pronunciation must be verified against a dictionary it lists,
45
+ and audio comes from what it lists or from `youparle tts`.
46
+ - When a resource fails, misleads you, or you find a faster way to use it, fix
47
+ its file in the same turn (`youparle skill resources`).
48
+ - If a file in `agent/` was damaged by mistake, the student can bring back an
49
+ earlier version: Obsidian keeps them, for changes made while it was open,
50
+ in Settings › File recovery. Tell them how.
51
+
52
+ ## This folder
53
+
54
+ - `lessons/`, `cards/`: published through `youparle`; the student's once
55
+ published.
56
+ - `notes/`: the student's own notes. Read them, never change them.
57
+ - `library/`: pictures and sounds shown in notes.
58
+ - `agent/`: yours: memory, journal, exercises, drafts, and `agent/resources/`,
59
+ where facts and recordings come from, starting from its `index.md`.
60
+ <!-- youparle:end -->