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>
122 lines
3.0 KiB
JavaScript
122 lines
3.0 KiB
JavaScript
/**
|
|
* @typedef {import('./types').Jiti} Jiti
|
|
* @typedef {import('./types').JitiOptions} JitiOptions
|
|
*/
|
|
|
|
const isDeno = "Deno" in globalThis;
|
|
|
|
/**
|
|
* @param {string|URL} [parentURL]
|
|
* @param {JitiOptions} [jitiOptions]
|
|
* @returns {Jiti}
|
|
*/
|
|
export function createJiti(parentURL, jitiOptions) {
|
|
parentURL = normalizeParentURL(parentURL);
|
|
|
|
/** @type {Jiti} */
|
|
function jiti() {
|
|
throw unsupportedError(
|
|
"`jiti()` is not supported in native mode, use `jiti.import()` instead.",
|
|
);
|
|
}
|
|
|
|
jiti.resolve = () => {
|
|
throw unsupportedError("`jiti.resolve()` is not supported in native mode.");
|
|
};
|
|
|
|
jiti.esmResolve = (id, opts) => {
|
|
try {
|
|
const importMeta = jitiOptions?.importMeta || import.meta;
|
|
if (isDeno) {
|
|
// Deno throws TypeError: Invalid arguments when passing parentURL
|
|
return importMeta.resolve(id);
|
|
}
|
|
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
return importMeta.resolve(id, parent);
|
|
} catch (error) {
|
|
if (opts?.try) {
|
|
return undefined;
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
};
|
|
|
|
jiti.import = async function (id, opts) {
|
|
for (const suffix of ["", "/index"]) {
|
|
// prettier-ignore
|
|
for (const ext of ["", ".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts"]) {
|
|
try {
|
|
const resolved = this.esmResolve(id + suffix + ext, opts);
|
|
if (!resolved) {
|
|
continue;
|
|
}
|
|
let importAttrs = undefined
|
|
if (resolved.endsWith('.json')) {
|
|
importAttrs = { with: { type: 'json'}}
|
|
}
|
|
return await import(resolved, importAttrs);
|
|
} catch (error) {
|
|
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
|
continue
|
|
}
|
|
if (opts?.try) {
|
|
return undefined;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
if (!opts?.try) {
|
|
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
const error = new Error(
|
|
`[jiti] [ERR_MODULE_NOT_FOUND] Cannot import '${id}' from '${parent}'.`,
|
|
);
|
|
error.code = "ERR_MODULE_NOT_FOUND";
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
jiti.transform = () => {
|
|
throw unsupportedError(
|
|
"`jiti.transform()` is not supported in native mode.",
|
|
);
|
|
};
|
|
|
|
jiti.evalModule = () => {
|
|
throw unsupportedError(
|
|
"`jiti.evalModule()` is not supported in native mode.",
|
|
);
|
|
};
|
|
|
|
jiti.main = undefined;
|
|
jiti.extensions = Object.create(null);
|
|
jiti.cache = Object.create(null);
|
|
|
|
return jiti;
|
|
}
|
|
|
|
export default createJiti;
|
|
|
|
/**
|
|
* @param {string} message
|
|
*/
|
|
function unsupportedError(message) {
|
|
throw new Error(
|
|
`[jiti] ${message} (import or require 'jiti' instead of 'jiti/native' for more features).`,
|
|
);
|
|
}
|
|
|
|
function normalizeParentURL(input) {
|
|
if (!input) {
|
|
return "file:///";
|
|
}
|
|
if (typeof filename !== "string" || input.startsWith("file://")) {
|
|
return input;
|
|
}
|
|
if (input.endsWith("/")) {
|
|
input += "_"; // append a dummy filename
|
|
}
|
|
return `file://${input}`;
|
|
}
|