@yahaha-studio/kichi-forwarder 0.0.1-alpha.45 → 0.0.1-alpha.46
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/index.ts +60 -14
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -106,6 +106,10 @@ type WorkspaceScreenState = {
|
|
|
106
106
|
currentFocus: string;
|
|
107
107
|
hint: string;
|
|
108
108
|
prompt: string;
|
|
109
|
+
title: string;
|
|
110
|
+
shellName: string;
|
|
111
|
+
cwdLabel: string;
|
|
112
|
+
modelLabel: string;
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
function createWorkspaceScreenState(): WorkspaceScreenState {
|
|
@@ -118,7 +122,43 @@ function createWorkspaceScreenState(): WorkspaceScreenState {
|
|
|
118
122
|
recentActivity: [],
|
|
119
123
|
currentFocus: "Waiting for the next thread to pick up.",
|
|
120
124
|
hint: "Low-noise live workspace view.",
|
|
121
|
-
prompt: "
|
|
125
|
+
prompt: "$ _",
|
|
126
|
+
title: "Workspace",
|
|
127
|
+
shellName: "agent",
|
|
128
|
+
cwdLabel: process.cwd(),
|
|
129
|
+
modelLabel: "model: unknown",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function normalizeShellToken(value: string): string {
|
|
134
|
+
const normalized = value
|
|
135
|
+
.trim()
|
|
136
|
+
.toLowerCase()
|
|
137
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
138
|
+
.replace(/^-+|-+$/g, "");
|
|
139
|
+
return normalized || "agent";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function parseIdentityNameFromWorkspace(workspaceRoot: string): string | null {
|
|
143
|
+
try {
|
|
144
|
+
const identityPath = path.join(workspaceRoot, "IDENTITY.md");
|
|
145
|
+
if (!fs.existsSync(identityPath)) return null;
|
|
146
|
+
const raw = fs.readFileSync(identityPath, "utf-8");
|
|
147
|
+
const match = raw.match(/^-\s*\*\*Name:\*\*\s*(.+)$/m);
|
|
148
|
+
const value = match?.[1]?.trim();
|
|
149
|
+
return value || null;
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function deriveWorkspaceIdentity(workspaceRoot: string): Pick<WorkspaceScreenState, "title" | "shellName" | "cwdLabel"> {
|
|
156
|
+
const identityName = parseIdentityNameFromWorkspace(workspaceRoot);
|
|
157
|
+
const titleBase = identityName || path.basename(workspaceRoot) || "workspace";
|
|
158
|
+
return {
|
|
159
|
+
title: `${titleBase} Workspace`,
|
|
160
|
+
shellName: normalizeShellToken(identityName || titleBase),
|
|
161
|
+
cwdLabel: workspaceRoot,
|
|
122
162
|
};
|
|
123
163
|
}
|
|
124
164
|
|
|
@@ -161,7 +201,7 @@ function pushActivity(line: string): void {
|
|
|
161
201
|
|
|
162
202
|
function renderWorkspaceScreen(): string {
|
|
163
203
|
const innerWidth = WORKSPACE_SCREEN_WIDTH - 2;
|
|
164
|
-
const topTitle = `${color(
|
|
204
|
+
const topTitle = `${color(` ${workspaceState.title} `, "bold")}${color("live session", "gray")}`;
|
|
165
205
|
const topLine = `╭─── ${topTitle}${"─".repeat(Math.max(0, innerWidth - 4 - visibleLength(topTitle)))}╮`;
|
|
166
206
|
const bottomLine = `╰${"─".repeat(innerWidth)}╯`;
|
|
167
207
|
|
|
@@ -191,8 +231,8 @@ function renderWorkspaceScreen(): string {
|
|
|
191
231
|
pushRow(`${color(" Hint", "cyan")}`);
|
|
192
232
|
pushRow(` ${truncatePlain(workspaceState.hint, innerWidth - 2)}`);
|
|
193
233
|
pushRow("");
|
|
194
|
-
pushRow(` ${color(
|
|
195
|
-
pushRow(` ${color(
|
|
234
|
+
pushRow(` ${color(workspaceState.modelLabel, "magenta")}`);
|
|
235
|
+
pushRow(` ${color(workspaceState.cwdLabel, "blue")}`);
|
|
196
236
|
pushRow(` ${color(`updated: ${workspaceState.updatedAtLabel}`, "gray")}`);
|
|
197
237
|
pushRow("");
|
|
198
238
|
|
|
@@ -202,7 +242,7 @@ function renderWorkspaceScreen(): string {
|
|
|
202
242
|
bottomLine,
|
|
203
243
|
"",
|
|
204
244
|
color("─".repeat(WORKSPACE_SCREEN_WIDTH), "gray"),
|
|
205
|
-
`${color(
|
|
245
|
+
`${color(workspaceState.shellName, "green")}:${color("~", "blue")} ${workspaceState.prompt}`,
|
|
206
246
|
].join("\n");
|
|
207
247
|
}
|
|
208
248
|
|
|
@@ -445,7 +485,7 @@ async function handleMessageReceivedHook(content: string): Promise<void> {
|
|
|
445
485
|
phase: "processing inbound message",
|
|
446
486
|
currentFocus: trimmed ? `User message: ${trimmed}` : "Reading the latest message.",
|
|
447
487
|
hint: "Inbound message updated the live workspace.",
|
|
448
|
-
prompt: "
|
|
488
|
+
prompt: "$ reading-message",
|
|
449
489
|
},
|
|
450
490
|
`received message: ${trimmed || "(empty)"}`,
|
|
451
491
|
);
|
|
@@ -462,7 +502,7 @@ function handleMessageSentHook(): void {
|
|
|
462
502
|
phase: "message delivered",
|
|
463
503
|
currentFocus: "Latest reply has been sent to the active chat.",
|
|
464
504
|
hint: "Workspace settles after delivery.",
|
|
465
|
-
prompt: "
|
|
505
|
+
prompt: "$ idle",
|
|
466
506
|
},
|
|
467
507
|
"sent assistant reply",
|
|
468
508
|
);
|
|
@@ -476,7 +516,7 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
476
516
|
phase: "building prompt",
|
|
477
517
|
currentFocus: "Preparing the next response from current session context.",
|
|
478
518
|
hint: "Prompt assembly is in progress.",
|
|
479
|
-
prompt: "
|
|
519
|
+
prompt: "$ build-prompt",
|
|
480
520
|
},
|
|
481
521
|
"building prompt context",
|
|
482
522
|
);
|
|
@@ -499,7 +539,8 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
499
539
|
phase: `llm input · ${event.model}`,
|
|
500
540
|
currentFocus: "Feeding the model the current thread and constraints.",
|
|
501
541
|
hint: `provider: ${event.provider} · images: ${event.imagesCount}`,
|
|
502
|
-
prompt: "
|
|
542
|
+
prompt: "$ llm-input",
|
|
543
|
+
modelLabel: `${event.provider}/${event.model}`,
|
|
503
544
|
},
|
|
504
545
|
`entered llm input: ${event.model}`,
|
|
505
546
|
);
|
|
@@ -512,7 +553,8 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
512
553
|
phase: `llm output · ${event.model}`,
|
|
513
554
|
currentFocus: "Shaping model output into the visible reply.",
|
|
514
555
|
hint: `assistant chunks: ${event.assistantTexts.length}`,
|
|
515
|
-
prompt: "
|
|
556
|
+
prompt: "$ draft-reply",
|
|
557
|
+
modelLabel: `${event.provider}/${event.model}`,
|
|
516
558
|
},
|
|
517
559
|
`received llm output: ${event.model}`,
|
|
518
560
|
);
|
|
@@ -525,7 +567,7 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
525
567
|
phase: `running ${event.toolName}`,
|
|
526
568
|
currentFocus: `Tool call in flight: ${event.toolName}`,
|
|
527
569
|
hint: `tool context: ${ctx.toolName}`,
|
|
528
|
-
prompt:
|
|
570
|
+
prompt: `$ tool ${event.toolName}`,
|
|
529
571
|
},
|
|
530
572
|
`tool start: ${event.toolName}`,
|
|
531
573
|
);
|
|
@@ -541,7 +583,7 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
541
583
|
phase: `tool finished ${event.toolName}`,
|
|
542
584
|
currentFocus: `Tool result returned from ${event.toolName}.`,
|
|
543
585
|
hint: event.error ? `tool error: ${event.error}` : `tool completed in ${event.durationMs ?? 0}ms`,
|
|
544
|
-
prompt:
|
|
586
|
+
prompt: `$ continue ${event.toolName}`,
|
|
545
587
|
},
|
|
546
588
|
event.error ? `tool error: ${event.toolName}` : `tool done: ${event.toolName}`,
|
|
547
589
|
);
|
|
@@ -563,7 +605,7 @@ function registerPluginHooks(api: OpenClawPluginApi): void {
|
|
|
563
605
|
phase: event.success ? "run complete" : "run failed",
|
|
564
606
|
currentFocus: event.success ? "Run complete. Waiting for the next thread." : `Run failed: ${event.error ?? "unknown error"}`,
|
|
565
607
|
hint: `duration: ${event.durationMs ?? 0}ms`,
|
|
566
|
-
prompt: event.success ? "
|
|
608
|
+
prompt: event.success ? "$ _" : "$ recover",
|
|
567
609
|
},
|
|
568
610
|
event.success ? "agent run complete" : "agent run failed",
|
|
569
611
|
);
|
|
@@ -828,7 +870,11 @@ const plugin = {
|
|
|
828
870
|
ctx.config.plugins?.entries?.["kichi-forwarder"]?.config,
|
|
829
871
|
) as KichiForwarderConfig;
|
|
830
872
|
service = new KichiForwarderService(cfg, api.logger);
|
|
831
|
-
|
|
873
|
+
const workspaceRoot = ctx.repoPath ?? "/Users/xiaoxinshi/.openclaw/workspace";
|
|
874
|
+
workspaceState = {
|
|
875
|
+
...createWorkspaceScreenState(),
|
|
876
|
+
...deriveWorkspaceIdentity(workspaceRoot),
|
|
877
|
+
};
|
|
832
878
|
workspaceState.channel = ctx.channelId ?? "unknown";
|
|
833
879
|
scheduleWorkspacePush();
|
|
834
880
|
return service.start();
|
package/package.json
CHANGED