Skip to content

Feature/epic 14 refine prompt - #21

Merged
razvantomegea merged 3 commits into
mainfrom
feature/epic-14-refine-prompt
Apr 30, 2026
Merged

Feature/epic 14 refine prompt#21
razvantomegea merged 3 commits into
mainfrom
feature/epic-14-refine-prompt

Conversation

@razvantomegea

@razvantomegea razvantomegea commented Apr 30, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Emits an executable AGENTS_REFINE.md prompt after init/update (unless opted out) to guide workspace-specific agent refinements.
    • Added a CLI opt-out flag to suppress the refine prompt.
  • Documentation

    • README/plan/PRD updated to document the post-init/update refine workflow and the opt-out flag; console next-step messaging standardized.
  • Tests

    • Added tests validating refine-prompt content, opt-out behavior, and agent inclusion rules.

- Introduced `AGENTS_REFINE.md` to be emitted after every `init` and `update`, serving as a planning-only handoff for users to tailor generated agent files to their workspace.
- Updated CLI options to include `--no-refine-prompt` for skipping the emission of the refinement prompt.
- Enhanced `README.md` to document the new refinement process and usage instructions for the emitted prompt.
- Added tests to ensure the correct generation of `AGENTS_REFINE.md` and its contents based on the active agents.
- Refactored generator logic to conditionally include the refinement prompt based on user preferences.

This commit aims to improve user experience by providing a structured way to refine agent configurations post-initialization.
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e104b78-cff5-4286-a307-c698562bda32

📥 Commits

Reviewing files that changed from the base of the PR and between edb8f61 and 2b20d8d.

📒 Files selected for processing (7)
  • PRD.md
  • src/cli/init-command.ts
  • src/generator/generate-agents.ts
  • src/generator/generate-refine-prompt.ts
  • src/schema/stack-config.ts
  • src/templates/refine/AGENTS_REFINE.md.ejs
  • tests/generator/refine-prompt.test.ts

📝 Walkthrough

Walkthrough

Adds a post-init/post-update refinement workflow: CLI opt-out flag, a new generator that emits AGENTS_REFINE.md (template + generator + exported path), generator wiring to include the prompt conditionally, schema tightening/renames, generate-agents path helpers, and tests validating prompt emission and opt-out behavior. (≤50 words)

Changes

Cohort / File(s) Summary
Documentation
PLAN.md, PRD.md, README.md
Updated planning/product/readme to record Epic 14 completion, describe the post-init/update AGENTS_REFINE.md prompt, and document the --no-refine-prompt opt-out and example CLI usage.
CLI Wiring
src/cli/index.ts, src/cli/init-command.ts, src/cli/update-command.ts
Added --no-refine-prompt flag, threaded refinePrompt?: boolean through CLI options, forwarded it into init/update handlers, and conditionalized the post-generation "Hand AGENTS_REFINE.md…" next-step message.
Generator: refine prompt
src/generator/generate-refine-prompt.ts, src/generator/index.ts
New generateRefinePrompt() and exported REFINE_PROMPT_PATH = 'AGENTS_REFINE.md'; generateAll gains GenerateAllOptions and options.refinePrompt to conditionally include the refine prompt file in outputs and post-processing.
Generator: agents paths refactor
src/generator/generate-agents.ts
Introduced getAgentOutputPaths (internal) and exported getGeneratedAgentPaths(config); refactored generateAgents to reuse computed paths and conditionally apply Codex skill transform based on path.
Schema changes
src/schema/stack-config.ts
Added SAFE_STACK_VALUE and SAFE_STACK_VALUE_NULLABLE validators, renamed primary Zod exports to STACK_CONFIG_SCHEMA/SAFE_PROJECT_DESCRIPTION with backward-compatible aliases, and updated inferred StackConfig/SecurityConfig types.
Template
src/templates/refine/AGENTS_REFINE.md.ejs
New EJS template generating the AGENTS_REFINE.md prompt (audit instructions, per-agent diff proposals, verification loop, test/typecheck commands).
Tests
tests/generator/refine-prompt.test.ts
Added Jest tests verifying AGENTS_REFINE.md content, inclusion/exclusion of disabled agents, target-aware path references, presence of configured commands, and that refinePrompt: false suppresses emission.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI<br/>(init/update)
    participant Handler as Command<br/>Handler
    participant Generator as generateAll()
    participant RefineGen as generateRefinePrompt()
    participant Template as EJS Template
    participant FileSystem as Filesystem

    User->>CLI: run init/update (+/− --no-refine-prompt)
    CLI->>Handler: parse options & invoke
    Handler->>Generator: generateAll(config, {refinePrompt})
    
    rect rgba(100, 150, 200, 0.5)
        Generator->>Generator: check refinePrompt != false
        alt refinePrompt enabled
            Generator->>RefineGen: call generateRefinePrompt()
            RefineGen->>Template: render AGENTS_REFINE.md.ejs
            Template-->>RefineGen: rendered markdown
            RefineGen-->>Generator: GeneratedFile(AGENTS_REFINE.md)
            Generator->>Generator: append to output files
        end
    end

    Generator->>FileSystem: write generated files
    Generator-->>Handler: return generated files

    alt refinePrompt enabled
        Handler->>User: print "Hand AGENTS_REFINE.md..." next-step message
    else
        Handler->>User: skip next-step message
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly Related PRs

Poem

🐰
New prompts bloom where init seeds sow,
Agents audit, and refinements grow—
Skip the dance with a --no-refine-prompt wink,
Or follow AGENTS_REFINE.md and let the workspace think. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main feature being implemented: Epic 14's post-init/post-update workspace refinement prompt functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/epic-14-refine-prompt

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/schema/stack-config.ts (1)

34-35: ⚡ Quick win

Rename schema constants to UPPER_SNAKE_CASE for guideline compliance.

safeStackValue and safeStackValueNullable are module-level constants; please rename them to UPPER_SNAKE_CASE and update call sites.

Proposed diff
-const safeStackValue = z.string().trim().min(1).max(100).regex(SAFE_STACK_VALUE_RE, SAFE_STACK_VALUE_MESSAGE);
-const safeStackValueNullable = safeStackValue.nullable().default(null);
+const SAFE_STACK_VALUE = z.string().trim().min(1).max(100).regex(SAFE_STACK_VALUE_RE, SAFE_STACK_VALUE_MESSAGE);
+const SAFE_STACK_VALUE_NULLABLE = SAFE_STACK_VALUE.nullable().default(null);
...
-    language: safeStackValue,
-    runtime: safeStackValue,
-    framework: safeStackValueNullable,
-    uiLibrary: safeStackValueNullable,
-    stateManagement: safeStackValueNullable,
-    database: safeStackValueNullable,
-    auth: safeStackValueNullable,
-    i18nLibrary: safeStackValueNullable,
+    language: SAFE_STACK_VALUE,
+    runtime: SAFE_STACK_VALUE,
+    framework: SAFE_STACK_VALUE_NULLABLE,
+    uiLibrary: SAFE_STACK_VALUE_NULLABLE,
+    stateManagement: SAFE_STACK_VALUE_NULLABLE,
+    database: SAFE_STACK_VALUE_NULLABLE,
+    auth: SAFE_STACK_VALUE_NULLABLE,
+    i18nLibrary: SAFE_STACK_VALUE_NULLABLE,
...
-    packageManager: safeStackValue,
+    packageManager: SAFE_STACK_VALUE,
...
-    testFramework: safeStackValue,
-    testLibrary: safeStackValueNullable,
-    e2eFramework: safeStackValueNullable,
-    linter: safeStackValueNullable,
-    formatter: safeStackValueNullable,
+    testFramework: SAFE_STACK_VALUE,
+    testLibrary: SAFE_STACK_VALUE_NULLABLE,
+    e2eFramework: SAFE_STACK_VALUE_NULLABLE,
+    linter: SAFE_STACK_VALUE_NULLABLE,
+    formatter: SAFE_STACK_VALUE_NULLABLE,

As per coding guidelines "Name module-level constants in UPPER_SNAKE_CASE".

Also applies to: 81-88, 92-92, 94-98

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/schema/stack-config.ts` around lines 34 - 35, Rename the module-level
schema constants to UPPER_SNAKE_CASE: change safeStackValue → SAFE_STACK_VALUE
and safeStackValueNullable → SAFE_STACK_VALUE_NULLABLE, update every
usage/call-site accordingly, and apply the same renaming convention to the other
module-level schema constants referenced in the file (the constants around lines
81–98) so they follow UPPER_SNAKE_CASE; ensure imports/exports and any
references inside functions or validators are updated to the new names to avoid
unresolved identifier errors.
src/templates/refine/AGENTS_REFINE.md.ejs (1)

19-19: ⚡ Quick win

Make Codex skill audit targets explicit in the generated target list

The mission says to audit both .claude/agents/ and .codex/skills/, but the explicit “Generated agent files to audit” list currently renders only Claude paths. Adding a Codex entry (or enumerated Codex paths) would remove ambiguity during execution.

Suggested minimal clarification
 Generated agent files to audit:
@@
 <% for (const path of claudeAgents) { -%>
 - `<%= path %>`
 <% } -%>
+- All generated files under `.codex/skills/`.

Also applies to: 48-52

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/templates/refine/AGENTS_REFINE.md.ejs` at line 19, Update the "Generated
agent files to audit" list in the AGENTS_REFINE.md.ejs template to explicitly
include Codex skill paths (e.g., add `.codex/skills/` or enumerate expected
Codex files) in addition to the existing Claude paths so the audit target list
is unambiguous; modify the list rendered at the current snippet (around the
"Generated agent files to audit" text) and the other occurrence mentioned (lines
~48-52) to mirror this change, ensuring any template variables or loops that
output the Claude entries also include the Codex entries or a separate Codex
block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@PRD.md`:
- Around line 2006-2008: The delivery snapshot table for "Epic 14 — Post-Init
Workspace Refinement Prompt" is inconsistent with the epic header marked DONE;
update the snapshot row for Epic 14 to reflect DONE status, change the "planned
— no template or generator yet" cell to indicate completed (e.g., "DONE —
template/generator implemented"), and ensure the branch column matches the
landed branch `feature/epic-14-refine-prompt` so the snapshot no longer
contradicts the epic header.

In `@src/cli/init-command.ts`:
- Line 213: The logged "next" instruction in init-command.ts is the only
numbered item; update the logger.info call that currently prints '  4. Hand
AGENTS_REFINE.md to your agent to tailor the generated agent files to this
workspace.' (in the init command output) to remove the "4. " prefix so it
matches the surrounding plain-bullet "next:" lines—i.e., change the message to
start with the same indentation and text but without the numeric label so
formatting is consistent with the other messages.

In `@src/generator/generate-refine-prompt.ts`:
- Around line 22-25: The template render call for 'refine/AGENTS_REFINE.md.ejs'
currently receives only boolean agent flags via "agents: config.agents"; instead
compute and pass the actual generated agent path list (e.g., agentPaths or
generatedAgents) derived from the same logic that emits real outputs and include
it in the render context (for example alongside context and config.agents) so
the template can iterate concrete paths rather than booleans; update the
renderTemplate invocation in generate-refine-prompt.ts to pass that computed
array (name it something like generatedAgentPaths) and adjust the template to
consume that new variable.

In `@src/templates/refine/AGENTS_REFINE.md.ejs`:
- Line 35: The template unconditionally interpolates paths.utilsDir which can
produce "undefined" in output; update the AGENTS_REFINE.md.ejs fragment that
renders "Representative source files..." to guard the interpolation (like the
existing checks for paths.componentsDir) so you only append `, <%=
paths.utilsDir %>` when paths.utilsDir is truthy (e.g., wrap it in an if/`<% if
(paths.utilsDir) { %>...<% } %>` block).

---

Nitpick comments:
In `@src/schema/stack-config.ts`:
- Around line 34-35: Rename the module-level schema constants to
UPPER_SNAKE_CASE: change safeStackValue → SAFE_STACK_VALUE and
safeStackValueNullable → SAFE_STACK_VALUE_NULLABLE, update every usage/call-site
accordingly, and apply the same renaming convention to the other module-level
schema constants referenced in the file (the constants around lines 81–98) so
they follow UPPER_SNAKE_CASE; ensure imports/exports and any references inside
functions or validators are updated to the new names to avoid unresolved
identifier errors.

In `@src/templates/refine/AGENTS_REFINE.md.ejs`:
- Line 19: Update the "Generated agent files to audit" list in the
AGENTS_REFINE.md.ejs template to explicitly include Codex skill paths (e.g., add
`.codex/skills/` or enumerate expected Codex files) in addition to the existing
Claude paths so the audit target list is unambiguous; modify the list rendered
at the current snippet (around the "Generated agent files to audit" text) and
the other occurrence mentioned (lines ~48-52) to mirror this change, ensuring
any template variables or loops that output the Claude entries also include the
Codex entries or a separate Codex block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c26ff82-4973-4e8a-b1d4-7d472d43e3f7

📥 Commits

Reviewing files that changed from the base of the PR and between 4d58c93 and edb8f61.

📒 Files selected for processing (11)
  • PLAN.md
  • PRD.md
  • README.md
  • src/cli/index.ts
  • src/cli/init-command.ts
  • src/cli/update-command.ts
  • src/generator/generate-refine-prompt.ts
  • src/generator/index.ts
  • src/schema/stack-config.ts
  • src/templates/refine/AGENTS_REFINE.md.ejs
  • tests/generator/refine-prompt.test.ts

Comment thread PRD.md
Comment thread src/cli/init-command.ts Outdated
Comment thread src/generator/generate-refine-prompt.ts
Comment thread src/templates/refine/AGENTS_REFINE.md.ejs Outdated
- Updated the `AGENTS_REFINE.md` template to reference generated agent files directly, enhancing clarity for users on which files to audit.
- Modified the CLI output in `init-command.ts` to append a new unnumbered line for handing off `AGENTS_REFINE.md` to agents, improving user guidance.
- Introduced a new function in `generate-agents.ts` to retrieve paths for generated agent files based on active configurations, streamlining the generation process.
- Enhanced the refinement prompt generation to include target-specific agent paths, ensuring accurate representation of available agents based on user settings.
- Updated tests to validate the correct generation of agent paths and the contents of `AGENTS_REFINE.md`, ensuring robust functionality.

This commit aims to improve the user experience by providing clearer instructions and accurate references in the refinement process.
@razvantomegea
razvantomegea merged commit cba9893 into main Apr 30, 2026
1 of 2 checks passed
@razvantomegea
razvantomegea deleted the feature/epic-14-refine-prompt branch April 30, 2026 13:22
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