pi-declaw 0.2.0

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 (70) hide show
  1. package/ARCHITECTURE.md +90 -0
  2. package/GLOSSARY.md +48 -0
  3. package/LICENSE +201 -0
  4. package/NOTICE +30 -0
  5. package/PLUGIN_GUIDE.md +142 -0
  6. package/README.md +161 -0
  7. package/SOURCES.md +139 -0
  8. package/index.ts +2 -0
  9. package/licenses/asd-ste100-skill-LICENSE +21 -0
  10. package/licenses/i-have-adhd-LICENSE +21 -0
  11. package/licenses/speak-like-you-eat-LICENSE +9 -0
  12. package/licenses/squirrel-mode-LICENSE +21 -0
  13. package/package.json +63 -0
  14. package/playground/README.md +64 -0
  15. package/playground/app.js +123 -0
  16. package/playground/assets/declaw-e.png +0 -0
  17. package/playground/assets/declaw-favicon.png +0 -0
  18. package/playground/assets/declaw-wordmark-charcoal.png +0 -0
  19. package/playground/assets/declaw-wordmark-white.png +0 -0
  20. package/playground/assets/geist.woff2 +0 -0
  21. package/playground/assets/licenses/Claudish-MIT.txt +21 -0
  22. package/playground/assets/licenses/Geist-NOTICE.txt +4 -0
  23. package/playground/assets/licenses/Geist-OFL.txt +93 -0
  24. package/playground/assets/licenses/asd-ste100-skill-LICENSE +21 -0
  25. package/playground/assets/licenses/i-have-adhd-LICENSE +21 -0
  26. package/playground/assets/licenses/paseo-plain-LICENSE +211 -0
  27. package/playground/assets/licenses/squirrel-mode-LICENSE +21 -0
  28. package/playground/build.ts +180 -0
  29. package/playground/credits.html +14 -0
  30. package/playground/diff.ts +65 -0
  31. package/playground/evidence.css +1 -0
  32. package/playground/index.html +96 -0
  33. package/playground/inline-diff.ts +131 -0
  34. package/playground/markdown.ts +239 -0
  35. package/playground/samples.json +244 -0
  36. package/playground/serve.ts +21 -0
  37. package/playground/styles.css +30 -0
  38. package/playground/unified.ts +136 -0
  39. package/src/adapters/command.ts +203 -0
  40. package/src/adapters/model.ts +53 -0
  41. package/src/adapters/pi.ts +56 -0
  42. package/src/adapters/settings.ts +117 -0
  43. package/src/application/rewrite.ts +39 -0
  44. package/src/domain/preservation.ts +62 -0
  45. package/src/domain/rewrite.ts +55 -0
  46. package/src/domain/styles.ts +169 -0
  47. package/src/extension.ts +50 -0
  48. package/src/plugin-api.ts +88 -0
  49. package/src/plugins/built-in/asd-ste100/plugin.ts +19 -0
  50. package/src/plugins/built-in/asd-ste100/prompt.ts +24 -0
  51. package/src/plugins/built-in/catalog.ts +17 -0
  52. package/src/plugins/built-in/i-have-adhd/plugin.ts +19 -0
  53. package/src/plugins/built-in/i-have-adhd/prompt.ts +20 -0
  54. package/src/plugins/built-in/index.ts +17 -0
  55. package/src/plugins/built-in/paseo-plain/plugin.ts +26 -0
  56. package/src/plugins/built-in/paseo-plain/upstream/Claudish-MIT.txt +21 -0
  57. package/src/plugins/built-in/paseo-plain/upstream/LICENSE +211 -0
  58. package/src/plugins/built-in/paseo-plain/upstream/NOTICE +16 -0
  59. package/src/plugins/built-in/paseo-plain/upstream/prompt.ts +351 -0
  60. package/src/plugins/built-in/paseo-plain/upstream/rewriter.ts +46 -0
  61. package/src/plugins/built-in/shared/adapted-rules.ts +28 -0
  62. package/src/plugins/built-in/shared/json-payload.ts +5 -0
  63. package/src/plugins/built-in/speak-like-you-eat/payload.ts +5 -0
  64. package/src/plugins/built-in/speak-like-you-eat/plugin.ts +26 -0
  65. package/src/plugins/built-in/speak-like-you-eat/prompt.ts +4 -0
  66. package/src/plugins/built-in/speak-like-you-eat/upstream/model-rewrite.ts +19 -0
  67. package/src/plugins/built-in/squirrel-mode/plugin.ts +19 -0
  68. package/src/plugins/built-in/squirrel-mode/prompt.ts +24 -0
  69. package/src/plugins/built-in/terse/plugin.ts +18 -0
  70. package/src/plugins/built-in/terse/prompt.ts +9 -0
package/SOURCES.md ADDED
@@ -0,0 +1,139 @@
1
+ # Adapted writing presets
2
+
3
+ I Have ADHD, Squirrel Mode, and ASD-STE100 are **adaptations of output rules**,
4
+ not installations of the original skills or claims of equivalent behavior.
5
+ Paseo Plain and Speak Like You Eat retain pinned source prompts. All six built-in
6
+ styles now add the same package rules for preserving meaning and exact text.
7
+ Paseo Plain's repository license is Apache-2.0; its retained Claudish wording
8
+ and the three adapted skills are MIT-licensed. Copyright notices and license
9
+ texts are retained beside the relevant plugin or in `licenses/`.
10
+ No endorsement by the original authors is claimed.
11
+
12
+ ## Paseo Plain (`plain`)
13
+
14
+ Source: [scowalt/paseo-plain, server/prompt.ts](https://github.com/scowalt/paseo-plain/blob/35e63ee2e5f17a5bad40a8772c84fa5f21a8678f/server/prompt.ts)
15
+
16
+ Revision: `35e63ee2e5f17a5bad40a8772c84fa5f21a8678f`, prompt policy 5.
17
+ Copyright 2026 scowalt — [upstream Apache-2.0 license and notices](src/plugins/built-in/paseo-plain/upstream/LICENSE).
18
+
19
+ `src/plugins/built-in/paseo-plain/upstream/prompt.ts` retains the upstream source unchanged.
20
+ The Paseo Plain plugin adapter combines it with the package's shared meaning-preservation
21
+ rules. The installed command and the private example generator use that combined prompt
22
+ and the same exact-text protection. No earlier request or reader profile is supplied. The model remains
23
+ Luna with low thinking, not necessarily the upstream application's configured model.
24
+
25
+ The upstream prompt retains wording from Mike Gvozdev's Claudish to English
26
+ v0.9.0, revision `bf271f95fd2c1a7d00ea545bbc6de44a1b6a1d3c`.
27
+ Its [MIT notice](src/plugins/built-in/paseo-plain/upstream/Claudish-MIT.txt) is included as well.
28
+
29
+ Earlier `plain-lab-1` and `plain-lab-2` recordings used custom local prompts,
30
+ not Scott's writing prompt. Do not retroactively label their results as upstream
31
+ prompt outputs. Source-faithful integration is not proof of model fidelity.
32
+ Earlier private experiments were unmasked. Current `package-styles-8` evaluations
33
+ use the same `src/domain/preservation.ts` helper as the installed extension. That local helper fixes
34
+ an ordinary English “make” phrase being mistaken for a command; the original
35
+ upstream helper remains in `src/plugins/built-in/paseo-plain/upstream/rewriter.ts` for reference.
36
+
37
+ ## Terse (`terse`)
38
+
39
+ A local control preset, not adapted from a third-party skill.
40
+
41
+ ## I Have ADHD (`adhd`, formerly Action first)
42
+
43
+ Source: [ayghri/i-have-adhd](https://github.com/ayghri/i-have-adhd/blob/6f1f982d0a47c65899af3c5a7450b7098bc65325/skills/i-have-adhd/SKILL.md)
44
+
45
+ Revision: `6f1f982d0a47c65899af3c5a7450b7098bc65325`
46
+
47
+ Copyright (c) 2026 Ayoub Ghriss — [MIT license](licenses/i-have-adhd-LICENSE).
48
+
49
+ Retained: action-first orientation, visible completed work, numbered bounded
50
+ steps, small groups, matter-of-fact errors, no filler or pleasantries, and a
51
+ source-supported next action when useful.
52
+
53
+ Changed: no session persistence, tools, invented estimates, assumed diagnosis,
54
+ made-up progress counts, or new questions. Small groups must include **all**
55
+ relevant information in this output. A proposed assistant action cannot become a
56
+ command to the user. The mode does not assume any medical condition in the reader.
57
+
58
+ ## Squirrel Mode (`squirrel`)
59
+
60
+ Source: [thgMatajs/squirrel-mode canonical base rules](https://github.com/thgMatajs/squirrel-mode/blob/6cf8a4103779183b6a55066e6a736ff73b94ba50/rules/base-rules.md)
61
+
62
+ Revision: `6cf8a4103779183b6a55066e6a736ff73b94ba50`
63
+
64
+ Copyright (c) 2026 Thiago Matajs — [MIT license](licenses/squirrel-mode-LICENSE).
65
+
66
+ Retained: answer first, one concept per paragraph, numbered steps in small groups,
67
+ code-first presentation when code is the answer, separate answers for separate
68
+ questions, neutral tone, and grouped workstream status when the source supports it.
69
+
70
+ Changed: a fixed experimental profile replaces the upstream persistent profile.
71
+ No checkpoint files, scope guard, topic-switch questions, tool calls, new
72
+ estimates, or cross-turn state. Options, later phases, and necessary explanation
73
+ remain visible even when the upstream profile would delay or limit them. Safety
74
+ conditions precede the relevant code or action. This is not a port of the separate
75
+ `squirrel:digest` skill and does not impose its fixed multi-section brief.
76
+
77
+ ## ASD-STE100 skill (`ste`, formerly Technical)
78
+
79
+ Source: [danyuchn/asd-ste100-skill](https://github.com/danyuchn/asd-ste100-skill/blob/7d4a135a199a5d7447c4886bcd7ffe742a627bc9/SKILL.md)
80
+
81
+ Revision: `7d4a135a199a5d7447c4886bcd7ffe742a627bc9`
82
+
83
+ Copyright (c) 2026 Dustin Yuchen Teng — [MIT license](licenses/asd-ste100-skill-LICENSE).
84
+
85
+ Retained: the STE-flavored approach, explicit subjects, active voice when the
86
+ actor is known, consistent terminology, one instruction per sentence, short
87
+ sentences and noun phrases, literal verbs, and preservation of modality.
88
+
89
+ Changed: sentence lengths are targets subordinate to fidelity, not certified
90
+ constraints. No invented actors, definitions, dictionary assertions, rule tables,
91
+ or added explanations. Code and other exact text are exempt from punctuation and
92
+ length changes. A compound tense remains when it conveys current relevance or
93
+ uncertainty. This package does not port the upstream linter.
94
+
95
+ **No official ASD dictionary or standard text is bundled.** The upstream skill
96
+ also excludes the official dictionary and disclaims certified compliance. Its MIT
97
+ license does not grant redistribution rights to the separate ASD standard. This
98
+ mode is STE-inspired, not a certified or dictionary-validated ASD-STE100 tool.
99
+
100
+ ## Speak Like You Eat (`slye`, built in)
101
+
102
+ Source: [wtfzambo/speak-like-you-eat, src/model-rewrite.ts](https://github.com/wtfzambo/speak-like-you-eat/blob/e1725d982ec5b03fe26e7d637ce2d9384c3ef820/src/model-rewrite.ts)
103
+
104
+ Stable version: `1.1.0`; revision `e1725d982ec5b03fe26e7d637ce2d9384c3ef820`.
105
+ Copyright (c) 2026 wtfzambo — [MIT license](licenses/speak-like-you-eat-LICENSE).
106
+
107
+ `src/plugins/built-in/speak-like-you-eat/upstream/model-rewrite.ts` contains the retained
108
+ prompt fragment. The plugin adapter adds
109
+ shared meaning-preservation rules and uses the original `Context:` / `Target:`
110
+ envelope with empty context. It preserves the source language and intentional
111
+ language mix. The upstream README credits Claudish to English as inspiration.
112
+
113
+ SLYE is fully integrated into the same manual rewrite command, model selection,
114
+ exact-text protection, cancellation, storage and style picker as the other five
115
+ styles. Use `/declaw slye` once or save it with `/declaw style`; no separate package
116
+ is installed. Private evaluation tooling also uses it by default. We intentionally do not import
117
+ upstream automatic rewriting or conversation collection, because this package
118
+ rewrites only when asked and never changes the agent's conversation.
119
+
120
+ The newer unreleased rule broadly deleting contrastive negations was not imported;
121
+ it can conflict with retaining meaningful caveats. Fresh demo recordings for this
122
+ shared engine still require an authorized run and review.
123
+
124
+ ## Shared boundary
125
+
126
+ The main assistant's answer remains the authority. Supporting request context can
127
+ resolve references, but cannot restore superseded plans or supply extra claims.
128
+ All source facts, caveats, permissions, alternatives, dependencies, commands, and
129
+ uncertainty must survive. We adapt rules that conflict with this boundary rather
130
+ than silently weakening it.
131
+
132
+ The shared rules in `src/domain/styles.ts` also capture failures found in the recorded
133
+ comparison: preserve certainty, action ownership, prerequisite scope, reasons for
134
+ recommendations, measurement targets, and meaningful table relationships. These
135
+ fixes are in the installed files, not just the demo.
136
+
137
+ These are prompt contracts, not proven model capabilities. Exact-string checks
138
+ cannot enforce semantic fidelity, sentence limits, or correct prioritization.
139
+ Review generated samples before promoting a preset into the live extension.
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Pi package entrypoint. Runtime code lives under src/. */
2
+ export { default } from "./src/extension.ts";
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dustin Yuchen Teng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayoub Ghriss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wtfzambo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thiago Matajs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "pi-declaw",
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "description": "Rewrite completed Pi answers into clearer readings without changing the original conversation.",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jzlosman/declaw.git"
11
+ },
12
+ "homepage": "https://jzlosman.github.io/declaw/",
13
+ "bugs": {
14
+ "url": "https://github.com/jzlosman/declaw/issues"
15
+ },
16
+ "keywords": [
17
+ "pi-package",
18
+ "pi-extension",
19
+ "declaw",
20
+ "answer-rewriting",
21
+ "readability"
22
+ ],
23
+ "exports": {
24
+ "./plugin-api": "./src/plugin-api.ts"
25
+ },
26
+ "files": [
27
+ "index.ts",
28
+ "src/",
29
+ "licenses/",
30
+ "SOURCES.md",
31
+ "playground/*.ts",
32
+ "playground/*.html",
33
+ "playground/*.js",
34
+ "playground/*.css",
35
+ "playground/*.json",
36
+ "playground/assets/",
37
+ "README.md",
38
+ "PLUGIN_GUIDE.md",
39
+ "GLOSSARY.md",
40
+ "ARCHITECTURE.md",
41
+ "LICENSE",
42
+ "NOTICE"
43
+ ],
44
+ "scripts": {
45
+ "test": "node --test $(find tests -type f -name '*.test.ts' | sort)",
46
+ "build:playground": "node playground/build.ts",
47
+ "playground": "node playground/build.ts && node playground/serve.ts"
48
+ },
49
+ "pi": {
50
+ "extensions": [
51
+ "./index.ts"
52
+ ],
53
+ "image": "https://jzlosman.github.io/declaw/assets/declaw-wordmark-charcoal.png"
54
+ },
55
+ "peerDependencies": {
56
+ "@earendil-works/pi-ai": "*",
57
+ "@earendil-works/pi-coding-agent": "*",
58
+ "@earendil-works/pi-tui": "*"
59
+ },
60
+ "devDependencies": {
61
+ "fast-check": "^4.10.0"
62
+ }
63
+ }
@@ -0,0 +1,64 @@
1
+ # Declaw playground
2
+
3
+ The playground is a static comparison page. It uses saved outputs only.
4
+ Visitors do not send model requests, provide credentials, or generate analytics.
5
+
6
+ ## Build and open
7
+
8
+ Node 24. No package install is required for the static build.
9
+
10
+ ```sh
11
+ npm run build:playground
12
+ open dist/playground/index.html
13
+ ```
14
+
15
+ For an HTTP preview:
16
+
17
+ ```sh
18
+ npm run playground
19
+ open http://127.0.0.1:4197
20
+ ```
21
+
22
+ GitHub Pages serves only the generated `dist/playground/` directory. It does not
23
+ serve the private generation lab or any Pi session data.
24
+
25
+ ## Reading and changes
26
+
27
+ - The long-form example opens first.
28
+ - Choose an example and reading mode in the rail, or use the mobile selectors.
29
+ - Desktop shows the original and rewrite side by side.
30
+ - Mobile uses Original/Rewrite tabs and normal page scrolling.
31
+ - **Show changes** opens one combined inline diff.
32
+ - Copy buttons return the exact saved Markdown.
33
+
34
+ The diff keeps common wording in place. Removed wording is crossed out. Added
35
+ wording is underlined. Lists, tables, code, and paragraph structure remain readable.
36
+ Whitespace-only changes show **Unchanged**.
37
+
38
+ The standalone E logo is used where the full wordmark does not fit. Credits link to
39
+ source repositories and license texts. Source attribution distinguishes local presets,
40
+ adaptations, and prompt sources.
41
+
42
+ ## Data
43
+
44
+ `samples.json` contains four synthetic inputs and twenty reviewed historical outputs.
45
+ The recordings use the earlier five-style package and are labeled accordingly.
46
+ Speak Like You Eat is built into the Declaw extension but has no public recording yet.
47
+ Do not relabel old outputs or invent new examples.
48
+
49
+ `markdown.ts` renders a bounded inert subset of Markdown. Raw HTML is escaped.
50
+ Links and images do not load. `unified.ts` and `inline-diff.ts` align safe rendered
51
+ blocks without changing saved source or rewrite text.
52
+
53
+ The private generation and review lab is stored outside this repository. It is not
54
+ part of the hosted site or the public source tree.
55
+
56
+ ## Verification
57
+
58
+ ```sh
59
+ npm test
60
+ npm run build:playground
61
+ ```
62
+
63
+ The build validates the saved snapshot and emits a self-contained Pages artifact.
64
+ Native Safari/iOS verification remains open.
@@ -0,0 +1,123 @@
1
+ (() => {
2
+ "use strict";
3
+ const $ = selector => document.querySelector(selector);
4
+ const $$ = selector => [...document.querySelectorAll(selector)];
5
+ const data = globalThis.PLAIN_DEMO;
6
+ if (!data?.cases?.length) { $("#fatal-error").hidden = false; return; }
7
+ const mobile = matchMedia("(max-width: 900px)");
8
+ const copyTimers = new WeakMap();
9
+ const COPY_FEEDBACK_MS = 1600;
10
+ let caseId = data.defaultCaseId, modeId = "plain", side = "rewrite", showChanges = false;
11
+ let positions = { original: 0, rewrite: 0, changes: 0 };
12
+ const currentCase = () => data.cases.find(c => c.id === caseId);
13
+ const currentVariant = () => currentCase().variants.find(v => v.mode === modeId);
14
+ const announce = text => { $("#announcer").textContent = text; };
15
+ const viewKey = () => showChanges ? "changes" : side;
16
+
17
+ function syncView() {
18
+ document.body.dataset.view = showChanges ? "changes" : "reading";
19
+ document.body.dataset.side = side;
20
+ $(".documents").hidden = showChanges;
21
+ $("#unified-panel").hidden = !showChanges;
22
+ $(".mobile-tabs").hidden = showChanges;
23
+ $('[data-diff]').setAttribute("aria-pressed", String(showChanges));
24
+ $("#diff-label").textContent = showChanges ? "Hide changes" : "Show changes";
25
+ $$('[role="tab"]').forEach(tab => {
26
+ const selected = tab.dataset.side === side;
27
+ tab.setAttribute("aria-selected", String(selected)); tab.tabIndex = selected ? 0 : -1;
28
+ });
29
+ ["original", "rewrite"].forEach(name => {
30
+ const panel = $(`#${name}-panel`);
31
+ if (mobile.matches) { panel.setAttribute("role", "tabpanel"); panel.setAttribute("aria-labelledby", `tab-${name}`); }
32
+ else { panel.removeAttribute("role"); panel.setAttribute("aria-labelledby", `${name}-label`); }
33
+ });
34
+ // Phones scroll the document, not a nested focusable scroll region.
35
+ $$('.reading-scroll').forEach(region => mobile.matches ? region.removeAttribute("tabindex") : region.setAttribute("tabindex", "0"));
36
+ }
37
+ function switchView(change) {
38
+ if (mobile.matches) positions[viewKey()] = window.scrollY;
39
+ change(); syncView();
40
+ if (mobile.matches) window.scrollTo({ top: positions[viewKey()], behavior: "auto" });
41
+ }
42
+ function setChanges(next) {
43
+ switchView(() => { showChanges = next; });
44
+ announce(showChanges ? currentVariant().visibleChanged ? "Removals and additions shown together." : "No wording changes." : "Reading view.");
45
+ }
46
+ function writeHash() {
47
+ try { history.replaceState(null, "", `#${new URLSearchParams({ example: caseId, mode: modeId })}`); }
48
+ catch { /* Reading does not depend on local-file history support. */ }
49
+ }
50
+ function render(changedCase = false) {
51
+ const sample = currentCase(), variant = currentVariant();
52
+ const originalScroll = $("#original-scroll").scrollTop;
53
+ $("#original-content").innerHTML = variant.beforeHtml;
54
+ $("#rewrite-content").innerHTML = variant.afterHtml;
55
+ $("#unified-content").innerHTML = variant.unifiedHtml;
56
+ $("#case-label").textContent = sample.label;
57
+ $("#rewrite-label").textContent = data.modes.find(m => m.id === modeId).label;
58
+ $("#source-attribution").innerHTML = variant.attributionHtml;
59
+ $("#unchanged-note").hidden = variant.visibleChanged;
60
+ $("#no-changes").hidden = variant.visibleChanged;
61
+ $(".diff-legend").hidden = !variant.visibleChanged;
62
+ $("#example-select").value = caseId; $("#mode-select").value = modeId;
63
+ $$('[data-case]').forEach(button => button.setAttribute("aria-pressed", String(button.dataset.case === caseId)));
64
+ $$('[data-mode]').forEach(button => button.setAttribute("aria-pressed", String(button.dataset.mode === modeId)));
65
+ $("#original-scroll").scrollTop = changedCase ? 0 : originalScroll;
66
+ $("#rewrite-scroll").scrollTop = 0; $("#unified-scroll").scrollTop = 0;
67
+ positions.rewrite = positions.changes = 0;
68
+ if (changedCase) positions.original = 0;
69
+ syncView();
70
+ if (mobile.matches && (changedCase || showChanges || side === "rewrite")) window.scrollTo({ top: 0, behavior: "auto" });
71
+ }
72
+ function choose(kind, id) {
73
+ const changedCase = kind === "case" && id !== caseId;
74
+ if (kind === "case" && data.cases.some(c => c.id === id)) caseId = id;
75
+ else if (kind === "mode" && data.modes.some(m => m.id === id)) modeId = id;
76
+ else return;
77
+ render(changedCase); writeHash();
78
+ announce(`${currentCase().label}. ${data.modes.find(m => m.id === modeId).label}.`);
79
+ }
80
+ function readHash() {
81
+ if (location.hash === "#workspace") return;
82
+ const params = new URLSearchParams(location.hash.slice(1));
83
+ const nextCase = params.get("example"), nextMode = params.get("mode");
84
+ const oldCase = caseId;
85
+ caseId = data.cases.some(c => c.id === nextCase) ? nextCase : data.defaultCaseId;
86
+ modeId = data.modes.some(m => m.id === nextMode) ? nextMode : "plain";
87
+ render(oldCase !== caseId);
88
+ }
89
+ for (const [selector, items] of [["#example-select", data.cases], ["#mode-select", data.modes]]) {
90
+ $(selector).replaceChildren(...items.map(item => { const option = document.createElement("option"); option.value = item.id; option.textContent = item.label; return option; }));
91
+ }
92
+ $('[data-diff]').addEventListener("click", () => setChanges(!showChanges));
93
+ $$('[data-case]').forEach(button => button.addEventListener("click", () => choose("case", button.dataset.case)));
94
+ $$('[data-mode]').forEach(button => button.addEventListener("click", () => choose("mode", button.dataset.mode)));
95
+ $("#example-select").addEventListener("change", event => choose("case", event.target.value));
96
+ $("#mode-select").addEventListener("change", event => choose("mode", event.target.value));
97
+ $$('[role="tab"]').forEach(tab => tab.addEventListener("click", () => switchView(() => { side = tab.dataset.side; })));
98
+ document.addEventListener("keydown", event => {
99
+ const tab = event.target?.closest?.('[role="tab"]');
100
+ if (tab && ["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
101
+ event.preventDefault();
102
+ switchView(() => { side = event.key === "Home" ? "original" : event.key === "End" ? "rewrite" : side === "original" ? "rewrite" : "original"; });
103
+ $(`#tab-${side}`).focus({ preventScroll: true });
104
+ }
105
+ const group = event.target?.closest?.('[data-picker-group]');
106
+ if (group && ["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
107
+ const buttons = [...group.querySelectorAll("button")], at = buttons.indexOf(document.activeElement);
108
+ if (at >= 0) { event.preventDefault(); buttons[event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (at + (event.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length].focus(); }
109
+ }
110
+ });
111
+ $$('[data-copy]').forEach(button => button.addEventListener("click", async () => {
112
+ const text = button.dataset.copy === "original" ? currentCase().original : currentVariant().text;
113
+ try {
114
+ await navigator.clipboard.writeText(text);
115
+ announce("Copied."); clearTimeout(copyTimers.get(button)); button.dataset.copied = "true";
116
+ copyTimers.set(button, setTimeout(() => { delete button.dataset.copied; }, COPY_FEEDBACK_MS));
117
+ } catch { announce("Copy unavailable. Select the text to copy it."); }
118
+ }));
119
+ window.addEventListener("hashchange", readHash);
120
+ mobile.addEventListener("change", () => { positions = { original: 0, rewrite: 0, changes: 0 }; syncView(); });
121
+ $$('[data-interactive]').forEach(control => { control.disabled = false; });
122
+ render(); readHash();
123
+ })();
Binary file
Binary file
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mike Gvozdev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ Geist variable font
2
+ Source: https://github.com/vercel/geist-font
3
+ Revision: 10dc7658f13c38a474cde201bb09a4617267545b
4
+ License: SIL Open Font License 1.1 (Geist-OFL.txt)
@@ -0,0 +1,93 @@
1
+ Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dustin Yuchen Teng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayoub Ghriss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.