Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "analysis-workflow",
"version": "0.9.0",
"version": "0.9.1",
"description": "Conventions for analysis repos where humans and coding agents work side by side: versioned task directories for both, one session, worktree and PR per agent task; worktree-safe output paths; additive write-back to AnnData and SpatialData stores, which record which task wrote what. Ships a skill, guard hooks and the analysis_workflow Python package.",
"author": {
"name": "quadbio"
Expand Down
17 changes: 14 additions & 3 deletions src/analysis_workflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ def _version(directory: str, name: str) -> int | None:
return None


def new_task(path: Path, author: str, notebook: str | None = None, today: datetime.date | None = None) -> Path:
def new_task(
path: Path, author: str | None = None, notebook: str | None = None, today: datetime.date | None = None
) -> Path:
"""Create the task directory ``path`` from the task template; return it.

``path`` is ``analysis/<dataset>/<topic>/.../<lane>_<name>_vN``, relative to the working directory or absolute,
and ``vN`` must be the next version of ``<name>`` beside it, counted over both lanes, in this checkout and the
main one. ``notebook`` (``NN_<step>``) copies the repo's starter notebook into ``notebooks/``.
main one. ``author`` defaults, for a human's task, to the git user name; an agent's task names its model.
``notebook`` (``NN_<step>``) copies the repo's starter notebook into ``notebooks/``.
"""
path = Path(path).resolve()
checkout, main = _checkouts_of(path)
Expand All @@ -57,6 +60,12 @@ def new_task(path: Path, author: str, notebook: str | None = None, today: dateti
raise ValueError(f"{path.name!r} is not a task name: {form}.")
if path.exists():
raise FileExistsError(f"{path} already exists.")
if author is None and m["lane"] == "human":
author = subprocess.run(
["git", "-C", str(checkout), "config", "user.name"], capture_output=True, text=True
).stdout.strip()
if not author:
raise ValueError("Pass --author: the model for an agent's task, or a name where git has no `user.name`.")
parent = path.parent.relative_to(checkout)
found = [
v
Expand Down Expand Up @@ -95,7 +104,9 @@ def new_task(path: Path, author: str, notebook: str | None = None, today: dateti
@app.command("new")
def new(
path: Path = typer.Argument(..., help="analysis/<dataset>/<topic>/<human|agent>_<name>_v<N>"),
author: str = typer.Option(..., help="A human's initials, or the model, e.g. 'Claude Opus 5.5'."),
author: str | None = typer.Option(
None, help="A human's name or initials (default: the git user name), or the model, e.g. 'Claude Opus 5.5'."
),
notebook: str | None = typer.Option(None, help="Also copy the repo's starter notebook in, as NN_<step>."),
) -> None:
"""Start a task directory from the task template."""
Expand Down
2 changes: 1 addition & 1 deletion src/analysis_workflow/task_template/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# <task directory name, e.g. human_niches_v2>

**Date:** <YYYY-MM-DD, when the task started>
**Author:** <a human's initials, or the model, e.g. Claude Opus 5.5>
**Author:** <a human's name or initials, or the model, e.g. Claude Opus 5.5>
**Id:** <set by `analysis-workflow new`; shared stores record under it what this task wrote>

<!-- Every heading below stays, in this order, and no others are added; a section with nothing to say reads "None."
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ def test_new_task_counts_versions_in_the_main_checkout(repo):
assert new("analysis/ds/topic/agent_markers_v2", "--author", "x", cwd=worktree).exit_code == 0


def test_new_task_author_defaults_to_the_git_user_for_a_human_only(repo, git):
main, worktree = repo
git("config", "user.name", "Ada Lovelace", cwd=main)
assert new("analysis/ds/topic/human_markers_v1", cwd=main).exit_code == 0
readme = main / "analysis" / "ds" / "topic" / "human_markers_v1" / "README.md"
assert "**Author:** Ada Lovelace\n" in readme.read_text()
result = new("analysis/ds/topic/agent_markers_v2", cwd=worktree)
assert result.exit_code == 1 and "--author" in result.output


def test_new_task_needs_a_dataset_and_topic(repo):
main, _ = repo
assert "not of the form" in new("analysis/human_markers_v1", "--author", "ML", cwd=main).output
Expand Down
Loading