Skip to content

Conversation

@dluc
Copy link
Collaborator

@dluc dluc commented Dec 1, 2025

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):

{
  "id": "sh7lxf0xxkyekj70632czg2c",
  "content": "Call pediatrician for flu shot appointment",
  "mimeType": "text/plain",
  "byteSize": 42,
  ...
}

After (get command):

{
  "id": "sh7lxf0xxkyekj70632czg2c",
  "node": "personal",
  "content": "Call pediatrician for flu shot appointment",
  "mimeType": "text/plain",
  "byteSize": 42,
  ...
}

Before (list command):

{
  "items": [
    {
      "id": "sh7lxf0xxkyekj70632czg2c",
      "content": "...",
      ...
    }
  ],
  "pagination": {...}
}

After (list command):

{
  "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.

dluc and others added 2 commits December 1, 2025 16:06
Add node ID to the JSON/YAML responses of both get and list commands to inform users which node was used for the operation.

Changes:
- Modified GetCommand to include node.Id in response output
- Modified ListCommand to include node.Id in each item's response
- Both commands now show: {id, node, content, mimeType, byteSize, ...}
- All 301 tests pass with 81.99% coverage

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <[email protected]>
@dluc dluc merged commit 2e2516f into microsoft:main Dec 1, 2025
3 checks passed
@dluc dluc deleted the add-node-to-get-list branch December 1, 2025 17:26
dluc added a commit to dluc/kernel-memory that referenced this pull request Dec 1, 2025
Fixes broken human format output caused by microsoft#1100 which wrapped ContentDto
in anonymous objects, breaking HumanOutputFormatter's type checking. Also
simplifies human format by hiding technical details (mimeType, size, dates)
in normal mode, showing only essential information.

Changes:
- Created ContentDtoWithNode wrapper class instead of anonymous objects
- Updated HumanOutputFormatter to handle ContentDtoWithNode
- Moved node field before ID in both get and list displays
- Moved mimeType, size, and dates to verbose mode only
- Human format now shows: Node, ID, Content (+ Title, Description, Tags if present)

All 301 tests pass, 0 skipped, coverage 80.14%
dluc added a commit that referenced this pull request Dec 1, 2025
)

## Summary

Fixes broken human format output in `km get` and `km list` commands
caused by #1100, which wrapped ContentDto objects in anonymous types
that broke HumanOutputFormatter's type checking. This PR restores the
table display functionality and improves the human format by:

- Creating a proper `ContentDtoWithNode` wrapper class instead of using
anonymous objects
- Repositioning node field before ID for better visibility
- Simplifying human format output by moving technical details (mimeType,
size, dates) to verbose mode only

**Before:** Human format was broken (displayed as JSON instead of
tables)
**After:** Clean tables showing only essential information: Node, ID,
Content, Title, Description, Tags

## Changes

- **New file:** `src/Core/Storage/Models/ContentDtoWithNode.cs` - Proper
wrapper class for content with node information
- **Modified:** `src/Main/CLI/Commands/GetCommand.cs` - Uses
`ContentDtoWithNode.FromContentDto()` instead of anonymous object
- **Modified:** `src/Main/CLI/Commands/ListCommand.cs` - Uses
`ContentDtoWithNode.FromContentDto()` for list items
- **Modified:** `src/Main/CLI/OutputFormatters/HumanOutputFormatter.cs`
- Added `FormatContentWithNode()` and `FormatContentWithNodeList()`
methods

### Human Format Display

**km get (normal mode):**
- Node
- ID
- Content
- Title (if present)
- Description (if present)
- Tags (if present)

**km get (verbose mode adds):**
- MimeType, Size, ContentCreatedAt, RecordCreatedAt, RecordUpdatedAt,
Metadata

**km list (normal mode):**
| Node | ID | Content Preview |

## Test Plan

- [x] All 301 tests pass, 0 skipped
- [x] Code coverage: 80.14% (exceeds 80% threshold)
- [x] Build: 0 warnings, 0 errors
- [x] Formatting: Clean
- [x] Manual testing: `km get` displays table with node information
- [x] Manual testing: `km list` displays table with node column
- [x] JSON/YAML formats still include all fields including node

## Stats

- **Files changed:** 5
- **Lines added:** 179
- **Lines removed:** 36
- **New classes:** 1 (`ContentDtoWithNode`)

## Breaking Changes

None - this is a bug fix that restores expected functionality and
improves UX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant