@digithings-ai/digichat-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
- # Temporary Holding Version
1
+ # @digithings-ai/digichat-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared digichat CSS and helpers: the `.dc-*` session grammar, the caret styles,
4
+ the slash palette, the brand mark and the transcript markdown export.
5
+
6
+ It is **not** a session shell. digichat 2.0 renders its session through the
7
+ stock `assistant-ui` Thread in `apps/digichat`; parents (digithings-web, the
8
+ dashboard popup, `widget.js`) embed digichat through `/embed`. The transcript
9
+ helpers live in `@digithings-ai/ui/chat/transcript` and are re-exported here.
10
+
11
+ | Entry | What it is |
12
+ |---|---|
13
+ | `@digithings-ai/digichat-ui` | `DigiChatMark`, the slash-command helpers, the transcript helpers |
14
+ | `@digithings-ai/digichat-ui/styles/session.css` | The `.dc-*` session grammar |
15
+ | `@digithings-ai/digichat-ui/styles/cursor.css` | The caret and keyframe tokens |
16
+
17
+ ```tsx
18
+ import { DigiChatMark } from "@digithings-ai/digichat-ui";
19
+ import "@digithings-ai/digichat-ui/styles/session.css";
20
+ ```
21
+
22
+ [`ARCHITECTURE.md`](ARCHITECTURE.md) has the module map and the public API
23
+ contract.
24
+
25
+ ## Publishing
26
+
27
+ This package is published to npm as part of the digithings R0 release. Its
28
+ `exports` point at **TypeScript source** and raw CSS, not a build output, so the
29
+ published tarball is the same code the workspace consumes.
30
+
31
+ A Next.js consumer must therefore transpile it — add the package to
32
+ `transpilePackages` in `next.config.mjs`:
33
+
34
+ ```js
35
+ const nextConfig = {
36
+ transpilePackages: ["@digithings-ai/digichat-ui", "@digithings-ai/ui"],
37
+ };
38
+ ```
39
+
40
+ A bundler that already compiles TS (Vite, tsup, Bun) resolves the source
41
+ directly and needs no extra configuration. `react` and `react-dom` are peers.
42
+
43
+ Tests: `npm test --workspace @digithings-ai/digichat-ui`.
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@digithings-ai/digichat-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Shared digichat CSS, slash helpers, brand marks, and transcript markdown. digichat 2.0 session UI is the stock assistant-ui Thread in apps/digichat; parents iframe /embed; backends are digigraph | foundry.",
5
+ "license": "MIT",
6
+ "homepage": "https://digithings.ai",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/digithings-ai/digithings.git",
10
+ "directory": "packages/digichat-ui"
11
+ },
12
+ "type": "module",
13
+ "exports": {
14
+ ".": "./src/index.ts",
15
+ "./styles/session.css": "./src/styles/session.css",
16
+ "./styles/cursor.css": "./src/styles/cursor.css"
17
+ },
18
+ "files": [
19
+ "src",
20
+ "!src/**/*.test.ts",
21
+ "!src/**/*.test.tsx",
22
+ "README.md"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "test": "vitest run",
29
+ "lint": "eslint ."
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^19.2.4",
33
+ "react-dom": "^19.2.4"
34
+ },
35
+ "dependencies": {
36
+ "@digithings-ai/ui": "0.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^19.2.14",
40
+ "@types/react-dom": "^19.2.3",
41
+ "typescript": "^6.0.2",
42
+ "vitest": "^4.1.0"
43
+ }
44
+ }
@@ -0,0 +1,31 @@
1
+ export function DigiChatMark({ size = 18, title }: { size?: number; title?: string }) {
2
+ return (
3
+ <svg
4
+ viewBox="0 0 56 56"
5
+ width={size}
6
+ height={size}
7
+ fill="none"
8
+ role={title ? "img" : undefined}
9
+ aria-hidden={title ? undefined : true}
10
+ aria-label={title}
11
+ >
12
+ {title ? <title>{title}</title> : null}
13
+ <rect x="5" y="8" width="46" height="33" rx="10" stroke="currentColor" strokeWidth="2.6" />
14
+ <path
15
+ d="M17 41 L17 50 L28 41"
16
+ stroke="currentColor"
17
+ strokeWidth="2.6"
18
+ strokeLinecap="round"
19
+ strokeLinejoin="round"
20
+ />
21
+ <path
22
+ d="M16 18 L23 24.5 L16 31"
23
+ stroke="currentColor"
24
+ strokeWidth="2.6"
25
+ strokeLinecap="round"
26
+ strokeLinejoin="round"
27
+ />
28
+ <rect x="27" y="29" width="12" height="2.6" rx="1.3" fill="currentColor" />
29
+ </svg>
30
+ );
31
+ }
@@ -0,0 +1,62 @@
1
+ "use client";
2
+
3
+ import { IconButton } from "@digithings-ai/ui/ui";
4
+
5
+ import { MiniMarkdown } from "./MiniMarkdown";
6
+ import { readableSnippet, type VaultHitSummary } from "@digithings-ai/ui/chat/transcript";
7
+
8
+ function isHttpUrl(path: string): boolean {
9
+ return /^https?:\/\//i.test(path);
10
+ }
11
+
12
+ function isPdfPath(path: string): boolean {
13
+ return /\.pdf(\?|#|$)/i.test(path);
14
+ }
15
+
16
+ /**
17
+ * Side pane for an original document (#3419). Paths without an http(s) URL
18
+ * never become links — vault notes render from `body` loaded via get_note.
19
+ */
20
+ export function DocumentPane({
21
+ hit,
22
+ onClose,
23
+ }: {
24
+ hit: VaultHitSummary;
25
+ onClose: () => void;
26
+ }) {
27
+ const http = isHttpUrl(hit.path);
28
+ const pdf = http && isPdfPath(hit.path);
29
+ const markdown = hit.body?.trim() || "";
30
+ return (
31
+ <aside className="dc-doc-pane" aria-label="Document">
32
+ <header className="dc-doc-pane-head">
33
+ <strong className="dc-doc-pane-title">{hit.title}</strong>
34
+ <IconButton className="dc-doc-pane-close" onClick={onClose} aria-label="Close document">
35
+ ×
36
+ </IconButton>
37
+ </header>
38
+ {http ? (
39
+ <p className="dc-doc-pane-path">
40
+ <a href={hit.path} target="_blank" rel="noreferrer noopener">
41
+ Download
42
+ </a>
43
+ </p>
44
+ ) : hit.path && hit.path !== hit.title ? (
45
+ <p className="dc-doc-pane-path">{hit.path}</p>
46
+ ) : null}
47
+ {pdf ? (
48
+ <object data={hit.path} type="application/pdf" className="dc-doc-pane-frame" title={hit.title}>
49
+ <p>PDF preview is unavailable in this browser.</p>
50
+ </object>
51
+ ) : markdown ? (
52
+ <div className="dc-doc-pane-body">
53
+ <MiniMarkdown text={markdown} />
54
+ </div>
55
+ ) : hit.snippet ? (
56
+ <p className="dc-doc-pane-snippet">{readableSnippet(hit.snippet)}</p>
57
+ ) : (
58
+ <p className="dc-doc-pane-empty">No preview available.</p>
59
+ )}
60
+ </aside>
61
+ );
62
+ }
@@ -0,0 +1,9 @@
1
+ import { ChatMarkdown } from "@digithings-ai/ui";
2
+
3
+ /**
4
+ * Thin delegate to `@digithings-ai/ui` `ChatMarkdown` (`.chat-md`).
5
+ * An edit here lands on digichat `/embed` and digithings.ai/chat together.
6
+ */
7
+ export function MiniMarkdown({ text }: { text: string }) {
8
+ return <ChatMarkdown source={text} />;
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,91 @@
1
+ export { DigiChatMark } from "./components/DigiChatMark";
2
+ export { MiniMarkdown } from "./components/MiniMarkdown";
3
+ export { DocumentPane } from "./components/DocumentPane";
4
+ export {
5
+ toCanonRows,
6
+ outcomeMeta,
7
+ citationHits,
8
+ readableSnippet,
9
+ toolDisplayName,
10
+ stripFoundryCitationMarkers,
11
+ type CanonActivityRow,
12
+ } from "@digithings-ai/ui/chat/transcript";
13
+ export {
14
+ serializeAssistantMarkdown,
15
+ serializeThreadMarkdown,
16
+ copyMarkdownWithFallback,
17
+ downloadMarkdown,
18
+ downloadTextFile,
19
+ downloadPlainText,
20
+ downloadHtml,
21
+ markdownToPlainText,
22
+ markdownToHtmlDocument,
23
+ truncateForMailto,
24
+ buildMailtoUrl,
25
+ buildAnswerMailto,
26
+ buildThreadMailto,
27
+ openMailtoWithFallback,
28
+ printTranscriptWithFallback,
29
+ MAILTO_MAX_ENCODED_LEN,
30
+ MAILTO_TRUNCATION_NOTE,
31
+ type TranscriptTurn,
32
+ type TranscriptSource,
33
+ type CopyMarkdownResult,
34
+ type TruncateForMailtoResult,
35
+ type MailtoOpenResult,
36
+ type PrintTranscriptResult,
37
+ } from "@digithings-ai/ui/chat/transcript";
38
+ export {
39
+ parseSlashInput,
40
+ matchingSlashCommands,
41
+ slashHelpText,
42
+ nextPaletteIndex,
43
+ formatCliSettingLine,
44
+ isLangCode,
45
+ commandOpensPane,
46
+ menuIdForCommand,
47
+ paletteFrame,
48
+ paletteSurfaces,
49
+ applyPaletteFrame,
50
+ paneDraftForId,
51
+ optionDraft,
52
+ submenuRows,
53
+ SLASH_COMMANDS,
54
+ SLASH_CATEGORIES,
55
+ LANG_CODES,
56
+ LANG_LABELS,
57
+ LANG_CHOICES,
58
+ EFFORT_CODES,
59
+ EFFORT_CHOICES,
60
+ isEffortCode,
61
+ SEARCH_ENGINE_CODES,
62
+ SEARCH_ENGINE_CHOICES,
63
+ isSearchEngine,
64
+ VIEW_CODES,
65
+ VIEW_LABELS,
66
+ VIEW_CHOICES,
67
+ isViewCode,
68
+ THINKING_CODES,
69
+ THINKING_CHOICES,
70
+ isThinkingCode,
71
+ type SlashDef,
72
+ type SlashId,
73
+ type SlashCategory,
74
+ type SlashVisibility,
75
+ type PaletteFrame,
76
+ type PaletteKind,
77
+ type PaletteApply,
78
+ type SubmenuOption,
79
+ type CliSettingRow,
80
+ type LangCode,
81
+ type SearchEngineCode,
82
+ type ViewCode,
83
+ type ThinkingCode,
84
+ EXPORT_CHOICES,
85
+ } from "./slash-commands";
86
+ export type {
87
+ DigiChatActivity,
88
+ DigiChatController,
89
+ DigiChatMessage,
90
+ VaultHitSummary,
91
+ } from "@digithings-ai/ui/chat/transcript";