@docsworth/cli 0.0.0-stage → 0.3.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 (103) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +238 -2
  3. package/dist/cli.d.ts +11 -0
  4. package/dist/cli.js +458 -0
  5. package/dist/core/acl.d.ts +37 -0
  6. package/dist/core/acl.js +136 -0
  7. package/dist/core/adopt.d.ts +68 -0
  8. package/dist/core/adopt.js +665 -0
  9. package/dist/core/audit-log.d.ts +133 -0
  10. package/dist/core/audit-log.js +290 -0
  11. package/dist/core/blocks.d.ts +35 -0
  12. package/dist/core/blocks.js +417 -0
  13. package/dist/core/codeowners.d.ts +62 -0
  14. package/dist/core/codeowners.js +133 -0
  15. package/dist/core/config.d.ts +101 -0
  16. package/dist/core/config.js +175 -0
  17. package/dist/core/coverage.d.ts +25 -0
  18. package/dist/core/coverage.js +41 -0
  19. package/dist/core/duration.d.ts +20 -0
  20. package/dist/core/duration.js +60 -0
  21. package/dist/core/edits.d.ts +13 -0
  22. package/dist/core/edits.js +20 -0
  23. package/dist/core/errors.d.ts +11 -0
  24. package/dist/core/errors.js +13 -0
  25. package/dist/core/frontmatter.d.ts +29 -0
  26. package/dist/core/frontmatter.js +49 -0
  27. package/dist/core/gate.d.ts +17 -0
  28. package/dist/core/gate.js +25 -0
  29. package/dist/core/gfm.d.ts +13 -0
  30. package/dist/core/gfm.js +244 -0
  31. package/dist/core/github.d.ts +152 -0
  32. package/dist/core/github.js +234 -0
  33. package/dist/core/host.d.ts +125 -0
  34. package/dist/core/host.js +22 -0
  35. package/dist/core/identity.d.ts +39 -0
  36. package/dist/core/identity.js +127 -0
  37. package/dist/core/init.d.ts +25 -0
  38. package/dist/core/init.js +86 -0
  39. package/dist/core/links.d.ts +82 -0
  40. package/dist/core/links.js +345 -0
  41. package/dist/core/lint.d.ts +16 -0
  42. package/dist/core/lint.js +149 -0
  43. package/dist/core/mcp/audit-transport.d.ts +16 -0
  44. package/dist/core/mcp/audit-transport.js +238 -0
  45. package/dist/core/mcp/server.d.ts +19 -0
  46. package/dist/core/mcp/server.js +216 -0
  47. package/dist/core/mcp/text.d.ts +14 -0
  48. package/dist/core/mcp/text.js +43 -0
  49. package/dist/core/mirror-view.d.ts +68 -0
  50. package/dist/core/mirror-view.js +367 -0
  51. package/dist/core/new-page.d.ts +52 -0
  52. package/dist/core/new-page.js +49 -0
  53. package/dist/core/policy.d.ts +10 -0
  54. package/dist/core/policy.js +30 -0
  55. package/dist/core/polish.d.ts +42 -0
  56. package/dist/core/polish.js +1000 -0
  57. package/dist/core/printable.d.ts +4 -0
  58. package/dist/core/printable.js +16 -0
  59. package/dist/core/references.d.ts +87 -0
  60. package/dist/core/references.js +1744 -0
  61. package/dist/core/repo.d.ts +46 -0
  62. package/dist/core/repo.js +118 -0
  63. package/dist/core/schema.d.ts +50 -0
  64. package/dist/core/schema.js +51 -0
  65. package/dist/core/search.d.ts +32 -0
  66. package/dist/core/search.js +132 -0
  67. package/dist/core/serve/auth.d.ts +23 -0
  68. package/dist/core/serve/auth.js +38 -0
  69. package/dist/core/serve/server.d.ts +21 -0
  70. package/dist/core/serve/server.js +138 -0
  71. package/dist/core/serve/sessions.d.ts +40 -0
  72. package/dist/core/serve/sessions.js +203 -0
  73. package/dist/core/serve/token.d.ts +10 -0
  74. package/dist/core/serve/token.js +96 -0
  75. package/dist/core/service.d.ts +473 -0
  76. package/dist/core/service.js +973 -0
  77. package/dist/core/sla.d.ts +16 -0
  78. package/dist/core/sla.js +20 -0
  79. package/dist/core/stale.d.ts +16 -0
  80. package/dist/core/stale.js +24 -0
  81. package/dist/core/tool-registry.d.ts +31 -0
  82. package/dist/core/tool-registry.js +80 -0
  83. package/dist/core/url.d.ts +4 -0
  84. package/dist/core/url.js +31 -0
  85. package/dist/core/verify-pages.d.ts +19 -0
  86. package/dist/core/verify-pages.js +110 -0
  87. package/dist/core/version.d.ts +22 -0
  88. package/dist/core/version.js +32 -0
  89. package/dist/core/writes.d.ts +58 -0
  90. package/dist/core/writes.js +113 -0
  91. package/dist/web/assets/index-8J-FUbb0.js +29 -0
  92. package/dist/web/assets/index-BGpAZzeM.css +1 -0
  93. package/dist/web/index.html +14 -0
  94. package/docs/format-spec.md +349 -0
  95. package/package.json +75 -4
  96. package/plugin/.claude-plugin/plugin.json +8 -0
  97. package/plugin/.mcp.json +8 -0
  98. package/plugin/bin/docsworth-mcp.mjs +46 -0
  99. package/plugin/skills/draft-runbook/SKILL.md +75 -0
  100. package/plugin/skills/polish-page/SKILL.md +64 -0
  101. package/plugin/skills/update-after-incident/SKILL.md +59 -0
  102. package/plugin/skills/verify-page/SKILL.md +46 -0
  103. package/templates/github/knowledge.yml +51 -0
@@ -0,0 +1,4 @@
1
+ /** `text` with control and bidirectional characters written as escapes (`\x1b`, `\u202e`). */
2
+ export declare function printable(text: string): string;
3
+ /** `value` as JSON, every such character a `\u` escape: JSON.stringify leaves C1 and bidirectional ones as they are. */
4
+ export declare function printableJson(value: unknown): string;
@@ -0,0 +1,16 @@
1
+ // Text a page holds, made safe to print on a terminal: a decoded link, a frontmatter value or a
2
+ // file name could carry escape sequences that clear or spoof a report, line breaks that fake
3
+ // another line, or bidirectional overrides that reorder it.
4
+ // C0 and C1 controls, Unicode's Bidi_Control set, and its line and paragraph separators.
5
+ const UNPRINTABLE = /[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
6
+ // The same but C0, which JSON.stringify escapes inside strings and uses outside them (a newline).
7
+ const UNPRINTABLE_IN_JSON = /[\u007f-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
8
+ const hex = (c, width) => c.charCodeAt(0).toString(16).padStart(width, "0");
9
+ /** `text` with control and bidirectional characters written as escapes (`\x1b`, `\u202e`). */
10
+ export function printable(text) {
11
+ return text.replace(UNPRINTABLE, (c) => (c.charCodeAt(0) < 0x100 ? `\\x${hex(c, 2)}` : `\\u${hex(c, 4)}`));
12
+ }
13
+ /** `value` as JSON, every such character a `\u` escape: JSON.stringify leaves C1 and bidirectional ones as they are. */
14
+ export function printableJson(value) {
15
+ return JSON.stringify(value, null, 2).replace(UNPRINTABLE_IN_JSON, (c) => `\\u${hex(c, 4)}`);
16
+ }
@@ -0,0 +1,87 @@
1
+ import type { Page, Repo } from "./repo.js";
2
+ /**
3
+ * HTML's named character references that hold an ASCII character: all 49 of them. Every
4
+ * other name stands for non-ASCII characters only. test/references.test.ts checks this
5
+ * table against the `entities` package.
6
+ */
7
+ export declare const ASCII_REFERENCES: Readonly<Record<string, string>>;
8
+ /**
9
+ * HTML's named references to invisible format characters only (soft hyphen, zero-width
10
+ * space and joiners, word joiner, bidi marks): all 17. The rendered view drops them.
11
+ * test/references.test.ts checks this list against the `entities` package.
12
+ */
13
+ export declare const INVISIBLE_REFERENCES: ReadonlySet<string>;
14
+ /** The pages `who` can't see, as a sweep reads names. Built once per repo and audience. */
15
+ export interface PageNames {
16
+ /** The knowledge root, without a trailing slash. */
17
+ root: string;
18
+ /** Skeleton of each repo path → whether it's hidden (hidden wins a collision). */
19
+ paths: Map<string, boolean>;
20
+ /** The same for each path under the knowledge root, when it has two segments or more. */
21
+ under: Map<string, boolean>;
22
+ /** Skeletons of hidden pages' file names, by length. */
23
+ names: Map<number, Set<string>>;
24
+ /** For each such file name, the hidden pages' repo paths. */
25
+ spelled: Map<string, string[]>;
26
+ /** For each such file name, the hidden pages' paths under the root (two segments or more). */
27
+ spelledUnder: Map<string, string[]>;
28
+ /** The most segments in a repo path: a longer tail can't name one. */
29
+ depth: number;
30
+ /** The knowledge repo's URL prefixes on GitHub (`github.com/acme/knowledge/`), if it's there. */
31
+ repoUrls: string[];
32
+ /** Each page's one route on a docs site (`pageRoute`) → whether it's hidden (hidden wins a shared route). */
33
+ routes: Map<string, boolean>;
34
+ /** Hidden pages' paths under the root without `.md`: a link by a file's stem (`sec/1.0-release`). */
35
+ stems: Set<string>;
36
+ /** For each loaded page's repo path, the directories its URL reads a relative link from. */
37
+ urlDirs: Map<string, string[]>;
38
+ /** `site_url`'s host (port included), path prefix (no trailing slash), host name, and where that name starts a token's URL. */
39
+ site?: {
40
+ host: string;
41
+ prefix: string;
42
+ name: string;
43
+ at: RegExp;
44
+ };
45
+ /** Whether a repo path, as written (not folded), is a file or directory in the repo. */
46
+ exists: (repoPath: string) => boolean;
47
+ /** The same, folded as rendered text (`foldRendered`), for the rendered view. */
48
+ rendered?: PageNames;
49
+ }
50
+ export declare function pageNames(repo: Repo, hidden: (page: Page) => boolean): PageNames;
51
+ /**
52
+ * Whether a link destination, as written on page `from`, leads to a hidden page: one
53
+ * that resolves to it, or a URL that ends with its path. A path under the knowledge root
54
+ * that is no loaded page fails closed: a page that didn't load has no trustworthy ACL.
55
+ * `html` for an attribute in raw HTML, where backslash escapes don't apply. `links`, the
56
+ * text's CommonMark links (`linkPaths`): a route naming nothing fails closed only where it's
57
+ * one of them (or an attribute's), not where only the liberal reading finds it (`[^1]: The
58
+ * note`, `[term]: word`); a hidden page's route hides it wherever it stands.
59
+ */
60
+ export declare function destinationHides(dest: string, from: string, names: PageNames, html?: boolean, links?: ReadonlySet<string>): boolean;
61
+ /** The paths of `text`'s links and images, as commonmark.js parses them (`commonmarkPath`). */
62
+ export declare function linkPaths(text: string): Set<string>;
63
+ /**
64
+ * CommonMark's link definitions in `text`, the first for each label (keyed as `normalLabel`
65
+ * keys a label) → its destination; undefined where commonmark.js doesn't say.
66
+ */
67
+ export declare function definitionsIn(text: string): Map<string, string> | undefined;
68
+ /**
69
+ * The lines of `text` holding a reference to one of `labels` (definitions that go): left, a
70
+ * reference shows its label as text, in whatever container (code review, round 1: `> [HSM]`
71
+ * over `> [HSM]: …`), or before a `:` (`[ref]:` that can't start a definition is one).
72
+ * Matched as CommonMark matches labels (case, runs of space, and space inside the brackets
73
+ * aside), anywhere on a line.
74
+ */
75
+ export declare function labelLines(text: string, labels: Iterable<string>): Set<number>;
76
+ /** A label as CommonMark compares labels: runs of space one space, case folded as Unicode folds it (`ß` is `SS`: code review, round 2). */
77
+ export declare const normalLabel: (s: string) => string;
78
+ /** The lines of `text`, on page `from`, that name a hidden page: see the module comment. */
79
+ export declare function namingLines(text: string, from: string, names: PageNames, depth?: number, inherited?: string[], liberal?: boolean, gone?: Set<string>): Set<number>;
80
+ /**
81
+ * The lines of `text` where `find`, run over each view the sweep reads (as prose and
82
+ * joined, with and without CommonMark's escapes, and as rendered), reports a span. For
83
+ * names that aren't paths: a mirrored page's id, say.
84
+ */
85
+ export declare function linesWhere(text: string, find: (view: string, cased: string) => Iterable<[number, number]>, depth?: number, inherited?: string[]): Set<number>;
86
+ /** `text` with each line in `lines` replaced by its container markers and `placeholder`. */
87
+ export declare function replaceLines(text: string, lines: Set<number>, placeholder: string): string;