Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
import { isDocument, } from 'domhandler';
|
|
import { parse as parseDocument, parseFragment, serializeOuter } from 'parse5';
|
|
import { adapter as htmlparser2Adapter } from 'parse5-htmlparser2-tree-adapter';
|
|
/**
|
|
* Parse the content with `parse5` in the context of the given `ParentNode`.
|
|
*
|
|
* @param content - The content to parse.
|
|
* @param options - A set of options to use to parse.
|
|
* @param isDocument - Whether to parse the content as a full HTML document.
|
|
* @param context - The context in which to parse the content.
|
|
* @returns The parsed content.
|
|
*/
|
|
export function parseWithParse5(content, options, isDocument, context) {
|
|
var _a;
|
|
(_a = options.treeAdapter) !== null && _a !== void 0 ? _a : (options.treeAdapter = htmlparser2Adapter);
|
|
if (options.scriptingEnabled !== false) {
|
|
options.scriptingEnabled = true;
|
|
}
|
|
return isDocument
|
|
? parseDocument(content, options)
|
|
: parseFragment(context, content, options);
|
|
}
|
|
const renderOpts = { treeAdapter: htmlparser2Adapter };
|
|
/**
|
|
* Renders the given DOM tree with `parse5` and returns the result as a string.
|
|
*
|
|
* @param dom - The DOM tree to render.
|
|
* @returns The rendered document.
|
|
*/
|
|
export function renderWithParse5(dom) {
|
|
/*
|
|
* `dom-serializer` passes over the special "root" node and renders the
|
|
* node's children in its place. To mimic this behavior with `parse5`, an
|
|
* equivalent operation must be applied to the input array.
|
|
*/
|
|
const nodes = 'length' in dom ? dom : [dom];
|
|
for (let index = 0; index < nodes.length; index += 1) {
|
|
const node = nodes[index];
|
|
if (isDocument(node)) {
|
|
Array.prototype.splice.call(nodes, index, 1, ...node.children);
|
|
}
|
|
}
|
|
let result = '';
|
|
for (let index = 0; index < nodes.length; index += 1) {
|
|
const node = nodes[index];
|
|
result += serializeOuter(node, renderOpts);
|
|
}
|
|
return result;
|
|
}
|
|
//# sourceMappingURL=parse5-adapter.js.map
|