Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/prompt-schema-drift-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ on:
paths:
- "documents/prompt_engineering/**"
- "frontend/src/lib/prompts/**"
- "frontend/src/lib/services/**"
- "frontend/src/lib/utils/**"
- "frontend/src/lib/services/insightSchemas.ts"
- "packages/vesti-content-package/**"
- "packages/vesti-ui/src/lib/artifactSummary.ts"
- "packages/vesti-ui/src/lib/messagePackage.ts"
- "scripts/eval-prompts.ts"
- "scripts/check-frontend-ui-boundary.mjs"
- "scripts/tsconfig.eval.json"
- "eval/**"
- "package.json"
- "frontend/package.json"
- "frontend/pnpm-lock.yaml"

Expand All @@ -29,8 +37,11 @@ jobs:
with:
version: 10.29.2

- name: Install frontend deps
run: pnpm -C frontend install --frozen-lockfile
- name: Install workspace deps
run: pnpm install --frozen-lockfile

- name: Check frontend non-UI boundary
run: pnpm -C frontend check:ui-boundaries

- name: Run prompt eval (mock strict)
run: pnpm -C frontend eval:prompts --mode=mock --strict
Expand Down
4 changes: 4 additions & 0 deletions documents/prompt_engineering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ on:
- `documents/capture_engine/`
- `documents/reader_pipeline/`

Pure text-side content-package helpers used by prompt/eval/export now live under the internal
workspace package `@vesti/content-package`. `@vesti/ui` may re-export those helpers for UI
consumers, but prompt/runtime service code must not depend on `@vesti/ui` as their source.

## Active canonical docs

- `export_ai_handoff_architecture.md`
Expand Down
6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
"author": "Vesti",
"scripts": {
"dev": "plasmo dev",
"prebuild": "pnpm -C ../packages/vesti-ui build && pnpm -C .. install --frozen-lockfile",
"prebuild": "pnpm -C ../packages/vesti-content-package build && pnpm -C ../packages/vesti-ui build && pnpm -C .. install --frozen-lockfile",
"build": "plasmo build",
"package": "node -e \"console.error('Local packaging is disabled. Use CI workflow extension-package or run pnpm -C frontend package:safe.'); process.exit(1)\"",
"package:ci": "pnpm run build && plasmo package",
"package:safe": "powershell -NoProfile -ExecutionPolicy Bypass -File ../scripts/safe-package.ps1 -Overwrite",
"eval:prompts": "pnpm exec tsc --project ../scripts/tsconfig.eval.json && node ../.tmp/eval/scripts/eval-prompts.js"
"eval:prompts": "pnpm -C ../packages/vesti-content-package build && pnpm exec tsc --project ../scripts/tsconfig.eval.json && node ../.tmp/eval/scripts/eval-prompts.js",
"check:ui-boundaries": "node ../scripts/check-frontend-ui-boundary.mjs"
},
"dependencies": {
"@fontsource/inter": "^5.2.8",
"@fontsource/lora": "^5.2.8",
"@fontsource/newsreader": "^5.2.10",
"@fontsource/nunito-sans": "^5.2.7",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@vesti/content-package": "file:../packages/vesti-content-package",
"@vesti/ui": "file:../packages/vesti-ui",
"dexie": "^4.3.0",
"katex": "^0.16.25",
Expand Down
7 changes: 7 additions & 0 deletions frontend/plasmo.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ export default {
vite: (config) => {
const repoRoot = path.resolve(__dirname, "..", "..");
const packagesRoot = path.resolve(repoRoot, "packages");
const vestiContentPackageEntry = path.resolve(
packagesRoot,
"vesti-content-package",
"src",
"index.ts"
);
const vestiUiEntry = path.resolve(packagesRoot, "vesti-ui", "src", "index.ts");
const localNodeModules = path.resolve(__dirname, "node_modules");

config.resolve = config.resolve || {};
config.resolve.preserveSymlinks = false;
config.resolve.alias = {
...(config.resolve.alias || {}),
"@vesti/content-package": vestiContentPackageEntry,
// Force the extension to consume the shared UI through a frontend-controlled
// entrypoint so all React imports resolve to the frontend's React 18 runtime.
"@vesti/ui": vestiUiEntry,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/prompts/promptIngestionAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Conversation, Message } from "../types";
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/ui";
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/content-package";
import { extractAstPlainText, inspectAstStructure, isAstRoot, shouldPreferAstCanonicalText } from "../utils/astText";
import {
buildMessageSidecarSummaryLines,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/services/exportSerializers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/ui";
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/content-package";
import type {
Annotation,
Conversation,
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/lib/utils/messageContentPackage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
buildMessageFallbackDisplayText as buildSharedFallbackDisplayText,
buildMessagePreviewText as buildSharedPreviewText,
buildMessageSidecarSummaryLines as buildSharedSidecarSummaryLines,
} from "@vesti/ui";
buildMessageFallbackDisplayText as buildContentPackageFallbackDisplayText,
buildMessagePreviewText as buildContentPackagePreviewText,
buildMessageSidecarSummaryLines as buildContentPackageSidecarSummaryLines,
} from "@vesti/content-package";
import type { Message } from "../types";
import { extractAstPlainText, isAstRoot, shouldPreferAstCanonicalText } from "./astText";

Expand Down Expand Up @@ -46,7 +46,7 @@ export function resolveCanonicalBodyText(
}

export function buildMessageSidecarSummaryLines(message: MessageContentPackageLike): string[] {
return buildSharedSidecarSummaryLines(message);
return buildContentPackageSidecarSummaryLines(message);
}

export function buildMessagePreviewText(
Expand All @@ -57,7 +57,7 @@ export function buildMessagePreviewText(
includeSidecarsWhenBodyPresent?: boolean;
} = {},
): string {
return buildSharedPreviewText(
return buildContentPackagePreviewText(
{
...message,
content_text: resolveCanonicalBodyText(message),
Expand All @@ -69,14 +69,14 @@ export function buildMessagePreviewText(
export function buildMessageFallbackDisplayText(
message: MessageContentPackageLike
): string {
return buildSharedFallbackDisplayText({
return buildContentPackageFallbackDisplayText({
...message,
content_text: resolveCanonicalBodyText(message),
});
}

export function buildMessageSearchIndexText(message: MessageContentPackageLike): string {
const bodyText = resolveCanonicalBodyText(message);
const sidecarLines = buildSharedSidecarSummaryLines(message);
const sidecarLines = buildContentPackageSidecarSummaryLines(message);
return [bodyText, ...sidecarLines].filter(Boolean).join("\n").trim();
}
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/messageExportPackage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/ui";
import { formatArtifactDescriptor, getArtifactExcerptText } from "@vesti/content-package";
import type { Message, MessageAttachment, MessageArtifact, MessageCitation } from "../types";
import { resolveCanonicalBodyText } from "./messageContentPackage";

Expand Down
3 changes: 3 additions & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"./src/*",
"./*"
],
"@vesti/content-package": [
"../packages/vesti-content-package/src/index.ts"
],
"@vesti/ui": [
"../packages/vesti-ui/src/index.ts"
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"remark-gfm": "^2.0.0"
},
"devDependencies": {
"@vesti/content-package": "file:./packages/vesti-content-package",
"@playwright/test": "^1.55.0",
"@types/react": "18.2.48",
"@types/react-dom": "18.2.18"
Expand Down
23 changes: 23 additions & 0 deletions packages/vesti-content-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@vesti/content-package",
"version": "0.0.0",
"private": true,
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"scripts": {
"build": "node ./scripts/build-content-package.mjs"
}
}
93 changes: 93 additions & 0 deletions packages/vesti-content-package/scripts/build-content-package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { existsSync, rmSync } from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";

const rootDir = process.cwd();
const frontendDir = path.resolve(rootDir, "../../frontend");
const distDir = path.resolve(rootDir, "dist");
const esbuildBin = path.resolve(
frontendDir,
"node_modules",
".bin",
process.platform === "win32" ? "esbuild.cmd" : "esbuild"
);
const tscBin = path.resolve(
frontendDir,
"node_modules",
".bin",
process.platform === "win32" ? "tsc.cmd" : "tsc"
);

rmSync(distDir, { recursive: true, force: true });

for (const [label, bin] of [
["esbuild", esbuildBin],
["tsc", tscBin],
]) {
if (!existsSync(bin)) {
console.error(`[@vesti/content-package] ${label} binary not found: ${bin}`);
process.exit(1);
}
}

const entry = path.resolve(rootDir, "src/index.ts");
const tsconfigPath = path.resolve(rootDir, "tsconfig.build.json");

const esbuildCommonArgs = [
entry,
"--bundle",
"--platform=neutral",
"--target=es2020",
`--tsconfig=${tsconfigPath}`,
];

const esmRun = spawnSync(
esbuildBin,
[...esbuildCommonArgs, "--format=esm", `--outfile=${path.resolve(distDir, "index.js")}`],
{
stdio: "inherit",
env: process.env,
shell: process.platform === "win32",
}
);

if (esmRun.error || (esmRun.status ?? 1) !== 0) {
if (esmRun.error) {
console.error(esmRun.error.message);
}
process.exit(esmRun.status ?? 1);
}

const cjsRun = spawnSync(
esbuildBin,
[...esbuildCommonArgs, "--format=cjs", `--outfile=${path.resolve(distDir, "index.cjs")}`],
{
stdio: "inherit",
env: process.env,
shell: process.platform === "win32",
}
);

if (cjsRun.error || (cjsRun.status ?? 1) !== 0) {
if (cjsRun.error) {
console.error(cjsRun.error.message);
}
process.exit(cjsRun.status ?? 1);
}

const dtsRun = spawnSync(
tscBin,
["--project", tsconfigPath],
{
stdio: "inherit",
env: process.env,
shell: process.platform === "win32",
}
);

if (dtsRun.error) {
console.error(dtsRun.error.message);
process.exit(1);
}

process.exit(dtsRun.status ?? 1);
Loading
Loading