Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Jan 3, 2026

Summary

This PR implements indented Links Notation format support as requested in #17. The new format provides a human-readable representation for displaying objects with key-value pairs.

New Format

The indented Links Notation format displays objects as:

<identifier>
  <key> "<value>"
  <key> "<value>"
  ...

Example:

6dcf4c1b-ff3f-482c-95ab-711ea7d1b019
  uuid "6dcf4c1b-ff3f-482c-95ab-711ea7d1b019"
  status "executed"
  command "echo test"
  exitCode "0"

Changes

  • JavaScript: Added formatIndented() and parseIndented() functions in format.js
  • Python: Added format_indented() and parse_indented() functions in new format.py module
  • Rust: Added format module with format_indented(), format_indented_ordered(), and parse_indented()
  • C#: Added Format class with FormatIndented(), FormatIndentedOrdered(), and ParseIndented()

Key Implementation Details

All parseIndented functions now use the links-notation library for parsing:

  • JavaScript: Uses Parser from links-notation
  • Python: Uses Parser from links_notation
  • Rust: Uses parse_lino_to_links from links_notation
  • C#: Uses Parser from Link.Foundation.Links.Notation

The parsing implementation:

  1. Adds colon after identifier if not present (converting to standard lino format)
  2. Filters empty lines to preserve indentation structure
  3. Extracts key-value pairs from the parsed Link structure

Value quoting uses links-notation compatible format:

  • Values containing double quotes are wrapped in single quotes: 'He said "hello"'
  • Values containing single quotes are wrapped in double quotes: "it's"
  • This ensures round-trip compatibility with the links-notation parser

API Reference

Language Format Function Parse Function
JavaScript formatIndented({ id, obj, indent }) parseIndented({ text })
Python format_indented(id, obj, indent) parse_indented(text)
Rust format::format_indented(id, &obj, indent) format::parse_indented(text)
C# Format.FormatIndented(id, obj, indent) Format.ParseIndented(text)

Test Results

  • JavaScript: 144 tests passing
  • Python: 71 tests passing (91% coverage)
  • Rust: 37 tests passing (32 unit + 5 doc tests)
  • C#: 86 tests passing

Version Bump

All packages bumped to version 0.2.0.

Test plan

  • Run JavaScript tests: cd js && npm test
  • Run Python tests: cd python && pytest tests/
  • Run Rust tests: cd rust && cargo test
  • Run C# tests: cd csharp && dotnet test
  • Verify roundtrip formatting/parsing works correctly
  • Verify quote escaping works as expected
  • Verify parseIndented uses links-notation for parsing in all languages

Closes #17

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #17
@konard konard self-assigned this Jan 3, 2026
konard and others added 6 commits January 3, 2026 23:51
Implements indented Links Notation format support as requested in #17.
The new format displays objects in a human-readable style:

<identifier>
  <key> "<value>"
  ...

Functions added:
- formatIndented({ id, obj, indent }) - Format object to indented style
- parseIndented({ text }) - Parse indented style back to object

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements indented Links Notation format support as requested in #17.
The new format displays objects in a human-readable style:

<identifier>
  <key> "<value>"
  ...

Functions added:
- format_indented(id, obj, indent) - Format object to indented style
- parse_indented(text) - Parse indented style back to (id, obj) tuple
- escape_reference(value) - Escape a reference for Links Notation
- unescape_reference(str) - Unescape a reference from Links Notation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements indented Links Notation format support as requested in #17.
The new format displays objects in a human-readable style:

<identifier>
  <key> "<value>"
  ...

Functions added in lino_objects_codec::format module:
- format_indented(id, obj, indent) - Format HashMap to indented style
- format_indented_ordered(id, pairs, indent) - Format with key order preserved
- parse_indented(text) - Parse indented style back to (id, HashMap)
- escape_reference(value) - Escape a reference for Links Notation
- unescape_reference(str) - Unescape a reference from Links Notation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements indented Links Notation format support as requested in #17.
The new format displays objects in a human-readable style:

<identifier>
  <key> "<value>"
  ...

Methods added in Lino.Objects.Codec.Format class:
- FormatIndented(id, obj, indent) - Format dictionary to indented style
- FormatIndentedOrdered(id, pairs, indent) - Format with key order preserved
- ParseIndented(text) - Parse indented style back to (id, Dictionary)
- EscapeReference(value) - Escape a reference for Links Notation
- UnescapeReference(str) - Unescape a reference from Links Notation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add examples and documentation for the new formatIndented and parseIndented
functions in JavaScript, Python, Rust, and C#.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New feature release including:
- formatIndented / parseIndented functions for human-readable object display
- escape_reference / unescape_reference utilities
- Comprehensive tests for all implementations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add indented Links Notation format support to lino-objects-codec Add indented Links Notation format support (#17) Jan 4, 2026
konard and others added 7 commits January 4, 2026 00:04
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Python:
- Fix mypy Optional[str] type error in parse_indented
- Fix ruff E712 comparison to True in experiment
- Fix ruff E402 import order in experiment

Rust:
- Remove redundant else block in escape_reference
- Add BuildHasher generic to format_indented for clippy
- Convert match to let-else pattern in parse_indented

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 4, 2026 00:20
@konard
Copy link
Member Author

konard commented Jan 4, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $18.513091 USD
  • Calculated by Anthropic: $12.868724 USD
  • Difference: $-5.644366 (-30.49%)
    📎 Log file uploaded as GitHub Gist (1882KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Jan 4, 2026

I want us to prefer using http://github.com/link-foundation/links-notation for any parsing, and if it has formatting that is not extensible or configurable enough for us to accomplish all required tasks in the code, we need to file issues about missing features or bugs in http://github.com/link-foundation/links-notation repository. As this library is more specific to objects, the links-notation library should be kept universal for any links, that are covered by the links theory https://habr.com/en/articles/895896

@konard konard marked this pull request as draft January 4, 2026 00:30
@konard
Copy link
Member Author

konard commented Jan 4, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-04T00:30:01.311Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

This commit addresses the review feedback requesting that parsing should
use the links-notation library instead of custom parsing logic.

Changes:
- JavaScript: parseIndented now uses links-notation Parser for parsing
- Python: parse_indented now uses links_notation.Parser for parsing
- Rust: parse_indented now uses links_notation::parse_lino_to_links
- C#: ParseIndented now uses Link.Foundation.Links.Notation.Parser

All implementations:
- Add colon to identifier if not present (standard lino format)
- Filter empty lines to preserve indentation structure
- Extract key-value pairs from parsed Link structure

Also updated value quoting strategy to use links-notation compatible format:
- Values containing double quotes are wrapped in single quotes
- Values containing single quotes are wrapped in double quotes
- This ensures round-trip compatibility with the links-notation parser

Added experiment scripts in experiments/ folder for testing and validation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard
Copy link
Member Author

konard commented Jan 4, 2026

I've addressed the feedback to use the links-notation library for parsing.

Changes made:

  • All parseIndented implementations (JavaScript, Python, Rust, C#) now use the links-notation parser
  • Updated value quoting to use links-notation compatible format (single quotes for values containing double quotes)
  • Added experiment scripts in experiments/ folder for testing and validation

The implementation:

  1. Converts input to standard lino format by adding colon after identifier
  2. Filters empty lines to preserve indentation structure
  3. Uses the respective language's links-notation parser
  4. Extracts key-value pairs from the parsed Link structure

All tests pass across all languages.

@konard konard marked this pull request as ready for review January 4, 2026 00:49
@konard
Copy link
Member Author

konard commented Jan 4, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $16.928608 USD
  • Calculated by Anthropic: $10.013252 USD
  • Difference: $-6.915356 (-40.85%)
    📎 Log file uploaded as GitHub Gist (1835KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Jan 4, 2026

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

M js/package-lock.json

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard
Copy link
Member Author

konard commented Jan 4, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $0.732972 USD
  • Calculated by Anthropic: $0.402383 USD
  • Difference: $-0.330589 (-45.10%)
    📎 Log file uploaded as GitHub Gist (1962KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 5ecc9f5 into main Jan 8, 2026
30 checks passed
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.

Add indented Links Notation format support to lino-objects-codec

2 participants