mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-15 23:31:04 +00:00
chore: fix HookEngine typings and add CI workflow
This commit is contained in:
parent
4fe5e0a5f6
commit
b0bb6c73dc
4 changed files with 95 additions and 225 deletions
65
.github/workflows/ci.yml
vendored
Normal file
65
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js and pnpm
|
||||
uses: ./.github/actions/setup-node-pnpm
|
||||
- name: Run linter
|
||||
run: pnpm lint
|
||||
|
||||
type-check:
|
||||
name: Type Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js and pnpm
|
||||
uses: ./.github/actions/setup-node-pnpm
|
||||
- name: Check TypeScript types
|
||||
run: pnpm check-types
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js and pnpm
|
||||
uses: ./.github/actions/setup-node-pnpm
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js and pnpm
|
||||
uses: ./.github/actions/setup-node-pnpm
|
||||
- name: Build project
|
||||
run: pnpm build
|
||||
|
||||
format-check:
|
||||
name: Format Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js and pnpm
|
||||
uses: ./.github/actions/setup-node-pnpm
|
||||
- name: Check code formatting
|
||||
run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-path .gitignore || (echo "Code formatting check failed. Run 'pnpm format' to fix." && exit 1)
|
||||
|
||||
169
Architecture.md
169
Architecture.md
|
|
@ -1,169 +0,0 @@
|
|||
|
||||
## **1. Project Overview**
|
||||
|
||||
**Goal:**
|
||||
Develop an **Intent-Code Traceability system** for the AI-Native IDE that ensures AI-generated code aligns with user intent and can be tracked, reasoned over, and verified.
|
||||
|
||||
**Core Features:**
|
||||
|
||||
* **Two-stage Reasoning Loop** (State Machine):
|
||||
|
||||
* **Stage 1:** Capture client intent, map to AI code action.
|
||||
* **Stage 2:** Validate AI-generated code, detect misalignment, log corrections.
|
||||
* **Hook System Integration**:
|
||||
|
||||
* Identify injection points in **Roo Code** for tracking.
|
||||
* Pre-commit, post-commit, and runtime hooks for tracing execution.
|
||||
* **`.orchestration/` directory**:
|
||||
|
||||
* Stores intent metadata, execution logs, and reasoning states.
|
||||
* **Intent-Code Mapping**:
|
||||
|
||||
* Links user intent → AI agent decisions → generated code → execution results.
|
||||
* **Auditability**:
|
||||
|
||||
* Every code change is traceable to its originating intent.
|
||||
|
||||
---
|
||||
|
||||
## **2. Architecture Layers**
|
||||
|
||||
### **A. Input Layer (Intent Capture)**
|
||||
|
||||
* **Source:** User commands in the IDE, chat prompts, or code requests.
|
||||
* **Components:**
|
||||
|
||||
* Intent Parser (NLP model / regex-based)
|
||||
* Preprocessing Engine (normalize ambiguous input)
|
||||
* **Output:** Structured intent objects (`JSON/YAML`).
|
||||
|
||||
### **B. Hook System Layer**
|
||||
|
||||
* **Integration Points:** Roo Code Extension
|
||||
|
||||
* **Pre-commit hook:** Captures intent vs proposed AI code.
|
||||
* **Post-commit hook:** Logs executed code and execution result.
|
||||
* **Custom Reasoning hooks:** Intercepts AI agent output for validation.
|
||||
* **Responsibilities:**
|
||||
|
||||
* Validate AI output before commit.
|
||||
* Trigger state updates in Reasoning Loop.
|
||||
* Maintain orchestration logs.
|
||||
|
||||
### **C. Orchestration & Reasoning Layer**
|
||||
|
||||
* **State Machine (Two-Stage Loop)**:
|
||||
|
||||
* **Stage 1: Intent → Proposed Code**
|
||||
|
||||
* AI agent generates code based on captured intent.
|
||||
* Hook system verifies structure and alignment.
|
||||
* **Stage 2: Code Validation**
|
||||
|
||||
* Execute test cases or lint checks.
|
||||
* Detect mismatches and suggest corrections.
|
||||
* **Data Storage:** `.orchestration/` directory
|
||||
|
||||
* Stores:
|
||||
|
||||
* Intent metadata
|
||||
* AI decisions and reasoning traces
|
||||
* Validation results
|
||||
* Hook system logs
|
||||
|
||||
### **D. Storage & Traceability Layer**
|
||||
|
||||
* **File System:** `.orchestration/` for local tracking
|
||||
* **Optional DB:** Lightweight database (SQLite/PostgreSQL) for:
|
||||
|
||||
* Intent history
|
||||
* AI agent output logs
|
||||
* Validation state
|
||||
* **Purpose:** Allows historical analysis and auditability.
|
||||
|
||||
### **E. Output & Feedback Layer**
|
||||
|
||||
* **Developer Feedback:**
|
||||
|
||||
* Misalignment alerts
|
||||
* Suggested corrections
|
||||
* Intent-Code mapping visualizations
|
||||
* **Metrics & Analysis:**
|
||||
|
||||
* Traceability coverage
|
||||
* Reasoning loop success rate
|
||||
* Hook system performance
|
||||
|
||||
---
|
||||
|
||||
## **3. Development Plan / Workflow**
|
||||
|
||||
1. **Phase 0: Prep**
|
||||
|
||||
* Review `ARCHITECTURE-NOTES.md` for Roo Code injection points.
|
||||
* Map the cognitive and trust debt decisions → reasoning logic.
|
||||
* Setup Git repo with **Git Speck Kit**.
|
||||
|
||||
2. **Phase 1: Hook System Implementation**
|
||||
|
||||
* Identify Roo Code extension points for:
|
||||
|
||||
* pre-commit
|
||||
* post-commit
|
||||
* runtime reasoning interception
|
||||
* Build hook scripts.
|
||||
* Unit test hooks independently.
|
||||
|
||||
3. **Phase 2: Reasoning Loop**
|
||||
|
||||
* Implement two-stage state machine.
|
||||
* Connect hooks to Reasoning Loop states.
|
||||
* Implement intent validation logic.
|
||||
|
||||
4. **Phase 3: Orchestration Directory**
|
||||
|
||||
* `.orchestration/` for:
|
||||
|
||||
* intent.json
|
||||
* reasoning_state.json
|
||||
* validation_results.json
|
||||
* Implement read/write APIs for traceability.
|
||||
|
||||
5. **Phase 4: Logging & Traceability**
|
||||
|
||||
* Implement audit logs for every hook event.
|
||||
* Integrate with Git Speck Kit for code snapshots.
|
||||
* Enable metrics collection for AI alignment tracking.
|
||||
|
||||
6. **Phase 5: Testing & Validation**
|
||||
|
||||
* Create sample AI-generated code scenarios.
|
||||
* Test traceability pipeline end-to-end.
|
||||
* Measure coverage of intent-code alignment.
|
||||
|
||||
7. **Phase 6: Documentation**
|
||||
|
||||
* Maintain `ARCHITECTURE_NOTES.md` and `README.md`.
|
||||
* Document hook usage, state machine, and orchestration structure.
|
||||
|
||||
---
|
||||
|
||||
## **4. Tech Stack / Tools**
|
||||
|
||||
* **Git & Git Speck Kit:** Source control, snapshots, hooks.
|
||||
* **Python / Node.js:** For hooks and orchestration logic.
|
||||
* **JSON/YAML:** Intent and traceability storage.
|
||||
* **Roo Code Extension:** Injection points for hook system.
|
||||
* **Lightweight DB (Optional):** SQLite or PostgreSQL for logs.
|
||||
* **NLP / Parsing:** Optional intent parsing models.
|
||||
* **Testing Frameworks:** pytest / Jest for automated validation.
|
||||
|
||||
---
|
||||
|
||||
## **5. Key Architectural Decisions (From Cognitive & Trust Debt)**
|
||||
|
||||
* Track only **AI-generated code relevant to intent** instead of all outputs.
|
||||
* Enforce **two-stage validation loop** to prevent drift between intent and code.
|
||||
* Maintain **self-contained orchestration directory** to simplify tracing and rollback.
|
||||
* Use **hooks as checkpoints** rather than full code reviews to scale traceability.
|
||||
* **Metrics-driven design:** Log reasoning steps to improve future AI alignment.
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { Task } from "../task/Task"
|
||||
import type { ToolUse, ToolName } from "../../shared/tools"
|
||||
import type { ToolUse } from "../../shared/tools"
|
||||
import type { ToolName } from "@roo-code/types"
|
||||
import { OrchestrationDataModel, type ActiveIntent } from "../orchestration/OrchestrationDataModel"
|
||||
import * as vscode from "vscode"
|
||||
import * as path from "path"
|
||||
|
|
@ -111,8 +112,9 @@ export class HookEngine {
|
|||
|
||||
// Load intent details (for authorization prompt + scope checks)
|
||||
if (!activeIntent) {
|
||||
activeIntent = await this.dataModel.getIntent(activeIntentId)
|
||||
if (activeIntent) {
|
||||
const loadedIntent = await this.dataModel.getIntent(activeIntentId)
|
||||
if (loadedIntent) {
|
||||
activeIntent = loadedIntent
|
||||
;(task as any).activeIntent = activeIntent
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,22 +111,11 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
)
|
||||
|
||||
// Execute: Call select_active_intent
|
||||
const toolUse: ToolUse<"select_active_intent"> = {
|
||||
type: "tool_use",
|
||||
id: "tool-1",
|
||||
name: "select_active_intent",
|
||||
params: { intent_id: "INT-001" },
|
||||
}
|
||||
|
||||
await selectActiveIntentTool.execute(
|
||||
{ intent_id: "INT-001" },
|
||||
mockTask,
|
||||
{
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
},
|
||||
)
|
||||
await selectActiveIntentTool.execute({ intent_id: "INT-001" }, mockTask, {
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
})
|
||||
|
||||
// Verify: pushToolResult was called with XML context
|
||||
expect(mockPushToolResult).toHaveBeenCalledTimes(1)
|
||||
|
|
@ -178,15 +167,11 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
await fs.writeFile(tracePath, "", "utf-8")
|
||||
|
||||
// Execute
|
||||
await selectActiveIntentTool.execute(
|
||||
{ intent_id: "INT-002" },
|
||||
mockTask,
|
||||
{
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
},
|
||||
)
|
||||
await selectActiveIntentTool.execute({ intent_id: "INT-002" }, mockTask, {
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
})
|
||||
|
||||
// Verify: XML contains "No recent changes" message
|
||||
const contextXml = mockPushToolResult.mock.calls[0][0]
|
||||
|
|
@ -261,15 +246,11 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
)
|
||||
|
||||
// Execute: Select INT-001
|
||||
await selectActiveIntentTool.execute(
|
||||
{ intent_id: "INT-001" },
|
||||
mockTask,
|
||||
{
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
},
|
||||
)
|
||||
await selectActiveIntentTool.execute({ intent_id: "INT-001" }, mockTask, {
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
})
|
||||
|
||||
// Verify: Only INT-001 trace entry is included
|
||||
const contextXml = mockPushToolResult.mock.calls[0][0]
|
||||
|
|
@ -285,15 +266,11 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
await fs.writeFile(intentsPath, intentsYaml, "utf-8")
|
||||
|
||||
// Execute
|
||||
await selectActiveIntentTool.execute(
|
||||
{ intent_id: "INT-999" },
|
||||
mockTask,
|
||||
{
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
},
|
||||
)
|
||||
await selectActiveIntentTool.execute({ intent_id: "INT-999" }, mockTask, {
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
})
|
||||
|
||||
// Verify: Error was returned
|
||||
expect(mockPushToolResult).toHaveBeenCalled()
|
||||
|
|
@ -304,15 +281,11 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
|
||||
it("should handle missing intent_id parameter", async () => {
|
||||
// Execute without intent_id
|
||||
await selectActiveIntentTool.execute(
|
||||
{ intent_id: "" },
|
||||
mockTask,
|
||||
{
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
},
|
||||
)
|
||||
await selectActiveIntentTool.execute({ intent_id: "" }, mockTask, {
|
||||
askApproval: vi.fn(),
|
||||
handleError: mockHandleError,
|
||||
pushToolResult: mockPushToolResult,
|
||||
})
|
||||
|
||||
// Verify: Missing parameter error
|
||||
expect(mockSayAndCreateMissingParamError).toHaveBeenCalledWith("select_active_intent", "intent_id")
|
||||
|
|
@ -320,4 +293,3 @@ describe("SelectActiveIntentTool - Phase 1 End-to-End Test", () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue