Skip to content

Commit 067cffb

Browse files
CopilotShlomoStept
andcommitted
Add comprehensive schema analysis report and update documentation
- Merge copilot/analyze-repository-core-flows branch with PR #7 docs - Create SCHEMA_ANALYSIS_REPORT.md with consolidated schema definitions - Update ARCHITECTURE_SUMMARY.md with complete SessionLogEntry schema - Update ARCHITECTURE_ANALYSIS.md with sub-agent support clarification - Add Task, TaskOutput, Read, Glob, Grep tool input schemas - Add signature field to ThinkingBlock schema - Expand entry types to include queue-operation and file-history-snapshot - Update docs README with new document and version history Co-authored-by: ShlomoStept <74121686+ShlomoStept@users.noreply.github.com>
1 parent eccd6a9 commit 067cffb

File tree

4 files changed

+942
-51
lines changed

4 files changed

+942
-51
lines changed

docs/ARCHITECTURE_ANALYSIS.md

Lines changed: 140 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,29 @@ Generate HTML Files
392392

393393
## 2. Connecting the Main Agent to Sub-Agent Activity
394394

395-
### 2.1 Current State: No Sub-Agent Tracking
395+
### 2.1 Current State: Sub-Agent Format Supported, Discovery Disabled
396396

397-
**Important Finding:** The current codebase does **not** have explicit sub-agent tracking or hierarchical agent relationships.
397+
> **Update (2026-01-02):** Analysis of Claude Code artifacts reveals that sub-agent fields exist in the format. See [SCHEMA_ANALYSIS_REPORT.md](./SCHEMA_ANALYSIS_REPORT.md) for complete details.
398398
399-
**Evidence:**
400-
1. Session filtering explicitly excludes agent files:
401-
```python
402-
# Line 359 in find_local_sessions()
403-
if f.name.startswith("agent-"):
404-
continue
405-
```
399+
**Finding:** The artifact format **does support** sub-agent tracking via:
400+
- `agentId` field in session entries
401+
- `Task` tool for sub-agent invocation
402+
- `TaskOutput` tool for sub-agent result retrieval
403+
- `resume` parameter for resuming sub-agent context
406404

407-
2. No agent ID or parent-child relationships in message schemas
405+
**Current Limitation:**
406+
The discovery code excludes agent files from listing:
407+
```python
408+
# Line 359 in find_local_sessions()
409+
if f.name.startswith("agent-"):
410+
continue
411+
```
408412

409-
3. All messages treated as single-agent conversation
413+
**To Enable Sub-Agent Support:**
414+
1. Add `--include-agents` flag to discovery functions
415+
2. Parse `agentId` field from session entries
416+
3. Link conversations via `parentUuid` relationship
417+
4. Add specialized renderer for `Task` tool
410418

411419
### 2.2 Tool Call and Tool Response Linking
412420

@@ -624,12 +632,30 @@ interface NormalizedJSONLSession {
624632

625633
### 3.3 LogLine Schema
626634

635+
> **Note:** The complete, all-inclusive schema has been documented in [SCHEMA_ANALYSIS_REPORT.md](./SCHEMA_ANALYSIS_REPORT.md). The schema below represents the normalized parsing output, while the full artifact format includes additional fields.
636+
627637
```typescript
628638
interface LogLine {
629-
type: "user" | "assistant";
639+
// Core Identifiers (from raw artifacts)
640+
uuid?: string; // Unique event identifier
641+
parentUuid?: string | null; // Linked-list parent pointer
642+
sessionId?: string; // Session grouping ID
643+
644+
// Entry Type (expanded)
645+
type: "user" | "assistant" | "queue-operation" | "file-history-snapshot";
646+
630647
timestamp: string; // ISO 8601 format, e.g., "2025-12-24T10:00:00.000Z"
631648
message: Message;
632-
isCompactSummary?: boolean; // Optional, indicates session continuation
649+
650+
// Context Fields (optional)
651+
cwd?: string; // Current working directory
652+
gitBranch?: string; // Active git branch
653+
userType?: "external"; // User type indicator
654+
isSidechain?: boolean; // Parallel conversation flag
655+
agentId?: string; // Sub-agent identifier
656+
slug?: string; // Human-readable session ID
657+
658+
isCompactSummary?: boolean; // Session continuation indicator
633659
}
634660
```
635661

@@ -639,8 +665,11 @@ interface LogLine {
639665

640666
**Field Details:**
641667

642-
- **`type`**: Role of the message sender
643-
- Values: `"user"` | `"assistant"`
668+
- **`type`**: Entry type
669+
- Values: `"user"` | `"assistant"` | `"queue-operation"` | `"file-history-snapshot"`
670+
- `user`/`assistant`: Standard message entries
671+
- `queue-operation`: Background task queue operations
672+
- `file-history-snapshot`: File backup state at message time
644673
- Determines rendering style and icon
645674

646675
- **`timestamp`**: When the message was created
@@ -650,6 +679,11 @@ interface LogLine {
650679

651680
- **`message`**: The actual message content (see Message schema)
652681

682+
- **`agentId`**: Sub-agent identifier
683+
- Type: string (optional)
684+
- Present when message is from a sub-agent
685+
- Can be used to link sub-agent sessions
686+
653687
- **`isCompactSummary`**: Indicates session continuation/resume
654688
- Type: boolean (optional)
655689
- When true: Rendered as collapsible summary
@@ -729,22 +763,26 @@ interface TextBlock extends BaseContentBlock {
729763
```typescript
730764
interface ThinkingBlock extends BaseContentBlock {
731765
type: "thinking";
732-
thinking: string; // Markdown-formatted internal reasoning
766+
thinking: string; // Markdown-formatted internal reasoning
767+
signature: string; // Cryptographic verification signature
733768
}
734769
```
735770

736771
**Example:**
737772
```json
738773
{
739774
"type": "thinking",
740-
"thinking": "The user wants a simple addition function. I should:\n1. Create the function\n2. Add a basic test"
775+
"thinking": "The user wants a simple addition function. I should:\n1. Create the function\n2. Add a basic test",
776+
"signature": "abc123..."
741777
}
742778
```
743779

744780
**Rendering:** Lines 946-948
745781
**Renderer:** `_macros.thinking(content_html)`
746782
**Styling:** Closed by default, yellow background
747783

784+
> **Note:** The `signature` field was discovered during artifact analysis (see [SCHEMA_ANALYSIS_REPORT.md](./SCHEMA_ANALYSIS_REPORT.md)).
785+
748786
---
749787

750788
#### 3.5.3 Tool Use Block
@@ -982,7 +1020,91 @@ interface TodoItem {
9821020

9831021
---
9841022

985-
#### 3.6.5 Generic Tool Input
1023+
#### 3.6.5 Task Tool Input (Sub-Agent Invocation)
1024+
1025+
> **Added (2026-01-02):** Documented based on artifact analysis. See [SCHEMA_ANALYSIS_REPORT.md](./SCHEMA_ANALYSIS_REPORT.md).
1026+
1027+
```typescript
1028+
interface TaskToolInput {
1029+
subagent_type: string; // e.g., "Explore", "Plan", "general-purpose", "structured-engineering-agent"
1030+
prompt: string; // Detailed instructions for the sub-agent
1031+
description: string; // Short human-readable summary
1032+
resume?: string; // Optional agentId to resume existing context
1033+
model?: string; // Optional model override (e.g., "opus")
1034+
run_in_background?: boolean; // Whether to run asynchronously
1035+
}
1036+
```
1037+
1038+
**Known `subagent_type` Values:**
1039+
- `"general-purpose"` - General task execution
1040+
- `"Explore"` - Code/file exploration
1041+
- `"Plan"` - Planning and strategy
1042+
- `"structured-engineering-agent"` - Complex engineering tasks
1043+
1044+
**Example:**
1045+
```json
1046+
{
1047+
"subagent_type": "Explore",
1048+
"prompt": "Find all Python files that contain database queries",
1049+
"description": "Finding database-related code",
1050+
"run_in_background": true
1051+
}
1052+
```
1053+
1054+
**Rendering:** Currently uses generic tool renderer
1055+
**Recommendation:** Add specialized renderer with sub-agent type highlighting
1056+
1057+
---
1058+
1059+
#### 3.6.6 TaskOutput Tool Input
1060+
1061+
```typescript
1062+
interface TaskOutputToolInput {
1063+
task_id: string; // ID of the Task to get output from
1064+
block: boolean; // Whether to block waiting for output
1065+
timeout: number; // Timeout in seconds
1066+
}
1067+
```
1068+
1069+
---
1070+
1071+
#### 3.6.7 Read Tool Input
1072+
1073+
```typescript
1074+
interface ReadToolInput {
1075+
file_path: string; // Path to file to read
1076+
offset?: number; // Starting line number
1077+
limit?: number; // Number of lines to read
1078+
}
1079+
```
1080+
1081+
---
1082+
1083+
#### 3.6.8 Glob Tool Input
1084+
1085+
```typescript
1086+
interface GlobToolInput {
1087+
pattern: string; // Glob pattern (e.g., "**/*.py")
1088+
path?: string; // Base directory path
1089+
}
1090+
```
1091+
1092+
---
1093+
1094+
#### 3.6.9 Grep Tool Input
1095+
1096+
```typescript
1097+
interface GrepToolInput {
1098+
pattern: string; // Search pattern (regex)
1099+
path: string; // Directory or file to search
1100+
output_mode?: string; // Output format mode
1101+
"-n"?: boolean; // Show line numbers
1102+
}
1103+
```
1104+
1105+
---
1106+
1107+
#### 3.6.10 Generic Tool Input
9861108
```typescript
9871109
interface GenericToolInput {
9881110
description?: string; // Optional description field
@@ -991,14 +1113,10 @@ interface GenericToolInput {
9911113
```
9921114

9931115
**Used For:** Tools without specialized renderers:
994-
- Glob
995-
- Grep
996-
- Read
9971116
- WebFetch
9981117
- WebSearch
9991118
- Agent
10001119
- Skill
1001-
- Task
10021120

10031121
**Rendering:** Lines 964-977
10041122
**Features:**

docs/ARCHITECTURE_SUMMARY.md

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,68 @@
4848
**Session (Normalized):**
4949
```typescript
5050
{
51-
loglines: [
52-
{
53-
type: "user" | "assistant",
54-
timestamp: string, // ISO 8601
55-
message: {
56-
role: string,
57-
content: string | ContentBlock[]
58-
},
59-
isCompactSummary?: boolean
60-
}
61-
]
51+
loglines: SessionLogEntry[]
52+
}
53+
54+
interface SessionLogEntry {
55+
// Core Identifiers
56+
uuid: string; // Unique event identifier
57+
parentUuid: string | null; // Linked-list parent pointer for ordering
58+
sessionId: string; // Conversation/session grouping ID
59+
60+
// Entry Type (expanded from user/assistant)
61+
type: "user" | "assistant" | "queue-operation" | "file-history-snapshot";
62+
63+
timestamp: string; // ISO 8601
64+
65+
// Context Fields (optional)
66+
cwd?: string; // Current working directory
67+
gitBranch?: string; // Active git branch
68+
userType?: "external"; // User type indicator
69+
isSidechain?: boolean; // Parallel/sidechain conversation flag
70+
agentId?: string; // Sub-agent identifier (e.g., "a85b54c")
71+
slug?: string; // Human-readable session identifier
72+
73+
// Message Payload (for user/assistant types)
74+
message?: {
75+
role: "user" | "assistant";
76+
content: ContentBlock[];
77+
model?: string; // e.g., "claude-opus-4-5-20251101"
78+
id?: string; // Message-specific ID
79+
};
80+
81+
// Snapshot Payload (for file-history-snapshot type)
82+
snapshot?: {
83+
messageId: string;
84+
trackedFileBackups: Record<string, any>;
85+
timestamp: string;
86+
};
87+
88+
// Queue Payload (for queue-operation type)
89+
operation?: "enqueue" | "remove";
90+
content?: string; // Queue item content
91+
92+
isCompactSummary?: boolean; // Session continuation indicator
6293
}
6394
```
6495

6596
**Content Blocks:**
66-
- `text` - Markdown text
67-
- `thinking` - Internal reasoning
68-
- `tool_use` - Tool invocation
69-
- `tool_result` - Tool output
70-
- `image` - Base64 image
71-
72-
**Tool Inputs:**
73-
- `Write`: `{file_path, content}`
74-
- `Edit`: `{file_path, old_string, new_string, replace_all?}`
75-
- `Bash`: `{command, description?}`
76-
- `TodoWrite`: `{todos: [{content, status, activeForm?}]}`
97+
- `text`: `{ type: "text", text: string }` - Markdown text
98+
- `thinking`: `{ type: "thinking", thinking: string, signature: string }` - Internal reasoning with verification signature
99+
- `tool_use`: `{ type: "tool_use", id: string, name: string, input: object }` - Tool invocation
100+
- `tool_result`: `{ type: "tool_result", tool_use_id: string, content: string | ContentBlock[], is_error?: boolean }` - Tool output
101+
- `image`: `{ type: "image", source: { type: "base64", media_type: string, data: string } }` - Base64 image
102+
103+
**Tool Inputs (Complete List):**
104+
- `Write`: `{ file_path: string, content: string }`
105+
- `Edit`: `{ file_path: string, old_string: string, new_string: string, replace_all?: boolean }`
106+
- `Bash`: `{ command: string, description?: string }`
107+
- `TodoWrite`: `{ todos: [{ content: string, status: "pending" | "in_progress" | "completed", activeForm?: string }] }`
108+
- `Task` (Sub-Agent): `{ subagent_type: string, prompt: string, description: string, resume?: string, model?: string, run_in_background?: boolean }`
109+
- `TaskOutput`: `{ task_id: string, block: boolean, timeout: number }`
110+
- `Read`: `{ file_path: string, offset?: number, limit?: number }`
111+
- `Glob`: `{ pattern: string, path?: string }`
112+
- `Grep`: `{ pattern: string, path: string, output_mode?: string, "-n"?: boolean }`
77113

78114
### Module Boundaries (Current Monolith)
79115

@@ -96,16 +132,18 @@ assets/ - CSS/JS
96132
- **Lines of Code:** 2994 (single file)
97133
- **Content Block Types:** 5 (text, thinking, tool_use, tool_result, image)
98134
- **Tool Renderers:** 4 specialized (Write, Edit, Bash, TodoWrite) + 1 generic
135+
- **Tool Input Types:** 9 documented (Write, Edit, Bash, TodoWrite, Task, TaskOutput, Read, Glob, Grep)
136+
- **Entry Types:** 4 (user, assistant, queue-operation, file-history-snapshot)
99137
- **Session Formats:** 2 (JSON, JSONL)
100138
- **CLI Commands:** 4 (local, web, json, all)
101139

102140
---
103141

104142
## Key Findings
105143

106-
1. **No Sub-Agent Support:** Current code explicitly excludes agent files
107-
2. **Schemas Implicit:** No formal definitions, inferred from code
108-
3. **Tool Pairing Works:** Reliable ID-based system
144+
1. **Sub-Agent Format Supported:** Artifacts include `agentId` field and `Task` tool for sub-agent tracking. Discovery code excludes `agent-*` files from listing, but the format fully supports sub-agents.
145+
2. **Schemas Now Documented:** Complete specifications including SessionLogEntry, Content Blocks, and 9 Tool Input types (see [SCHEMA_ANALYSIS_REPORT.md](./SCHEMA_ANALYSIS_REPORT.md))
146+
3. **Tool Pairing Works:** Reliable ID-based system (`tool_use.id``tool_result.tool_use_id`)
109147
4. **Componentization Needed:** Monolithic structure limits maintainability
110148

111149
## Next Steps

0 commit comments

Comments
 (0)