feat: Enhance CLI output handling with structured Intermediate Representation (IR)

- Introduced `CliOutputUnit` and `IOutputParser` interfaces for unified output processing.
- Implemented `PlainTextParser` and `JsonLinesParser` for parsing raw CLI output into structured units.
- Updated `executeCliTool` to utilize output parsers and handle structured output.
- Added `flattenOutputUnits` utility for extracting clean output from structured data.
- Enhanced `ConversationTurn` and `ExecutionRecord` interfaces to include structured output.
- Created comprehensive documentation for CLI Output Converter usage and integration.
- Improved error handling and type mapping for various output formats.
This commit is contained in:
catlog22
2026-01-08 17:26:40 +08:00
parent b86cdd6644
commit d0523684e5
22 changed files with 1618 additions and 111 deletions

View File

@@ -203,6 +203,168 @@
color: hsl(142 76% 36%);
}
/* Tool Tags - displayed in tool cards */
.tool-tags {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
margin-top: 0.25rem;
}
.tool-tag {
font-size: 0.5625rem;
font-weight: 500;
padding: 0.125rem 0.375rem;
background: hsl(var(--primary) / 0.1);
color: hsl(var(--primary));
border-radius: 0.25rem;
}
/* Tags Input - used in config modal */
.tags-input-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
/* Unified tag input - tags and input in one container */
.tags-unified-input {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.375rem;
min-height: 2.5rem;
padding: 0.375rem 0.5rem;
background: hsl(var(--background));
border: 1px solid hsl(var(--border));
border-radius: 0.5rem;
cursor: text;
transition: border-color 0.15s ease;
}
.tags-unified-input:focus-within {
border-color: hsl(var(--primary));
box-shadow: 0 0 0 2px hsl(var(--primary) / 0.1);
}
.tag-inline-input {
flex: 1;
min-width: 120px;
border: none;
background: transparent;
outline: none;
font-size: 0.8125rem;
color: hsl(var(--foreground));
padding: 0.25rem 0;
}
.tag-inline-input::placeholder {
color: hsl(var(--muted-foreground) / 0.6);
}
.tags-container {
display: flex;
flex-wrap: wrap;
gap: 0.375rem;
min-height: 1.75rem;
padding: 0.25rem;
background: hsl(var(--muted) / 0.3);
border-radius: 0.375rem;
}
.tag-item {
display: inline-flex;
align-items: center;
gap: 0.25rem;
font-size: 0.75rem;
font-weight: 500;
padding: 0.25rem 0.5rem;
background: hsl(var(--primary) / 0.15);
color: hsl(var(--primary));
border-radius: 0.25rem;
}
.tag-remove {
display: flex;
align-items: center;
justify-content: center;
width: 1rem;
height: 1rem;
padding: 0;
border: none;
background: transparent;
color: hsl(var(--primary) / 0.6);
cursor: pointer;
font-size: 0.875rem;
line-height: 1;
border-radius: 0.125rem;
}
.tag-remove:hover {
background: hsl(var(--destructive) / 0.2);
color: hsl(var(--destructive));
}
/* Predefined Tags Row - prominent quick add buttons */
.predefined-tags-row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.75rem;
}
.predefined-tag-btn {
display: inline-flex;
align-items: center;
gap: 0.375rem;
font-size: 0.75rem;
font-weight: 500;
padding: 0.375rem 0.625rem;
background: hsl(var(--muted));
color: hsl(var(--foreground));
border: 1px solid hsl(var(--border));
border-radius: 0.375rem;
cursor: pointer;
transition: all 0.15s ease;
}
.predefined-tag-btn:hover {
background: hsl(var(--primary) / 0.15);
color: hsl(var(--primary));
border-color: hsl(var(--primary) / 0.3);
}
.predefined-tag-btn i {
opacity: 0.7;
}
/* Legacy predefined tags */
.predefined-tags {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.375rem;
margin-top: 0.5rem;
}
.predefined-tag {
font-size: 0.6875rem;
font-weight: 500;
padding: 0.25rem 0.5rem;
background: hsl(var(--muted) / 0.5);
color: hsl(var(--muted-foreground));
border: 1px dashed hsl(var(--border));
border-radius: 0.25rem;
cursor: pointer;
transition: all 0.15s ease;
}
.predefined-tag:hover {
background: hsl(var(--primary) / 0.1);
color: hsl(var(--primary));
border-color: hsl(var(--primary) / 0.3);
}
.tool-item-right {
display: flex;
align-items: center;

View File

@@ -549,6 +549,77 @@
color: hsl(200 70% 70%);
}
/* ===== Backend ChunkType Badges (CliOutputUnit.type) ===== */
/* Thought/Thinking Message (from JSONL parser) */
.cli-stream-line.formatted.thought {
background: hsl(280 50% 20% / 0.3);
border-left: 3px solid hsl(280 70% 65%);
font-style: italic;
}
.cli-msg-badge.cli-msg-thought {
background: hsl(280 70% 65% / 0.2);
color: hsl(280 70% 75%);
}
/* Code Block Message */
.cli-stream-line.formatted.code {
background: hsl(220 40% 18% / 0.4);
border-left: 3px solid hsl(220 60% 55%);
font-family: var(--font-mono, 'Consolas', 'Monaco', 'Courier New', monospace);
}
.cli-msg-badge.cli-msg-code {
background: hsl(220 60% 55% / 0.25);
color: hsl(220 60% 70%);
}
/* File Diff Message */
.cli-stream-line.formatted.file_diff {
background: hsl(35 50% 18% / 0.4);
border-left: 3px solid hsl(35 80% 55%);
}
.cli-msg-badge.cli-msg-file_diff {
background: hsl(35 80% 55% / 0.25);
color: hsl(35 80% 65%);
}
/* Progress Message */
.cli-stream-line.formatted.progress {
background: hsl(190 40% 18% / 0.3);
border-left: 3px solid hsl(190 70% 50%);
}
.cli-msg-badge.cli-msg-progress {
background: hsl(190 70% 50% / 0.2);
color: hsl(190 70% 65%);
}
/* Metadata Message */
.cli-stream-line.formatted.metadata {
background: hsl(250 30% 18% / 0.3);
border-left: 3px solid hsl(250 50% 60%);
font-size: 0.85em;
}
.cli-msg-badge.cli-msg-metadata {
background: hsl(250 50% 60% / 0.2);
color: hsl(250 50% 75%);
}
/* Stderr Message (Error) */
.cli-stream-line.formatted.stderr {
background: hsl(0 50% 20% / 0.4);
border-left: 3px solid hsl(0 70% 55%);
}
.cli-msg-badge.cli-msg-stderr {
background: hsl(0 70% 55% / 0.25);
color: hsl(0 70% 70%);
}
/* Inline Code */
.cli-inline-code {
padding: 1px 5px;