@getpagr/cli 1.0.4 → 1.0.6
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/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +13 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +6 -275
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/skills.d.ts +3 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +294 -0
- package/dist/lib/skills.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,qDAuExB,CAAA"}
|
package/dist/commands/config.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
1
3
|
import { defineCommand } from 'citty';
|
|
2
4
|
import { readConfig, writeConfig } from '../lib/config.js';
|
|
5
|
+
import { writeSkillFiles } from '../lib/skills.js';
|
|
3
6
|
export const configCommand = defineCommand({
|
|
4
7
|
meta: {
|
|
5
8
|
name: 'config',
|
|
@@ -26,6 +29,16 @@ export const configCommand = defineCommand({
|
|
|
26
29
|
const current = readConfig();
|
|
27
30
|
writeConfig({ ...current, apiKey: args.key });
|
|
28
31
|
console.log('API key saved to ~/.pagr/config.json');
|
|
32
|
+
// Also update skill files in the current workspace if it's initialized
|
|
33
|
+
const cwd = process.cwd();
|
|
34
|
+
const skillMdPath = join(cwd, 'SKILL.md');
|
|
35
|
+
const hasSkillFile = existsSync(skillMdPath);
|
|
36
|
+
const hasClaudeDir = existsSync(join(cwd, '.claude'));
|
|
37
|
+
const hasAgentsDir = existsSync(join(cwd, '.agents'));
|
|
38
|
+
if (hasSkillFile || hasClaudeDir || hasAgentsDir) {
|
|
39
|
+
writeSkillFiles(cwd, args.key, hasClaudeDir);
|
|
40
|
+
console.log('Workspace skill files updated with your active API key and remote MCP instructions.');
|
|
41
|
+
}
|
|
29
42
|
},
|
|
30
43
|
}),
|
|
31
44
|
'set-url': defineCommand({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;IACzC,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0BAA0B;KACxC;IACD,WAAW,EAAE;QACX,SAAS,EAAE,aAAa,CAAC;YACvB,IAAI,EAAE;gBACJ,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8CAA8C;aAC5D;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE;oBACH,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,cAAc;oBAC3B,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,GAAG,CAAC,EAAE,IAAI,EAAE;gBACV,IAAI,CAAC,IA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AU,EAAE,CAAA;gBAC5B,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;gBAChD,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;YAC9C,CAAC;SACF,CAAC;QACF,IAAI,EAAE,aAAa,CAAC;YAClB,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,4BAA4B;aAC1C;YACD,GAAG;gBACD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAA;gBACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,MAAM,CAAA;gBACrD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;gBAC3E,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,SAAS,IAAI,mBAAmB,CAAC,CAAA;YACjG,CAAC;SACF,CAAC;KACH;CACF,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,WAAW;;;;;;;;;;;;;EAqCtB,CAAA"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,265 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { defineCommand } from 'citty';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'',
|
|
7
|
-
'Use this skill when the user wants to publish, update, list, delete, or manage HTML files with the Pagr CLI.',
|
|
8
|
-
'',
|
|
9
|
-
'## When To Use This Skill',
|
|
10
|
-
'',
|
|
11
|
-
'- Publishing generated HTML reports, dashboards, documents, or plans.',
|
|
12
|
-
'- Updating existing published Pagr pages while keeping the same public URL.',
|
|
13
|
-
'- Creating shareable URLs for local HTML artifacts.',
|
|
14
|
-
'- Listing or deleting Pagr files from a user account.',
|
|
15
|
-
'- Setting up Pagr in a project for agent workflows.',
|
|
16
|
-
'- Publishing HTML artifacts from CI.',
|
|
17
|
-
'',
|
|
18
|
-
'## Core Rules',
|
|
19
|
-
'',
|
|
20
|
-
'- Use `pagr upload <file>` for HTML files.',
|
|
21
|
-
'- Never invent a Pagr URL. Always return the URL printed by the CLI.',
|
|
22
|
-
'- If a file contains `<meta name="pagr-id">` or `<meta name="pagr-slug">`, `pagr upload <file>` may update the existing page instead of creating a new one.',
|
|
23
|
-
'- Updates replace the current HTML in place. Pagr does not store previous HTML versions or rollback history.',
|
|
24
|
-
'- Prefer `PAGR_API_KEY` in CI instead of writing `~/.pagr/config.json`.',
|
|
25
|
-
'- Do not print or expose full API keys unless the user explicitly asks to configure authentication.',
|
|
26
|
-
'- If upload, update, list, or delete fails, surface the exact CLI/API error.',
|
|
27
|
-
'',
|
|
28
|
-
'## Installation',
|
|
29
|
-
'',
|
|
30
|
-
'```bash',
|
|
31
|
-
'npm install -g @getpagr/cli',
|
|
32
|
-
'```',
|
|
33
|
-
'',
|
|
34
|
-
'Pagr CLI requires Node.js 20 or newer. The installed command is `pagr`.',
|
|
35
|
-
'',
|
|
36
|
-
'## Authentication',
|
|
37
|
-
'',
|
|
38
|
-
'Browser login:',
|
|
39
|
-
'',
|
|
40
|
-
'```bash',
|
|
41
|
-
'pagr login',
|
|
42
|
-
'```',
|
|
43
|
-
'',
|
|
44
|
-
'`pagr login` starts a browser login flow, authenticates with Pagr, receives a CLI API key through a local callback, and saves it to `~/.pagr/config.json`.',
|
|
45
|
-
'',
|
|
46
|
-
'Manual login for SSH, headless, or locked-down environments:',
|
|
47
|
-
'',
|
|
48
|
-
'```bash',
|
|
49
|
-
'pagr login --manual',
|
|
50
|
-
'```',
|
|
51
|
-
'',
|
|
52
|
-
'Save a key without prompting:',
|
|
53
|
-
'',
|
|
54
|
-
'```bash',
|
|
55
|
-
'pagr login --key pagr_...',
|
|
56
|
-
'```',
|
|
57
|
-
'',
|
|
58
|
-
'Set a key directly in local config:',
|
|
59
|
-
'',
|
|
60
|
-
'```bash',
|
|
61
|
-
'pagr config set-key pagr_...',
|
|
62
|
-
'```',
|
|
63
|
-
'',
|
|
64
|
-
'API keys must start with `pagr_`.',
|
|
65
|
-
'',
|
|
66
|
-
'Config location:',
|
|
67
|
-
'',
|
|
68
|
-
'```text',
|
|
69
|
-
'~/.pagr/config.json',
|
|
70
|
-
'```',
|
|
71
|
-
'',
|
|
72
|
-
'Auth lookup order:',
|
|
73
|
-
'',
|
|
74
|
-
'1. `PAGR_API_KEY`',
|
|
75
|
-
'2. `~/.pagr/config.json`',
|
|
76
|
-
'3. Error if neither exists',
|
|
77
|
-
'',
|
|
78
|
-
'## Upload New HTML',
|
|
79
|
-
'',
|
|
80
|
-
'```bash',
|
|
81
|
-
'pagr upload report.html',
|
|
82
|
-
'```',
|
|
83
|
-
'',
|
|
84
|
-
'Behavior:',
|
|
85
|
-
'',
|
|
86
|
-
'- Reads the local HTML file as UTF-8.',
|
|
87
|
-
'- Uploads raw HTML to Pagr.',
|
|
88
|
-
'- Prints the public URL.',
|
|
89
|
-
'- Copies the URL to the clipboard when supported.',
|
|
90
|
-
'- When `CI` is set, also prints:',
|
|
91
|
-
'',
|
|
92
|
-
'```text',
|
|
93
|
-
'PAGR_SLUG=...',
|
|
94
|
-
'PAGR_URL=...',
|
|
95
|
-
'```',
|
|
96
|
-
'',
|
|
97
|
-
'## Upload With Title And Slug',
|
|
98
|
-
'',
|
|
99
|
-
'Set a page title:',
|
|
100
|
-
'',
|
|
101
|
-
'```bash',
|
|
102
|
-
'pagr upload report.html --title "Weekly report"',
|
|
103
|
-
'pagr upload report.html -t "Weekly report"',
|
|
104
|
-
'```',
|
|
105
|
-
'',
|
|
106
|
-
'Request a stable readable slug:',
|
|
107
|
-
'',
|
|
108
|
-
'```bash',
|
|
109
|
-
'pagr upload report.html --slug weekly-report',
|
|
110
|
-
'pagr upload report.html -s weekly-report',
|
|
111
|
-
'```',
|
|
112
|
-
'',
|
|
113
|
-
'Use both:',
|
|
114
|
-
'',
|
|
115
|
-
'```bash',
|
|
116
|
-
'pagr upload report.html --slug weekly-report --title "Weekly report"',
|
|
117
|
-
'```',
|
|
118
|
-
'',
|
|
119
|
-
'`--title` sends `X-Pagr-Title`. `--slug` requests a stable readable URL. Custom slugs can be plan-gated.',
|
|
120
|
-
'',
|
|
121
|
-
'## Update Existing Pages',
|
|
122
|
-
'',
|
|
123
|
-
'```bash',
|
|
124
|
-
'pagr upload report.html --update --slug weekly-report',
|
|
125
|
-
'pagr upload report.html -u -s weekly-report',
|
|
126
|
-
'```',
|
|
127
|
-
'',
|
|
128
|
-
'Behavior:',
|
|
129
|
-
'',
|
|
130
|
-
'- Checks slug ownership first.',
|
|
131
|
-
'- Fails if the slug is missing or not owned by the authenticated user.',
|
|
132
|
-
'- Sends replacement HTML to the existing page.',
|
|
133
|
-
'- Keeps the public URL stable.',
|
|
134
|
-
'- Replaces current content in place; this is not versioning.',
|
|
135
|
-
'',
|
|
136
|
-
'## Auto-Update With Meta Tags',
|
|
137
|
-
'',
|
|
138
|
-
'```html',
|
|
139
|
-
'<meta name="pagr-id" content="...">',
|
|
140
|
-
'<meta name="pagr-slug" content="weekly-report">',
|
|
141
|
-
'```',
|
|
142
|
-
'',
|
|
143
|
-
'Update priority:',
|
|
144
|
-
'',
|
|
145
|
-
'1. `pagr-id` updates by stable document ID.',
|
|
146
|
-
'2. `pagr-slug` updates by slug.',
|
|
147
|
-
'3. `--update --slug` forces update by slug.',
|
|
148
|
-
'4. Otherwise a new file is uploaded.',
|
|
149
|
-
'',
|
|
150
|
-
'Inject Pagr metadata into the source file:',
|
|
151
|
-
'',
|
|
152
|
-
'```bash',
|
|
153
|
-
'pagr upload report.html --inject',
|
|
154
|
-
'```',
|
|
155
|
-
'',
|
|
156
|
-
'`--inject` writes Pagr metadata into the local HTML source after upload. If a new upload has no `pagr-slug`, the CLI auto-injects metadata for future updates. This modifies the local source HTML file.',
|
|
157
|
-
'',
|
|
158
|
-
'## List Files',
|
|
159
|
-
'',
|
|
160
|
-
'```bash',
|
|
161
|
-
'pagr ls',
|
|
162
|
-
'pagr ls --limit 20',
|
|
163
|
-
'```',
|
|
164
|
-
'',
|
|
165
|
-
'Default limit is 50. Output includes slug, views, plan, title, and URL. If no files exist, the CLI prints `No files found.`',
|
|
166
|
-
'',
|
|
167
|
-
'## Delete Files',
|
|
168
|
-
'',
|
|
169
|
-
'```bash',
|
|
170
|
-
'pagr rm weekly-report',
|
|
171
|
-
'pagr rm weekly-report --yes',
|
|
172
|
-
'pagr rm weekly-report -y',
|
|
173
|
-
'```',
|
|
174
|
-
'',
|
|
175
|
-
'Without `--yes`, the CLI asks for confirmation and accepts `y` or `yes`. Delete is not reversible.',
|
|
176
|
-
'',
|
|
177
|
-
'## Config Commands',
|
|
178
|
-
'',
|
|
179
|
-
'```bash',
|
|
180
|
-
'pagr config show',
|
|
181
|
-
'pagr config set-key pagr_...',
|
|
182
|
-
'pagr config set-url https://pagr.link',
|
|
183
|
-
'```',
|
|
184
|
-
'',
|
|
185
|
-
'`pagr config show` masks the API key. `set-key` requires a `pagr_` prefix. `set-url` overrides the Worker API URL in local config. Environment variables override local config.',
|
|
186
|
-
'',
|
|
187
|
-
'## Init Command',
|
|
188
|
-
'',
|
|
189
|
-
'```bash',
|
|
190
|
-
'pagr init',
|
|
191
|
-
'pagr init --no-claude',
|
|
192
|
-
'pagr init --no-mcp',
|
|
193
|
-
'```',
|
|
194
|
-
'',
|
|
195
|
-
'`pagr init` writes:',
|
|
196
|
-
'',
|
|
197
|
-
'- `SKILL.md`',
|
|
198
|
-
'- `.claude/skills/pagr/SKILL.md` unless `--no-claude`',
|
|
199
|
-
'- `.agents/skills/pagr/SKILL.md`',
|
|
200
|
-
'- `.claude/settings.json` MCP server config unless `--no-mcp`',
|
|
201
|
-
'',
|
|
202
|
-
'MCP config:',
|
|
203
|
-
'',
|
|
204
|
-
'```json',
|
|
205
|
-
'{',
|
|
206
|
-
' "mcpServers": {',
|
|
207
|
-
' "pagr": {',
|
|
208
|
-
' "command": "npx",',
|
|
209
|
-
' "args": ["-y", "@pagr/mcp"]',
|
|
210
|
-
' }',
|
|
211
|
-
' }',
|
|
212
|
-
'}',
|
|
213
|
-
'```',
|
|
214
|
-
'',
|
|
215
|
-
'## CI Usage',
|
|
216
|
-
'',
|
|
217
|
-
'Use `PAGR_API_KEY` in CI. Do not write `~/.pagr/config.json` in CI.',
|
|
218
|
-
'',
|
|
219
|
-
'```yaml',
|
|
220
|
-
'- name: Publish HTML report',
|
|
221
|
-
' run: pagr upload output/report.html --title "Nightly report"',
|
|
222
|
-
' env:',
|
|
223
|
-
' PAGR_API_KEY: ${{ secrets.PAGR_API_KEY }}',
|
|
224
|
-
'```',
|
|
225
|
-
'',
|
|
226
|
-
'When `CI` is set, use the machine-readable `PAGR_SLUG` and `PAGR_URL` output lines.',
|
|
227
|
-
'',
|
|
228
|
-
'## Environment Variables',
|
|
229
|
-
'',
|
|
230
|
-
'- `PAGR_API_KEY`: overrides the locally saved key.',
|
|
231
|
-
'- `PAGR_WORKER_URL`: overrides the Worker API URL. Default is `https://pagr.link`.',
|
|
232
|
-
'- `PAGR_APP_URL`: overrides the app URL used by `pagr login`. Default is `https://app.getpagr.co`.',
|
|
233
|
-
'- `CI`: makes upload print machine-readable `PAGR_SLUG` and `PAGR_URL`.',
|
|
234
|
-
'',
|
|
235
|
-
'## Error Handling',
|
|
236
|
-
'',
|
|
237
|
-
'Common failures:',
|
|
238
|
-
'',
|
|
239
|
-
'- Missing API key: run `pagr login`, run `pagr login --manual`, or set `PAGR_API_KEY`.',
|
|
240
|
-
'- Invalid API key format: keys must start with `pagr_`.',
|
|
241
|
-
'- Cannot read file: confirm the path exists and points to an HTML file.',
|
|
242
|
-
'- Slug not found or not owned during update: upload without `--update` or use the correct slug.',
|
|
243
|
-
'- Upload/update/list/delete API errors: surface the exact CLI error.',
|
|
244
|
-
'- Clipboard failure does not fail upload; the URL is still printed.',
|
|
245
|
-
'',
|
|
246
|
-
'If browser login fails, use `pagr login --manual`. If upload fails due to plan or file limit, surface the CLI error and tell the user to check account plan and file size.',
|
|
247
|
-
'',
|
|
248
|
-
'## Agent Workflow',
|
|
249
|
-
'',
|
|
250
|
-
'1. Confirm the target file exists and is HTML.',
|
|
251
|
-
'2. If the user wants a stable URL, use `--slug`.',
|
|
252
|
-
'3. If the file already has `pagr-id` or `pagr-slug`, use plain `pagr upload <file>` unless the user asks for a new page.',
|
|
253
|
-
'4. If the user explicitly wants to replace an existing page, use:',
|
|
254
|
-
'',
|
|
255
|
-
'```bash',
|
|
256
|
-
'pagr upload <file> --update --slug <slug>',
|
|
257
|
-
'```',
|
|
258
|
-
'',
|
|
259
|
-
'5. Return the URL printed by the CLI.',
|
|
260
|
-
'6. In CI, capture `PAGR_URL`.',
|
|
261
|
-
].join('\n') + '\n';
|
|
262
|
-
const CLAUDE_SKILL_MD = SKILL_MD;
|
|
4
|
+
import { readConfig } from '../lib/config.js';
|
|
5
|
+
import { writeSkillFiles } from '../lib/skills.js';
|
|
263
6
|
export const initCommand = defineCommand({
|
|
264
7
|
meta: {
|
|
265
8
|
name: 'init',
|
|
@@ -281,22 +24,10 @@ export const initCommand = defineCommand({
|
|
|
281
24
|
},
|
|
282
25
|
run({ args }) {
|
|
283
26
|
const cwd = process.cwd();
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (!existsSync(claudeSkillsDir)) {
|
|
289
|
-
mkdirSync(claudeSkillsDir, { recursive: true });
|
|
290
|
-
}
|
|
291
|
-
writeFileSync(join(claudeSkillsDir, 'SKILL.md'), CLAUDE_SKILL_MD, 'utf-8');
|
|
292
|
-
console.log('Created .claude/skills/pagr/SKILL.md');
|
|
293
|
-
}
|
|
294
|
-
const agentsSkillsDir = join(cwd, '.agents', 'skills', 'pagr');
|
|
295
|
-
if (!existsSync(agentsSkillsDir)) {
|
|
296
|
-
mkdirSync(agentsSkillsDir, { recursive: true });
|
|
297
|
-
}
|
|
298
|
-
writeFileSync(join(agentsSkillsDir, 'SKILL.md'), SKILL_MD, 'utf-8');
|
|
299
|
-
console.log('Created .agents/skills/pagr/SKILL.md');
|
|
27
|
+
const cfg = readConfig();
|
|
28
|
+
const apiKey = cfg.apiKey;
|
|
29
|
+
writeSkillFiles(cwd, apiKey, args.claude);
|
|
30
|
+
console.log('Created workspace skill files.');
|
|
300
31
|
if (args.mcp) {
|
|
301
32
|
writeClaudeMcpSettings(cwd);
|
|
302
33
|
console.log('Updated .claude/settings.json with the Pagr MCP server');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe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CAAC,EAAE,CAAC;QAC3B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAA;IACjD,QAAQ,CAAC,UAAU,GAAG;QACpB,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;QAC9B,IAAI,EAAE;YACJ,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC;SAC1B;KACF,CAAA;IAED,aAAa,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,EAAE,CAAA;IAExC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAmB,CAAA;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,IAAI,CAAC,mBAAmB,YAAY,mDAAmD,CAAC,CAAA;QAChG,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { defineCommand, runMain } from 'citty';
|
|
3
4
|
import { uploadCommand } from './commands/upload.js';
|
|
4
5
|
import { configCommand } from './commands/config.js';
|
|
@@ -8,11 +9,20 @@ import { logoutCommand } from './commands/logout.js';
|
|
|
8
9
|
import { whoamiCommand } from './commands/whoami.js';
|
|
9
10
|
import { listCommand } from './commands/list.js';
|
|
10
11
|
import { removeCommand } from './commands/remove.js';
|
|
12
|
+
function readPackageVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
|
|
15
|
+
return pkg.version ?? '0.0.0';
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return '0.0.0';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
const main = defineCommand({
|
|
12
22
|
meta: {
|
|
13
23
|
name: 'pagr',
|
|
14
|
-
version:
|
|
15
|
-
description: '
|
|
24
|
+
version: readPackageVersion(),
|
|
25
|
+
description: 'Upload and manage HTML files from the command line. Visit getpagr.co for more information.',
|
|
16
26
|
},
|
|
17
27
|
subCommands: {
|
|
18
28
|
login: loginCommand,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,IAAI,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings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AAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/lib/skills.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,GAAI,SAAQ,MAAoB,KAAG,MA+Q/D,CAAA;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,GAAE,OAAc,GAAG,IAAI,CAqB/F"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export const getSkillTemplate = (apiKey = '{api_key}') => {
|
|
4
|
+
return [
|
|
5
|
+
'# Pagr CLI Skill',
|
|
6
|
+
'',
|
|
7
|
+
'Use this skill when the user wants to publish, update, list, delete, or manage HTML files with the Pagr CLI or through the remote MCP server.',
|
|
8
|
+
'',
|
|
9
|
+
'## When To Use This Skill',
|
|
10
|
+
'',
|
|
11
|
+
'- Publishing generated HTML reports, dashboards, documents, or plans.',
|
|
12
|
+
'- Updating existing published Pagr pages while keeping the same public URL.',
|
|
13
|
+
'- Creating shareable URLs for local HTML artifacts.',
|
|
14
|
+
'- Listing or deleting Pagr files from a user account.',
|
|
15
|
+
'- Setting up Pagr in a project for agent workflows.',
|
|
16
|
+
'- Publishing HTML artifacts from CI.',
|
|
17
|
+
'- Using the remote MCP server to publish HTML reports.',
|
|
18
|
+
'',
|
|
19
|
+
'## Core Rules',
|
|
20
|
+
'',
|
|
21
|
+
'- Use `pagr upload <file>` for HTML files.',
|
|
22
|
+
'- Never invent a Pagr URL. Always return the URL printed by the CLI.',
|
|
23
|
+
'- If a file contains `<meta name="pagr-id">` or `<meta name="pagr-slug">`, `pagr upload <file>` may update the existing page instead of creating a new one.',
|
|
24
|
+
'- Updates replace the current HTML in place. Pagr does not store previous HTML versions or rollback history.',
|
|
25
|
+
'- Prefer `PAGR_API_KEY` in CI instead of writing `~/.pagr/config.json`.',
|
|
26
|
+
'- Do not print or expose full API keys unless the user explicitly asks to configure authentication.',
|
|
27
|
+
'- If upload, update, list, or delete fails, surface the exact CLI/API error.',
|
|
28
|
+
'',
|
|
29
|
+
'## Remote MCP Server (SSE)',
|
|
30
|
+
'',
|
|
31
|
+
'You can connect to Pagr\'s remote Model Context Protocol (MCP) server over SSE (Server-Sent Events) to allow any MCP-compatible agent to publish files directly.',
|
|
32
|
+
'',
|
|
33
|
+
'The remote MCP server endpoint is:',
|
|
34
|
+
'```text',
|
|
35
|
+
`https://mcp.getpagr.co/mcp?PAGR_API_KEY=${apiKey}`,
|
|
36
|
+
'```',
|
|
37
|
+
'',
|
|
38
|
+
'When using an MCP-compatible client (like Claude.ai Web App Custom Connectors, Cursor IDE, or others), configure the Server URL pointing to the endpoint above. This allows the client to call tools like `upload_file` and publish pages seamlessly.',
|
|
39
|
+
'',
|
|
40
|
+
'## Installation',
|
|
41
|
+
'',
|
|
42
|
+
'```bash',
|
|
43
|
+
'npm install -g @getpagr/cli',
|
|
44
|
+
'```',
|
|
45
|
+
'',
|
|
46
|
+
'Pagr CLI requires Node.js 20 or newer. The installed command is `pagr`.',
|
|
47
|
+
'',
|
|
48
|
+
'## Authentication',
|
|
49
|
+
'',
|
|
50
|
+
'Browser login:',
|
|
51
|
+
'',
|
|
52
|
+
'```bash',
|
|
53
|
+
'pagr login',
|
|
54
|
+
'```',
|
|
55
|
+
'',
|
|
56
|
+
'`pagr login` starts a browser login flow, authenticates with Pagr, receives a CLI API key through a local callback, and saves it to `~/.pagr/config.json`.',
|
|
57
|
+
'',
|
|
58
|
+
'Manual login for SSH, headless, or locked-down environments:',
|
|
59
|
+
'',
|
|
60
|
+
'```bash',
|
|
61
|
+
'pagr login --manual',
|
|
62
|
+
'```',
|
|
63
|
+
'',
|
|
64
|
+
'Save a key without prompting:',
|
|
65
|
+
'',
|
|
66
|
+
'```bash',
|
|
67
|
+
'pagr login --key pagr_...',
|
|
68
|
+
'```',
|
|
69
|
+
'',
|
|
70
|
+
'Set a key directly in local config:',
|
|
71
|
+
'',
|
|
72
|
+
'```bash',
|
|
73
|
+
'pagr config set-key pagr_...',
|
|
74
|
+
'```',
|
|
75
|
+
'',
|
|
76
|
+
'API keys must start with `pagr_`.',
|
|
77
|
+
'',
|
|
78
|
+
'Config location:',
|
|
79
|
+
'',
|
|
80
|
+
'```text',
|
|
81
|
+
'~/.pagr/config.json',
|
|
82
|
+
'```',
|
|
83
|
+
'',
|
|
84
|
+
'Auth lookup order:',
|
|
85
|
+
'',
|
|
86
|
+
'1. `PAGR_API_KEY`',
|
|
87
|
+
'2. `~/.pagr/config.json`',
|
|
88
|
+
'3. Error if neither exists',
|
|
89
|
+
'',
|
|
90
|
+
'## Upload New HTML',
|
|
91
|
+
'',
|
|
92
|
+
'```bash',
|
|
93
|
+
'pagr upload report.html',
|
|
94
|
+
'```',
|
|
95
|
+
'',
|
|
96
|
+
'Behavior:',
|
|
97
|
+
'',
|
|
98
|
+
'- Reads the local HTML file as UTF-8.',
|
|
99
|
+
'- Uploads raw HTML to Pagr.',
|
|
100
|
+
'- Prints the public URL.',
|
|
101
|
+
'- Copies the URL to the clipboard when supported.',
|
|
102
|
+
'- When `CI` is set, also prints:',
|
|
103
|
+
'',
|
|
104
|
+
'```text',
|
|
105
|
+
'PAGR_SLUG=...',
|
|
106
|
+
'PAGR_URL=...',
|
|
107
|
+
'```',
|
|
108
|
+
'',
|
|
109
|
+
'## Upload With Title And Slug',
|
|
110
|
+
'',
|
|
111
|
+
'Set a page title:',
|
|
112
|
+
'',
|
|
113
|
+
'```bash',
|
|
114
|
+
'pagr upload report.html --title "Weekly report"',
|
|
115
|
+
'pagr upload report.html -t "Weekly report"',
|
|
116
|
+
'```',
|
|
117
|
+
'',
|
|
118
|
+
'Request a stable readable slug:',
|
|
119
|
+
'',
|
|
120
|
+
'```bash',
|
|
121
|
+
'pagr upload report.html --slug weekly-report',
|
|
122
|
+
'pagr upload report.html -s weekly-report',
|
|
123
|
+
'```',
|
|
124
|
+
'',
|
|
125
|
+
'Use both:',
|
|
126
|
+
'',
|
|
127
|
+
'```bash',
|
|
128
|
+
'pagr upload report.html --slug weekly-report --title "Weekly report"',
|
|
129
|
+
'```',
|
|
130
|
+
'',
|
|
131
|
+
'`--title` sends `X-Pagr-Title`. `--slug` requests a stable readable URL. Custom slugs can be plan-gated.',
|
|
132
|
+
'',
|
|
133
|
+
'## Update Existing Pages',
|
|
134
|
+
'',
|
|
135
|
+
'```bash',
|
|
136
|
+
'pagr upload report.html --update --slug weekly-report',
|
|
137
|
+
'pagr upload report.html -u -s weekly-report',
|
|
138
|
+
'```',
|
|
139
|
+
'',
|
|
140
|
+
'Behavior:',
|
|
141
|
+
'',
|
|
142
|
+
'- Checks slug ownership first.',
|
|
143
|
+
'- Fails if the slug is missing or not owned by the authenticated user.',
|
|
144
|
+
'- Sends replacement HTML to the existing page.',
|
|
145
|
+
'- Keeps the public URL stable.',
|
|
146
|
+
'- Replaces current content in place; this is not versioning.',
|
|
147
|
+
'',
|
|
148
|
+
'## Auto-Update With Meta Tags',
|
|
149
|
+
'',
|
|
150
|
+
'```html',
|
|
151
|
+
'<meta name="pagr-id" content="...">',
|
|
152
|
+
'<meta name="pagr-slug" content="weekly-report">',
|
|
153
|
+
'```',
|
|
154
|
+
'',
|
|
155
|
+
'Update priority:',
|
|
156
|
+
'',
|
|
157
|
+
'1. `pagr-id` updates by stable document ID.',
|
|
158
|
+
'2. `pagr-slug` updates by slug.',
|
|
159
|
+
'3. `--update --slug` forces update by slug.',
|
|
160
|
+
'4. Otherwise a new file is uploaded.',
|
|
161
|
+
'',
|
|
162
|
+
'Inject Pagr metadata into the source file:',
|
|
163
|
+
'',
|
|
164
|
+
'```bash',
|
|
165
|
+
'pagr upload report.html --inject',
|
|
166
|
+
'```',
|
|
167
|
+
'',
|
|
168
|
+
'`--inject` writes Pagr metadata into the local HTML source after upload. If a new upload has no `pagr-slug`, the CLI auto-injects metadata for future updates. This modifies the local source HTML file.',
|
|
169
|
+
'',
|
|
170
|
+
'## List Files',
|
|
171
|
+
'',
|
|
172
|
+
'```bash',
|
|
173
|
+
'pagr ls',
|
|
174
|
+
'pagr ls --limit 20',
|
|
175
|
+
'```',
|
|
176
|
+
'',
|
|
177
|
+
'Default limit is 50. Output includes slug, views, plan, title, and URL. If no files exist, the CLI prints `No files found.`',
|
|
178
|
+
'',
|
|
179
|
+
'## Delete Files',
|
|
180
|
+
'',
|
|
181
|
+
'```bash',
|
|
182
|
+
'pagr rm weekly-report',
|
|
183
|
+
'pagr rm weekly-report --yes',
|
|
184
|
+
'pagr rm weekly-report -y',
|
|
185
|
+
'```',
|
|
186
|
+
'',
|
|
187
|
+
'Without `--yes`, the CLI asks for confirmation and accepts `y` or `yes`. Delete is not reversible.',
|
|
188
|
+
'',
|
|
189
|
+
'## Config Commands',
|
|
190
|
+
'',
|
|
191
|
+
'```bash',
|
|
192
|
+
'pagr config show',
|
|
193
|
+
'pagr config set-key pagr_...',
|
|
194
|
+
'pagr config set-url https://pagr.link',
|
|
195
|
+
'```',
|
|
196
|
+
'',
|
|
197
|
+
'`pagr config show` masks the API key. `set-key` requires a `pagr_` prefix. `set-url` overrides the Worker API URL in local config. Environment variables override local config.',
|
|
198
|
+
'',
|
|
199
|
+
'## Init Command',
|
|
200
|
+
'',
|
|
201
|
+
'```bash',
|
|
202
|
+
'pagr init',
|
|
203
|
+
'pagr init --no-claude',
|
|
204
|
+
'pagr init --no-mcp',
|
|
205
|
+
'```',
|
|
206
|
+
'',
|
|
207
|
+
'`pagr init` writes:',
|
|
208
|
+
'',
|
|
209
|
+
'- `SKILL.md`',
|
|
210
|
+
'- `.claude/skills/pagr/SKILL.md` unless `--no-claude`',
|
|
211
|
+
'- `.agents/skills/pagr/SKILL.md`',
|
|
212
|
+
'- `.claude/settings.json` MCP server config unless `--no-mcp`',
|
|
213
|
+
'',
|
|
214
|
+
'MCP config:',
|
|
215
|
+
'',
|
|
216
|
+
'```json',
|
|
217
|
+
'{',
|
|
218
|
+
' "mcpServers": {',
|
|
219
|
+
' "pagr": {',
|
|
220
|
+
' "command": "npx",',
|
|
221
|
+
' "args": ["-y", "@pagr/mcp"]',
|
|
222
|
+
' }',
|
|
223
|
+
' }',
|
|
224
|
+
'}',
|
|
225
|
+
'```',
|
|
226
|
+
'',
|
|
227
|
+
'## CI Usage',
|
|
228
|
+
'',
|
|
229
|
+
'Use `PAGR_API_KEY` in CI. Do not write `~/.pagr/config.json` in CI.',
|
|
230
|
+
'',
|
|
231
|
+
'```yaml',
|
|
232
|
+
'- name: Publish HTML report',
|
|
233
|
+
' run: pagr upload output/report.html --title "Nightly report"',
|
|
234
|
+
' env:',
|
|
235
|
+
' PAGR_API_KEY: ${{ secrets.PAGR_API_KEY }}',
|
|
236
|
+
'```',
|
|
237
|
+
'',
|
|
238
|
+
'When `CI` is set, use the machine-readable `PAGR_SLUG` and `PAGR_URL` output lines.',
|
|
239
|
+
'',
|
|
240
|
+
'## Environment Variables',
|
|
241
|
+
'',
|
|
242
|
+
'- `PAGR_API_KEY`: overrides the locally saved key.',
|
|
243
|
+
'- `PAGR_WORKER_URL`: overrides the Worker API URL. Default is `https://pagr.link`.',
|
|
244
|
+
'- `PAGR_APP_URL`: overrides the app URL used by `pagr login`. Default is `https://app.getpagr.co`.',
|
|
245
|
+
'- `CI`: makes upload print machine-readable `PAGR_SLUG` and `PAGR_URL`.',
|
|
246
|
+
'',
|
|
247
|
+
'## Error Handling',
|
|
248
|
+
'',
|
|
249
|
+
'Common failures:',
|
|
250
|
+
'',
|
|
251
|
+
'- Missing API key: run `pagr login`, run `pagr login --manual`, or set `PAGR_API_KEY`.',
|
|
252
|
+
'- Invalid API key format: keys must start with `pagr_`.',
|
|
253
|
+
'- Cannot read file: confirm the path exists and points to an HTML file.',
|
|
254
|
+
'- Slug not found or not owned during update: upload without `--update` or use the correct slug.',
|
|
255
|
+
'- Upload/update/list/delete API errors: surface the exact CLI error.',
|
|
256
|
+
'- Clipboard failure does not fail upload; the URL is still printed.',
|
|
257
|
+
'',
|
|
258
|
+
'If browser login fails, use `pagr login --manual`. If upload fails due to plan or file limit, surface the CLI error and tell the user to check account plan and file size.',
|
|
259
|
+
'',
|
|
260
|
+
'## Agent Workflow',
|
|
261
|
+
'',
|
|
262
|
+
'1. Confirm the target file exists and is HTML.',
|
|
263
|
+
'2. If the user wants a stable URL, use `--slug`.',
|
|
264
|
+
'3. If the file already has `pagr-id` or `pagr-slug`, use plain `pagr upload <file>` unless the user asks for a new page.',
|
|
265
|
+
'4. If the user explicitly wants to replace an existing page, use:',
|
|
266
|
+
'',
|
|
267
|
+
'```bash',
|
|
268
|
+
'pagr upload <file> --update --slug <slug>',
|
|
269
|
+
'```',
|
|
270
|
+
'',
|
|
271
|
+
'5. Return the URL printed by the CLI.',
|
|
272
|
+
'6. In CI, capture `PAGR_URL`.',
|
|
273
|
+
].join('\n') + '\n';
|
|
274
|
+
};
|
|
275
|
+
export function writeSkillFiles(cwd, apiKey, writeClaude = true) {
|
|
276
|
+
const content = getSkillTemplate(apiKey);
|
|
277
|
+
// 1. Write root SKILL.md
|
|
278
|
+
writeFileSync(join(cwd, 'SKILL.md'), content, 'utf-8');
|
|
279
|
+
// 2. Write .claude/skills/pagr/SKILL.md
|
|
280
|
+
if (writeClaude) {
|
|
281
|
+
const claudeSkillsDir = join(cwd, '.claude', 'skills', 'pagr');
|
|
282
|
+
if (!existsSync(claudeSkillsDir)) {
|
|
283
|
+
mkdirSync(claudeSkillsDir, { recursive: true });
|
|
284
|
+
}
|
|
285
|
+
writeFileSync(join(claudeSkillsDir, 'SKILL.md'), content, 'utf-8');
|
|
286
|
+
}
|
|
287
|
+
// 3. Write .agents/skills/pagr/SKILL.md
|
|
288
|
+
const agentsSkillsDir = join(cwd, '.agents', 'skills', 'pagr');
|
|
289
|
+
if (!existsSync(agentsSkillsDir)) {
|
|
290
|
+
mkdirSync(agentsSkillsDir, { recursive: true });
|
|
291
|
+
}
|
|
292
|
+
writeFileSync(join(agentsSkillsDir, 'SKILL.md'), content, 'utf-8');
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/lib/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAiB,WAAW,EAAU,EAAE;IACvE,OAAO;QACL,kBAAkB;QAClB,EAAE;QACF,+IAA+I;QAC/I,EAAE;QACF,2BAA2B;QAC3B,EAAE;QACF,uEAAuE;QACvE,6EAA6E;QAC7E,qDAAqD;QACrD,uDAAuD;QACvD,qDAAqD;QACrD,sCAAsC;QACtC,wDAAwD;QACxD,EAAE;QACF,eAAe;QACf,EAAE;QACF,4CAA4C;QAC5C,sEAAsE;QACtE,6JAA6J;QAC7J,8GAA8G;QAC9G,yEAAyE;QACzE,qGAAqG;QACrG,8EAA8E;QAC9E,EAAE;QACF,4BAA4B;QAC5B,EAAE;QACF,kKAAkK;QAClK,EAAE;QACF,oCAAoC;QACpC,SAAS;QACT,2CAA2C,MAAM,EAAE;QACnD,KAAK;QACL,EAAE;QACF,uPAAuP;QACvP,EAAE;QACF,iBAAiB;QACjB,EAAE;QACF,SAAS;QACT,6BAA6B;QAC7B,KAAK;QACL,EAAE;QACF,yEAAyE;QACzE,EAAE;QACF,mBAAmB;QACnB,EAAE;QACF,gBAAgB;QAChB,EAAE;QACF,SAAS;QACT,YAAY;QACZ,KAAK;QACL,EAAE;QACF,4JAA4J;QAC5J,EAAE;QACF,8DAA8D;QAC9D,EAAE;QACF,SAAS;QACT,qBAAqB;QACrB,KAAK;QACL,EAAE;QACF,+BAA+B;QAC/B,EAAE;QACF,SAAS;QACT,2BA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