Skip to content

Comments

feat(prometheus): integrate hierarchical plan generation#1889

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

feat(prometheus): integrate hierarchical plan generation#1889
rentiansheng wants to merge 1 commit 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

input:

Plan the implementation of a user management system with:
- User registration with email verification
- Login with JWT tokens
- Profile management
- Admin panel for user oversight

plan md file:
user-management-system.md

Testing

bun run typecheck
bun test

Related Issues

Closes #1785


Summary by cubic

Integrates hierarchical plan generation (V2) into Prometheus with wave‑consistent N.x task IDs, a markdown renderer, and a task_tree tool. V2 is now the default for new plans; v1 plans remain supported. Addresses #1785.

  • New Features

    • Plan Template V2 added to system prompt with ; hierarchical numbering and wave‑consistent IDs are mandatory. Detector keeps v1 plans readable.
    • Plan generation prefers task_create/task_update (task_list/get) with guided hierarchical Edit steps; falls back to TodoWrite when task system is disabled.
    • task_tree tool renders numbered hierarchies with progress and collapses past depth 6; tree utils add numbering, progress, and validation.
  • Bug Fixes

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

Written for commit 4ec93a8. 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.

@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
- 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

 (MR CR opinion) resolve tool API mismatches and tree 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

issue code-yeongyu#1785
@rentiansheng rentiansheng force-pushed the feat/prometheus-discussions-issue-1785 branch from 0f7761b to 4ec93a8 Compare February 21, 2026 08:08
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