Skip to content

feat: add documents duplicate command for template instantiation (#40)#47

Merged
teslakoile merged 5 commits into
masterfrom
feat/issue-40-documents-duplicate
Apr 19, 2026
Merged

feat: add documents duplicate command for template instantiation (#40)#47
teslakoile merged 5 commits into
masterfrom
feat/issue-40-documents-duplicate

Conversation

@teslakoile

Copy link
Copy Markdown
Owner

Summary

Adds a new huly documents duplicate DOC_ID --title "..." subcommand that compresses the 4-5 step template-instantiation workflow (describe → save → create → set-file → re-parent) into a single command. Inherits the source's space and parent by default; --space or --parent override either.

Changes

  • src/huly_cli/commands/documents.py

    • Adds the duplicate Typer command. Internally composes existing CRUD: _find_document_by_id (source + re-fetch), _resolve_teamspace_by_name (only when --space is passed — branches cleanly to avoid resolving the already-ID source space), client.tx for the create, then the same create-content + update-tx path describe --set-file uses.
    • Extracts two small private helpers — _read_doc_markdown(client, doc) and _write_markdown_to_doc(client, auth, doc, md) — so both describe and duplicate share the inline-vs-blob read path and the create-content write path. describe --set now delegates to _write_markdown_to_doc.
    • No changes to client.py, markup.py, or output.py.
  • tests/test_issue_write_path.py

    • Seven CliRunner command-layer tests covering: inherited space+parent, --space override (teamspace name resolution), --parent override, --json full-record return, source-not-found error, missing --title (required option), and that the content copy path uses create_content (not set_content) against a brand-new empty doc.
    • Adds a narrow autouse fixture to reset the module-level JSON-mode flag between tests in this file (previously leaked from earlier --json tests).
  • README.md — adds documents duplicate to the example command block plus a one-paragraph note on inheritance behavior.

  • skills/huly-cli/SKILL.md — lists duplicate in the documents command surface and adds a short "clone the weekly template" agent workflow example.

Test plan

  • uv run pytest -x — 273 tests pass (7 new)
  • uv run ruff format . && uv run ruff check . — clean
  • Scope verified via git diff master --stat — only the four allowed files touched; no changes to client.py, markup.py, output.py, or unrelated command modules.
  • Behavior covered: default inheritance, both overrides, --json, not-found, missing-title, and that new-doc content is written through create_content (not set_content).

Closes #40

teslakoile and others added 5 commits April 19, 2026 21:07
Adds `huly documents duplicate DOC_ID --title "..."` which compresses the
four-to-five-step template-instantiation workflow (describe → save → create
→ set-file → re-parent) into a single command. Reuses existing CRUD and
content paths — `--space` / `--parent` override the source's inherited
space and parent respectively, `--json` returns the full new record.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ents-duplicate

# Conflicts:
#	skills/huly-cli/SKILL.md
…ents-duplicate

# Conflicts:
#	skills/huly-cli/SKILL.md
…ents-duplicate

# Conflicts:
#	README.md
#	skills/huly-cli/SKILL.md
#	src/huly_cli/commands/documents.py
@teslakoile teslakoile merged commit 55b13cd into master Apr 19, 2026
1 check 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.

documents: add duplicate command for template instantiation

1 participant