Skip to content

Commit 2e2516f

Browse files
feat: include node information in get and list command responses (#1100)
## Summary Enhances both the `get` and `list` commands to include node information in their JSON/YAML responses, allowing users to see which node was used for retrieving the content. **Before (get command):** ```json { "id": "sh7lxf0xxkyekj70632czg2c", "content": "Call pediatrician for flu shot appointment", "mimeType": "text/plain", "byteSize": 42, ... } ``` **After (get command):** ```json { "id": "sh7lxf0xxkyekj70632czg2c", "node": "personal", "content": "Call pediatrician for flu shot appointment", "mimeType": "text/plain", "byteSize": 42, ... } ``` **Before (list command):** ```json { "items": [ { "id": "sh7lxf0xxkyekj70632czg2c", "content": "...", ... } ], "pagination": {...} } ``` **After (list command):** ```json { "items": [ { "id": "sh7lxf0xxkyekj70632czg2c", "node": "personal", "content": "...", ... } ], "pagination": {...} } ``` ## Changes - Modified `GetCommand.cs` to wrap result with node information - Modified `ListCommand.cs` to wrap each item with node information - Node information is already available from the `Initialize()` method - Maintains all existing fields in the response ## Testing - ✅ All 301 tests pass (192 Main.Tests + 109 Core.Tests) - ✅ 0 skipped tests - ✅ Code coverage: 81.99% (exceeds 80% threshold) - ✅ Build: 0 warnings, 0 errors ## Stats - **Files changed:** 2 - **Lines added:** 36 - **Lines removed:** 2 - **Tests added:** 0 (existing tests validate behavior) ## Breaking Changes None - this is a backward-compatible enhancement that adds information to the response while maintaining all existing fields. Co-authored-by: Amplifier <[email protected]>
1 parent bdd7221 commit 2e2516f

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/Main/CLI/Commands/GetCommand.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,26 @@ public override async Task<int> ExecuteAsync(
6969
return Constants.ExitCodeUserError;
7070
}
7171

72+
// Wrap result with node information
73+
var response = new
74+
{
75+
id = result.Id,
76+
node = node.Id,
77+
content = result.Content,
78+
mimeType = result.MimeType,
79+
byteSize = result.ByteSize,
80+
contentCreatedAt = result.ContentCreatedAt,
81+
recordCreatedAt = result.RecordCreatedAt,
82+
recordUpdatedAt = result.RecordUpdatedAt,
83+
title = result.Title,
84+
description = result.Description,
85+
tags = result.Tags,
86+
metadata = result.Metadata
87+
};
88+
7289
// If --full flag is set, ensure verbose mode for human formatter
7390
// For JSON/YAML, all fields are always included
74-
formatter.Format(result);
91+
formatter.Format(response);
7592

7693
return Constants.ExitCodeSuccess;
7794
}

src/Main/CLI/Commands/ListCommand.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,25 @@ public override async Task<int> ExecuteAsync(
7474
// Get page of items
7575
var items = await service.ListAsync(settings.Skip, settings.Take, CancellationToken.None).ConfigureAwait(false);
7676

77+
// Wrap items with node information
78+
var itemsWithNode = items.Select(item => new
79+
{
80+
id = item.Id,
81+
node = node.Id,
82+
content = item.Content,
83+
mimeType = item.MimeType,
84+
byteSize = item.ByteSize,
85+
contentCreatedAt = item.ContentCreatedAt,
86+
recordCreatedAt = item.RecordCreatedAt,
87+
recordUpdatedAt = item.RecordUpdatedAt,
88+
title = item.Title,
89+
description = item.Description,
90+
tags = item.Tags,
91+
metadata = item.Metadata
92+
});
93+
7794
// Format list with pagination info
78-
formatter.FormatList(items, totalCount, settings.Skip, settings.Take);
95+
formatter.FormatList(itemsWithNode, totalCount, settings.Skip, settings.Take);
7996

8097
return Constants.ExitCodeSuccess;
8198
}

0 commit comments

Comments
 (0)