Skip to content

feat(typefully): add comment-thread CRUD and comment marker handling instructions for draft updates - #22

Merged
rajatkapoor merged 1 commit into
mainfrom
feat/typefully-comments-and-marker-flags
May 5, 2026
Merged

feat(typefully): add comment-thread CRUD and comment marker handling instructions for draft updates#22
rajatkapoor merged 1 commit into
mainfrom
feat/typefully-comments-and-marker-flags

Conversation

@rajatkapoor

Copy link
Copy Markdown
Collaborator

TL;DR

  • New comments:* subcommandslist, create, reply, resolve, update, delete give the CLI full parity with the API's per-draft comment-thread endpoints, so agents can read and write reviewer feedback directly.
  • Two new marker-handling flags on drafts:get / drafts:update--exclude-comment-markers renders posts[*].text without <typ:comment-thread> markers (display-only), and --force-overwrite-comments deliberately drops threads on PATCH when the submitted text doesn't carry their markers.
  • Strong agent guidance in SKILL.md so comments behave well: preserve every marker on PATCH, never resolve/delete a thread without explicit user instruction, after addressing a comment ask the user before resolving, and treat --force-overwrite-comments as a strict last resort. Self-closing markers are explicitly documented as paragraph anchors (not "empty" or "resolved" comments). Includes prose guidance to talk to users about comments, not the underlying marker tags.
  • New teststests/comments.test.js covers all six new subcommands (success paths, missing-positional errors, query/body shape). tests/drafts.test.js adds four cases for the new marker flags (--exclude-comment-markers query string on GET/PATCH, --force-overwrite-comments alone vs. combined with --text).
  • Changelog entry under Unreleased > Added documenting the new commands and flags for end users.

What's new

CLI (skills/typefully/scripts/typefully.js)

  • comments:list <draft_id> — paginates comment-threads with optional --platform, --status, --limit, --offset.
  • comments:create <draft_id> — creates a thread anchored on --selected-text at --post-index, with optional --platform / --occurrence.
  • comments:reply <draft_id> <thread_id> — posts a reply on an existing thread.
  • comments:resolve <draft_id> <thread_id> — resolves a thread (only after explicit user authorization, per skill guidance).
  • comments:update <draft_id> <thread_id> <comment_id> — author-only edit of a comment's text.
  • comments:delete <draft_id> <thread_id> [comment_id] — deletes either a single comment or the whole thread.
  • drafts:get --exclude-comment-markers and drafts:update --exclude-comment-markers — render markers out of the response (display only; the response is not safe to PATCH back).
  • drafts:update --force-overwrite-comments — sets force_overwrite_comments: true on the PATCH body so missing markers no longer trigger 409 COMMENTS_MARKER_MISMATCH. Skill guidance treats this as a last resort.
  • New helpers: requireDraftIdPositional, requireThreadPositional, requireCommentPositional for consistent positional-argument error messages with usage hints.

Skill (skills/typefully/SKILL.md)

Reorganized "Comments on Drafts" into a single coherent flow, putting the mental model and core safety rules first:

  1. Mental model — what markers are, span vs. self-closing/zero-width, with an explicit callout that self-closing markers anchor to the whole following paragraph and are not "empty" or "resolved" comments.
  2. Core rules (3, numbered) — preserve every marker on PATCH; never resolve/delete without explicit user instruction; talk about comments, not markers.
  3. Default edit workflow — GET → modify keeping markers → PATCH → ask the user, per addressed comment, whether to resolve.
  4. Resolving and deleting: the ask-first rule — full list of "even when…" cases that do not authorize a resolve/delete.
  5. Commands + technical notes (codepoint-equal selected_text, --occurrence, LinkedIn mention indivisibility, multi-platform --platform requirement, author-only comments:update).
  6. Marker-handling flags--exclude-comment-markers (display only) and --force-overwrite-comments (last resort with three explicit acceptable conditions).
  7. How to talk about comments to the user — bad/good example pair so agents report "X post Add update instructions to Typefully skill #2 has 3 comments — one on …" instead of describing marker tag occurrences.
  8. Quick reference table.

Changelog (skills/typefully/CHANGELOG.md)

Added entry under Unreleased > Added covering the new commands and flags.

Testing

  • npx vitest run tests/comments.test.js tests/drafts.test.js — 61 tests pass (16 new comment-command tests + 4 new marker-flag tests + existing drafts coverage).
  • All tests run against a hermetic local mock HTTP server (no network, no real Typefully API calls).

Notes

  • No production-API behavior changes — only CLI commands, flags, and skill guidance.
  • --force-overwrite-comments is intentionally surfaced but documented as a last resort to avoid accidental loss of reviewer comments during agent-driven edits.

@rajatkapoor
rajatkapoor requested review from frankdilo and linuz90 May 5, 2026 08:05

@frankdilo frankdilo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall, left a couple minor comments

did not test the skill in actual use


comments:create <draft_id> [options] Create a new comment thread anchored on a span of a post
--social-set-id <id> Social set (uses default if omitted)
--post-index <n> Zero-based index of the post to anchor on (required)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if this might confuse LLMs on LinkedIn posts that only have 1 post/atom, worth to test manually with the skill and see if worth chaning

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. tried it and it made comment on the right word in the first shot

@rajatkapoor rajatkapoor May 5, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CleanShot 2026-05-05 at 13 46 48@2x

Comment thread skills/typefully/scripts/typefully.js Outdated

# PATCH a draft and accept that some stored threads weren't included in the submitted text;
# the dropped threads are resolved server-side
./typefully.js drafts:update 456 --text "Rewritten body" --force-overwrite-comments --use-default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does --use-defaults do here? not immediately clear

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is existing. It uses the social set that has been set as the default

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an escape hatch in all commands that allows you to skip passing the social set id

@rajatkapoor
rajatkapoor requested a review from frankdilo May 5, 2026 08:16
@rajatkapoor rajatkapoor changed the title feat(typefully): add comment-thread CRUD and marker-handling flags feat(typefully): add comment-thread CRUD and comment marker handling instructions for draft updates May 5, 2026

@linuz90 linuz90 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments

Comment thread skills/typefully/SKILL.md Outdated
---
name: typefully

## name: typefully

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajatkapoor why commenting this?CleanShot 2026-05-05 at 10.46.36@2x.png

Comment thread skills/typefully/SKILL.md
./scripts/typefully.js drafts:create --platform linkedin --text "Thanks @[Typefully](urn:li:organization:86779668) for the support."
```

## Comments on Drafts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section seems too big and verbose to me. The point of including a CLI in this skill is to avoid teaching LLMs about the underlying API, or at least not extensively. I'm pretty confident this part could be half as long and still achieve the same goal of enabling agents to handle comments with the skill.

Adds six `comments:*` subcommands (list, create, reply, resolve, update,
delete) for managing per-draft comment threads, plus
`--exclude-comment-markers` on `drafts:get`/`drafts:update` for marker-free
display rendering and `--force-overwrite-comments` on `drafts:update` to
intentionally drop threads when submitting text without their markers.

Includes a new `tests/comments.test.js` covering all six commands and four
new `drafts.test.js` cases exercising the marker-handling flags.
@rajatkapoor
rajatkapoor force-pushed the feat/typefully-comments-and-marker-flags branch from 62aebaf to 5cc4445 Compare May 5, 2026 12:00
@rajatkapoor
rajatkapoor merged commit e05cb7b into main May 5, 2026
2 checks passed
@rajatkapoor
rajatkapoor deleted the feat/typefully-comments-and-marker-flags branch May 5, 2026 12:05
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.

3 participants