@p11-core/cli 0.0.1

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.
@@ -0,0 +1,103 @@
1
+ # P11 Components
2
+
3
+ P11 documents are React modules that export a default component and import document-safe components from `@p11-core/components`.
4
+
5
+ ## Minimal Document
6
+
7
+ ```tsx
8
+ import { Document, Heading, Section, Text } from "@p11-core/components";
9
+
10
+ export default function Page() {
11
+ return (
12
+ <Document>
13
+ <Section>
14
+ <Heading level={1}>Title</Heading>
15
+ <Text>Write document content here.</Text>
16
+ </Section>
17
+ </Document>
18
+ );
19
+ }
20
+ ```
21
+
22
+ ## Supported Exports
23
+
24
+ ```txt
25
+ Document
26
+ Page
27
+ Section
28
+ Heading
29
+ Text
30
+ List
31
+ ListItem
32
+ DefinitionList
33
+ DefinitionTerm
34
+ DefinitionDescription
35
+ Quote
36
+ Strikethrough
37
+ CodeBlock
38
+ Table
39
+ TableHeader
40
+ TableBody
41
+ TableRow
42
+ TableHead
43
+ TableCell
44
+ Figure
45
+ Caption
46
+ Divider
47
+ PageBreak
48
+ code
49
+ ```
50
+
51
+ `Document` accepts `mode?: "page" | "pageless"`. Pageless is the default screen presentation. Page mode shows letter-sized page boxes.
52
+
53
+ Use `<PageBreak />` to force a new page.
54
+
55
+ ## Code Blocks
56
+
57
+ ```tsx
58
+ import { CodeBlock, Document, Section, code } from "@p11-core/components";
59
+
60
+ export default function Page() {
61
+ return (
62
+ <Document>
63
+ <Section>
64
+ <CodeBlock language="typescript">
65
+ {code`
66
+ const ok = true;
67
+ `}
68
+ </CodeBlock>
69
+ </Section>
70
+ </Document>
71
+ );
72
+ }
73
+ ```
74
+
75
+ Supported languages include TypeScript, JavaScript, Python, Rust, HTML/XML, CSS, JSON, YAML, and Bash.
76
+
77
+ ## Validation
78
+
79
+ `p11 publish` validates the document before build and upload.
80
+
81
+ Do not import or render app/control components such as:
82
+
83
+ ```txt
84
+ Alert
85
+ Badge
86
+ Button
87
+ Card
88
+ Separator
89
+ Stack
90
+ Tabs
91
+ Accordion
92
+ ```
93
+
94
+ Do not use native interactive tags inside authored content:
95
+
96
+ ```txt
97
+ button
98
+ input
99
+ select
100
+ textarea
101
+ form
102
+ nav
103
+ ```
package/docs/index.md ADDED
@@ -0,0 +1,31 @@
1
+ # P11 CLI Docs
2
+
3
+ P11 publishes reviewable, public-but-unlisted document pages from React document modules.
4
+
5
+ ## Common Commands
6
+
7
+ ```bash
8
+ p11 publish <page.tsx>
9
+ p11 publish <page.tsx> --edit-url <editUrl>
10
+ p11 history
11
+ p11 comments <readUrl|editUrl|readId|editId>
12
+ ```
13
+
14
+ Add `--json` when scripting or when exact structured fields are needed.
15
+
16
+ ## Docs Topics
17
+
18
+ ```bash
19
+ p11 docs components
20
+ p11 docs publishing
21
+ ```
22
+
23
+ ## Examples
24
+
25
+ ```bash
26
+ p11 example
27
+ p11 example all-components
28
+ p11 example all-components --output ./all-components.tsx
29
+ ```
30
+
31
+ Use `p11 publish --help`, `p11 comments --help`, and `p11 history --help` for command-specific flags.
@@ -0,0 +1,33 @@
1
+ # P11 Publishing
2
+
3
+ Publish a document module:
4
+
5
+ ```bash
6
+ p11 publish ./page.tsx
7
+ ```
8
+
9
+ Update an existing document with an edit URL or edit id:
10
+
11
+ ```bash
12
+ p11 publish ./page.tsx --edit-url <editUrl>
13
+ ```
14
+
15
+ Fetch recent local publish history:
16
+
17
+ ```bash
18
+ p11 history
19
+ ```
20
+
21
+ Fetch comments:
22
+
23
+ ```bash
24
+ p11 comments <readUrl|editUrl|readId|editId>
25
+ p11 comments <readUrl|editUrl|readId|editId> --version 1
26
+ p11 comments <readUrl|editUrl|readId|editId> --output comments.json
27
+ ```
28
+
29
+ Add `--json` when scripting or when exact structured fields are needed.
30
+
31
+ `P11_API_URL` overrides the default API URL. `--api-url <url>` can override it per command.
32
+
33
+ Edit URLs are bearer credentials for updating a document. Keep them private.
@@ -0,0 +1,333 @@
1
+ import {
2
+ Caption,
3
+ CodeBlock,
4
+ DefinitionDescription,
5
+ DefinitionList,
6
+ DefinitionTerm,
7
+ Divider,
8
+ Document,
9
+ Figure,
10
+ Heading,
11
+ List,
12
+ ListItem,
13
+ Page,
14
+ PageBreak,
15
+ Quote,
16
+ Section,
17
+ Strikethrough,
18
+ Table,
19
+ TableBody,
20
+ TableCell,
21
+ TableHead,
22
+ TableHeader,
23
+ TableRow,
24
+ Text,
25
+ code,
26
+ } from "@p11-core/components";
27
+
28
+ const figureSrc =
29
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 720 240'%3E%3Crect width='720' height='240' fill='%23f8fafc'/%3E%3Cpath d='M80 172h560' stroke='%23d4d4d8' stroke-width='2'/%3E%3Ccircle cx='160' cy='132' r='42' fill='%2318181b'/%3E%3Crect x='260' y='92' width='120' height='80' rx='8' fill='%2352525b'/%3E%3Cpath d='M460 172 540 72l80 100z' fill='%2371717a'/%3E%3Ctext x='80' y='52' font-family='Inter, Arial' font-size='28' font-weight='700' fill='%2318181b'%3EP11 document figure%3C/text%3E%3C/svg%3E";
30
+
31
+ export default function All() {
32
+ return (
33
+ <Document mode="page">
34
+ <Page>
35
+ <Section>
36
+ <Heading level={1}>All Components Showcase</Heading>
37
+ <Text>
38
+ This example replaces the original decision brief with a compact
39
+ tour of every document-safe component exported by{" "}
40
+ <code>@p11-core/components</code>. It also includes safe inline markup
41
+ such as <strong>strong text</strong>, <em>emphasis</em>,{" "}
42
+ <code>inline code</code>,{" "}
43
+ <Strikethrough>obsolete wording</Strikethrough>, and a{" "}
44
+ <a href="https://example.com">print-safe link</a>.
45
+ </Text>
46
+ <Quote>
47
+ The page is intentionally broad: authors can use it to inspect
48
+ screen layout, print pagination, source-line anchors, tables,
49
+ figures, and syntax highlighting in one published document.
50
+ </Quote>
51
+ </Section>
52
+
53
+ <Section>
54
+ <Heading>1. Text Hierarchy</Heading>
55
+ <Text>
56
+ The heading component supports levels one through six while keeping
57
+ the document printable and commentable.
58
+ </Text>
59
+ <Heading level={2}>Level Two Heading</Heading>
60
+ <Text>
61
+ Level two is the default heading level and works well for document
62
+ sections.
63
+ </Text>
64
+ <Heading level={3}>Level Three Heading</Heading>
65
+ <Text>
66
+ Level three is useful for subsections inside a larger topic.
67
+ </Text>
68
+ <Heading level={4}>Level Four Heading</Heading>
69
+ <Heading level={5}>Level Five Heading</Heading>
70
+ <Heading level={6}>Level Six Heading</Heading>
71
+ </Section>
72
+
73
+ <Section>
74
+ <Heading>2. Lists</Heading>
75
+ <Text>
76
+ Unordered lists work for parallel facts and short capabilities.
77
+ </Text>
78
+ <List>
79
+ <ListItem>Publish static React-authored documents.</ListItem>
80
+ <ListItem>Allow anonymous comments on text selections.</ListItem>
81
+ <ListItem>
82
+ Export comments with source file and line anchors.
83
+ </ListItem>
84
+ </List>
85
+ <Text>Ordered lists work for procedural steps.</Text>
86
+ <List ordered>
87
+ <ListItem>Author a document module.</ListItem>
88
+ <ListItem>Publish it with the CLI.</ListItem>
89
+ <ListItem>
90
+ Review the screen view and browser print output.
91
+ </ListItem>
92
+ </List>
93
+ </Section>
94
+
95
+ <Divider />
96
+
97
+ <Section>
98
+ <Heading>3. Definition Lists</Heading>
99
+ <Text>
100
+ Definition lists work for compact glossaries and named concepts.
101
+ </Text>
102
+ <DefinitionList>
103
+ <DefinitionTerm>Page</DefinitionTerm>
104
+ <DefinitionDescription>
105
+ A printable document surface with fixed letter-sized dimensions.
106
+ </DefinitionDescription>
107
+ <DefinitionTerm>Comment anchor</DefinitionTerm>
108
+ <DefinitionDescription>
109
+ Source metadata attached to document text so reviewer feedback can
110
+ point back to authored content.
111
+ </DefinitionDescription>
112
+ </DefinitionList>
113
+ </Section>
114
+
115
+ <Section>
116
+ <Heading>4. Tables</Heading>
117
+ <Table>
118
+ <TableHeader>
119
+ <TableRow>
120
+ <TableHead>Component</TableHead>
121
+ <TableHead>Rendered Tag</TableHead>
122
+ <TableHead>Purpose</TableHead>
123
+ </TableRow>
124
+ </TableHeader>
125
+ <TableBody>
126
+ <TableRow>
127
+ <TableCell>TableHeader</TableCell>
128
+ <TableCell>thead</TableCell>
129
+ <TableCell>
130
+ Groups the header rows for print-safe tables.
131
+ </TableCell>
132
+ </TableRow>
133
+ <TableRow>
134
+ <TableCell>TableBody</TableCell>
135
+ <TableCell>tbody</TableCell>
136
+ <TableCell>Groups the body rows and cells.</TableCell>
137
+ </TableRow>
138
+ <TableRow>
139
+ <TableCell>TableHead and TableCell</TableCell>
140
+ <TableCell>th and td</TableCell>
141
+ <TableCell>Provide commentable table content.</TableCell>
142
+ </TableRow>
143
+ </TableBody>
144
+ </Table>
145
+ </Section>
146
+
147
+ <Section>
148
+ <Heading>5. Figures</Heading>
149
+ <Figure>
150
+ <img
151
+ src={figureSrc}
152
+ alt="Abstract P11 document figure with simple geometric marks"
153
+ />
154
+ <Caption>
155
+ Figure 1. Figure and Caption components keep visual evidence with
156
+ its explanatory text.
157
+ </Caption>
158
+ </Figure>
159
+ </Section>
160
+ </Page>
161
+
162
+ <PageBreak />
163
+
164
+ <Page>
165
+ <Section>
166
+ <Heading>6. TypeScript</Heading>
167
+ <CodeBlock language="typescript">
168
+ {code`
169
+ type PublishOptions = {
170
+ input: string;
171
+ comments?: boolean;
172
+ };
173
+
174
+ export async function publish(options: PublishOptions) {
175
+ const response = await fetch("/api/pages", {
176
+ method: "POST",
177
+ body: JSON.stringify(options)
178
+ });
179
+
180
+ return response.json() as Promise<{ docId: string; readUrl: string; editUrl: string; version: number }>;
181
+ }
182
+ `}
183
+ </CodeBlock>
184
+ </Section>
185
+
186
+ <Section>
187
+ <Heading>7. JavaScript</Heading>
188
+ <CodeBlock language="javascript">
189
+ {code`
190
+ const pages = new Map();
191
+
192
+ export function rememberPage(page) {
193
+ pages.set(page.id, {
194
+ ...page,
195
+ updatedAt: new Date().toISOString()
196
+ });
197
+ }
198
+ `}
199
+ </CodeBlock>
200
+ </Section>
201
+
202
+ <Section>
203
+ <Heading>8. Python</Heading>
204
+ <CodeBlock language="python">
205
+ {code`
206
+ from dataclasses import dataclass
207
+
208
+ @dataclass
209
+ class Comment:
210
+ author: str
211
+ body: str
212
+
213
+ def preview(comment: Comment) -> str:
214
+ return f"{comment.author}: {comment.body[:48]}"
215
+ `}
216
+ </CodeBlock>
217
+ </Section>
218
+
219
+ <Section>
220
+ <Heading>9. Rust</Heading>
221
+ <CodeBlock language="rust">
222
+ {code`
223
+ #[derive(Debug)]
224
+ struct Page<'a> {
225
+ id: &'a str,
226
+ comments_enabled: bool,
227
+ }
228
+
229
+ fn describe(page: &Page) -> String {
230
+ format!("{} comments={}", page.id, page.comments_enabled)
231
+ }
232
+ `}
233
+ </CodeBlock>
234
+ </Section>
235
+
236
+ <Section>
237
+ <Heading>10. HTML And XML</Heading>
238
+ <CodeBlock language="html">
239
+ {code`
240
+ <article class="p11-page">
241
+ <h1>All Components Showcase</h1>
242
+ <p data-p11-block>Reviewers can comment on document text.</p>
243
+ </article>
244
+ `}
245
+ </CodeBlock>
246
+ </Section>
247
+ </Page>
248
+
249
+ <PageBreak />
250
+
251
+ <Page>
252
+ <Section>
253
+ <Heading>11. CSS</Heading>
254
+ <CodeBlock language="css">
255
+ {code`
256
+ .p11-page {
257
+ color: #27272a;
258
+ font-family: var(--p11-font-body);
259
+ line-height: 1.62;
260
+ }
261
+
262
+ .p11-code-block code.hljs {
263
+ background: transparent;
264
+ }
265
+ `}
266
+ </CodeBlock>
267
+ </Section>
268
+
269
+ <Section>
270
+ <Heading>12. JSON</Heading>
271
+ <CodeBlock language="json">
272
+ {code`
273
+ {
274
+ "docId": "all-components",
275
+ "version": 2,
276
+ "comments": true,
277
+ "languages": ["typescript", "javascript", "python", "rust", "html", "css", "json", "yaml", "bash"]
278
+ }
279
+ `}
280
+ </CodeBlock>
281
+ </Section>
282
+
283
+ <Section>
284
+ <Heading>13. YAML</Heading>
285
+ <CodeBlock language="yaml">
286
+ {code`
287
+ document:
288
+ id: all-components
289
+ version: 2
290
+ comments: true
291
+ retentionDays: 7
292
+ languages:
293
+ - typescript
294
+ - javascript
295
+ - python
296
+ - rust
297
+ - html
298
+ - css
299
+ - json
300
+ - yaml
301
+ - bash
302
+ `}
303
+ </CodeBlock>
304
+ </Section>
305
+
306
+ <Section>
307
+ <Heading>14. Bash</Heading>
308
+ <CodeBlock language="bash">
309
+ {code`
310
+ p11 publish ./all-components.tsx
311
+ p11 comments <readUrl> --version 1
312
+ `}
313
+ </CodeBlock>
314
+ </Section>
315
+
316
+ <Divider />
317
+
318
+ <Section>
319
+ <Heading>15. Complete Export Surface</Heading>
320
+ <Text>The all example includes every supported component tag:</Text>
321
+ <CodeBlock language="typescript">
322
+ {code`
323
+ Document, Page, Section, Heading, Text, List, ListItem, Quote, CodeBlock,
324
+ DefinitionList, DefinitionTerm, DefinitionDescription, Strikethrough,
325
+ Table, TableHeader, TableBody, TableRow, TableHead, TableCell, Figure,
326
+ Caption, Divider, PageBreak
327
+ `}
328
+ </CodeBlock>
329
+ </Section>
330
+ </Page>
331
+ </Document>
332
+ );
333
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@p11-core/cli",
3
+ "version": "0.0.1",
4
+ "license": "UNLICENSED",
5
+ "type": "module",
6
+ "bin": {
7
+ "p11": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "docs",
12
+ "examples"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "prepack": "npm run build",
17
+ "test": "npm run build && node --test test/validation.test.mjs",
18
+ "typecheck": "tsgo --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@babel/generator": "^7.27.1",
22
+ "@babel/parser": "^7.27.2",
23
+ "@babel/traverse": "^7.27.1",
24
+ "@babel/types": "^7.27.1",
25
+ "@p11-core/components": "0.0.1",
26
+ "@recogito/text-annotator": "^4.0.0",
27
+ "@tailwindcss/vite": "^4.3.0",
28
+ "@vitejs/plugin-react": "^6.0.1",
29
+ "fflate": "^0.8.2",
30
+ "react": "^19.0.0",
31
+ "react-dom": "^19.0.0",
32
+ "semver": "^7.8.0",
33
+ "tailwindcss": "^4.3.0",
34
+ "vite": "^8.0.12"
35
+ },
36
+ "devDependencies": {
37
+ "@types/babel__traverse": "^7.28.0",
38
+ "@types/node": "^22.15.0",
39
+ "@types/semver": "^7.7.1",
40
+ "commander": "^14.0.3",
41
+ "dotenv": "^17.4.2",
42
+ "tsup": "^8.5.1",
43
+ "typescript": "^6.0.3"
44
+ }
45
+ }