kind: llman.sdd.spec
name: "cursor-export"
purpose: "Describe Cursor export selection and output behavior (interactive and non-interactive)."
valid_scope[2]: src/,tests/
requirements[7]{req_id,title,statement}:
  r1,"Non-interactive database selection order","Non-interactive cursor export MUST honor `db_path` first, then `workspace_dir` resolution, then auto-discovery when neither is provided. Auto-discovery selects the latest workspace database, preferring a database that contains chat/composer data."
  r2,"Non-interactive selection defaults","When `composer_id` is provided, the export MUST target only that composer conversation; otherwise it MUST export all conversations from the resolved database."
  r3,Output mode validation,"`output_mode` MUST be one of `console`, `file`, or `single-file` (default `console`). Unsupported values MUST return an error instead of printing and continuing."
  r4,File output location rules,"File-based output modes MUST follow deterministic output locations and naming."
  r5,交互选择必须使用稳定对话标识符,交互式 cursor export MUST 将用户选择映射到稳定的对话标识符（例如：composer 使用 `composer_id`，传统聊天使用 `tab_id`）。导出结果 MUST 与被选择的标识符集合一致，而不是依赖展示 index。
  r6,搜索选择必须共享同一标识符空间,交互搜索结果 MUST 返回与主列表相同的稳定标识符。导出 MUST 将搜索选择与主列表选择以一致方式处理（可合并、可去重，不得混用不同 index 空间）。
  r7,交互导出不得加载未选中对话的完整内容,交互式 cursor export MUST 避免为未选中对话加载完整内容（尤其是 composer bubbles 等重数据），只为被选中项加载必要数据。
scenarios[11]{req_id,id,given,when,then}:
  r1,"db-path-provided","","`db_path` is set in non-interactive mode",the export uses that database path directly
  r1,"workspace-dir-provided","",`workspace_dir` is set and `db_path` is not provided,the export resolves the workspace to its database path and uses it
  r1,"no-overrides","",neither `db_path` nor `workspace_dir` is provided,"the export selects a database path via auto-discovery"
  r2,"composer-id-provided","","`composer_id` is set in non-interactive mode",the export writes only the matching composer conversation or returns an error if not found
  r2,"no-composer-id","","`composer_id` is not provided in non-interactive mode",the export writes all available conversations
  r3,"unsupported-output-mode","",`output_mode` is not one of the supported values,the command returns an error that is surfaced by the CLI entrypoint
  r4,"output-mode-single-file","","`output_mode` is `single-file`","the export writes to `output_file` if provided, otherwise defaults to `cursor_conversations.md`"
  r4,"output-mode-file","",`output_mode` is `file`,"the export writes into the `output_file` directory if provided, otherwise defaults to `./cursor_exports`"
  r5,排序展示不影响导出正确性,"",交互 UI 展示的是排序后的对话列表，用户选择了 A 与 B,即使底层存储顺序不同，导出也只包含 A 与 B
  r6,搜索选择导出正确,"",用户通过 “search more” 流程选择了若干对话,导出结果与搜索选择完全一致
  r7,大库仅选少量对话,"",workspace 中存在大量对话但用户只选择少量导出,导出仅为被选中对话加载完整内容
