File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { Plugin } from "@opencode-ai/plugin"
2- import type { Event , Part , Permission } from "@opencode-ai/sdk"
2+ import type { Event , Permission } from "@opencode-ai/sdk"
33
44import { buildPayload } from "./payload"
55import { warpNotify } from "./notify"
6+ import { truncate , extractTextFromParts } from "./utils"
67import pkg from "../package.json" with { type : "json" }
78
89const PLUGIN_VERSION = pkg . version
910const NOTIFICATION_TITLE = "warp://cli-agent"
1011
11- export function truncate ( str : string , maxLen : number ) : string {
12- if ( str . length <= maxLen ) return str
13- return str . slice ( 0 , maxLen - 3 ) + "..."
14- }
15-
16- export function extractTextFromParts ( parts : Part [ ] ) : string {
17- return parts
18- . filter ( ( p ) : p is Part & { type : "text" ; text : string } =>
19- p . type === "text" && "text" in p && Boolean ( p . text ) ,
20- )
21- . map ( ( p ) => p . text )
22- . join ( " " )
23- }
24-
2512function sendPermissionNotification ( perm : Permission , cwd : string ) : void {
2613 const sessionId = perm . sessionID
2714 const toolName = perm . type || "unknown"
Original file line number Diff line number Diff line change 1+ import type { Part } from "@opencode-ai/sdk"
2+
3+ export function truncate ( str : string , maxLen : number ) : string {
4+ if ( str . length <= maxLen ) return str
5+ return str . slice ( 0 , maxLen - 3 ) + "..."
6+ }
7+
8+ export function extractTextFromParts ( parts : Part [ ] ) : string {
9+ return parts
10+ . filter ( ( p ) : p is Part & { type : "text" ; text : string } =>
11+ p . type === "text" && "text" in p && Boolean ( p . text ) ,
12+ )
13+ . map ( ( p ) => p . text )
14+ . join ( " " )
15+ }
Original file line number Diff line number Diff line change 11import { describe , it } from "node:test"
22import assert from "node:assert/strict"
3- import { truncate , extractTextFromParts } from "../src/index "
3+ import { truncate , extractTextFromParts } from "../src/utils "
44import { buildPayload } from "../src/payload"
55
66describe ( "truncate" , ( ) => {
You can’t perform that action at this time.
0 commit comments