Skip to content

feat(prometheus): integrate hierarchical plan generation#1889

Open
rentiansheng wants to merge 2 commits intocode-yeongyu:devfrom
rentiansheng:feat/prometheus-discussions-issue-1785
Open

feat(prometheus): integrate hierarchical plan generation#1889
rentiansheng wants to merge 2 commits intocode-yeongyu:devfrom
rentiansheng:feat/prometheus-discussions-issue-1785

Conversation

@rentiansheng
Copy link

@rentiansheng rentiansheng commented Feb 16, 2026

  • Update system-prompt.ts to include PROMETHEUS_PLAN_TEMPLATE_V2
  • Prometheus now generates v2 hierarchical plans for complex tasks
  • Update plan-generation.ts to conditionally use task_create/task_update when available
  • Fall back to TodoWrite when task_system disabled
  • Add step-by-step guidance for both tooling paths
  • Maintain V2 hierarchical TODO format requirement
  • Resolve conflicts with tasks-todowrite-disabler hook expectations

Summary

Changes

Screenshots

Before After
image

Testing

bun run typecheck
bun test

Related Issues

Closes #1785


Summary by cubic

Adds hierarchical plan generation (V2) to Prometheus with numbered task trees, markdown rendering, and a new task_tree tool. Backward compatible (v1 by default) and addresses #1785.

  • New Features

    • Plan Template V2 added to system prompt; plans marked with .
    • plan-generation prefers task_create/task_update (task_list/get) with step-by-step guidance; falls back to TodoWrite when task system is disabled; examples updated for metadata priority and ID capture; includes hierarchical parentID and TodoWrite nested numbering examples.
    • task_tree tool renders a numbered hierarchy with progress; collapses beyond depth 6.
    • Plan format detector (v1 vs v2) and markdown renderer for hierarchical tasks; tree utils with numbering and validation (parent exists, cycles, max depth); broad tests.
  • Bug Fixes

    • Fixed tool API examples (priority now in metadata, proper ID capture); documented flat and hierarchical workflows.
    • Fixed tree-numbering issues (deleted root lookup, duplicate sibling indices) with regression tests.
    • Optimized markdown renderer to avoid O(N^2) tree reconstruction.

Written for commit 0f7761b. Summary will update on new commits.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

5 issues found across 27 files

Confidence score: 3/5

  • Several medium-high severity issues in src/agents/prometheus/plan-generation.ts could cause tool misuse: prompt examples reference a non-existent priority arg and promote a flawed task-creation workflow that may yield race conditions or hallucinated IDs.
  • src/features/claude-tasks/tree-numbering.ts has concrete numbering bugs (duplicate sibling indexes and deleted roots never numbered), which can affect visible task ordering for users.
  • Given multiple user-facing logic issues (severity ~6–7/10), there is some regression risk; this PR feels slightly risky to merge without fixes.
  • Pay close attention to src/agents/prometheus/plan-generation.ts and src/features/claude-tasks/tree-numbering.ts - prompt/tool mismatches and numbering logic errors.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/agents/prometheus/plan-generation.ts">

<violation number="1" location="src/agents/prometheus/plan-generation.ts:41">
P1: Rule violated: **Opencode Compatibility**

The `task_create` prompt examples use `priority` as a top-level parameter, but the actual `task_create` tool (defined in `src/tools/task/task-create.ts`) has no `priority` arg. Priority must be passed inside the `metadata` field: `metadata: { priority: "high" }`. All 8 example calls will either silently drop the priority or fail validation when the AI follows this template.</violation>

<violation number="2" location="src/agents/prometheus/plan-generation.ts:51">
P1: Flawed few-shot example for task creation workflow encourages race condition/hallucinated IDs</violation>
</file>

<file name="src/agents/prometheus/markdown-renderer-v2.ts">

<violation number="1" location="src/agents/prometheus/markdown-renderer-v2.ts:20">
P2: Inefficient O(N²) tree reconstruction - `getNumberingPath` rebuilds the task tree for each task</violation>
</file>

<file name="src/features/claude-tasks/tree-numbering.ts">

<violation number="1" location="src/features/claude-tasks/tree-numbering.ts:86">
P2: Deleted root tasks are never numbered due to flawed lookup logic: `activeRoots` filters out deleted tasks, but the fallback numbering logic for deleted roots searches within `activeRoots`, causing a guaranteed lookup failure (-1) for any deleted root task. This also prevents numbering of their subtrees.</violation>

<violation number="2" location="src/features/claude-tasks/tree-numbering.ts:97">
P1: Incorrect sibling index calculation assigns the same duplicate index to all deleted siblings. The filter().length - 1 always returns the last position for every task, not each task's specific position.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@rentiansheng
Copy link
Author

rentiansheng commented Feb 17, 2026

  • Pay close attention to src/agents/prometheus/plan-generation.ts and src/features/claude-tasks/tree-numbering.ts - prompt/tool mismatches and numbering logic errors.

5 issues found across 27 files

Confidence score: 3/5

  • Several medium-high severity issues in src/agents/prometheus/plan-generation.ts could cause tool misuse: prompt examples reference a non-existent priority arg and promote a flawed task-creation workflow that may yield race conditions or hallucinated IDs.
  • src/features/claude-tasks/tree-numbering.ts has concrete numbering bugs (duplicate sibling indexes and deleted roots never numbered), which can affect visible task ordering for users.
  • Given multiple user-facing logic issues (severity ~6–7/10), there is some regression risk; this PR feels slightly risky to merge without fixes.
  • Pay close attention to src/agents/prometheus/plan-generation.ts and src/features/claude-tasks/tree-numbering.ts - prompt/tool mismatches and numbering logic errors.

Prompt for AI agents (all issues)


Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/agents/prometheus/plan-generation.ts">

<violation number="1" location="src/agents/prometheus/plan-generation.ts:41">
P1: Rule violated: **Opencode Compatibility**

The `task_create` prompt examples use `priority` as a top-level parameter, but the actual `task_create` tool (defined in `src/tools/task/task-create.ts`) has no `priority` arg. Priority must be passed inside the `metadata` field: `metadata: { priority: "high" }`. All 8 example calls will either silently drop the priority or fail validation when the AI follows this template.</violation>

<violation number="2" location="src/agents/prometheus/plan-generation.ts:51">
P1: Flawed few-shot example for task creation workflow encourages race condition/hallucinated IDs</violation>
</file>

<file name="src/agents/prometheus/markdown-renderer-v2.ts">

<violation number="1" location="src/agents/prometheus/markdown-renderer-v2.ts:20">
P2: Inefficient O(N²) tree reconstruction - `getNumberingPath` rebuilds the task tree for each task</violation>
</file>

<file name="src/features/claude-tasks/tree-numbering.ts">

<violation number="1" location="src/features/claude-tasks/tree-numbering.ts:86">
P2: Deleted root tasks are never numbered due to flawed lookup logic: `activeRoots` filters out deleted tasks, but the fallback numbering logic for deleted roots searches within `activeRoots`, causing a guaranteed lookup failure (-1) for any deleted root task. This also prevents numbering of their subtrees.</violation>

<violation number="2" location="src/features/claude-tasks/tree-numbering.ts:97">
P1: Incorrect sibling index calculation assigns the same duplicate index to all deleted siblings. The filter().length - 1 always returns the last position for every task, not each task's specific position.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Pay close attention to src/agents/prometheus/plan-generation.ts and src/features/claude-tasks/tree-numbering.ts - prompt/tool mismatches and numbering logic errors.
opencode use compatibility mode, there is has diff.

- Update system-prompt.ts to include PROMETHEUS_PLAN_TEMPLATE_V2
- Prometheus now generates v2 hierarchical plans for complex tasks
- Update plan-generation.ts to conditionally use task_create/task_update when available
- Fall back to TodoWrite when task_system disabled
- Add step-by-step guidance for both tooling paths
- Maintain V2 hierarchical TODO format requirement
- Resolve conflicts with tasks-todowrite-disabler hook expectations

issue code-yeongyu#1785
… numbering bugs

- Fix task_create examples to use metadata: { priority } instead of top-level priority parameter
- Fix task creation workflow example to demonstrate proper ID capture from response
- Add hierarchical parent-child examples for task_create using parentID (1., 1.1, 1.1.1 format)
- Add hierarchical examples for TodoWrite showing nested numbering (1., 1.1, 1.1.1 format)
- Both flat (sequential) and hierarchical (parent-child) workflows now documented
- Optimize markdown-renderer-v2 to eliminate O(N²) tree reconstruction
- Fix deleted root task numbering lookup failure in tree-numbering.ts
- Fix duplicate sibling index calculation in tree-numbering.ts
- Add regression tests for deleted task numbering scenarios
@rentiansheng
Copy link
Author

Going forward, I plan to add a todo list to the chat process before "Generate work plan to .sisyphus/plans/user-management.md", allowing discussion of the plan.

@rentiansheng rentiansheng force-pushed the feat/prometheus-discussions-issue-1785 branch from c9c1410 to 0f7761b Compare February 17, 2026 11:04
@sisyphus-dev-ai
Copy link
Collaborator

@rentiansheng Thanks for the PR! The rebase looks good and it is now mergeable.

However, the Cubic AI reviewer identified 5 issues that need attention before merging:

  1. task_create examples have incorrect API usage - priority is shown as top-level param but should be inside metadata: { priority: "high" }. The actual tool definition requires this.

  2. Task creation workflow has race condition risk - The few-shot example may encourage hallucinated IDs.

  3. Performance issue - getNumberingPath rebuilds task tree O(N²) for each task.

  4. Tree numbering bug - Deleted root tasks are never numbered (lookup in activeRoots fails).

  5. Duplicate sibling indexes - Deleted siblings all get same index due to filter().length - 1 logic.

Also the CLA check is currently failing - please make sure to sign it.

Could you address these issues? Happy to re-review once fixed.

@rentiansheng
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@rentiansheng
Copy link
Author

recheck

github-actions bot added a commit that referenced this pull request Feb 17, 2026
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.

[Question]: Prometheus discussion mode(plan or todo list is tree not line)

2 participants