feat: integrate custom features for smart context management
Some checks failed
CI / test (map[image:macos-latest name:macos], 1, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 2, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 3, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 4, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 1, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 2, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 3, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 4, 4) (push) Has been cancelled
CI / merge-reports (push) Has been cancelled

- Added a new integration script to manage custom features related to smart context.
- Implemented handlers for smart context operations (get, update, clear, stats) in ipc.
- Created a SmartContextStore class to manage context snippets and summaries.
- Developed hooks for React to interact with smart context (useSmartContext, useUpdateSmartContext, useClearSmartContext, useSmartContextStats).
- Included backup and restore functionality in the integration script.
- Validated integration by checking for custom modifications and file existence.
This commit is contained in:
Kunthawat Greethong
2025-12-18 15:56:48 +07:00
parent 99b0cdf8ac
commit 5660de49de
423 changed files with 70726 additions and 982 deletions

View File

@@ -0,0 +1,50 @@
import path from "node:path";
import os from "node:os";
import { IS_TEST_BUILD } from "../ipc/utils/test_utils";
export function getDyadAppPath(appPath: string): string {
if (IS_TEST_BUILD) {
const electron = getElectron();
return path.join(electron!.app.getPath("userData"), "dyad-apps", appPath);
}
return path.join(os.homedir(), "dyad-apps", appPath);
}
export function getTypeScriptCachePath(): string {
const electron = getElectron();
return path.join(electron!.app.getPath("sessionData"), "typescript-cache");
}
/**
* Gets the user data path, handling both Electron and non-Electron environments
* In Electron: returns the app's userData directory
* In non-Electron: returns "./userData" in the current directory
*/
export function getUserDataPath(): string {
const electron = getElectron();
// When running in Electron and app is ready
if (process.env.NODE_ENV !== "development" && electron) {
return electron!.app.getPath("userData");
}
// For development or when the Electron app object isn't available
return path.resolve("./userData");
}
/**
* Get a reference to electron in a way that won't break in non-electron environments
*/
export function getElectron(): typeof import("electron") | undefined {
let electron: typeof import("electron") | undefined;
try {
// Check if we're in an Electron environment
if (process.versions.electron) {
electron = require("electron");
}
} catch {
// Not in Electron environment
}
return electron;
}