@opencode-ai/util 0.0.0-next-16592 → 0.0.0-next-16596

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.
@@ -0,0 +1,16 @@
1
+ export * as SessionTitleFallback from "./session-title-fallback.js";
2
+ interface Info {
3
+ readonly title?: string;
4
+ readonly parentID?: string;
5
+ readonly time: {
6
+ readonly created: number;
7
+ };
8
+ }
9
+ /** Supplies the timestamped title required by compatibility surfaces. */
10
+ export declare function withTimestampedFallback(info: Info): string;
11
+ /** Supplies a compact human label and collapses historical timestamped fallbacks. */
12
+ export declare function displayLabel(info: Pick<Info, "title" | "parentID">): string;
13
+ /** Recognizes missing and historical root or child fallback titles. */
14
+ export declare function isFallbackTitle(title?: string): boolean;
15
+ /** Recognizes a missing title or the exact root fallback for this session. */
16
+ export declare function isExactRootFallback(info: Pick<Info, "title" | "time">): boolean;
@@ -0,0 +1,23 @@
1
+ export * as SessionTitleFallback from "./session-title-fallback.js";
2
+ const pattern = /^(New session|Child session) - \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
3
+ /** Supplies the timestamped title required by compatibility surfaces. */
4
+ export function withTimestampedFallback(info) {
5
+ return info.title ?? fallback(info);
6
+ }
7
+ /** Supplies a compact human label and collapses historical timestamped fallbacks. */
8
+ export function displayLabel(info) {
9
+ if (!info.title)
10
+ return info.parentID ? "Child session" : "New session";
11
+ return info.title.match(pattern)?.[1] ?? info.title;
12
+ }
13
+ /** Recognizes missing and historical root or child fallback titles. */
14
+ export function isFallbackTitle(title) {
15
+ return title === undefined || pattern.test(title);
16
+ }
17
+ /** Recognizes a missing title or the exact root fallback for this session. */
18
+ export function isExactRootFallback(info) {
19
+ return info.title === undefined || info.title === fallback({ time: info.time });
20
+ }
21
+ function fallback(info) {
22
+ return `${info.parentID ? "Child" : "New"} session - ${new Date(info.time.created).toISOString()}`;
23
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/util",
4
- "version": "0.0.0-next-16592",
4
+ "version": "0.0.0-next-16596",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "scripts": {
36
36
  "build": "bun run script/build.ts",
37
+ "test": "bun test --only-failures",
37
38
  "typecheck": "tsgo --noEmit"
38
39
  },
39
40
  "dependencies": {