Skip to content

Experiment feat impl:Intent Coding MVP workflow (#854)#873

Open
harryfan1985 wants to merge 16 commits into
GCWing:mainfrom
harryfan1985:codex-intent-coding-mvp
Open

Experiment feat impl:Intent Coding MVP workflow (#854)#873
harryfan1985 wants to merge 16 commits into
GCWing:mainfrom
harryfan1985:codex-intent-coding-mvp

Conversation

@harryfan1985
Copy link
Copy Markdown
Contributor

@harryfan1985 harryfan1985 commented May 25, 2026

Linked Issue

Closes #854

Issue: #854

This PR is the experimental MVP implementation for the intent-aligned Coding Agent workflow discussed in #854. It is intentionally scoped as a first working loop rather than the full five-phase platform.

Summary

This PR implements the first BitFun-native MVP for intent-aligned Coding Agent work.

The core goal is to move Coding Agent delivery from:

user asks -> agent writes code -> human reviews code

to:

user asks -> agent aligns intent -> accepted checks/tests -> scoped execution -> verification -> evidence package -> human reviews evidence

This is intentionally an MVP. It proves the value of an intent-first delivery loop with a dedicated mode, built-in workflow rules, runtime-created Intent/Evidence artifacts, prompt guidance, and structural validation.

Theoretical Basis and Design Thinking

This implementation is based on the direction from #854: Coding Agent reliability is now less limited by code generation ability and more limited by intent engineering. In practice, many agent failures happen because the model acts quickly inside ambiguous requirements, incomplete context, or missing domain constraints.

The design borrows from three related research/product ideas:

  • Context engineering / MEP-style preparation: durable project knowledge, constraints, ADR-like notes, and known pitfalls should be explicit instead of only living in one-off prompts.
  • Intent formalization / TiCoder-style clarification: ask high-information questions around behavioral disagreement, boundary behavior, security, compatibility, and UI/API semantics. The point is to move human judgment earlier from “review code line by line” to “review intent and acceptance”.
  • Intent-centric software engineering: treat software delivery as an intent, context, verification, and governance system rather than a pure code-generation pipeline.

The MVP intentionally avoids a large platform build. Instead, it creates a hard local delivery constraint:

  • meaningful coding tasks should start with an Intent Record,
  • tasks should define Accepted Checks/Tests before implementation,
  • verification should run after changes,
  • final delivery should include an Evidence Package,
  • workflow structure should be machine-checkable when artifacts exist.

What Changed

Intent Coding Mode

  • Added a dedicated built-in IntentCoding mode.
  • Added a dedicated prompt requiring:
    • Intent Record before coding,
    • up to 3 high-risk clarification questions,
    • risk classification,
    • Accepted Checks/Tests,
    • scoped execution contract,
    • verification,
    • Evidence Package,
    • repair-loop and provenance reporting,
    • pnpm run agent:check when available.

Key files:

  • src/crates/core/src/agentic/agents/definitions/modes/intent_coding.rs
  • src/crates/core/src/agentic/agents/prompts/intent_coding_mode.md
  • src/crates/core/src/agentic/agents/registry/catalog.rs
  • src/crates/core/src/agentic/agents/registry/builtin.rs

Built-In Intent Coding Rules

Workflow rules are now product code, not repository-local .agent source files. They live under:

src/crates/core/src/agentic/agents/prompts/intent_coding_rules/

IntentCodingMode embeds these rules with include_str!() and appends them to the mode prompt as a dedicated context section.

Rules cover:

  • accepted checks/tests,
  • risk classification,
  • repair-loop failure classification,
  • provenance chain,
  • workflow structure checking,
  • architecture/coding/security guardrails.

Runtime Intent/Evidence Artifacts

Intent Records and Evidence Packages are runtime/on-demand artifacts:

.agent/intents/intent-YYYYMMDD-short-task-name.md
.agent/evidence/evidence-YYYYMMDD-short-task-name.md

They are no longer committed as repository scaffolding. The .agent directory is treated as an active-task workspace artifact, not as the product prompt/template registry. For the MVP this is the chosen artifact location; durable provenance should later move into session-scoped structured storage such as .bitfun/sessions or a dedicated session provenance store.

Workflow Checker

Added:

pnpm run agent:check

The checker validates active .agent artifacts when they exist:

  • Intent Record required sections,
  • Evidence Package required sections,
  • Evidence-to-Intent references,
  • Intent/Evidence pairing by task slug.
  • Evidence Accepted Checks status markers.

If no .agent artifacts exist, the command exits successfully and reports that there is no active Intent Coding task.

The command now runs in CI as a lightweight structural gate. This check is structural only. It does not replace product verification and does not judge acceptance quality.

Frontend Support

  • Allows IntentCoding in Flow Chat persisted agent types.
  • Adds localized mode labels/descriptions.
  • Adds mode display helper and tests.
  • Adds rendered mode picker option coverage for the IntentCoding entry.
  • Adds frontend agent utility tests for IntentCoding.
  • Adds a soft warning when an IntentCoding turn completes without an Evidence Package signal.

Vitest Monaco Isolation

Full web tests exposed a pre-existing Node/Vitest environment problem around static monaco-editor resolution. This PR adds a test-mode-only Monaco alias and lightweight mock so non-editor tests do not resolve real Monaco runtime modules.

The alias is only active in test mode.

Verification

Previously run and passing on this branch:

cargo check --workspace
cargo test --workspace
pnpm --dir src/web-ui run test:run
pnpm run lint:web
pnpm run type-check:web
pnpm run agent:check

Additional local checks:

  • focused Rust tests for IntentCoding prompt/registry behavior,
  • focused frontend tests for mode mapping/display,
  • diff/status scope audit.

Current CI status should be treated as authoritative before merge.

Review Guide

Recommended review order:

  1. src/crates/core/src/agentic/agents/prompts/intent_coding_mode.md

    • Is the workflow strict enough without being too heavy?
    • Are clarification, acceptance, risk, verification, and evidence requirements clear?
  2. src/crates/core/src/agentic/agents/definitions/modes/intent_coding.rs

    • Is embedding built-in rules with include_str!() the right product location?
    • Is the request context policy appropriate for this mode?
  3. src/crates/core/src/agentic/agents/prompts/intent_coding_rules/*

    • Are the rules stable enough to be product-owned prompt context?
    • Are any rules too process-heavy for MVP?
  4. scripts/check-agent-workflow.mjs

    • Is the structural checker strict enough for active Intent/Evidence artifacts?
    • Is running it in CI as a lightweight structural gate appropriate for this MVP?
  5. Frontend mode and test changes

    • Is the IntentCoding mode naming/description acceptable?
    • Is the Monaco test alias appropriately test-only?

Architecture Reference

Purpose Path
Mode definition src/crates/core/src/agentic/agents/definitions/modes/intent_coding.rs
Mode prompt src/crates/core/src/agentic/agents/prompts/intent_coding_mode.md
Built-in rules src/crates/core/src/agentic/agents/prompts/intent_coding_rules/
Mode registration src/crates/core/src/agentic/agents/registry/catalog.rs
Frontend persistence src/web-ui/src/flow_chat/store/FlowChatStore.ts
Frontend mode display src/web-ui/src/app/scenes/agents/utils.ts
Active artifact checker scripts/check-agent-workflow.mjs

Constraints:

  • Intent Coding should not replace the default Agentic mode.
  • Product logic stays platform-agnostic.
  • .agent is an active-task artifact location, not the product prompt/template source.
  • Built-in rules live in the core prompt tree so they are versioned as product behavior.

MVP Boundaries

This PR does not implement:

  • hard runtime enforcement that every task writes Intent/Evidence artifacts,
  • automatic risk classification,
  • semantic validation of accepted checks,
  • automatic Deep Review trigger,
  • OPA/Rego policy engine,
  • multi-agent Beads execution,
  • automatic merge,
  • structured session provenance store.

These are deliberate P1/P2 follow-ups.

Follow-Up TODO

P2:

  • Add a structured provenance store tied to sessions/turns.
  • Add automatic risk classification suggestions.
  • Integrate L3/L4 tasks with Deep Review or specialist review routing.
  • Add a repair-loop classifier with structured failure counters.
  • Add Context Compiler retrieval/ranking if workspace-owned guidance is reintroduced.
  • Explore policy-as-code gates for high-risk areas.

Notes For Reviewers

The current PR is now code/prompt-rule focused rather than .agent artifact focused. The main product decision is whether IntentCoding should ship as an experimental separate mode with built-in workflow rules, while hard runtime artifact enforcement and governance remain future work.

@harryfan1985 harryfan1985 changed the title Add Intent Coding MVP workflow 实验特性: Add Intent Coding MVP workflow May 25, 2026
@harryfan1985 harryfan1985 changed the title 实验特性: Add Intent Coding MVP workflow 实验特性: Intent Coding MVP workflow (#854) May 25, 2026
@harryfan1985 harryfan1985 changed the title 实验特性: Intent Coding MVP workflow (#854) Experiment feat impl:Intent Coding MVP workflow (#854) May 25, 2026
harryfan1985 and others added 2 commits May 25, 2026 14:53
Main refactored RequestContextPolicy from static constructors to a
builder pattern (::empty().with_*()). Update IntentCodingMode to
use the new API instead of the removed ::full() method.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@harryfan1985 harryfan1985 force-pushed the codex-intent-coding-mvp branch from 53a43fa to 8b98639 Compare May 25, 2026 06:54
harryfan1985 and others added 14 commits May 25, 2026 15:33
…se in README

The 26 intent/evidence pairs were self-hosted development artifacts from
the MVP implementation, not runtime dependencies. Only rules/, knowledge/,
and changes/ are loaded into agent context.

- Keep 1 representative pair as a format example
- Add a table in README clarifying that intents/evidence are per-task
  delivery artifacts, not runtime context
- agent:check still passes (1 Intent Record + 1 Evidence Package)
…les/

The three-directory split (rules/knowledge/changes) was a conceptual
distinction with no functional difference — the context loader
processes all three identically.  At MVP stage, one context directory
is sufficient.

- Delete .agent/knowledge/ and .agent/changes/
- instruction_context.rs: AGENT_CONTEXT_DIRS reduced to .agent/rules
- Update all context-loader tests to use rules/ only
- intent_coding_mode.md prompt: simplify context-loading instructions
- .agent/README.md: drop knowledge/changes from directory map and task lifecycle
- provenance-chain.md, context-budget.md: remove knowledge/changes references
- PR GCWing#873 body: add architecture reference table from former knowledge file
…runtime

These are per-task delivery artifacts, not repository scaffolding.
The agent creates .agent/intents/ and .agent/evidence/ on demand when
writing Intent Records and Evidence Packages.

- Delete .agent/intents/ and .agent/evidence/
- Delete stale templates: knowledge-template.md, change-template.md
- agent:check: intents/evidence no longer required; validate
  only when the dirs have files, otherwise report 'No active' info
- Update README, prompt to document runtime-on-demand behavior
Move IntentCoding workflow rules from workspace .agent/ into
prompts/intent_coding_rules/, loaded via include_str!().

- 9 rule files embedded in intent_coding.rs build_prompt()
- instruction_context.rs: .agent/rules removed from context dirs
- intent_coding_mode.md: updated to reference built-in rules
- agent:check: simplified to only validate Intent/Evidence when present
- Delete .agent/ directory from repository

Signed-off-by: harryfan1985 <harryfan1985@gmail.com>
- Add .agent/ to .gitignore to prevent accidental commit of runtime artifacts
- Downgrade intent-without-evidence to WARN in agent:check so mid-task runs don't fail
- Replace fragile rules.len()==9 assertion with per-name checks in test
- Remove context-budget.md rule (implementation detail, not agent guidance)
- Remove redundant || '' in modeDisplay.translatedOrEmpty

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[feat-plan] 面向意图对齐的 Coding Agent 工作流 (Intent-Aligned Coding Agent Workflow)

1 participant