Skip to content

Add repository context explorer#98

Merged
slashdevcorpse merged 4 commits into
mainfrom
feature/repo-context-explorer
May 31, 2026
Merged

Add repository context explorer#98
slashdevcorpse merged 4 commits into
mainfrom
feature/repo-context-explorer

Conversation

@slashdevcorpse
Copy link
Copy Markdown
Owner

@slashdevcorpse slashdevcorpse commented May 31, 2026

Summary\n- add an ignore-aware repository context API for the active workspace\n- detect root and nested AGENTS.md files and mark which ones apply to selected paths\n- add a composer repository-context picker with search, file/directory selection, AGENTS visibility, and context impact estimates\n- send selected repo context as a bounded prompt context block without starting a run from health/context checks\n\n## Testing\n- pnpm -C apps/codex-claw lint\n- pnpm -C apps/codex-claw build\n- pnpm -C apps/codex-claw test\n\nCloses #85


Summary by cubic

Adds a repository context explorer so users can pick files/folders for chats with ignore-aware scanning and AGENTS.md visibility. Selected context is sent as a bounded prompt block and can be used without typing a message. Closes #85.

  • New Features
    • API: GET /api/repo-context returns an ignore-aware repo tree, applicable AGENTS.md files, and size/token estimates (selections via repeated selected params).
    • UI: Composer picker with search, file/directory selection, removable summary chips, and oversized warnings.
    • Sending: Builds and appends a bounded context block from selected files plus applicable AGENTS.md; supports context-only sends and optimistic “Repository context: …” messages.
    • Server: Uses git ls-files (with a safe fallback scan), normalizes paths, limits depth/entries, includes only text-like files, and truncates at ~32k chars.
    • Tests: Cover AGENTS.md visibility and prompt assembly.

Written for commit 4297725. Summary will update on new commits.

Review in cubic

Copilot AI review requested due to automatic review settings May 31, 2026 07:49
@slashdevcorpse slashdevcorpse merged commit c44e012 into main May 31, 2026
5 of 6 checks passed
@slashdevcorpse slashdevcorpse deleted the feature/repo-context-explorer branch May 31, 2026 07:51
Copy link
Copy Markdown

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

2 issues found across 14 files

Prompt for AI agents (unresolved 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="apps/codex-claw/src/server/repo-context.ts">

<violation number="1" location="apps/codex-claw/src/server/repo-context.ts:248">
P1: Nested AGENTS.md files are not marked applicable when a parent directory is selected, so required instructions can be omitted from repository context.</violation>

<violation number="2" location="apps/codex-claw/src/server/repo-context.ts:343">
P2: Truncation appends a marker after slicing to `remaining`, which can exceed `maxContextChars` and break the prompt-size bound.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

const appliesToSelected = normalizedSelections.some((selection) => {
if (!selection) return false
if (!directory) return true
return selection === directory || selection.startsWith(directory + '/')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Nested AGENTS.md files are not marked applicable when a parent directory is selected, so required instructions can be omitted from repository context.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/codex-claw/src/server/repo-context.ts, line 248:

<comment>Nested AGENTS.md files are not marked applicable when a parent directory is selected, so required instructions can be omitted from repository context.</comment>

<file context>
@@ -0,0 +1,361 @@
+      const appliesToSelected = normalizedSelections.some((selection) => {
+        if (!selection) return false
+        if (!directory) return true
+        return selection === directory || selection.startsWith(directory + '/')
+      })
+      return {
</file context>

if (remaining <= 0) break
const body =
content.length > remaining
? content.slice(0, remaining) + '\n[truncated]'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Truncation appends a marker after slicing to remaining, which can exceed maxContextChars and break the prompt-size bound.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/codex-claw/src/server/repo-context.ts, line 343:

<comment>Truncation appends a marker after slicing to `remaining`, which can exceed `maxContextChars` and break the prompt-size bound.</comment>

<file context>
@@ -0,0 +1,361 @@
+    if (remaining <= 0) break
+    const body =
+      content.length > remaining
+        ? content.slice(0, remaining) + '\n[truncated]'
+        : content
+    usedChars += body.length
</file context>

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Feature: repository context explorer and AGENTS.md visibility

2 participants