deepvista-cli 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. deepvista_cli-1.1.0/.release-please-manifest.json +3 -0
  2. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/CHANGELOG.md +14 -0
  3. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/PKG-INFO +1 -1
  4. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/agents.py +26 -45
  5. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/skill.py +38 -4
  6. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/tasks.py +157 -34
  7. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/resources/workflow_host_runtime.md +24 -6
  8. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/session_note.py +44 -3
  9. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  10. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/hooks/hooks.json +12 -0
  11. deepvista_cli-1.1.0/plugins/claude-code/scripts/deepvista-agent-sync.sh +42 -0
  12. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/pyproject.toml +1 -1
  13. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/skill.md +6 -5
  14. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/tasks.md +7 -6
  15. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_session_note_format.py +43 -0
  16. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_tasks_commands.py +57 -48
  17. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/uv.lock +1 -1
  18. deepvista_cli-1.0.0/.release-please-manifest.json +0 -3
  19. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.claude-plugin/marketplace.json +0 -0
  20. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.github/workflows/ci.yml +0 -0
  21. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.github/workflows/publish.yml +0 -0
  22. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.github/workflows/release-please.yml +0 -0
  23. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.gitignore +0 -0
  24. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/.pre-commit-config.yaml +0 -0
  25. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/CLAUDE.md +0 -0
  26. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/CONTRIBUTING.md +0 -0
  27. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/LICENSE +0 -0
  28. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/README.md +0 -0
  29. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/__init__.py +0 -0
  30. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/agent_catalog.py +0 -0
  31. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/auth/__init__.py +0 -0
  32. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/auth/callback_server.py +0 -0
  33. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/auth/login.py +0 -0
  34. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/auth/tokens.py +0 -0
  35. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/client/__init__.py +0 -0
  36. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/client/http.py +0 -0
  37. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/client/origin.py +0 -0
  38. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/__init__.py +0 -0
  39. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/auth.py +0 -0
  40. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/card.py +0 -0
  41. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/chat.py +0 -0
  42. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/config.py +0 -0
  43. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/lint.py +0 -0
  44. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/notes.py +0 -0
  45. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/project.py +0 -0
  46. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/schedule.py +0 -0
  47. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/session.py +0 -0
  48. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/commands/upgrade.py +0 -0
  49. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/config.py +0 -0
  50. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/main.py +0 -0
  51. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/output/__init__.py +0 -0
  52. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/output/formatter.py +0 -0
  53. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/resources/__init__.py +0 -0
  54. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/skill_catalog.py +0 -0
  55. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/deepvista_cli/workflow_doc.py +0 -0
  56. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/docs/assets/deepvista-banner.png +0 -0
  57. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/install.ps1 +0 -0
  58. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/install.sh +0 -0
  59. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/README.md +0 -0
  60. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/README.md +0 -0
  61. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/agents/.gitignore +0 -0
  62. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/commands/deepvista.md +0 -0
  63. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/commands/refresh-skills.md +0 -0
  64. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/scripts/deepvista-session-end.sh +0 -0
  65. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/scripts/deepvista-session-start.sh +0 -0
  66. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/scripts/deepvista-session-turn.sh +0 -0
  67. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/scripts/deepvista-skill-url.py +0 -0
  68. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/scripts/deepvista-sync.sh +0 -0
  69. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/skills/.gitignore +0 -0
  70. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/plugins/claude-code/skills/install-deepvista-cli/SKILL.md +0 -0
  71. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/release-please-config.json +0 -0
  72. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/scripts/check_plugin_version.py +0 -0
  73. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/SKILL.md +0 -0
  74. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/chat.md +0 -0
  75. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/lint.md +0 -0
  76. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/notes.md +0 -0
  77. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/openclaw.md +0 -0
  78. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/project.md +0 -0
  79. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/session.md +0 -0
  80. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/shared.md +0 -0
  81. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/skill-analyze-notes.md +0 -0
  82. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/skill-create-from-note.md +0 -0
  83. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/skill-import-files.md +0 -0
  84. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/skill-research-to-skill.md +0 -0
  85. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/deepvista/reference/vistabase-card.md +0 -0
  86. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/skills/dv-workflow/SKILL.md +0 -0
  87. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/__init__.py +0 -0
  88. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_agent_id_tagging.py +0 -0
  89. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_project_commands.py +0 -0
  90. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_skill_catalog.py +0 -0
  91. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_skill_commands.py +0 -0
  92. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/tests/test_workflow_doc_phases.py +0 -0
  93. {deepvista_cli-1.0.0 → deepvista_cli-1.1.0}/uninstall.sh +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "1.1.0"
3
+ }
@@ -37,6 +37,20 @@ users what's new between the version they have installed and the latest release.
37
37
  adopts a pre-existing server-side row instead of failing when the local
38
38
  file is missing.
39
39
 
40
+ ## [1.1.0](https://github.com/DeepVista-AI/deepvista-cli/compare/v1.0.0...v1.1.0) (2026-06-26)
41
+
42
+
43
+ ### Features
44
+
45
+ * **DV-1277:** clean session-card title + link task runs to their chat ([#169](https://github.com/DeepVista-AI/deepvista-cli/issues/169)) ([b4de0c7](https://github.com/DeepVista-AI/deepvista-cli/commit/b4de0c7435bf89f475a25443e80524ab1da8420a))
46
+ * **skill:** add phase need-input for :::dvNeedIntervention mermaid state ([#166](https://github.com/DeepVista-AI/deepvista-cli/issues/166)) ([ade6edf](https://github.com/DeepVista-AI/deepvista-cli/commit/ade6edf8a462199ce8b59119e7eb0d662ad94fc6))
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **DV-1357:** move agent heartbeat into the Claude Code plugin ([#174](https://github.com/DeepVista-AI/deepvista-cli/issues/174)) ([41c4339](https://github.com/DeepVista-AI/deepvista-cli/commit/41c43390afaab06c90c103c5526e44f3f3f35ad8))
52
+ * reconcile _ensure_agents_for_projects return type (pyright) ([#173](https://github.com/DeepVista-AI/deepvista-cli/issues/173)) ([c134e42](https://github.com/DeepVista-AI/deepvista-cli/commit/c134e42abc39325cf2814126be7d249ba667f464))
53
+
40
54
  ## [1.0.0](https://github.com/DeepVista-AI/deepvista-cli/compare/v0.6.0...v1.0.0) (2026-06-25)
41
55
 
42
56
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepvista-cli
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: CLI for DeepVista — chat, notes, skills, and memory from your terminal.
5
5
  Project-URL: Homepage, https://deepvista.ai
6
6
  Project-URL: Repository, https://github.com/DeepVista-AI/deepvista-cli
@@ -238,16 +238,29 @@ def _remove_agent_id(
238
238
 
239
239
 
240
240
  # ---------------------------------------------------------------------------
241
- # Hook installation — auto-install sync hooks into agent settings
241
+ # Hook migration — heartbeat is now delivered by the DeepVista plugin
242
242
  # ---------------------------------------------------------------------------
243
243
 
244
244
  _HOOK_MARKER = "agents sync"
245
245
 
246
246
 
247
- def _install_hooks(agent_type: str, profile: str) -> bool:
248
- """Install heartbeat hooks into agent settings. Returns True if hooks were added."""
247
+ def _migrate_legacy_hooks(agent_type: str) -> bool:
248
+ """Strip the legacy standalone heartbeat hook from agent settings.
249
+
250
+ The agent heartbeat is now owned by the DeepVista Claude Code plugin
251
+ (``plugins/claude-code`` → ``scripts/deepvista-agent-sync.sh``), which wraps
252
+ the ``agents sync`` call in the safe hook pattern (PATH export,
253
+ ``command -v`` guard, backgrounded, output redirected to a log, always
254
+ ``exit 0``). Earlier versions injected a *raw* ``deepvista agents sync`` Stop
255
+ hook straight into ``~/.claude/settings.json``; with no safety wrapper it
256
+ errored and exited non-zero on every Stop whenever DNS/auth failed, which
257
+ Claude Code surfaced as a looping "Stop hook feedback" (DV-1357).
258
+
259
+ Registering now removes that legacy hook so the plugin is the single source
260
+ of truth. Returns True if a legacy hook was removed.
261
+ """
249
262
  if agent_type == "claude-code":
250
- return _install_claude_code_hooks(profile)
263
+ return _uninstall_claude_code_hooks()
251
264
  # Other agent types can be added here
252
265
  return False
253
266
 
@@ -271,40 +284,6 @@ def _find_hook_command(entry: dict) -> str:
271
284
  return entry.get("command", "")
272
285
 
273
286
 
274
- def _install_claude_code_hooks(profile: str) -> bool:
275
- """Add Stop hook to ~/.claude/settings.json for heartbeat sync."""
276
- settings_path = _HOME / ".claude" / "settings.json"
277
-
278
- settings: dict = {}
279
- if settings_path.is_file():
280
- try:
281
- settings = _json.loads(settings_path.read_text(encoding="utf-8"))
282
- except (_json.JSONDecodeError, OSError):
283
- settings = {}
284
-
285
- hooks = settings.setdefault("hooks", {})
286
- stop_hooks = hooks.setdefault("Stop", [])
287
-
288
- # Check if already installed
289
- for entry in stop_hooks:
290
- if isinstance(entry, dict) and _HOOK_MARKER in _find_hook_command(entry):
291
- return False # Already installed
292
-
293
- profile_flag = f" --profile {profile}" if profile != "default" else ""
294
- sync_cmd = f"deepvista{profile_flag} agents sync --type claude-code --status online"
295
-
296
- stop_hooks.append(
297
- {
298
- "matcher": "",
299
- "hooks": [{"type": "command", "command": sync_cmd}],
300
- }
301
- )
302
-
303
- settings_path.parent.mkdir(parents=True, exist_ok=True)
304
- settings_path.write_text(_json.dumps(settings, indent=2) + "\n", encoding="utf-8")
305
- return True
306
-
307
-
308
287
  def _uninstall_claude_code_hooks() -> bool:
309
288
  """Remove DeepVista hooks from ~/.claude/settings.json."""
310
289
  settings_path = _HOME / ".claude" / "settings.json"
@@ -692,8 +671,7 @@ def _ensure_agent_registered(ctx: click.Context, agent_type: str) -> str:
692
671
  if not agent_id:
693
672
  output_error(1, "Auto-registration failed", error or "Unknown error")
694
673
  raise SystemExit(1)
695
- profile = ctx.obj.profile if hasattr(ctx.obj, "profile") else "default"
696
- _install_hooks(agent_type, profile)
674
+ _migrate_legacy_hooks(agent_type)
697
675
  return agent_id
698
676
 
699
677
 
@@ -810,7 +788,7 @@ def agents_register(
810
788
  "name": name,
811
789
  "agent_type": agent_type,
812
790
  "agent_role": agent_role,
813
- "would_install_hooks": _install_hooks.__doc__ and agent_type == "claude-code",
791
+ "would_migrate_legacy_hooks": agent_type == "claude-code",
814
792
  "config_snapshot": config,
815
793
  "profile": profile,
816
794
  },
@@ -838,10 +816,13 @@ def agents_register(
838
816
 
839
817
  _save_agent_id(agent_type, agent["id"], agent.get("agent_role", agent_role), agent.get("project_id"))
840
818
 
841
- # Auto-install heartbeat hooks
842
- profile = ctx.obj.profile if hasattr(ctx.obj, "profile") else "default"
843
- if _install_hooks(agent_type, profile):
844
- click.echo(_json.dumps({"hooks": "installed Stop hook for heartbeat sync"}), err=True)
819
+ # Heartbeat is now delivered by the DeepVista plugin; strip any legacy
820
+ # standalone hook a prior CLI version injected into settings.json (DV-1357).
821
+ if _migrate_legacy_hooks(agent_type):
822
+ click.echo(
823
+ _json.dumps({"hooks": "removed legacy standalone heartbeat hook (now provided by the DeepVista plugin)"}),
824
+ err=True,
825
+ )
845
826
 
846
827
  # Initial sync — set online immediately so dashboard shows green
847
828
  _client(ctx).post(
@@ -547,14 +547,17 @@ def skill_phase_reset(ctx: click.Context, skill_id: str, phase_label: str, dry_r
547
547
  @click.option("--reason", required=True, help="Short sentence explaining what's blocking the run.")
548
548
  @click.pass_context
549
549
  def skill_phase_pause(ctx: click.Context, skill_id: str, reason: str) -> None:
550
- """Pause the run (lock held). Exits non-zero so wrapping scripts notice.
550
+ """Pause the run (lock held), marking the active phase ``:::dvNeedIntervention``.
551
551
 
552
- Does NOT change the card's ``status`` — the run lock stays held so a
553
- re-run resumes the same phase. The user resumes by re-invoking
554
- ``deepvista skill run --mode host <skill_id>``.
552
+ Sets the active phase's mermaid node to ``:::dvNeedIntervention`` so the
553
+ DeepVista UI shows the workflow is waiting for human action. Does NOT change
554
+ the card's ``status`` — the run lock stays held so a re-run resumes the same
555
+ phase. Exits non-zero so wrapping scripts notice.
555
556
  """
556
557
  card, doc = _load_skill_doc(ctx, skill_id)
557
558
  active = doc.active_phase()
559
+ if active:
560
+ _phase(ctx, skill_id, phase_label=active.title, action="need_input", reason=reason)
558
561
  out = {
559
562
  "ok": False,
560
563
  "paused": True,
@@ -570,6 +573,37 @@ def skill_phase_pause(ctx: click.Context, skill_id: str, reason: str) -> None:
570
573
  sys.exit(2)
571
574
 
572
575
 
576
+ @skill_phase_group.command("need-input")
577
+ @click.argument("skill_id")
578
+ @click.argument("phase_label")
579
+ @click.option("--reason", required=True, help="Short sentence describing what input is needed from the user.")
580
+ @click.pass_context
581
+ def skill_phase_need_input(ctx: click.Context, skill_id: str, phase_label: str, reason: str) -> None:
582
+ """Signal that a phase is blocked waiting for user input (mermaid ``:::dvNeedIntervention``).
583
+
584
+ Marks the accordion open and sets the mermaid node to
585
+ ``:::dvNeedIntervention`` so the DeepVista UI shows the phase as
586
+ waiting for the user — distinct from a technical blocker (``phase pause``)
587
+ or an error. Exits non-zero so wrapping scripts notice.
588
+
589
+ The user provides the required information and then resumes with:
590
+
591
+ deepvista skill run --mode host <skill_id>
592
+ """
593
+ result = _phase(ctx, skill_id, phase_label=phase_label, action="need_input", reason=reason)
594
+ out = {
595
+ "ok": False,
596
+ "need_input": True,
597
+ "skill_id": skill_id,
598
+ "phase": phase_label,
599
+ "title": result.get("title", ""),
600
+ "reason": reason,
601
+ "resume_with": f"deepvista skill run --mode host {skill_id}",
602
+ }
603
+ format_output(out, ctx.obj.output_format, entity_type="skill", base_url=ctx.obj.auth_url)
604
+ sys.exit(2)
605
+
606
+
573
607
  @skill_phase_group.command("run-on-deepvista")
574
608
  @click.argument("skill_id")
575
609
  @click.argument("phase_label")
@@ -39,6 +39,7 @@ import sys
39
39
  import threading
40
40
  import time
41
41
  from pathlib import Path
42
+ from typing import cast
42
43
 
43
44
  import click
44
45
 
@@ -50,8 +51,8 @@ from deepvista_cli.commands.agents import (
50
51
  DEFAULT_AGENT_ROLE,
51
52
  _build_config_snapshot,
52
53
  _default_agent_name,
53
- _install_hooks,
54
54
  _load_agent_id,
55
+ _migrate_legacy_hooks,
55
56
  _save_agent_id,
56
57
  )
57
58
  from deepvista_cli.commands.skill import emit_host_run_packet
@@ -433,8 +434,37 @@ def _run_task_card(ctx: click.Context, agent_id: str, project_id: str | None, ta
433
434
  cwd = os.environ.get("DEEPVISTA_TASK_CWD") or os.getcwd()
434
435
  argv = [_claude_binary(), "-p", f"/deepvista {prompt}", "--permission-mode", permission_mode]
435
436
 
437
+ # DV-1277: expose the originating chat + this task to the headless run so the
438
+ # session card the Claude Code plugin writes (`deepvista session init`) can
439
+ # cross-reference them. The run record shares the same task_id, so a run and
440
+ # its session both resolve back to the web chat that triggered the task.
441
+ run_env = {**os.environ, "DEEPVISTA_TASK_ID": task_id}
442
+ source_chat_id = str(task.get("source_chat_id") or "").strip()
443
+ if source_chat_id:
444
+ run_env["DEEPVISTA_SOURCE_CHAT_ID"] = source_chat_id
445
+
436
446
  short_id = task_id[:8]
447
+ title = task.get("title") or ""
448
+ prompt_preview = (prompt[:120] + "…") if len(prompt) > 120 else prompt
449
+ task_label = f"{title!r} — {prompt_preview}" if title else prompt_preview
450
+ created_at_raw = task.get("created_at") or ""
451
+ workflow_name = (
452
+ task.get("workflow_name")
453
+ or task.get("skill_name")
454
+ or task.get("source_workflow_name")
455
+ or task.get("triggered_by")
456
+ or ""
457
+ )
437
458
  click.echo(f" ▶ running task {short_id}… via claude -p (project {project_id or '?'})", err=True)
459
+ meta_parts = []
460
+ if created_at_raw:
461
+ display_ts = created_at_raw[:19].replace("T", " ") if "T" in created_at_raw else created_at_raw
462
+ meta_parts.append(f"added {display_ts}")
463
+ if workflow_name:
464
+ meta_parts.append(f"workflow: {workflow_name}")
465
+ if meta_parts:
466
+ click.echo(f" {' · '.join(meta_parts)}", err=True)
467
+ click.echo(f" prompt: {task_label}", err=True)
438
468
 
439
469
  _done = threading.Event()
440
470
  _start = time.monotonic()
@@ -442,7 +472,7 @@ def _run_task_card(ctx: click.Context, agent_id: str, project_id: str | None, ta
442
472
  def _progress() -> None:
443
473
  while not _done.wait(10):
444
474
  elapsed = int(time.monotonic() - _start)
445
- click.echo(f" task {short_id}… still running ({elapsed}s elapsed)", err=True)
475
+ click.echo(f" task {short_id}… still running ({elapsed}s elapsed) — {task_label}", err=True)
446
476
 
447
477
  _t = threading.Thread(target=_progress, daemon=True)
448
478
  _t.start()
@@ -453,6 +483,7 @@ def _run_task_card(ctx: click.Context, agent_id: str, project_id: str | None, ta
453
483
  text=True,
454
484
  timeout=TASK_RUN_TIMEOUT_SECONDS,
455
485
  cwd=cwd,
486
+ env=run_env,
456
487
  )
457
488
  exit_code = proc.returncode
458
489
  status = "completed" if exit_code == 0 else "failed"
@@ -482,7 +513,12 @@ def _run_task_card(ctx: click.Context, agent_id: str, project_id: str | None, ta
482
513
  {"status": status, "exit_code": exit_code, "output": output, "output_title": task.get("title")},
483
514
  extra_headers=headers,
484
515
  )
485
- return {"task_id": task_id, "title": task.get("title"), "status": status, "exit_code": exit_code}
516
+ result: dict = {"task_id": task_id, "title": task.get("title"), "status": status, "exit_code": exit_code}
517
+ if created_at_raw:
518
+ result["created_at"] = created_at_raw
519
+ if workflow_name:
520
+ result["workflow"] = workflow_name
521
+ return result
486
522
 
487
523
 
488
524
  def _claim_and_run_task_cards(ctx: click.Context, agent_id: str, project_id: str | None) -> list[dict]:
@@ -500,7 +536,8 @@ def _claim_and_run_task_cards(ctx: click.Context, agent_id: str, project_id: str
500
536
  if not error_code and status_code >= 400:
501
537
  error_code = data.get("detail") or str(status_code)
502
538
  if error_code or not data.get("success", True):
503
- if error_code == "project_not_found":
539
+ _agent_gone = error_code == "project_not_found" or status_code == 404
540
+ if _agent_gone:
504
541
  for aid, _, path in _iter_agent_files():
505
542
  if aid == agent_id:
506
543
  try:
@@ -508,10 +545,12 @@ def _claim_and_run_task_cards(ctx: click.Context, agent_id: str, project_id: str
508
545
  except OSError:
509
546
  pass
510
547
  break
511
- click.echo(
512
- f" removed stale agent {agent_id} (project {project_id} no longer accessible)",
513
- err=True,
548
+ reason = (
549
+ f"project {project_id} no longer accessible"
550
+ if error_code == "project_not_found"
551
+ else (error_code or "not found on server")
514
552
  )
553
+ click.echo(f" removed stale agent {agent_id} ({reason})", err=True)
515
554
  raise _StaleAgentError(agent_id)
516
555
  click.echo(
517
556
  f" [warn] could not claim task cards for agent {agent_id}: {error_code or 'unknown'}",
@@ -580,10 +619,46 @@ def _list_all_machine_agents() -> list[tuple[str, str | None]]:
580
619
  return [(aid, proj_id) for aid, proj_id, _ in _iter_agent_files()]
581
620
 
582
621
 
583
- def _ensure_agents_for_all_projects(
622
+ def _find_registered_agent_for_project(project_id: str) -> str | None:
623
+ """Return a locally registered agent_id for ``project_id``, any type."""
624
+ for agent_id, proj_id, _ in _iter_agent_files():
625
+ if proj_id == project_id:
626
+ return agent_id
627
+ return None
628
+
629
+
630
+ def _resolve_working_project(ctx: click.Context, project_override: str | None = None) -> str | None:
631
+ """Return the project ``tasks run`` should scope to.
632
+
633
+ Resolution order: per-command ``--project`` → global working project
634
+ (``project use`` / global ``--project`` / ``DEEPVISTA_PROJECT_ID``) →
635
+ backend default via ``GET /projects/me``.
636
+ """
637
+ if project_override:
638
+ return project_override
639
+ profile_project = getattr(ctx.obj, "project_id", None)
640
+ if profile_project:
641
+ return profile_project
642
+ try:
643
+ data = _client(ctx).get("/projects/me")
644
+ except SystemExit:
645
+ return None
646
+ if isinstance(data, dict):
647
+ pid = data.get("id")
648
+ return str(pid) if pid else None
649
+ return None
650
+
651
+
652
+ def _ensure_agents_for_projects(
584
653
  ctx: click.Context,
654
+ *,
655
+ project_ids: set[str] | None = None,
585
656
  ) -> tuple[list[tuple[str, str | None]], dict[str, str]]:
586
- """Fetch all projects and ensure a local agent is registered for each one.
657
+ """Ensure local agent registrations exist for the given project(s).
658
+
659
+ When ``project_ids`` is ``None``, every accessible project is covered
660
+ (legacy all-projects mode). Otherwise only the listed projects are
661
+ registered and returned.
587
662
 
588
663
  For projects that already have a local registration the existing agent_id
589
664
  is reused; for new projects a fresh agent is registered on-the-fly using
@@ -591,7 +666,8 @@ def _ensure_agents_for_all_projects(
591
666
 
592
667
  Stale local registrations whose project_id no longer appears in the API
593
668
  response are deleted so they stop producing 404 warnings on every poll.
594
- Agents with no project_id (legacy global registrations) are kept.
669
+ Agents with no project_id (legacy global registrations) are kept only in
670
+ all-projects mode.
595
671
 
596
672
  Returns ``((agent_id, project_id), project_names)`` where ``project_names``
597
673
  maps project_id → human-readable name. On network failure falls back to
@@ -607,7 +683,14 @@ def _ensure_agents_for_all_projects(
607
683
  projects_raw = _client(ctx).get("/projects")
608
684
  except SystemExit:
609
685
  click.echo(" [warn] could not fetch projects — using locally registered agents only", err=True)
610
- return _list_all_machine_agents(), {}
686
+ agents = _list_all_machine_agents()
687
+ if project_ids is not None:
688
+ agents = [(aid, pid) for aid, pid in agents if pid in project_ids]
689
+ # `pid in project_ids` narrows pid to str, so pyright infers the
690
+ # filtered list as list[tuple[str, str]] — invariant with the declared
691
+ # list[tuple[str, str | None]] return. Cast to reconcile (values are a
692
+ # subtype; the wider element type is what callers expect).
693
+ return cast("list[tuple[str, str | None]]", agents), {}
611
694
 
612
695
  # Backend returns a JSON array directly for GET /projects.
613
696
  projects: list[dict] = projects_raw if isinstance(projects_raw, list) else projects_raw.get("projects", [])
@@ -627,10 +710,14 @@ def _ensure_agents_for_all_projects(
627
710
  project_id = project.get("id")
628
711
  if not project_id:
629
712
  continue
713
+ if project_ids is not None and project_id not in project_ids:
714
+ continue
630
715
  project_name = project_names.get(project_id, "")
631
716
 
632
717
  # Reuse an existing local registration for this project.
633
- existing_id = _load_agent_id(agent_type, DEFAULT_AGENT_ROLE, project_id)
718
+ existing_id = _find_registered_agent_for_project(project_id) or _load_agent_id(
719
+ agent_type, DEFAULT_AGENT_ROLE, project_id
720
+ )
634
721
  if existing_id:
635
722
  if existing_id not in seen_agent_ids:
636
723
  seen_agent_ids.add(existing_id)
@@ -661,9 +748,9 @@ def _ensure_agents_for_all_projects(
661
748
  agent_role_saved = agent.get("agent_role", DEFAULT_AGENT_ROLE)
662
749
  _save_agent_id(agent_type, agent_id, agent_role_saved, project_id, project_name or None)
663
750
 
664
- # Mirror what `agents register` does: install hooks + initial sync.
665
- profile = getattr(ctx.obj, "profile", "default")
666
- _install_hooks(agent_type, profile)
751
+ # Mirror what `agents register` does: migrate off the legacy
752
+ # standalone hook (plugin now owns the heartbeat) + initial sync.
753
+ _migrate_legacy_hooks(agent_type)
667
754
  try:
668
755
  _client(ctx).post(
669
756
  f"/agents/{agent_id}/sync",
@@ -685,11 +772,15 @@ def _ensure_agents_for_all_projects(
685
772
  # Prune stale registrations and append any remaining local agents.
686
773
  # An agent file is stale if it has a project_id that no longer appears in
687
774
  # the API response; deleting it prevents repeated 404 warnings each poll.
688
- # Agents with no project_id (legacy global registrations) are kept.
775
+ # Agents with no project_id (legacy global registrations) are kept only
776
+ # when polling all projects.
689
777
  api_project_ids = {p.get("id") for p in projects if p.get("id")}
690
778
  for agent_id, proj_id, path in _iter_agent_files():
691
779
  if agent_id in seen_agent_ids:
692
780
  continue
781
+ if project_ids is not None:
782
+ if not proj_id or proj_id not in project_ids:
783
+ continue
693
784
  if proj_id and proj_id not in api_project_ids:
694
785
  try:
695
786
  path.unlink()
@@ -706,6 +797,13 @@ def _ensure_agents_for_all_projects(
706
797
  return result, project_names
707
798
 
708
799
 
800
+ def _ensure_agents_for_all_projects(
801
+ ctx: click.Context,
802
+ ) -> tuple[list[tuple[str, str | None]], dict[str, str]]:
803
+ """Ensure local agents exist for every accessible project (legacy helper)."""
804
+ return _ensure_agents_for_projects(ctx, project_ids=None)
805
+
806
+
709
807
  def _agent_type_label(agent_id: str) -> str:
710
808
  """Return the agent_type stored in the local registration file for this agent."""
711
809
  if not AGENTS_DIR.exists():
@@ -772,12 +870,18 @@ def _print_run_header(
772
870
 
773
871
  def _claim_and_run(ctx: click.Context, agent_id: str, host_mode: bool) -> tuple[list[dict], list[dict]]:
774
872
  """One claim/execute pass; returns (command task results, workflow tasks)."""
775
- data = _client(ctx).post(
873
+ data = _client(ctx).post_nofatal(
776
874
  f"/agents/{agent_id}/task-queue/claim",
777
875
  None if host_mode else {"command_only": True},
778
876
  )
779
- if not data.get("success"):
780
- output_error(1, "Failed to claim tasks", data.get("error", "Unknown error"))
877
+ status_code = data.get("_status_code", 200) if isinstance(data, dict) else 200
878
+ if status_code == 404:
879
+ raise _StaleAgentError(agent_id)
880
+ if status_code >= 400 or not data.get("success", True):
881
+ error = data.get("error", "Unknown error") if isinstance(data, dict) else "Unknown error"
882
+ if isinstance(error, dict):
883
+ error = error.get("detail") or error.get("message") or "unknown"
884
+ output_error(1, "Failed to claim tasks", error)
781
885
  raise SystemExit(1)
782
886
 
783
887
  tasks = data.get("tasks") or []
@@ -822,6 +926,9 @@ def _claim_and_run_all(
822
926
  # DV-936 / DV-955: queued CLI commands + host-driven workflow runs.
823
927
  try:
824
928
  results, wf_tasks = _claim_and_run(ctx, agent_id, host_mode)
929
+ except _StaleAgentError:
930
+ pruned.add(agent_id)
931
+ continue
825
932
  except SystemExit:
826
933
  click.echo(f" [warn] failed to claim tasks for agent {agent_id} — skipping", err=True)
827
934
  continue
@@ -833,7 +940,12 @@ def _claim_and_run_all(
833
940
  @tasks_group.command("run")
834
941
  @click.option("--type", "agent_type", default=None, help="Resolve agent by type from local storage.")
835
942
  @click.option("--role", "agent_role", default=None, help="Resolve agent by role (with --type).")
836
- @click.option("--project", "project_id", default=None, help="Restrict to the agent registered for this project ID.")
943
+ @click.option(
944
+ "--project",
945
+ "project_id",
946
+ default=None,
947
+ help="Scope to this project (overrides the working project for this call only).",
948
+ )
837
949
  @click.option(
838
950
  "--host",
839
951
  "host_mode",
@@ -877,17 +989,17 @@ def tasks_run(
877
989
  poll_interval: int,
878
990
  total_time: int | None,
879
991
  ) -> None:
880
- """Poll task queues for all registered agents and execute claimed tasks (DV-1079).
992
+ """Poll the task queue for the current project and execute claimed tasks (DV-1079).
881
993
 
882
- By default (no --type/--role/--project filter) polls EVERY agent registered
883
- on this machine, so tasks across all projects are serviced in one run.
884
- Pass --type/--role/--project to restrict to a single matching agent.
994
+ Scopes to the working project (``project use``, global ``--project``, or
995
+ ``DEEPVISTA_PROJECT_ID``), falling back to your backend default project.
996
+ Override per-invocation with ``--project``. Pass ``--type``/``--role`` to
997
+ resolve a specific local agent registration instead.
885
998
 
886
999
  Default mode polls in the foreground — claim, execute, sleep
887
1000
  --poll-interval, repeat — until --total-time elapses (or forever when
888
- unset), which keeps every registered agent on this machine picking up
889
- work without a cron job. --run-once does a single pass and exits; the
890
- cron entry installed by `tasks setup` uses it.
1001
+ unset). --run-once does a single pass and exits; the cron entry installed
1002
+ by `tasks setup` uses it.
891
1003
 
892
1004
  Only one `tasks run` may be active per machine — concurrent
893
1005
  invocations exit with an error instead of double-claiming the queue.
@@ -908,16 +1020,27 @@ def tasks_run(
908
1020
  raise SystemExit(2)
909
1021
 
910
1022
  project_names: dict[str, str] = {}
911
- if agent_type or agent_role or project_id:
912
- # Explicit filter — single-agent mode (backward-compatible).
913
- agent_id, resolved_project_id = _require_machine_agent_id(agent_type, agent_role, project_id)
1023
+ if agent_type or agent_role:
1024
+ # Explicit agent filter — single-agent mode (backward-compatible).
1025
+ working_project = _resolve_working_project(ctx, project_id)
1026
+ agent_id, resolved_project_id = _require_machine_agent_id(agent_type, agent_role, working_project)
914
1027
  agents = [(agent_id, resolved_project_id)]
915
1028
  else:
916
- # No filter — auto-register for every project the user has access to,
917
- # then poll all of them so nothing is missed.
918
- agents, project_names = _ensure_agents_for_all_projects(ctx)
1029
+ working_project = _resolve_working_project(ctx, project_id)
1030
+ if not working_project:
1031
+ output_error(
1032
+ 3,
1033
+ "No working project to poll",
1034
+ "Run `deepvista project use <id>` or pass `--project <id>`.",
1035
+ )
1036
+ raise SystemExit(3)
1037
+ agents, project_names = _ensure_agents_for_projects(ctx, project_ids={working_project})
919
1038
  if not agents:
920
- output_error(3, "No projects or registered agents found", "Run 'deepvista auth login' then retry.")
1039
+ output_error(
1040
+ 3,
1041
+ f"No registered agent for project {working_project}",
1042
+ "Run 'deepvista agents register' or retry after logging in.",
1043
+ )
921
1044
  raise SystemExit(3)
922
1045
 
923
1046
  host_mode = host_mode or _detect_host_agent()
@@ -110,8 +110,25 @@ follow steps 1–3.
110
110
 
111
111
  ### 5. Graceful exit when you can't continue
112
112
 
113
- If the current phase requires a tool you don't have (the user is offline,
114
- an MCP is unavailable, credentials are missing, …):
113
+ Two distinct cases:
114
+
115
+ **User input required** — the phase needs information, a decision, or
116
+ approval from the user before it can proceed:
117
+
118
+ 1. Save whatever partial output you produced as a note card via
119
+ `deepvista notes create` so DeepVista keeps the artifact.
120
+ 2. Run:
121
+ ```
122
+ deepvista skill phase need-input <skill_id> "<Phase N: title>" \
123
+ --reason "<one short sentence describing what's needed>"
124
+ ```
125
+ This sets the mermaid node to `:::dvNeedIntervention`, **keeps the
126
+ run lock held** (`status` stays `in_progress`), and exits non-zero.
127
+ 3. Tell the user in plain language what you need and how to resume
128
+ once they've provided it (e.g. "Please confirm the target audience
129
+ and re-run `deepvista skill run` to continue Phase 2").
130
+
131
+ **Technical blocker** — a tool, MCP, or credential is unavailable:
115
132
 
116
133
  1. Save whatever partial output you produced as a note card via
117
134
  `deepvista notes create` so DeepVista keeps the artifact.
@@ -119,8 +136,8 @@ an MCP is unavailable, credentials are missing, …):
119
136
  ```
120
137
  deepvista skill phase pause <skill_id> --reason "<one short sentence>"
121
138
  ```
122
- This **keeps the run lock held** (`status` stays `in_progress`),
123
- prints the reason for the user, and exits non-zero.
139
+ This also sets the active phase's mermaid node to `:::dvNeedIntervention`,
140
+ **keeps the run lock held** (`status` stays `in_progress`), and exits non-zero.
124
141
  3. Tell the user in plain language what's missing and how to resume
125
142
  (e.g. "Reconnect Gmail MCP and re-run `deepvista skill run` to
126
143
  continue Phase 3"). Do not pretend the phase succeeded.
@@ -148,8 +165,9 @@ be run again), and emits `<json>{"done": true}</json>`.
148
165
  | Open a phase | `deepvista skill phase open <skill_id> "Phase N: …"` |
149
166
  | Mark a phase done | `deepvista skill phase done <skill_id> "Phase N: …" [--artifact-card-id ID]…` |
150
167
  | Reset phase to pending | `deepvista skill phase reset <skill_id> "Phase N: …"` |
151
- | Pause (lock held) | `deepvista skill phase pause <skill_id> --reason "…"` |
152
- | Resume from pause | re-run `deepvista skill run --mode host <skill_id>` |
168
+ | Needs user input (:::dvNeedIntervention) | `deepvista skill phase need-input <skill_id> "Phase N: …" --reason "…"` |
169
+ | Pause — technical blocker (:::dvNeedIntervention, lock held) | `deepvista skill phase pause <skill_id> --reason "…"` |
170
+ | Resume from pause / need-input | re-run `deepvista skill run --mode host <skill_id>` |
153
171
  | One-phase fallback to DeepVista | `deepvista skill phase run-on-deepvista <skill_id> "Phase N: …"` |
154
172
  | Finalize the run | `deepvista skill complete <skill_id> --review "…"` |
155
173
  | Save an artifact (note) | `deepvista notes create --title "…" --content "…"` |