sfora-cli 0.10.0 → 0.11.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.
- package/README.md +139 -0
- package/dist/SforaFs.js +8 -6
- package/dist/api-client.d.ts +243 -4
- package/dist/api-client.js +248 -20
- package/dist/block-commands.d.ts +84 -0
- package/dist/block-commands.js +155 -0
- package/dist/cli.js +317 -26
- package/dist/format/blockSplice.d.ts +135 -0
- package/dist/format/blockSplice.js +330 -0
- package/dist/format/blocks/dropClosure.d.ts +10 -1
- package/dist/format/blocks/dropClosure.js +11 -1
- package/dist/format/callout.d.ts +69 -7
- package/dist/format/callout.js +112 -15
- package/dist/format/checklist.js +11 -4
- package/dist/format/formatAxes.d.ts +228 -0
- package/dist/format/formatAxes.js +454 -0
- package/dist/format/index.d.ts +1 -0
- package/dist/format/index.js +4 -0
- package/dist/format/lineGeometry.d.ts +34 -4
- package/dist/format/lineGeometry.js +140 -40
- package/dist/format/lint/appliesTo.d.ts +92 -0
- package/dist/format/lint/appliesTo.js +369 -0
- package/dist/format/lint/config.d.ts +106 -0
- package/dist/format/lint/config.js +205 -0
- package/dist/format/lint/fixAll.d.ts +62 -0
- package/dist/format/lint/fixAll.js +107 -0
- package/dist/format/lint/frontmatterSchema.d.ts +181 -0
- package/dist/format/lint/frontmatterSchema.js +660 -0
- package/dist/format/lint/index.d.ts +34 -5
- package/dist/format/lint/index.js +34 -5
- package/dist/format/lint/lintSource.d.ts +27 -7
- package/dist/format/lint/lintSource.js +67 -33
- package/dist/format/lint/rules/frontmatter-schema.d.ts +2 -0
- package/dist/format/lint/rules/frontmatter-schema.js +92 -0
- package/dist/format/lint/rules/index.d.ts +2 -1
- package/dist/format/lint/rules/index.js +7 -1
- package/dist/format/lint/rules/malformed-callout.js +25 -16
- package/dist/format/lint/rules/malformed-checklist.js +8 -3
- package/dist/format/lint/rules/malformed-frontmatter.js +6 -1
- package/dist/format/lint/severity.d.ts +15 -0
- package/dist/format/lint/severity.js +50 -0
- package/dist/format/lint/textEdits.d.ts +86 -0
- package/dist/format/lint/textEdits.js +162 -0
- package/dist/format/lint/types.d.ts +44 -8
- package/dist/format/markdown/slug.d.ts +28 -0
- package/dist/format/markdown/slug.js +63 -0
- package/dist/format/plaintext.js +13 -3
- package/dist/format/sheetCellSpans.d.ts +95 -0
- package/dist/format/sheetCellSpans.js +223 -0
- package/dist/format/sheetSelection.d.ts +136 -0
- package/dist/format/sheetSelection.js +282 -0
- package/dist/format/textStats.d.ts +23 -0
- package/dist/format/textStats.js +80 -0
- package/dist/format/wikiLinks.d.ts +60 -1
- package/dist/format/wikiLinks.js +195 -9
- package/dist/index.d.ts +26 -1
- package/dist/index.js +20 -3
- package/dist/opener.d.ts +23 -0
- package/dist/opener.js +26 -0
- package/dist/render.d.ts +132 -0
- package/dist/render.js +208 -0
- package/dist/shell-commands.d.ts +34 -0
- package/dist/shell-commands.js +108 -0
- package/dist/watch.d.ts +79 -0
- package/dist/watch.js +113 -0
- package/dist/web-url.d.ts +39 -0
- package/dist/web-url.js +63 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a thing lives on the web — read off the server's answer, never built.
|
|
3
|
+
*
|
|
4
|
+
* Card #335. The CLI holds NO route knowledge: it does not know that a document
|
|
5
|
+
* lives at `/org/<slug>/notes/<id>` or that a card opens as `?detail=card:<id>`,
|
|
6
|
+
* and it does not know the deployment's web origin. It asks for a path over
|
|
7
|
+
* `/v1/fs` and prints the link the server put on the answer. That is the whole
|
|
8
|
+
* contract, and it is why `sfora url` keeps working when the app's routes move.
|
|
9
|
+
*
|
|
10
|
+
* The server states it in one of two places, because fs responses come in two
|
|
11
|
+
* shapes:
|
|
12
|
+
*
|
|
13
|
+
* • a **markdown read** answers with the document's bytes, so the link rides
|
|
14
|
+
* in the `X-Sfora-Url` response header — putting it in the file would
|
|
15
|
+
* change the canonical bytes every block id is computed over;
|
|
16
|
+
* • a **JSON response** (a listing, a `?view=`, a write result) carries a
|
|
17
|
+
* top-level `url` field.
|
|
18
|
+
*
|
|
19
|
+
* Both are read here so no caller has to care which door it opened.
|
|
20
|
+
*/
|
|
21
|
+
/** The response header a markdown read carries its page link in. */
|
|
22
|
+
export declare const WEB_URL_HEADER = "x-sfora-url";
|
|
23
|
+
/**
|
|
24
|
+
* The web URL a response names, or null when it names none.
|
|
25
|
+
*
|
|
26
|
+
* `body` is the response text when the caller already has it; without it only
|
|
27
|
+
* the header is consulted. Passing a body that is not JSON is fine — a
|
|
28
|
+
* markdown read hands its own bytes in and the parse simply fails.
|
|
29
|
+
*/
|
|
30
|
+
export declare function webUrlFromResponse(headers: {
|
|
31
|
+
get(name: string): string | null;
|
|
32
|
+
}, body?: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* An fs path (`/projects/acme/posts/x.md`) as a `/v1/fs` request path.
|
|
35
|
+
*
|
|
36
|
+
* Each segment is encoded on its own so a filename with a space or a `#`
|
|
37
|
+
* survives, and the separators do not.
|
|
38
|
+
*/
|
|
39
|
+
export declare function fsRequestPath(path: string): string;
|
package/dist/web-url.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a thing lives on the web — read off the server's answer, never built.
|
|
3
|
+
*
|
|
4
|
+
* Card #335. The CLI holds NO route knowledge: it does not know that a document
|
|
5
|
+
* lives at `/org/<slug>/notes/<id>` or that a card opens as `?detail=card:<id>`,
|
|
6
|
+
* and it does not know the deployment's web origin. It asks for a path over
|
|
7
|
+
* `/v1/fs` and prints the link the server put on the answer. That is the whole
|
|
8
|
+
* contract, and it is why `sfora url` keeps working when the app's routes move.
|
|
9
|
+
*
|
|
10
|
+
* The server states it in one of two places, because fs responses come in two
|
|
11
|
+
* shapes:
|
|
12
|
+
*
|
|
13
|
+
* • a **markdown read** answers with the document's bytes, so the link rides
|
|
14
|
+
* in the `X-Sfora-Url` response header — putting it in the file would
|
|
15
|
+
* change the canonical bytes every block id is computed over;
|
|
16
|
+
* • a **JSON response** (a listing, a `?view=`, a write result) carries a
|
|
17
|
+
* top-level `url` field.
|
|
18
|
+
*
|
|
19
|
+
* Both are read here so no caller has to care which door it opened.
|
|
20
|
+
*/
|
|
21
|
+
/** The response header a markdown read carries its page link in. */
|
|
22
|
+
export const WEB_URL_HEADER = "x-sfora-url";
|
|
23
|
+
/** An absolute `http(s)` URL, or null. Anything else is not a link we print. */
|
|
24
|
+
function absolute(value) {
|
|
25
|
+
return typeof value === "string" && /^https?:\/\//.test(value) ? value : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The web URL a response names, or null when it names none.
|
|
29
|
+
*
|
|
30
|
+
* `body` is the response text when the caller already has it; without it only
|
|
31
|
+
* the header is consulted. Passing a body that is not JSON is fine — a
|
|
32
|
+
* markdown read hands its own bytes in and the parse simply fails.
|
|
33
|
+
*/
|
|
34
|
+
export function webUrlFromResponse(headers, body) {
|
|
35
|
+
const fromHeader = absolute(headers.get(WEB_URL_HEADER));
|
|
36
|
+
if (fromHeader)
|
|
37
|
+
return fromHeader;
|
|
38
|
+
if (!body)
|
|
39
|
+
return null;
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(body);
|
|
42
|
+
if (parsed && typeof parsed === "object") {
|
|
43
|
+
return absolute(parsed.url);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Not JSON — a markdown body, which says nothing about its page.
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An fs path (`/projects/acme/posts/x.md`) as a `/v1/fs` request path.
|
|
53
|
+
*
|
|
54
|
+
* Each segment is encoded on its own so a filename with a space or a `#`
|
|
55
|
+
* survives, and the separators do not.
|
|
56
|
+
*/
|
|
57
|
+
export function fsRequestPath(path) {
|
|
58
|
+
const segments = path
|
|
59
|
+
.split("/")
|
|
60
|
+
.filter((s) => s.length > 0)
|
|
61
|
+
.map(encodeURIComponent);
|
|
62
|
+
return `/v1/fs${segments.length ? `/${segments.join("/")}` : ""}`;
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfora-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Your sfora workspace as a markdown filesystem — a CLI + MCP server. Post/task/doc, ls/cat/grep, and a shell so agents operate sfora natively.",
|
|
6
6
|
"keywords": [
|