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>
120 lines
2.8 KiB
JavaScript
120 lines
2.8 KiB
JavaScript
/**
|
|
* @import {ElementContent, Element, Properties} from 'hast'
|
|
* @import {ListItem, Parents} from 'mdast'
|
|
* @import {State} from '../state.js'
|
|
*/
|
|
|
|
/**
|
|
* Turn an mdast `listItem` node into hast.
|
|
*
|
|
* @param {State} state
|
|
* Info passed around.
|
|
* @param {ListItem} node
|
|
* mdast node.
|
|
* @param {Parents | undefined} parent
|
|
* Parent of `node`.
|
|
* @returns {Element}
|
|
* hast node.
|
|
*/
|
|
export function listItem(state, node, parent) {
|
|
const results = state.all(node)
|
|
const loose = parent ? listLoose(parent) : listItemLoose(node)
|
|
/** @type {Properties} */
|
|
const properties = {}
|
|
/** @type {Array<ElementContent>} */
|
|
const children = []
|
|
|
|
if (typeof node.checked === 'boolean') {
|
|
const head = results[0]
|
|
/** @type {Element} */
|
|
let paragraph
|
|
|
|
if (head && head.type === 'element' && head.tagName === 'p') {
|
|
paragraph = head
|
|
} else {
|
|
paragraph = {type: 'element', tagName: 'p', properties: {}, children: []}
|
|
results.unshift(paragraph)
|
|
}
|
|
|
|
if (paragraph.children.length > 0) {
|
|
paragraph.children.unshift({type: 'text', value: ' '})
|
|
}
|
|
|
|
paragraph.children.unshift({
|
|
type: 'element',
|
|
tagName: 'input',
|
|
properties: {type: 'checkbox', checked: node.checked, disabled: true},
|
|
children: []
|
|
})
|
|
|
|
// According to github-markdown-css, this class hides bullet.
|
|
// See: <https://github.com/sindresorhus/github-markdown-css>.
|
|
properties.className = ['task-list-item']
|
|
}
|
|
|
|
let index = -1
|
|
|
|
while (++index < results.length) {
|
|
const child = results[index]
|
|
|
|
// Add eols before nodes, except if this is a loose, first paragraph.
|
|
if (
|
|
loose ||
|
|
index !== 0 ||
|
|
child.type !== 'element' ||
|
|
child.tagName !== 'p'
|
|
) {
|
|
children.push({type: 'text', value: '\n'})
|
|
}
|
|
|
|
if (child.type === 'element' && child.tagName === 'p' && !loose) {
|
|
children.push(...child.children)
|
|
} else {
|
|
children.push(child)
|
|
}
|
|
}
|
|
|
|
const tail = results[results.length - 1]
|
|
|
|
// Add a final eol.
|
|
if (tail && (loose || tail.type !== 'element' || tail.tagName !== 'p')) {
|
|
children.push({type: 'text', value: '\n'})
|
|
}
|
|
|
|
/** @type {Element} */
|
|
const result = {type: 'element', tagName: 'li', properties, children}
|
|
state.patch(node, result)
|
|
return state.applyData(node, result)
|
|
}
|
|
|
|
/**
|
|
* @param {Parents} node
|
|
* @return {Boolean}
|
|
*/
|
|
function listLoose(node) {
|
|
let loose = false
|
|
if (node.type === 'list') {
|
|
loose = node.spread || false
|
|
const children = node.children
|
|
let index = -1
|
|
|
|
while (!loose && ++index < children.length) {
|
|
loose = listItemLoose(children[index])
|
|
}
|
|
}
|
|
|
|
return loose
|
|
}
|
|
|
|
/**
|
|
* @param {ListItem} node
|
|
* @return {Boolean}
|
|
*/
|
|
function listItemLoose(node) {
|
|
const spread = node.spread
|
|
|
|
return spread === null || spread === undefined
|
|
? node.children.length > 1
|
|
: spread
|
|
}
|