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
@@ -0,0 +1,90 @@
1
+ # Declaw architecture
2
+
3
+ ## Bounded context
4
+
5
+ Declaw owns the **Answer Rewriting** bounded context. Its authority is the completed
6
+ assistant answer. It does not own the main agent conversation, provider credentials,
7
+ model selection, Pi navigation, or browser-generated output.
8
+
9
+ ```text
10
+ Pi command/UI ──► application action ──► domain plan
11
+ ▲ │ │
12
+ │ │ ├── StyleCatalog
13
+ │ │ └── Preservation policy
14
+ │ ▼
15
+ └── DisplayWriter ◄── accepted result ◄─ RewriteModel
16
+ ```
17
+
18
+ ## Dependency rule
19
+
20
+ ```text
21
+ domain / policy → no Pi, model SDK, filesystem, network, or UI
22
+ application actions → depend on domain and ports
23
+ adapters → implement ports and translate external shapes
24
+ composition root → wires built-ins, registered plugins, and adapters
25
+ ```
26
+
27
+ The files map to this boundary as follows:
28
+
29
+ - `src/domain/styles.ts`: style identity, plugin catalog, status, and request composition.
30
+ - `src/domain/preservation.ts`: host-owned exact-text protection and validation.
31
+ - `src/domain/rewrite.ts`: rewrite policy, limits, and domain outcomes.
32
+ - `src/plugin-api.ts`: framework-free plugin port and registration bridge.
33
+ - `src/plugins/built-in/*`: one self-contained module per built-in plugin; each owns its
34
+ prompt, provenance, and payload adapter. `src/plugins/built-in/index.ts` only aggregates them.
35
+ - `src/application/rewrite.ts`: rewrite use case and explicit completion/publication ports.
36
+ - `src/adapters/pi.ts`: Pi message/session/request translation.
37
+ - `src/adapters/model.ts`: Pi model/auth/provider translation and model selection.
38
+ - `src/adapters/settings.ts`: filesystem preference adapter.
39
+ - `index.ts`: composition root, lifecycle wiring, command registration, and display projection.
40
+ - `playground/`: static projection of saved recordings; never a model adapter.
41
+
42
+ ## Actions and effects
43
+
44
+ | Action | Reads | Effects | Success projection |
45
+ |---|---|---|---|
46
+ | Rewrite latest answer | current branch, style, model settings | isolated model call, then append custom entry | display-only rewrite |
47
+ | Choose style | style catalog, current preference | preference file write | future rewrite default |
48
+ | Choose model | Pi model registry/auth | preference file write | future rewrite provider |
49
+ | List plugins | catalog, status file | none | status text |
50
+ | Manage plugins | catalog, status file | status file write | active/disabled catalog |
51
+
52
+ The rewrite path masks exact source spans, builds a plan, calls the model, validates
53
+ returned tokens, and only then appends a custom entry. The original answer is never
54
+ mutated or reintroduced as a model message.
55
+
56
+ ## Plugin lifecycle
57
+
58
+ 1. Pi loads the Declaw package and any installed style packages.
59
+ 2. Each style package registers a versioned, framework-free plugin contract.
60
+ 3. Declaw validates plugin identity, style namespace, provenance, and collisions.
61
+ 4. `/declaw list` shows all registered plugins and status.
62
+ 5. `/declaw manage` persists `active` or `disabled` status.
63
+ 6. Only active styles enter `/declaw style` and rewrite resolution.
64
+ 7. Display entries save style snapshots so plugin removal does not break history.
65
+
66
+ The six built-in styles are six built-in plugin records. Third-party plugins use a
67
+ namespaced style ID such as `pirate/pirate`. The process-wide registration bridge
68
+ handles Pi extension load order; explicit package installation remains the trust boundary.
69
+
70
+ ## Outcome model
71
+
72
+ - **Accepted** — output passes completion, unchanged-text, and exact-preservation checks.
73
+ - **Rejected** — output is incomplete, unchanged, oversized, or damages protected text.
74
+ - **Cancelled** — user or Pi lifecycle cancels the attempt; nothing is appended.
75
+ - **Indeterminate** — provider/network failure leaves the external outcome unknown;
76
+ the original remains authoritative and no display entry is appended.
77
+
78
+ These outcomes are deliberately not collapsed into a boolean. The provider adapter
79
+ owns provider-specific errors; the domain owns semantic acceptance.
80
+
81
+ ## Test strategy
82
+
83
+ - Domain tests: style identity, plugin namespace, collision, status, payload composition,
84
+ masking, and preservation.
85
+ - Application tests: fake completion gateway, rejection, cancellation, and no-write behavior.
86
+ - Adapter tests: Pi message normalization, provider serialization, filesystem settings,
87
+ and custom-entry rendering.
88
+ - Composition tests: built-in registration, external registration, `/declaw` alias,
89
+ status persistence, and disabled-style selection.
90
+ - Static-site tests: saved snapshots only; no plugin or provider execution in the browser.
package/GLOSSARY.md ADDED
@@ -0,0 +1,48 @@
1
+ # Declaw glossary
2
+
3
+ Declaw's bounded context is **Answer Rewriting**: turning a completed assistant
4
+ answer into an alternate reading without changing the conversation or pretending
5
+ that shorter means better.
6
+
7
+ ## Domain language
8
+
9
+ - **Source answer** — the immutable completed assistant answer selected for rewriting.
10
+ - **Source entry ID** — Pi identity of the source answer. It prevents a late result
11
+ from being attached to a different branch or newer answer.
12
+ - **Reading style** — a named presentation policy, such as Terse or SLYE.
13
+ - **Style definition** — a style's stable ID, label, provenance, instructions, and
14
+ protected-answer payload formatter.
15
+ - **Style plugin** — a trusted package contribution containing one or more definitions.
16
+ - **Style catalog** — the host-owned registry that validates IDs, namespaces,
17
+ collisions, provenance, and active/disabled status.
18
+ - **Style snapshot** — style label, plugin ID, and plugin version saved with a
19
+ display entry so historical entries remain readable after plugin removal.
20
+ - **Protected answer** — source text with exact spans replaced by temporary tokens.
21
+ - **Rewrite request** — protected answer plus style instructions and selected model.
22
+ - **Rewrite attempt** — one isolated, tool-free provider invocation.
23
+ - **Rewrite result** — accepted text, unchanged text, preservation rejection,
24
+ cancellation, or operational failure.
25
+ - **Display rewrite** — a Pi custom entry rendered to the user but excluded from
26
+ future agent context.
27
+
28
+ ## Application language
29
+
30
+ - **Action** — an intentional user request: `RewriteLatestAnswer`, `ChooseStyle`,
31
+ `ChooseModel`, `ListPlugins`, or `ManagePlugins`.
32
+ - **Port** — an application-owned capability required from the outside world:
33
+ answer reading, model completion, preferences, clock/identity, and display writing.
34
+ - **Adapter** — an implementation of a port: Pi session, Pi provider, filesystem,
35
+ or TUI adapter.
36
+ - **Effect** — an observable side effect: provider call, preference write, or
37
+ `pi.appendEntry`. Effects happen after deterministic validation and planning.
38
+ - **Projection** — a representation for a consumer. The display rewrite is a
39
+ projection, not a new assistant message.
40
+ - **Provenance** — where a style or output came from and how it relates to its source.
41
+ - **Indeterminate** — an operational outcome where the provider result cannot be
42
+ known. It is not the same as a semantic rejection.
43
+
44
+ ## Non-domain concerns
45
+
46
+ Pi model IDs, OAuth, headers, filesystem paths, terminal widgets, package loading,
47
+ and GitHub Pages are infrastructure concerns. They may be represented at adapters,
48
+ but they are not reading-style policy.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,30 @@
1
+ This package includes writing prompts and code from the following projects.
2
+ The package's original code is licensed under Apache-2.0. Third-party components
3
+ retain their own licenses and copyright notices.
4
+
5
+ Paseo Plain — Copyright 2026 scowalt.
6
+ Repository license: Apache-2.0, retaining original Paseo notices.
7
+ See src/plugins/built-in/paseo-plain/upstream/NOTICE and
8
+ src/plugins/built-in/paseo-plain/upstream/LICENSE.
9
+ The local preservation.ts adaptation changes command recognition. The upstream
10
+ source extracts remain under the Paseo Plain plugin's upstream/ directory.
11
+
12
+ Claudish to English — Copyright (c) 2026 Mike Gvozdev. MIT.
13
+ Retained wording in the Paseo Plain prompt. See
14
+ src/plugins/built-in/paseo-plain/upstream/Claudish-MIT.txt.
15
+
16
+ I Have ADHD — Copyright (c) 2026 Ayoub Ghriss. MIT.
17
+ See licenses/i-have-adhd-LICENSE.
18
+
19
+ Squirrel Mode — Copyright (c) 2026 Thiago Matajs. MIT.
20
+ See licenses/squirrel-mode-LICENSE.
21
+
22
+ ASD-STE100 skill — Copyright (c) 2026 Dustin Yuchen Teng. MIT.
23
+ See licenses/asd-ste100-skill-LICENSE. The official ASD standard and dictionary
24
+ are not included, and no certified compliance is claimed.
25
+
26
+ Speak Like You Eat — Copyright (c) 2026 wtfzambo. MIT.
27
+ See licenses/speak-like-you-eat-LICENSE.
28
+
29
+ All styles add the package's shared meaning-preservation rules. The sources do
30
+ not endorse this package. Pinned revisions and adaptations: SOURCES.md.
@@ -0,0 +1,142 @@
1
+ # Build a Declaw style plugin
2
+
3
+ > **Agent-first prompt:** Copy this section into your coding agent when you want to
4
+ > add a rewriting style to Declaw.
5
+ >
6
+ > ```text
7
+ > You are adding a Declaw style plugin. Read PLUGIN_GUIDE.md and the Declaw plugin
8
+ > API before editing code. Create a separate Pi package. Keep the plugin framework-
9
+ > free and deterministic: it may provide style instructions and format the already-
10
+ > protected answer, but it must not call a model, read files, use Pi context, add
11
+ > tools, or perform side effects. Use a namespaced style ID. Preserve every fact,
12
+ > condition, actor, modality, number, command, link, procedure step, and table
13
+ > relationship. Add focused tests for registration, request formatting, and the
14
+ > plugin's distinctive voice. Do not fabricate demo output. Run the plugin tests,
15
+ > then install the package explicitly with Pi and verify `/declaw list`,
16
+ > `/declaw manage`, and `/declaw style`.
17
+ > ```
18
+
19
+ ## What a plugin is
20
+
21
+ A plugin is a normal Pi package that registers one or more Declaw reading styles.
22
+ Declaw supplies the preservation policy, protected-text validation, model gateway,
23
+ Pi session integration, display-only storage, cancellation, and status management.
24
+ The plugin supplies only a style identity, provenance, style instructions, and a
25
+ pure function that formats the protected answer for the model envelope.
26
+
27
+ Pi extensions run with full system permissions. The Declaw contract is a clean
28
+ architecture boundary, not a security sandbox. Review plugin source before installing.
29
+
30
+ ## Minimal package
31
+
32
+ ```text
33
+ declaw-style-pirate/
34
+ ├── package.json
35
+ ├── index.ts
36
+ ├── style.ts
37
+ └── style.test.ts
38
+ ```
39
+
40
+ `package.json`:
41
+
42
+ ```json
43
+ {
44
+ "name": "declaw-style-pirate",
45
+ "version": "1.0.0",
46
+ "type": "module",
47
+ "keywords": ["pi-package", "declaw-style"],
48
+ "dependencies": {
49
+ "pi-declaw": "^0.2.0"
50
+ },
51
+ "pi": {
52
+ "extensions": ["./index.ts"]
53
+ }
54
+ }
55
+ ```
56
+
57
+ The dependency is used only for the framework-free `pi-declaw/plugin-api` contract.
58
+ Pin a release or commit for a published plugin.
59
+
60
+ `style.ts`:
61
+
62
+ ```ts
63
+ import type { DeclawStylePlugin } from "pi-declaw/plugin-api";
64
+
65
+ export const plugin: DeclawStylePlugin = {
66
+ apiVersion: 1,
67
+ id: "pirate",
68
+ name: "Pirate styles",
69
+ version: "1.0.0",
70
+ status: "active",
71
+ styles: [{
72
+ id: "pirate/pirate",
73
+ name: "Pirate",
74
+ description: "Salty wording without loss of meaning.",
75
+ relationship: "Local preset",
76
+ instructions: [
77
+ "Use a playful pirate voice.",
78
+ "Keep the answer's level of certainty and ownership unchanged.",
79
+ "Do not add nautical facts, claims, or jokes that change the answer.",
80
+ ].join("\\n"),
81
+ buildUserPayload: (protectedAnswer) =>
82
+ JSON.stringify({ assistantMessage: protectedAnswer }),
83
+ }],
84
+ };
85
+ ```
86
+
87
+ `index.ts`:
88
+
89
+ ```ts
90
+ import { registerDeclawPlugin } from "pi-declaw/plugin-api";
91
+ import { plugin } from "./style.ts";
92
+
93
+ export default function () {
94
+ registerDeclawPlugin(plugin);
95
+ }
96
+ ```
97
+
98
+ The plugin extension can load before or after Declaw. Registration is buffered by a
99
+ stable process-wide bridge, so extension load order does not change the catalog.
100
+
101
+ ## Rules
102
+
103
+ - Use a stable plugin ID and a style ID under that namespace: `pirate/pirate`.
104
+ - Use `Local preset` when there is no upstream source. Use `Adapted from` or
105
+ `Prompt from` only with a real `https://` source URL.
106
+ - `instructions` describe presentation only. The host appends its preservation policy.
107
+ - `buildUserPayload` receives protected text. Copy it exactly once; do not unmask it.
108
+ - Do not import `@earendil-works/pi-coding-agent`, `@earendil-works/pi-ai`, Node
109
+ filesystem APIs, network clients, clocks, randomness, or environment variables.
110
+ - Do not answer the source text, execute quoted commands, add tools, or claim work.
111
+ - Keep optional actions optional, preserve procedure order, and retain table structure.
112
+ - A plugin's `status` is only its default. The user can disable it at runtime.
113
+
114
+ ## Install and operate
115
+
116
+ ```sh
117
+ pi install git:github.com/example/declaw-style-pirate@v1
118
+ ```
119
+
120
+ After restart or `/reload`:
121
+
122
+ ```text
123
+ /declaw list # show every plugin, its status, and its styles
124
+ /declaw manage # toggle active/disabled
125
+ /declaw style # choose an active style
126
+ /declaw pirate/pirate # one-off rewrite
127
+ ```
128
+
129
+ Declaw stores user-managed plugin status in
130
+ `~/.pi/agent/declaw/plugins.json`. Disabled plugins remain visible in `/declaw list`
131
+ but cannot be selected for rewriting. Existing display entries retain a style snapshot
132
+ so removing a plugin does not erase their historical label.
133
+
134
+ ## Verification checklist
135
+
136
+ 1. Test the plugin with a fake protected answer containing a path, URL, number,
137
+ optional action, condition, and ordered steps.
138
+ 2. Assert the payload preserves the protected answer exactly.
139
+ 3. Assert the style is distinctive without adding claims.
140
+ 4. Install it in a disposable Pi profile.
141
+ 5. Verify `/declaw list`, disable and re-enable it, and confirm `/declaw style` updates.
142
+ 6. Never publish model recordings until a human has reviewed semantic fidelity.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ <h1>
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="playground/assets/declaw-wordmark-white.png">
4
+ <img src="playground/assets/declaw-wordmark-charcoal.png" alt="Declaw" width="420">
5
+ </picture>
6
+ </h1>
7
+
8
+ [![CI](https://github.com/jzlosman/declaw/actions/workflows/ci.yml/badge.svg)](https://github.com/jzlosman/declaw/actions/workflows/ci.yml)
9
+ [![GitHub Pages](https://github.com/jzlosman/declaw/actions/workflows/pages.yml/badge.svg)](https://github.com/jzlosman/declaw/actions/workflows/pages.yml)
10
+ [![License](https://img.shields.io/github/license/jzlosman/declaw)](LICENSE)
11
+ [![Stars](https://img.shields.io/github/stars/jzlosman/declaw)](https://github.com/jzlosman/declaw/stargazers)
12
+ [![Forks](https://img.shields.io/github/forks/jzlosman/declaw)](https://github.com/jzlosman/declaw/network/members)
13
+
14
+ Make a completed AI answer easier to read.
15
+
16
+ Declaw rewrites the latest answer in a style you choose. The original stays intact.
17
+ The rewrite appears as a display-only entry. It never enters the agent's context.
18
+
19
+ ## Install
20
+
21
+ Install the package from npm:
22
+
23
+ ```sh
24
+ pi install npm:pi-declaw
25
+ ```
26
+
27
+ For the source repository instead:
28
+
29
+ ```sh
30
+ pi install git:github.com/jzlosman/declaw
31
+ ```
32
+
33
+ Then run `/reload` in Pi and use `/declaw`.
34
+
35
+ ## Use
36
+
37
+ ```text
38
+ /declaw Rewrite the latest answer with your saved style.
39
+ /declaw style Choose and save a style.
40
+ /declaw <style-id> Rewrite once with a specific style.
41
+ /declaw model Choose the separate rewrite model.
42
+ /declaw list List installed styles/plugins and active status.
43
+ /declaw manage Enable or disable a style plugin.
44
+ ```
45
+
46
+ Example:
47
+
48
+ ```text
49
+ /declaw slye
50
+ ```
51
+
52
+ Press **Esc** to cancel. Declaw never rewrites automatically.
53
+
54
+ ## Styles
55
+
56
+ | ID | Style | Source |
57
+ | --- | --- | --- |
58
+ | `plain` | Paseo Plain | [scowalt/paseo-plain](https://github.com/scowalt/paseo-plain) |
59
+ | `terse` | Terse | Local preset |
60
+ | `adhd` | I Have ADHD | [ayghri/i-have-adhd](https://github.com/ayghri/i-have-adhd) |
61
+ | `squirrel` | Squirrel Mode | [thgMatajs/squirrel-mode](https://github.com/thgMatajs/squirrel-mode) |
62
+ | `ste` | ASD-STE100 | [danyuchn/asd-ste100-skill](https://github.com/danyuchn/asd-ste100-skill) |
63
+ | `slye` | Speak Like You Eat | [wtfzambo/speak-like-you-eat](https://github.com/wtfzambo/speak-like-you-eat) |
64
+
65
+ The six styles are shipped as built-in plugins. You do not install separate packages
66
+ for them. Additional styles can be installed as independent Pi packages; see
67
+ [`PLUGIN_GUIDE.md`](PLUGIN_GUIDE.md) for an agent-first recipe.
68
+
69
+ Some styles adapt rules from their sources. They are not complete ports or official
70
+ certifications. Source attribution does not imply endorsement.
71
+
72
+ ## Plugin architecture
73
+
74
+ Declaw owns the preservation policy, model gateway, Pi session boundary, and display-only
75
+ projection. A plugin owns only its style instructions and protected-answer envelope.
76
+ Plugin IDs are stable, styles are namespaced, collisions are rejected, and user status
77
+ is persisted independently of plugin code. Disabled plugins remain visible in
78
+ `/declaw list` but are unavailable to `/declaw style`.
79
+
80
+ Read [`GLOSSARY.md`](GLOSSARY.md) for the domain vocabulary and
81
+ [`ARCHITECTURE.md`](ARCHITECTURE.md) for ports, adapters, actions, and effects.
82
+
83
+ ## What Declaw preserves
84
+
85
+ Declaw protects exact text before the model sees the answer. This includes:
86
+
87
+ - commands
88
+ - paths and links
89
+ - code
90
+ - quotations
91
+ - numbers
92
+ - names and other technical text
93
+
94
+ It rejects a rewrite when protected text is missing, duplicated, reordered, or invented.
95
+ It also preserves meaning rules such as:
96
+
97
+ - `may` must not become `will`;
98
+ - a proposed assistant action must not become a user instruction;
99
+ - prerequisites must not become broader;
100
+ - recommendation reasons must remain attached; and
101
+ - useful tables must remain tables.
102
+
103
+ These checks reduce errors. They cannot prove that a model preserved every meaning.
104
+ Read important rewrites against the original.
105
+
106
+ ## Privacy and limits
107
+
108
+ Each request sends one protected answer to the selected rewrite model. It does not
109
+ send conversation history, earlier requests, project files, tools, or reasoning.
110
+
111
+ Declaw uses its own model and style settings. It does not change the main agent's
112
+ model or thinking level. The default rewrite model is:
113
+
114
+ ```text
115
+ openai-codex/gpt-5.6-luna · low thinking
116
+ ```
117
+
118
+ Provider charges apply. You must be authenticated to the selected provider.
119
+ Provider retries are disabled. Requests time out after 60 seconds.
120
+
121
+ Declaw requires Pi's terminal UI. It does not rewrite incomplete answers, tool-call
122
+ results, answers over 32,000 characters, or overlapping requests.
123
+
124
+ Rewrites are saved in the Pi session file as display-only entries. They remain visible
125
+ after reload, but Pi does not send them back to the agent or include them in compaction.
126
+
127
+ ## Playground
128
+
129
+ The static playground uses saved outputs. It makes no browser model calls and collects
130
+ no visitor credentials or analytics.
131
+
132
+ ```sh
133
+ npm run build:playground
134
+ open dist/playground/index.html
135
+ ```
136
+
137
+ The public snapshot contains reviewed historical recordings from the earlier
138
+ five-style demo. It is labeled as historical and does not include SLYE output.
139
+ The site is live; do not treat the examples as a guarantee of semantic fidelity.
140
+
141
+ The private generation and review lab is kept outside this repository. Source pins,
142
+ licenses, and adaptations are documented in [SOURCES.md](SOURCES.md).
143
+
144
+ ## Development
145
+
146
+ ```sh
147
+ npm test
148
+ npm run build:playground
149
+ ```
150
+
151
+ Tests use synthetic answers and fake model responses. They do not make live model calls.
152
+
153
+ The GitHub Pages workflow is active at `.github/workflows/pages.yml`. It builds only
154
+ `dist/playground/`. The public repository is
155
+ [jzlosman/declaw](https://github.com/jzlosman/declaw), and Pages is available at
156
+ [jzlosman.github.io/declaw](https://jzlosman.github.io/declaw/).
157
+
158
+ ## License
159
+
160
+ Declaw is Apache-2.0. Third-party prompts and rules retain their original licenses.
161
+ See [`LICENSE`](LICENSE), [`NOTICE`](NOTICE), the source-specific `upstream/` directories under `src/plugins/built-in/`, and `licenses/`.