Skip to content

CLI: tsk edit --thread and --clear-thread - #308

Merged
smarzban merged 2 commits into
mainfrom
cli-edit-thread
Nov 17, 2026
Merged

smarzban merged 2 commits into
mainfrom
cli-edit-thread

Conversation

@smarzban

@smarzban smarzban commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Why

A thread could only be set when a task was created. Fixing it meant re-adding the task, which lost its number, steps and paper trail. The domain edit already carried the thread; only the CLI flag was missing.

What changed

  • tsk edit <task> --thread <name> sets or changes the thread (same name rules and refusal as tsk add --thread). --clear-thread clears it, matching edit's --clear-base / --clear-due / --clear-after.
  • Help, cli.md edit section, CONTEXT.md, llms.txt, CHANGELOG (Unreleased · Added).
  • tsk-cli skill: its refine rule said edit cannot change the thread. Rewritten, and both skills bumped 1.7.0 → 1.8.0 (the first skill edit since v0.14.0), with hash pins refreshed.

Scope

  • Covers: thread on an existing task from the CLI.
  • Leaves out: changing scope/project (still add-and-archive); the board already has a Thread field.

Done when

# Result Proved by Proof Step
1 --thread sets a thread on a task that has none; tsk list T1 shows #auth; paper trail records a thread edit agent smoke 1, cli_edit::edit_sets_changes_and_clears_the_thread_keeping_scope 5
2 --thread changes a set thread; --clear-thread clears it; scope unchanged agent smoke 1, same test 5
3 Invalid name and --thread with --clear-thread exit 2 without writing; a repeat writes nothing agent smoke 1, same test, parser::tests::edit_parses_thread_flags_by_the_thread_rules 5
4 Docs, help and the agent skill name the flags agent diff, cli_edit::edit_help_names_title_notes_and_equals_forms, setup_agent hash pins 4

Verification

Commit: c75907f (steps 1-3 rerun here; step 4 ran on 044403f, and the follow-up commit changes only help text, the skill, the hash pins and the test)

  1. cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test → exit 0, every suite test result: ok.
  2. cd site && npm run build && npm test → 64 pass, 0 fail.
  3. Regression: with next_thread reverted to found.thread in src/cli/edit.rs, the new integration test fails (left: None, right: Some("auth")); restored, it passes. The repeat check compares tsk.json bytes. With the no-change return disabled and the domain edit forced, it fails (a repeat writes nothing).
  4. Live CLI against an isolated TSK_STATE_DIR (debug binary of this commit):
    $ tsk edit T1 --thread Auth           → edited T1 Fix login timeout  (exit 0)  #auth
    $ tsk edit T1 --thread auth           → exit 0, no new paper trail entry
    $ tsk edit T1 --thread release        → exit 0  #release
    $ tsk edit T1 --thread bad_name       → tsk edit: invalid thread name · thread: use letters, numbers, hyphens, and dots  (exit 2)
    $ tsk edit T1 --thread x --clear-thread → tsk edit: --clear-thread cannot be used with --thread  (exit 2)
    $ tsk edit T1 --clear-thread          → exit 0, no thread
    $ tsk list T1                         → activity: thread edited ×3
    

Run any smoke with TSK_STATE_DIR set to a throwaway dir.

Could break

Only tsk edit parsing and the edit path. With no thread flag the stored thread passes through as before. tsk add's thread parsing now shares the same helper, with identical messages.

For the owner to decide

The flag spelling: --clear-thread matches edit's other --clear-* flags. tsk list uses --no-thread as a filter.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
herdr-tsk Ready Ready Preview Nov 17, 2026 6:15pm UTC

@smarzban

Copy link
Copy Markdown
Owner Author

Review panel · review

origin/main (9740f61) → 044403f
6/6 voted · 5 findings in 3 groups · 2m 7s · $1.1707
Seats: holistic (sol, opus), tests (sol, opus), specification-conformance (sol, opus), grouping (opus)

  • G-1 [medium, stated by a seat] Prove the repeated-thread edit leaves persisted state untouched
    • F-3 [medium] Prove the repeated-thread edit leaves persisted state untouched (tests/cli_edit.rs:349) — sol/tests
      Evidence: The repeat assertion counts only Edited events whose fields are exactly [Thread]. It still passes if a repeated edit writes the store, or appends an Edited event with no changed fields. Removing the early no-change return in src/cli/edit.rs::apply makes the repeat reach the successful changed=true return and persist again without increasing this counter. Thus acceptance (3)'s no-write guarantee remains unproved for CLI clients retrying tsk edit --thread. Fix this test by capturing the persisted state and complete history/revision before the repeat and asserting they remain unchanged afterward; use deterministic filesystem-write observation as well if identical-byte rewrites must be excluded, rather than sleeps or mtime-resolution assumptions.
    • F-4 [medium] "Repeat writes nothing" assertion passes even if a repeat edit writes a new event (tests/cli_edit.rs:349) — opus/tests
      Evidence: Acceptance (3) says repeating the same thread writes nothing. The test checks this with `thread_edits(&load()) == 1`, but `thread_edits` only counts `Edited` events whose `detail.fields == [EditedField::Thread]`. When the thread is unchanged, `edited_fields` (src/domain/task.rs:592) returns an empty list, so a no-op write would add an `Edited` event with `fields: []` and a new revision. The filter skips that event and the test still passes. Failure scenario: someone refactors the no-op guard in `src/cli/edit.rs::apply` (for example, `fields_changed` becomes true when `fields.thread.is_some()`, or the early return is dropped). `tsk edit T1 --thread auth` on a task already on `auth` then writes a new revision and an empty `Edited` event. `edit_sets_changes_and_clears_the_thread_keeping_scope` stays green, and users see a spurious edit in the paper trail. Fix: record `history.len()` and `revision` before the repeat call, and assert both are unchanged after it.
  • G-2 [low, stated by a seat] Update the edit help's claim that thread cannot change
    • F-1 [low] Update the edit help's claim that thread cannot change (src/cli/presenter.rs:2263) — sol/holistic
      Evidence: `tsk edit --help` still opens with “Scope and thread stay as they are,” and omits thread from its list of editable fields. This directly contradicts the newly added thread options and example. A user consulting command help to learn whether an existing task can change threads receives an incorrect answer. Include thread in the purpose text and say only that scope stays unchanged, as the CLI docs now do.
    • F-5 [low] `edit --help` purpose line still says the thread can't be changed (src/cli/presenter.rs:2264) — opus/specification-conformance
      Evidence: Acceptance item (4) requires `edit --help` to document the new behaviour. The diff adds `--thread` and `--clear-thread` rows to the options table, but the purpose line in `edit_help()` was not updated. It still reads: "Change a task's title, notes, assignee, dispatch base, due date, the tasks it runs after, or who its open block or review waits on. Scope and thread stay as they are." Failure scenario: someone runs `tsk edit --help`. The opening sentence omits thread from the editable fields and says it stays as it is. The options table below lists `--thread <name>` as "set or change the thread". The help contradicts itself and the updated cli.md, which now reads "Scope stays as it is." Fix: add thread to the list and change the closing sentence to "Scope stays as it is."
  • G-3 / F-2 [low] Shipped tsk-cli agent skill still says `edit` cannot change thread (skills/tsk-cli/SKILL.md:187) — opus/holistic
    Evidence: This change adds `tsk edit --thread` / `--clear-thread` and updates cli.md, CONTEXT.md, llms.txt and the edit help. skills/tsk-cli/SKILL.md:187 still says: "`edit` cannot change scope or thread: for a scope change re-add in the right scope and archive the stray". `tsk setup` installs this skill, so agents that follow it will tell users a thread can't be changed in place, or skip `--thread` when putting an existing task on a thread. They will never use the new flag. Fix: change the line to "`edit` cannot change scope". Under AGENTS.md's 'Agent skill version' rule, also bump the version of both skills (tsk-cli and tsk-coordinator) if it hasn't moved since the last release, and refresh the hash pin in src/setup_agent.rs so installed copies update.

@smarzban
smarzban merged commit 2aaf705 into main Nov 17, 2026
10 checks passed
@smarzban
smarzban deleted the cli-edit-thread branch November 17, 2026 18:34
@smarzban smarzban mentioned this pull request Nov 17, 2026

This branch was successfully deployed

1 active deployment
Preview — c75907f4 Deployed Nov 17, 2026 by vercel[bot]
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.

1 participant