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>
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.isTraversal = void 0;
|
|
var css_what_1 = require("css-what");
|
|
var procedure = new Map([
|
|
[css_what_1.SelectorType.Universal, 50],
|
|
[css_what_1.SelectorType.Tag, 30],
|
|
[css_what_1.SelectorType.Attribute, 1],
|
|
[css_what_1.SelectorType.Pseudo, 0],
|
|
]);
|
|
function isTraversal(token) {
|
|
return !procedure.has(token.type);
|
|
}
|
|
exports.isTraversal = isTraversal;
|
|
var attributes = new Map([
|
|
[css_what_1.AttributeAction.Exists, 10],
|
|
[css_what_1.AttributeAction.Equals, 8],
|
|
[css_what_1.AttributeAction.Not, 7],
|
|
[css_what_1.AttributeAction.Start, 6],
|
|
[css_what_1.AttributeAction.End, 6],
|
|
[css_what_1.AttributeAction.Any, 5],
|
|
]);
|
|
/**
|
|
* Sort the parts of the passed selector,
|
|
* as there is potential for optimization
|
|
* (some types of selectors are faster than others)
|
|
*
|
|
* @param arr Selector to sort
|
|
*/
|
|
function sortByProcedure(arr) {
|
|
var procs = arr.map(getProcedure);
|
|
for (var i = 1; i < arr.length; i++) {
|
|
var procNew = procs[i];
|
|
if (procNew < 0)
|
|
continue;
|
|
for (var j = i - 1; j >= 0 && procNew < procs[j]; j--) {
|
|
var token = arr[j + 1];
|
|
arr[j + 1] = arr[j];
|
|
arr[j] = token;
|
|
procs[j + 1] = procs[j];
|
|
procs[j] = procNew;
|
|
}
|
|
}
|
|
}
|
|
exports.default = sortByProcedure;
|
|
function getProcedure(token) {
|
|
var _a, _b;
|
|
var proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
|
|
if (token.type === css_what_1.SelectorType.Attribute) {
|
|
proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
|
|
if (token.action === css_what_1.AttributeAction.Equals && token.name === "id") {
|
|
// Prefer ID selectors (eg. #ID)
|
|
proc = 9;
|
|
}
|
|
if (token.ignoreCase) {
|
|
/*
|
|
* IgnoreCase adds some overhead, prefer "normal" token
|
|
* this is a binary operation, to ensure it's still an int
|
|
*/
|
|
proc >>= 1;
|
|
}
|
|
}
|
|
else if (token.type === css_what_1.SelectorType.Pseudo) {
|
|
if (!token.data) {
|
|
proc = 3;
|
|
}
|
|
else if (token.name === "has" || token.name === "contains") {
|
|
proc = 0; // Expensive in any case
|
|
}
|
|
else if (Array.isArray(token.data)) {
|
|
// Eg. :matches, :not
|
|
proc = Math.min.apply(Math, token.data.map(function (d) { return Math.min.apply(Math, d.map(getProcedure)); }));
|
|
// If we have traversals, try to avoid executing this selector
|
|
if (proc < 0) {
|
|
proc = 0;
|
|
}
|
|
}
|
|
else {
|
|
proc = 2;
|
|
}
|
|
}
|
|
return proc;
|
|
}
|
|
//# sourceMappingURL=sort.js.map
|