@anthusai/papyrus 0.0.0 → 1.0.0-next.2
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.
- package/LICENSE +21 -0
- package/amplify/auth/resource.js +61 -0
- package/amplify/auth/resource.ts +65 -0
- package/amplify/data/resource.js +2037 -0
- package/amplify/data/resource.ts +2148 -0
- package/amplify/data/schema.js +1850 -0
- package/amplify/data/schema.ts +1953 -0
- package/amplify/functions/assignment-action/handler.ts +1416 -0
- package/amplify/functions/assignment-action/resource.js +8 -0
- package/amplify/functions/assignment-action/resource.ts +9 -0
- package/amplify/functions/category-action/handler.ts +2259 -0
- package/amplify/functions/category-action/resource.js +8 -0
- package/amplify/functions/category-action/resource.ts +9 -0
- package/amplify/functions/console-chat-responder/Cargo.lock +3456 -0
- package/amplify/functions/console-chat-responder/Cargo.toml +26 -0
- package/amplify/functions/console-chat-responder/Dockerfile +19 -0
- package/amplify/functions/console-chat-responder/py/execute_tactus_runner.py +116 -0
- package/amplify/functions/console-chat-responder/resource.js +153 -0
- package/amplify/functions/console-chat-responder/resource.ts +179 -0
- package/amplify/functions/console-chat-responder/src/main.rs +3242 -0
- package/amplify/functions/email-submission-processor/handler.py +46 -0
- package/amplify/functions/email-submission-processor/requirements.txt +2 -0
- package/amplify/functions/email-submission-processor/resource.js +56 -0
- package/amplify/functions/email-submission-processor/resource.ts +69 -0
- package/amplify/functions/graphql-jwt-authorizer/handler.ts +193 -0
- package/amplify/functions/graphql-jwt-authorizer/resource.js +14 -0
- package/amplify/functions/graphql-jwt-authorizer/resource.ts +15 -0
- package/amplify/functions/knowledge-query/handler.py +1 -0
- package/amplify/functions/knowledge-query/requirements.txt +3 -0
- package/amplify/functions/knowledge-query/resource.js +50 -0
- package/amplify/functions/knowledge-query/resource.ts +61 -0
- package/amplify/functions/manage-user-role/handler.ts +799 -0
- package/amplify/functions/manage-user-role/resource.js +8 -0
- package/amplify/functions/manage-user-role/resource.ts +9 -0
- package/amplify/functions/model-attachment-upload/handler.ts +387 -0
- package/amplify/functions/model-attachment-upload/resource.js +8 -0
- package/amplify/functions/model-attachment-upload/resource.ts +9 -0
- package/amplify/functions/newsroom-summary/handler.ts +321 -0
- package/amplify/functions/newsroom-summary/resource.js +8 -0
- package/amplify/functions/newsroom-summary/resource.ts +9 -0
- package/amplify/functions/procedure-action/handler.ts +621 -0
- package/amplify/functions/procedure-action/resource.js +8 -0
- package/amplify/functions/procedure-action/resource.ts +9 -0
- package/amplify/functions/reader-settings/handler.ts +322 -0
- package/amplify/functions/reader-settings/resource.js +8 -0
- package/amplify/functions/reader-settings/resource.ts +9 -0
- package/amplify/functions/ses-inbound-receive/handler.ts +493 -0
- package/amplify/functions/ses-inbound-receive/resource.js +8 -0
- package/amplify/functions/ses-inbound-receive/resource.ts +9 -0
- package/amplify/functions/shared/amplify-secrets.ts +65 -0
- package/amplify/functions/shared/console-chat-enqueue.ts +117 -0
- package/amplify/functions/shared/email-mime-intake.ts +196 -0
- package/amplify/functions/shared/email-submission.ts +415 -0
- package/amplify/functions/shared/inbound-email-intake.ts +37 -0
- package/amplify/functions/shared/lambda-data-client.ts +21 -0
- package/amplify/functions/shared/model-payloads.ts +186 -0
- package/amplify/functions/shared/python-bundle.js +115 -0
- package/amplify/functions/shared/python-bundle.ts +141 -0
- package/amplify/functions/shared/slack-events.ts +111 -0
- package/amplify/functions/slack-delivery/handler.py +112 -0
- package/amplify/functions/slack-delivery/requirements.txt +2 -0
- package/amplify/functions/slack-delivery/resource.js +38 -0
- package/amplify/functions/slack-delivery/resource.ts +51 -0
- package/amplify/functions/slack-events/handler.ts +155 -0
- package/amplify/functions/slack-events/resource.js +11 -0
- package/amplify/functions/slack-events/resource.ts +12 -0
- package/amplify/inbound-email/stack.js +46 -0
- package/amplify/inbound-email/stack.ts +61 -0
- package/amplify/package.json +3 -0
- package/amplify/site-backend-config.js +1 -0
- package/amplify/site-backend-config.ts +30 -0
- package/amplify/site-backend.js +587 -0
- package/amplify/site-backend.ts +704 -0
- package/amplify/storage/resource.js +18 -0
- package/amplify/storage/resource.ts +19 -0
- package/app/[year]/[month]/[day]/[articleSlug]/page.tsx +62 -0
- package/app/[year]/[month]/[day]/edition-route-page.tsx +53 -0
- package/app/[year]/[month]/[day]/page/[pageNumber]/page.tsx +32 -0
- package/app/[year]/[month]/[day]/page.tsx +22 -0
- package/app/[year]/[month]/[day]/section/[sectionKey]/page.tsx +32 -0
- package/app/api/archive/editions/route.ts +18 -0
- package/app/api/media/[...path]/route.ts +35 -0
- package/app/api/revalidate/route.ts +94 -0
- package/app/archive/page.tsx +24 -0
- package/app/articles/[slug]/page.tsx +35 -0
- package/app/globals.css +10329 -0
- package/app/layout.tsx +146 -0
- package/app/newsroom/[section]/[...selection]/page.tsx +50 -0
- package/app/newsroom/[section]/page.tsx +47 -0
- package/app/newsroom/forum/[threadId]/page.tsx +35 -0
- package/app/newsroom/insights/[threadId]/page.tsx +22 -0
- package/app/newsroom/insights/page.tsx +14 -0
- package/app/newsroom/layout.tsx +12 -0
- package/app/newsroom/page.tsx +31 -0
- package/app/newsroom/sections/[sectionId]/page.tsx +17 -0
- package/app/page.tsx +272 -0
- package/app/settings/page.tsx +14 -0
- package/app/tailwind.css +65 -0
- package/bin/papyrus-app.mjs +10 -0
- package/bin/papyrus-infra.mjs +39 -0
- package/components/ai-elements/conversation.tsx +168 -0
- package/components/ai-elements/message.tsx +360 -0
- package/components/ai-elements/model-selector.tsx +30 -0
- package/components/ai-elements/prompt-input.tsx +1461 -0
- package/components/ai-elements/shimmer.tsx +76 -0
- package/components/ai-elements/suggestion.tsx +54 -0
- package/components/ai-elements/tool.tsx +173 -0
- package/components/amplify-client-provider.tsx +140 -0
- package/components/archive-grid.tsx +89 -0
- package/components/archive-shell.tsx +41 -0
- package/components/article-video.tsx +47 -0
- package/components/blog-page-background.tsx +20 -0
- package/components/dev-sandbox-editor-sign-in.tsx +60 -0
- package/components/news-desk-client-provider.tsx +211 -0
- package/components/news-desk-page.tsx +119 -0
- package/components/news-desk-taxonomy-client.ts +3684 -0
- package/components/newspaper.tsx +1929 -0
- package/components/newsroom-assignments-view.tsx +664 -0
- package/components/newsroom-ops-overview.tsx +226 -0
- package/components/newsroom-ops-shell.tsx +319 -0
- package/components/newsroom-references-view.tsx +598 -0
- package/components/newsroom-topics-view.tsx +425 -0
- package/components/papyrus-console-shell.tsx +1912 -0
- package/components/pictogram-figure.tsx +65 -0
- package/components/presentation-footer.tsx +146 -0
- package/components/reader-auth-control.tsx +162 -0
- package/components/reader-auth-state.ts +122 -0
- package/components/reader-settings.ts +332 -0
- package/components/reader-theme-control.tsx +85 -0
- package/components/reference-source-preview.tsx +163 -0
- package/components/settings-page.tsx +239 -0
- package/components/topic-steering-workspace.tsx +18063 -0
- package/components/ui/badge.tsx +30 -0
- package/components/ui/button-group.tsx +87 -0
- package/components/ui/button.tsx +58 -0
- package/components/ui/card.tsx +32 -0
- package/components/ui/command.tsx +194 -0
- package/components/ui/dialog.tsx +158 -0
- package/components/ui/dropdown-menu.tsx +266 -0
- package/components/ui/hover-card.tsx +51 -0
- package/components/ui/input-group.tsx +158 -0
- package/components/ui/input.tsx +20 -0
- package/components/ui/scroll-area.tsx +16 -0
- package/components/ui/select.tsx +199 -0
- package/components/ui/separator.tsx +23 -0
- package/components/ui/sheet.tsx +92 -0
- package/components/ui/spinner.tsx +10 -0
- package/components/ui/tabs.tsx +113 -0
- package/components/ui/textarea.tsx +18 -0
- package/components/ui/tooltip.tsx +66 -0
- package/components/use-resolved-papyrus-theme.ts +47 -0
- package/infra/amplify-app-shell.js +109 -0
- package/infra/amplify-app-shell.ts +155 -0
- package/infra/index.js +12 -0
- package/lib/amplify-outputs-guard.ts +24 -0
- package/lib/amplify-outputs-path.ts +16 -0
- package/lib/amplify-server-runtime.ts +63 -0
- package/lib/archive-data.ts +30 -0
- package/lib/archive-types.ts +15 -0
- package/lib/articles.ts +320 -0
- package/lib/cached-content-repository.ts +89 -0
- package/lib/category-dashboard.ts +37 -0
- package/lib/category-repository.ts +1907 -0
- package/lib/console-chat-client.ts +1316 -0
- package/lib/console-web-context.ts +118 -0
- package/lib/content-load-timing.ts +23 -0
- package/lib/content-repository.ts +40 -0
- package/lib/content-types.ts +104 -0
- package/lib/define-site.js +3 -0
- package/lib/define-site.ts +21 -0
- package/lib/demo-amplify-outputs.ts +15 -0
- package/lib/dev-sandbox-editor-auth.ts +18 -0
- package/lib/doctrine.ts +128 -0
- package/lib/edition-routes.ts +155 -0
- package/lib/edition-sections.ts +111 -0
- package/lib/empty-edition-layout-plan.ts +109 -0
- package/lib/excerpts.ts +8 -0
- package/lib/graphql-content-repository.ts +986 -0
- package/lib/image-url.ts +10 -0
- package/lib/layout-plan.ts +981 -0
- package/lib/layout-scenarios.ts +564 -0
- package/lib/markus-body.ts +168 -0
- package/lib/markus-ir.ts +235 -0
- package/lib/markus-projection.ts +243 -0
- package/lib/markus-to-article.ts +93 -0
- package/lib/news-desk-session.ts +160 -0
- package/lib/newspaper-layout.ts +3459 -0
- package/lib/newsroom-assignments.ts +173 -0
- package/lib/newsroom-base-path.ts +48 -0
- package/lib/newsroom-card-layout.ts +102 -0
- package/lib/newsroom-category-drilldown.ts +133 -0
- package/lib/newsroom-demo-dashboard.ts +267 -0
- package/lib/newsroom-demo-profile.ts +46 -0
- package/lib/newsroom-forum-routes.ts +153 -0
- package/lib/newsroom-index-filters.ts +202 -0
- package/lib/newsroom-knowledge-query-request.ts +51 -0
- package/lib/newsroom-list-selection.ts +42 -0
- package/lib/newsroom-nav.ts +42 -0
- package/lib/newsroom-references.ts +116 -0
- package/lib/newsroom-sections.ts +52 -0
- package/lib/newsroom-topics.ts +118 -0
- package/lib/papyrus-object-kinds.ts +24 -0
- package/lib/papyrus-web-locations.ts +480 -0
- package/lib/pilobol-sample.ts +167 -0
- package/lib/presentation-footer.ts +92 -0
- package/lib/pretext-layout.ts +179 -0
- package/lib/public-placeholder-config.ts +102 -0
- package/lib/publication-items.ts +181 -0
- package/lib/reader-route-config.ts +1 -0
- package/lib/reader-static-params.ts +56 -0
- package/lib/reader-storage-url.ts +63 -0
- package/lib/reference-display.ts +74 -0
- package/lib/reference-policy.ts +97 -0
- package/lib/reference-source-preview.ts +175 -0
- package/lib/renderer-config.ts +50 -0
- package/lib/renderer.ts +87 -0
- package/lib/reporting-story-budget.ts +638 -0
- package/lib/semantic-graph.ts +554 -0
- package/lib/site-brand-tenant.ts +41 -0
- package/lib/site-brand.ts +179 -0
- package/lib/site-renderer.ts +17 -0
- package/lib/site-stack.ts +195 -0
- package/lib/themed-image.ts +30 -0
- package/lib/utils.ts +6 -0
- package/middleware.ts +78 -0
- package/package.json +296 -1
- package/publications/anth_us/brand.ts +68 -0
- package/publications/anth_us/theme.css +66 -0
- package/publications/papyrus/theme.css +11 -0
- package/publications/pilobol_us/brand.ts +37 -0
- package/publications/pilobol_us/theme.css +140 -0
- package/publications/threat_intelligence/blog-defense/graph.ts +636 -0
- package/publications/threat_intelligence/blog-defense/layout.ts +934 -0
- package/publications/threat_intelligence/blog-defense/page-background.tsx +590 -0
- package/publications/threat_intelligence/brand.ts +40 -0
- package/publications/threat_intelligence/pictograms/art.tsx +608 -0
- package/publications/threat_intelligence/pictograms/figure.tsx +82 -0
- package/publications/threat_intelligence/pictograms/registry.ts +30 -0
- package/publications/threat_intelligence/pictograms/system.tsx +305 -0
- package/publications/threat_intelligence/seed/seed-edition-content.json +629 -0
- package/publications/threat_intelligence/theme.css +1440 -0
- package/renderers/markus/index.ts +25 -0
- package/renderers/markus/stubs.tsx +33 -0
- package/renderers/pretext/article-page.tsx +174 -0
- package/renderers/pretext/index.ts +30 -0
- package/renderers/pretext/layouts.ts +16 -0
- package/renderers/pretext/presentation-shell.tsx +477 -0
- package/routes.manifest.json +182 -0
- package/scripts/fixtures/pilobol-sample.ast.json +234 -0
- package/src/backend.js +1 -0
- package/src/backend.ts +3 -0
- package/src/sync.mjs +87 -0
- package/src/with-papyrus.d.mts +2 -0
- package/src/with-papyrus.mjs +47 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "document",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"front_matter": {
|
|
5
|
+
"title": "Agents work better with less freedom",
|
|
6
|
+
"authors": [
|
|
7
|
+
"Ada Lovelace"
|
|
8
|
+
],
|
|
9
|
+
"date": "2026-09-06"
|
|
10
|
+
},
|
|
11
|
+
"children": [
|
|
12
|
+
{
|
|
13
|
+
"type": "paragraph",
|
|
14
|
+
"inline": [
|
|
15
|
+
{
|
|
16
|
+
"type": "text",
|
|
17
|
+
"text": "Developers are learning that reliable agents need less freedom, not more."
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"line": 8
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "paragraph",
|
|
24
|
+
"inline": [
|
|
25
|
+
{
|
|
26
|
+
"type": "text",
|
|
27
|
+
"text": "Across demos and tool launches, builders kept circling the same answer."
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"line": 10
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "directive",
|
|
34
|
+
"name": "pull-quote",
|
|
35
|
+
"attributes": {
|
|
36
|
+
"id": null,
|
|
37
|
+
"attribution": "Editorial principle",
|
|
38
|
+
"source": null,
|
|
39
|
+
"tone": "default",
|
|
40
|
+
"align": "inline"
|
|
41
|
+
},
|
|
42
|
+
"leaf": false,
|
|
43
|
+
"line": 12,
|
|
44
|
+
"children": [
|
|
45
|
+
{
|
|
46
|
+
"type": "paragraph",
|
|
47
|
+
"inline": [
|
|
48
|
+
{
|
|
49
|
+
"type": "text",
|
|
50
|
+
"text": "The practical breakthrough is not giving agents a bigger sandbox."
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"line": 13
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "heading",
|
|
59
|
+
"level": 2,
|
|
60
|
+
"inline": [
|
|
61
|
+
{
|
|
62
|
+
"type": "text",
|
|
63
|
+
"text": "Planning state"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"line": 16
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "paragraph",
|
|
70
|
+
"inline": [
|
|
71
|
+
{
|
|
72
|
+
"type": "text",
|
|
73
|
+
"text": "Read-only tools. An inline "
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"type": "code_span",
|
|
77
|
+
"code": "code_span"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "text",
|
|
81
|
+
"text": " should not be confused with a block."
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"line": 18
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "code",
|
|
88
|
+
"lang": "python",
|
|
89
|
+
"value": "def plan():\n return \"read only\"\n",
|
|
90
|
+
"line": 20
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "directive",
|
|
94
|
+
"name": "card-grid",
|
|
95
|
+
"attributes": {
|
|
96
|
+
"id": null,
|
|
97
|
+
"label": null,
|
|
98
|
+
"columns": 2
|
|
99
|
+
},
|
|
100
|
+
"leaf": false,
|
|
101
|
+
"line": 25,
|
|
102
|
+
"children": [
|
|
103
|
+
{
|
|
104
|
+
"type": "directive",
|
|
105
|
+
"name": "card",
|
|
106
|
+
"attributes": {
|
|
107
|
+
"id": null,
|
|
108
|
+
"icon": null,
|
|
109
|
+
"title": "Read",
|
|
110
|
+
"span": null
|
|
111
|
+
},
|
|
112
|
+
"leaf": false,
|
|
113
|
+
"line": 26,
|
|
114
|
+
"children": [
|
|
115
|
+
{
|
|
116
|
+
"type": "paragraph",
|
|
117
|
+
"inline": [
|
|
118
|
+
{
|
|
119
|
+
"type": "text",
|
|
120
|
+
"text": "Look before you leap."
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"line": 27
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"type": "directive",
|
|
129
|
+
"name": "card",
|
|
130
|
+
"attributes": {
|
|
131
|
+
"id": null,
|
|
132
|
+
"icon": null,
|
|
133
|
+
"title": "Write",
|
|
134
|
+
"span": null
|
|
135
|
+
},
|
|
136
|
+
"leaf": false,
|
|
137
|
+
"line": 29,
|
|
138
|
+
"children": [
|
|
139
|
+
{
|
|
140
|
+
"type": "paragraph",
|
|
141
|
+
"inline": [
|
|
142
|
+
{
|
|
143
|
+
"type": "text",
|
|
144
|
+
"text": "Only after planning."
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"line": 30
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"type": "directive",
|
|
155
|
+
"name": "two-up",
|
|
156
|
+
"attributes": {
|
|
157
|
+
"id": null,
|
|
158
|
+
"ratio": "1:1",
|
|
159
|
+
"align": "start"
|
|
160
|
+
},
|
|
161
|
+
"leaf": false,
|
|
162
|
+
"line": 34,
|
|
163
|
+
"children": [
|
|
164
|
+
{
|
|
165
|
+
"type": "directive",
|
|
166
|
+
"name": "column",
|
|
167
|
+
"attributes": {
|
|
168
|
+
"id": null
|
|
169
|
+
},
|
|
170
|
+
"leaf": false,
|
|
171
|
+
"line": 35,
|
|
172
|
+
"children": [
|
|
173
|
+
{
|
|
174
|
+
"type": "paragraph",
|
|
175
|
+
"inline": [
|
|
176
|
+
{
|
|
177
|
+
"type": "text",
|
|
178
|
+
"text": "Planning state keeps risk low."
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"line": 36
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"type": "directive",
|
|
187
|
+
"name": "column",
|
|
188
|
+
"attributes": {
|
|
189
|
+
"id": null
|
|
190
|
+
},
|
|
191
|
+
"leaf": false,
|
|
192
|
+
"line": 38,
|
|
193
|
+
"children": [
|
|
194
|
+
{
|
|
195
|
+
"type": "paragraph",
|
|
196
|
+
"inline": [
|
|
197
|
+
{
|
|
198
|
+
"type": "text",
|
|
199
|
+
"text": "Implementation state is where damage happens."
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"line": 39
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"type": "directive",
|
|
210
|
+
"name": "figure",
|
|
211
|
+
"attributes": {
|
|
212
|
+
"id": null,
|
|
213
|
+
"src": "../assets/state-diagram.svg",
|
|
214
|
+
"alt": "State diagram",
|
|
215
|
+
"credit": null,
|
|
216
|
+
"caption": "Two states, one agent"
|
|
217
|
+
},
|
|
218
|
+
"leaf": false,
|
|
219
|
+
"line": 43,
|
|
220
|
+
"children": []
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"type": "paragraph",
|
|
224
|
+
"inline": [
|
|
225
|
+
{
|
|
226
|
+
"type": "text",
|
|
227
|
+
"text": "The lesson is not that agents are over."
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"line": 46
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"_papyrus_source_sha256": "cf899c47590d54b39b60824dc8718131a3ba8a77b073cc66947d70d2f6145757"
|
|
234
|
+
}
|
package/src/backend.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineSiteBackend } from "../amplify/site-backend.js";
|
package/src/backend.ts
ADDED
package/src/sync.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `papyrus-app sync`: write one-line route shims for Papyrus's routes into the
|
|
7
|
+
* publication repo (SPIKE, PPY-82be6c). Output is generated and gitignored;
|
|
8
|
+
* a site-owned file at the same path (no GENERATED header) always wins.
|
|
9
|
+
*/
|
|
10
|
+
const MARKER = "// GENERATED by `papyrus-app sync` from @anthusai/papyrus. Do not edit; add a site-owned file at this path to override.";
|
|
11
|
+
const NEXT_EXPORTS = new Set([
|
|
12
|
+
"generateMetadata", "metadata", "generateStaticParams", "generateViewport", "viewport",
|
|
13
|
+
"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS",
|
|
14
|
+
]);
|
|
15
|
+
const GITIGNORE_BEGIN = "# >>> papyrus-app sync (generated route shims)";
|
|
16
|
+
const GITIGNORE_END = "# <<< papyrus-app sync";
|
|
17
|
+
|
|
18
|
+
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
|
+
const PKG = "@anthusai/papyrus";
|
|
20
|
+
|
|
21
|
+
function isGenerated(file) {
|
|
22
|
+
try {
|
|
23
|
+
return fs.readFileSync(file, "utf8").startsWith(MARKER);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function shimFor(route) {
|
|
30
|
+
const spec = `${PKG}/${route.file.replace(/\.(tsx|ts)$/, "")}`;
|
|
31
|
+
const lines = [MARKER];
|
|
32
|
+
const named = route.exports.filter((n) => NEXT_EXPORTS.has(n));
|
|
33
|
+
if (route.hasDefault) lines.push(`export { default${named.length ? ", " + named.join(", ") : ""} } from "${spec}";`);
|
|
34
|
+
else if (named.length) lines.push(`export { ${named.join(", ")} } from "${spec}";`);
|
|
35
|
+
// Route-segment config must be a literal in the route file itself.
|
|
36
|
+
for (const [name, literal] of Object.entries(route.config)) lines.push(`export const ${name} = ${literal};`);
|
|
37
|
+
return lines.join("\n") + "\n";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function middlewareShim(manifest) {
|
|
41
|
+
const matcher = manifest.middleware.matcher ?? '["/((?!_next/static|_next/image|favicon.ico|icon).*)"]';
|
|
42
|
+
return [
|
|
43
|
+
MARKER,
|
|
44
|
+
`export { middleware } from "${PKG}/middleware";`,
|
|
45
|
+
`export const config = { matcher: ${matcher} };`,
|
|
46
|
+
"",
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function sync({ root = process.cwd(), log = console.log } = {}) {
|
|
51
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(pkgRoot, "routes.manifest.json"), "utf8"));
|
|
52
|
+
const generated = [];
|
|
53
|
+
const skipped = [];
|
|
54
|
+
const write = (relPath, content) => {
|
|
55
|
+
const dest = path.join(root, relPath);
|
|
56
|
+
if (fs.existsSync(dest) && !isGenerated(dest)) {
|
|
57
|
+
skipped.push(relPath);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
61
|
+
fs.writeFileSync(dest, content);
|
|
62
|
+
generated.push(relPath);
|
|
63
|
+
};
|
|
64
|
+
for (const route of manifest.routes) write(route.file, shimFor(route));
|
|
65
|
+
write("middleware.ts", middlewareShim(manifest));
|
|
66
|
+
|
|
67
|
+
// Remove shims that are no longer in the manifest (e.g. after an upgrade).
|
|
68
|
+
const stateFile = path.join(root, ".papyrus", "generated.json");
|
|
69
|
+
let previous = [];
|
|
70
|
+
try { previous = JSON.parse(fs.readFileSync(stateFile, "utf8")); } catch { /* first run */ }
|
|
71
|
+
for (const rel of previous) {
|
|
72
|
+
if (!generated.includes(rel) && isGenerated(path.join(root, rel))) fs.rmSync(path.join(root, rel));
|
|
73
|
+
}
|
|
74
|
+
fs.mkdirSync(path.dirname(stateFile), { recursive: true });
|
|
75
|
+
fs.writeFileSync(stateFile, JSON.stringify(generated, null, 2) + "\n");
|
|
76
|
+
|
|
77
|
+
// Keep generated shims out of git.
|
|
78
|
+
const giFile = path.join(root, ".gitignore");
|
|
79
|
+
const gi = fs.existsSync(giFile) ? fs.readFileSync(giFile, "utf8") : "";
|
|
80
|
+
const block = [GITIGNORE_BEGIN, ...generated.map((g) => "/" + g), "/.papyrus/", GITIGNORE_END].join("\n");
|
|
81
|
+
const re = new RegExp(`${GITIGNORE_BEGIN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${GITIGNORE_END}`);
|
|
82
|
+
fs.writeFileSync(giFile, re.test(gi) ? gi.replace(re, block) : `${gi}${gi.endsWith("\n") || !gi ? "" : "\n"}${block}\n`);
|
|
83
|
+
|
|
84
|
+
log(`papyrus-app sync: ${generated.length} shim(s) written, ${skipped.length} site-owned file(s) kept (${PKG}@${manifest.version})`);
|
|
85
|
+
for (const rel of skipped) log(` site-owned: ${rel}`);
|
|
86
|
+
return { generated, skipped };
|
|
87
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wrap a publication repo's Next config for Papyrus (SPIKE, PPY-82be6c).
|
|
5
|
+
* - transpile the package (it ships TypeScript source),
|
|
6
|
+
* - alias `papyrus-site` -> ./papyrus.config.ts and
|
|
7
|
+
* `papyrus-amplify-outputs` -> ./amplify_outputs.json (both webpack and turbopack),
|
|
8
|
+
* - carry Papyrus's own server-external packages and image settings.
|
|
9
|
+
*/
|
|
10
|
+
const SERVER_EXTERNAL = [
|
|
11
|
+
"aws-amplify",
|
|
12
|
+
"@aws-amplify/adapter-nextjs",
|
|
13
|
+
"@aws-amplify/core",
|
|
14
|
+
"@aws-amplify/api",
|
|
15
|
+
"@aws-amplify/api-graphql",
|
|
16
|
+
"@aws-amplify/auth",
|
|
17
|
+
"@aws-amplify/storage",
|
|
18
|
+
"@aws-amplify/data-schema",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export function withPapyrus(nextConfig = {}, options = {}) {
|
|
22
|
+
const root = options.root ?? process.cwd();
|
|
23
|
+
const aliases = {
|
|
24
|
+
"papyrus-site": path.join(root, "papyrus.config.ts"),
|
|
25
|
+
"papyrus-amplify-outputs": path.join(root, "amplify_outputs.json"),
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
distDir: process.env.NEXT_DIST_DIR || ".next",
|
|
29
|
+
...nextConfig,
|
|
30
|
+
transpilePackages: [...new Set([...(nextConfig.transpilePackages ?? []), "@anthusai/papyrus"])],
|
|
31
|
+
serverExternalPackages: [...new Set([...(nextConfig.serverExternalPackages ?? []), ...SERVER_EXTERNAL])],
|
|
32
|
+
images: nextConfig.images ?? { remotePatterns: [{ protocol: "https", hostname: "**" }] },
|
|
33
|
+
experimental: { devtoolSegmentExplorer: false, ...nextConfig.experimental },
|
|
34
|
+
turbopack: {
|
|
35
|
+
...nextConfig.turbopack,
|
|
36
|
+
resolveAlias: {
|
|
37
|
+
...nextConfig.turbopack?.resolveAlias,
|
|
38
|
+
"papyrus-site": "./papyrus.config.ts",
|
|
39
|
+
"papyrus-amplify-outputs": "./amplify_outputs.json",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
webpack(config, context) {
|
|
43
|
+
config.resolve.alias = { ...config.resolve.alias, ...aliases };
|
|
44
|
+
return typeof nextConfig.webpack === "function" ? nextConfig.webpack(config, context) : config;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|