Skip to content

Task 0.1.4: CLI Context Management (attach, detach) #92

@bordumb

Description

@bordumb

Task 0.1.4: CLI Context Management (attach, detach)

Title: Implement dataset context attachment for CLI sessions

Description:
The CLI should maintain a "current context" (attached dataset) that persists across commands within a session. This enables workflows like: attach to orders table → ask questions → see lineage → export results.

Why: Without context, every command requires repeating dataset identifiers. Context management makes the CLI feel like a proper development environment.

Acceptance Criteria:

  • dataing ds attach <dataset_id> sets current context
  • dataing ds attach <urn> resolves URN to dataset
  • dataing ds attach --sql "SELECT..." --datasource <id> attaches from SQL
  • dataing ds detach clears context
  • dataing ds current shows current context with details
  • Context persists in ~/.dataing/context.json
  • All investigation commands use current context if no explicit target
  • Context includes: dataset_id, datasource_id, URN, schema snapshot
  • --no-context flag on any command ignores saved context

Key Design Notes:

  • Context file is JSON with schema version for forward compatibility
  • URN resolution uses GET /api/v1/asset-instances/search
  • SQL attachment creates virtual context with inferred schema

Key APIs:

  • GET /api/v1/asset-instances/search (exists)
  • GET /api/v1/datasources/{id}/schema (exists)

Dependencies:

  • None (can be built independently)

Risks + Mitigations:

  • Risk: Stale context after schema changes → Mitigation: Warn if schema changed since attachment

Effort: S (2-3 days)

Designation: OSS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions