@oh-my-pi/pi-utils 17.2.8 → 17.2.10

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 (89) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/types/acp/connection.d.ts +118 -0
  3. package/dist/types/acp/protocol.d.ts +526 -0
  4. package/dist/types/acp/schema.d.ts +41 -0
  5. package/dist/types/acp/stream.d.ts +8 -0
  6. package/dist/types/acp/transport.d.ts +81 -0
  7. package/dist/types/acp.d.ts +6 -0
  8. package/dist/types/browsers.d.ts +68 -0
  9. package/dist/types/chalk.d.ts +125 -0
  10. package/dist/types/dates.d.ts +7 -0
  11. package/dist/types/docx/converter.d.ts +46 -0
  12. package/dist/types/docx/xml.d.ts +26 -0
  13. package/dist/types/docx/zip.d.ts +6 -0
  14. package/dist/types/docx.d.ts +11 -0
  15. package/dist/types/dom/core.d.ts +431 -0
  16. package/dist/types/dom/parser.d.ts +7 -0
  17. package/dist/types/dom/selector.d.ts +5 -0
  18. package/dist/types/dom.d.ts +5 -0
  19. package/dist/types/headers.d.ts +34 -0
  20. package/dist/types/index.d.ts +1 -0
  21. package/dist/types/logger/rotating-file.d.ts +18 -0
  22. package/dist/types/lru.d.ts +46 -0
  23. package/dist/types/marked/core.d.ts +445 -0
  24. package/dist/types/marked.d.ts +2 -0
  25. package/dist/types/postmortem.d.ts +14 -0
  26. package/dist/types/procmgr.d.ts +16 -0
  27. package/dist/types/prompt.d.ts +2 -2
  28. package/dist/types/readability/readability.d.ts +9 -0
  29. package/dist/types/readability/readerable.d.ts +10 -0
  30. package/dist/types/readability/types.d.ts +70 -0
  31. package/dist/types/readability.d.ts +4 -0
  32. package/dist/types/template.d.ts +62 -0
  33. package/dist/types/turndown/gfm.d.ts +11 -0
  34. package/dist/types/turndown/html.d.ts +5 -0
  35. package/dist/types/turndown/service.d.ts +21 -0
  36. package/dist/types/turndown/types.d.ts +70 -0
  37. package/dist/types/turndown.d.ts +4 -0
  38. package/dist/types/version.d.ts +18 -0
  39. package/dist/types/vterm/buffer.d.ts +99 -0
  40. package/dist/types/vterm/terminal.d.ts +44 -0
  41. package/dist/types/vterm.d.ts +8 -0
  42. package/dist/types/xml.d.ts +31 -0
  43. package/package.json +2 -5
  44. package/src/acp/connection.ts +344 -0
  45. package/src/acp/protocol.ts +466 -0
  46. package/src/acp/schema.ts +160 -0
  47. package/src/acp/stream.ts +82 -0
  48. package/src/acp/transport.ts +213 -0
  49. package/src/acp.ts +6 -0
  50. package/src/browsers.ts +501 -0
  51. package/src/chalk.ts +312 -0
  52. package/src/dates.ts +194 -0
  53. package/src/docx/converter.ts +681 -0
  54. package/src/docx/xml.ts +166 -0
  55. package/src/docx/zip.ts +87 -0
  56. package/src/docx.ts +20 -0
  57. package/src/dom/core.ts +1254 -0
  58. package/src/dom/parser.ts +370 -0
  59. package/src/dom/selector.ts +290 -0
  60. package/src/dom.ts +33 -0
  61. package/src/fetch-retry.ts +7 -1
  62. package/src/frontmatter.ts +1 -1
  63. package/src/headers.ts +167 -0
  64. package/src/index.ts +1 -0
  65. package/src/logger/rotating-file.ts +149 -0
  66. package/src/logger.ts +12 -28
  67. package/src/lru.ts +185 -0
  68. package/src/marked/core.ts +1576 -0
  69. package/src/marked.ts +2 -0
  70. package/src/postmortem.ts +44 -1
  71. package/src/procmgr.ts +21 -4
  72. package/src/prompt.ts +5 -22
  73. package/src/readability/readability.ts +533 -0
  74. package/src/readability/readerable.ts +51 -0
  75. package/src/readability/types.ts +72 -0
  76. package/src/readability.ts +11 -0
  77. package/src/template.ts +586 -0
  78. package/src/turndown/gfm.ts +106 -0
  79. package/src/turndown/html.ts +257 -0
  80. package/src/turndown/service.ts +334 -0
  81. package/src/turndown/types.ts +81 -0
  82. package/src/turndown.ts +5 -0
  83. package/src/version.ts +99 -0
  84. package/src/vterm/buffer.ts +218 -0
  85. package/src/vterm/terminal.ts +773 -0
  86. package/src/vterm.ts +8 -0
  87. package/src/which.ts +6 -4
  88. package/src/xml.ts +313 -0
  89. package/src/winston-daily-rotate-file.d.ts +0 -6
@@ -0,0 +1,11 @@
1
+ import type { TurndownPlugin } from "./types.js";
2
+ /** Install GitHub fenced code blocks selected by `highlight-source-*` wrappers. */
3
+ export declare const highlightedCodeBlock: TurndownPlugin;
4
+ /** Install GFM strikethrough conversion. */
5
+ export declare const strikethrough: TurndownPlugin;
6
+ /** Install GFM task-list checkbox conversion. */
7
+ export declare const taskListItems: TurndownPlugin;
8
+ /** Install GFM table conversion for tables with a heading row. */
9
+ export declare const tables: TurndownPlugin;
10
+ /** Install every GFM rule used by the coding agent. */
11
+ export declare const gfm: TurndownPlugin;
@@ -0,0 +1,5 @@
1
+ import type { TurndownNode } from "./types.js";
2
+ /** Parse an HTML fragment into the small DOM subset needed by Turndown. */
3
+ export declare function parseHtmlFragment(html: string): TurndownNode;
4
+ /** Serialize a standards-shaped or internal HTML node. */
5
+ export declare function serializeNode(node: TurndownNode): string;
@@ -0,0 +1,21 @@
1
+ import type { ResolvedTurndownOptions, RuleFilter, TurndownNode, TurndownOptions, TurndownPlugin, TurndownRule } from "./types.js";
2
+ /** Convert HTML fragments to Markdown with extensible Turndown-compatible rules. */
3
+ export default class TurndownService {
4
+ #private;
5
+ readonly options: ResolvedTurndownOptions;
6
+ constructor(options?: TurndownOptions);
7
+ /** Install a highest-priority named conversion rule. */
8
+ addRule(key: string, rule: TurndownRule): this;
9
+ /** Preserve matching elements as HTML when no custom rule handles them. */
10
+ keep(filter: RuleFilter): this;
11
+ /** Drop matching elements and all of their converted content. */
12
+ remove(filter: RuleFilter): this;
13
+ /** Install one plugin or an ordered list of plugins. */
14
+ use(plugin: TurndownPlugin | readonly TurndownPlugin[]): this;
15
+ /** Escape Markdown punctuation using Turndown's public escaping rules. */
16
+ escape(text: string): string;
17
+ /** Convert an HTML string or standards-shaped DOM node to Markdown. */
18
+ turndown(input: string | TurndownNode): string;
19
+ /** Convert only a node's children within the active conversion. */
20
+ convertChildren(node: TurndownNode): string;
21
+ }
@@ -0,0 +1,70 @@
1
+ /** Behavior-compatible reimplementation of turndown's used surface. */
2
+ /** A DOM-shaped node accepted by conversion rules. */
3
+ export interface TurndownNode {
4
+ readonly nodeType: number;
5
+ readonly nodeName: string;
6
+ readonly parentNode: TurndownNode | null;
7
+ readonly childNodes: ArrayLike<TurndownNode>;
8
+ readonly children: ArrayLike<TurndownNode>;
9
+ readonly firstChild: TurndownNode | null;
10
+ readonly lastChild: TurndownNode | null;
11
+ readonly nextSibling: TurndownNode | null;
12
+ readonly previousSibling: TurndownNode | null;
13
+ readonly textContent: string | null;
14
+ readonly outerHTML?: string;
15
+ getAttribute(name: string): string | null;
16
+ hasAttribute(name: string): boolean;
17
+ }
18
+ /** Options supported by the HTML-to-Markdown converter. */
19
+ export interface TurndownOptions {
20
+ headingStyle?: "setext" | "atx";
21
+ hr?: string;
22
+ bulletListMarker?: "*" | "-" | "+";
23
+ codeBlockStyle?: "indented" | "fenced";
24
+ fence?: string;
25
+ emDelimiter?: "_" | "*";
26
+ strongDelimiter?: "**" | "__";
27
+ linkStyle?: "inlined" | "referenced";
28
+ linkReferenceStyle?: "full" | "collapsed" | "shortcut";
29
+ preformattedCode?: boolean;
30
+ blankReplacement?: ReplacementFunction;
31
+ keepReplacement?: ReplacementFunction;
32
+ defaultReplacement?: ReplacementFunction;
33
+ }
34
+ /** Fully resolved options passed to replacement callbacks. */
35
+ export interface ResolvedTurndownOptions {
36
+ headingStyle: "setext" | "atx";
37
+ hr: string;
38
+ bulletListMarker: "*" | "-" | "+";
39
+ codeBlockStyle: "indented" | "fenced";
40
+ fence: string;
41
+ emDelimiter: "_" | "*";
42
+ strongDelimiter: "**" | "__";
43
+ linkStyle: "inlined" | "referenced";
44
+ linkReferenceStyle: "full" | "collapsed" | "shortcut";
45
+ preformattedCode: boolean;
46
+ blankReplacement?: ReplacementFunction;
47
+ keepReplacement?: ReplacementFunction;
48
+ defaultReplacement?: ReplacementFunction;
49
+ }
50
+ /** A tag name, list of tag names, or predicate selecting nodes for a rule. */
51
+ export type RuleFilter = string | readonly string[] | ((node: TurndownNode, options: ResolvedTurndownOptions) => boolean);
52
+ /** Produces Markdown for a matched node and its already-converted children. */
53
+ export type ReplacementFunction = (content: string, node: TurndownNode, options: ResolvedTurndownOptions) => string;
54
+ /** A named conversion rule accepted by `addRule`. */
55
+ export interface TurndownRule {
56
+ filter: RuleFilter;
57
+ replacement: ReplacementFunction;
58
+ }
59
+ /** A plugin that installs one or more conversion rules. */
60
+ export type TurndownPlugin = (service: TurndownServiceLike) => void;
61
+ /** Structural service surface available to plugins. */
62
+ export interface TurndownServiceLike {
63
+ readonly options: ResolvedTurndownOptions;
64
+ addRule(key: string, rule: TurndownRule): this;
65
+ convertChildren(node: TurndownNode): string;
66
+ keep(filter: RuleFilter): this;
67
+ remove(filter: RuleFilter): this;
68
+ turndown(input: string | TurndownNode): string;
69
+ escape(text: string): string;
70
+ }
@@ -0,0 +1,4 @@
1
+ /** Behavior-compatible reimplementation of turndown's used surface. */
2
+ export * from "./turndown/gfm.js";
3
+ export { default, default as TurndownService } from "./turndown/service.js";
4
+ export * from "./turndown/types.js";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Compare two version strings.
3
+ *
4
+ * Canonical comparator that supersedes the historical in-repo copies
5
+ * (update-cli, hackage scraper, release scripts):
6
+ * - inputs are trimmed and at most one leading `v`/`V` is stripped
7
+ * - dot-separated segments are compared numerically, missing trailing
8
+ * segments count as 0, so `1.2` === `1.2.0` and any segment count works
9
+ * - a SemVer-2.0 prerelease suffix sorts before the plain release
10
+ * (`1.0.0-beta` < `1.0.0`); prerelease identifiers follow SemVer order
11
+ * (numeric < alphanumeric, numeric compared by value, alphanumeric
12
+ * compared lexically, longer sets of equal fields win)
13
+ * - SemVer build metadata begins at the first `+` and does not participate
14
+ * in precedence; it is stripped before core/prerelease parsing
15
+ * - malformed numeric segments compare as 0 (`1.2.x` === `1.2.0`)
16
+ * - never throws; returns only -1 | 0 | 1
17
+ */
18
+ export declare function compareVersions(a: string, b: string): number;
@@ -0,0 +1,99 @@
1
+ /** Cell rendition tracked by the virtual terminal. */
2
+ export interface CellAttributes {
3
+ bold: boolean;
4
+ dim: boolean;
5
+ italic: boolean;
6
+ underline: boolean;
7
+ inverse: boolean;
8
+ strikethrough: boolean;
9
+ overline: boolean;
10
+ fgMode: 0 | 1 | 2;
11
+ fg: number;
12
+ bgMode: 0 | 1 | 2;
13
+ bg: number;
14
+ }
15
+ /** A mutable terminal grid cell. */
16
+ export interface CellData {
17
+ chars: string;
18
+ width: number;
19
+ attrs: CellAttributes;
20
+ }
21
+ /** Creates the default rendition. */
22
+ export declare function defaultAttributes(): CellAttributes;
23
+ /** Creates an empty cell with the supplied rendition. */
24
+ export declare function blankCell(attrs?: CellAttributes): CellData;
25
+ /** Proposed xterm-compatible cell readback object. */
26
+ export declare class BufferCell {
27
+ #private;
28
+ /** Reuses this object for another grid cell. */
29
+ setFrom(cell: CellData): this;
30
+ /** Returns the grapheme stored in this cell. */
31
+ getChars(): string;
32
+ /** Returns the cell width, with zero denoting a wide-cell continuation. */
33
+ getWidth(): number;
34
+ /** Returns the packed foreground palette index or RGB value. */
35
+ getFgColor(): number;
36
+ /** Returns the packed background palette index or RGB value. */
37
+ getBgColor(): number;
38
+ /** Reports bold rendition. */
39
+ isBold(): number;
40
+ /** Reports dim rendition. */
41
+ isDim(): number;
42
+ /** Reports italic rendition. */
43
+ isItalic(): number;
44
+ /** Reports underline rendition. */
45
+ isUnderline(): number;
46
+ /** Reports inverse rendition. */
47
+ isInverse(): number;
48
+ /** Reports strikethrough rendition. */
49
+ isStrikethrough(): number;
50
+ /** Reports overline rendition. */
51
+ isOverline(): number;
52
+ /** Reports a true-color foreground. */
53
+ isFgRGB(): boolean;
54
+ /** Reports a true-color background. */
55
+ isBgRGB(): boolean;
56
+ /** Reports a palette foreground. */
57
+ isFgPalette(): boolean;
58
+ /** Reports a palette background. */
59
+ isBgPalette(): boolean;
60
+ }
61
+ /** One physical row in a terminal buffer. */
62
+ export declare class BufferLine {
63
+ cells: CellData[];
64
+ isWrapped: boolean;
65
+ constructor(columns: number, attrs?: CellAttributes);
66
+ /** Number of grid columns in the line. */
67
+ get length(): number;
68
+ /** Reads a cell, optionally reusing the caller's object. */
69
+ getCell(column: number, cell?: BufferCell): BufferCell | undefined;
70
+ /** Converts a column range to text. */
71
+ translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
72
+ }
73
+ /** Storage backing one terminal screen and its history. */
74
+ export interface BufferState {
75
+ lines: BufferLine[];
76
+ baseY: number;
77
+ viewportY: number;
78
+ cursorX: number;
79
+ cursorY: number;
80
+ }
81
+ /** Public xterm-compatible view over a buffer state. */
82
+ export declare class BufferView {
83
+ private readonly state;
84
+ constructor(state: () => BufferState);
85
+ /** Number of physical lines, including scrollback. */
86
+ get length(): number;
87
+ /** First row of the live screen in the full buffer. */
88
+ get baseY(): number;
89
+ /** First row currently exposed by the viewport. */
90
+ get viewportY(): number;
91
+ /** Cursor column in the live screen. */
92
+ get cursorX(): number;
93
+ /** Cursor row in the live screen. */
94
+ get cursorY(): number;
95
+ /** Reads a physical buffer line. */
96
+ getLine(row: number): BufferLine | undefined;
97
+ /** Creates a reusable empty cell readback object. */
98
+ getNullCell(): BufferCell;
99
+ }
@@ -0,0 +1,44 @@
1
+ import { BufferView } from "./buffer.js";
2
+ /** Construction options supported by the headless virtual terminal. */
3
+ export interface TerminalOptions {
4
+ cols?: number;
5
+ rows?: number;
6
+ scrollback?: number;
7
+ allowProposedApi?: boolean;
8
+ disableStdin?: boolean;
9
+ }
10
+ /** Disposable event subscription. */
11
+ export interface Disposable {
12
+ dispose(): void;
13
+ }
14
+ /** Observable terminal modes used by interactive input normalization. */
15
+ export interface TerminalModes {
16
+ applicationCursorKeysMode: boolean;
17
+ }
18
+ /** Buffer collection exposed by the virtual terminal. */
19
+ export interface TerminalBuffers {
20
+ readonly active: BufferView;
21
+ readonly normal: BufferView;
22
+ readonly alternate: BufferView;
23
+ }
24
+ /** Behavior-compatible reimplementation of @xterm/headless's used surface. */
25
+ export declare class Terminal {
26
+ #private;
27
+ /** Current terminal column count. */
28
+ cols: number;
29
+ /** Current terminal row count. */
30
+ rows: number;
31
+ /** Normal, alternate, and active buffer views. */
32
+ readonly buffer: TerminalBuffers;
33
+ /** Currently active input modes. */
34
+ readonly modes: TerminalModes;
35
+ constructor(options?: TerminalOptions);
36
+ /** Parses terminal output and invokes the callback after the write is committed. */
37
+ write(data: string | Uint8Array, callback?: () => void): void;
38
+ /** Changes the terminal grid and reflows wrapped normal-buffer lines. */
39
+ resize(columns: number, rows: number): void;
40
+ /** Subscribes to terminal-generated input replies. */
41
+ onData(listener: (data: string) => void): Disposable;
42
+ /** Releases parser state and event listeners. */
43
+ dispose(): void;
44
+ }
@@ -0,0 +1,8 @@
1
+ /** Behavior-compatible reimplementation of @xterm/headless's used surface. */
2
+ export * from "./vterm/buffer.js";
3
+ export * from "./vterm/terminal.js";
4
+ import { Terminal } from "./vterm/terminal.js";
5
+ declare const vterm: {
6
+ Terminal: typeof Terminal;
7
+ };
8
+ export default vterm;
@@ -0,0 +1,31 @@
1
+ /** Behavior-compatible reimplementation of fast-xml-parser's used surface. */
2
+ /** Context supplied to an array-selection callback. */
3
+ export type XMLArraySelector = (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean | null) => boolean;
4
+ /** Options supported by {@link XMLParser}. */
5
+ export interface XMLParserOptions {
6
+ /** Omits attributes when true (default). */
7
+ ignoreAttributes?: boolean;
8
+ /** Prefix applied to attribute property names. */
9
+ attributeNamePrefix?: string;
10
+ /** Property used for text alongside children or attributes. */
11
+ textNodeName?: string;
12
+ /** Trims ordinary text and attribute values. */
13
+ trimValues?: boolean;
14
+ /** Coerces numeric and boolean element text. */
15
+ parseTagValue?: boolean;
16
+ /** Coerces numeric and boolean attribute values. */
17
+ parseAttributeValue?: boolean;
18
+ /** Controls entity processing and its expansion ceiling. */
19
+ processEntities?: boolean | {
20
+ maxTotalExpansions?: number;
21
+ };
22
+ /** Selects element or attribute properties that must always be arrays. */
23
+ isArray?: XMLArraySelector;
24
+ }
25
+ /** Parses XML into the object shape used by the document converters. */
26
+ export declare class XMLParser {
27
+ #private;
28
+ constructor(options?: XMLParserOptions);
29
+ /** Parses one XML document. */
30
+ parse(xml: string): unknown;
31
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "17.2.8",
4
+ "version": "17.2.10",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -31,10 +31,7 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
- "@oh-my-pi/pi-natives": "17.2.8",
35
- "handlebars": "^4.7.9",
36
- "winston": "^3.19.0",
37
- "winston-daily-rotate-file": "5.0.0"
34
+ "@oh-my-pi/pi-natives": "17.2.10"
38
35
  },
39
36
  "devDependencies": {
40
37
  "@types/bun": "^1.3.14"