Skip to content

Remove the vestigial folder-structure (getFolderStructure) feature (Fixes #3072) - #3356

Merged
acoliver merged 2 commits into
dev/0.12.0from
issue3072
Aug 30, 2026
Merged

Remove the vestigial folder-structure (getFolderStructure) feature (Fixes #3072)#3356
acoliver merged 2 commits into
dev/0.12.0from
issue3072

Conversation

@acoliver

@acoliver acoliver commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Removes the vestigial folder-structure (getFolderStructure) feature end to end: the util and its test, the {{FOLDER_STRUCTURE}} prompt template machinery, the profile setting (include-folder-structure), the ISkillService.folderStructure surface, the 13 client-test mocks, and the docs. 41 files, +435/−1205. Reviewers should look at the two places where removal could have over-reached and did not: getDirectoryContextString keeps its exported Promise<string> contract (preamble-only, no tree walk), and activate-skill now carries the resource directory in model-facing llmContent, not just returnDisplay.

Fixes #3072

Dive Deeper

What is gone

  • packages/core/src/utils/getFolderStructure.ts and its test, plus the ./utils/getFolderStructure.js entry in core's export map.
  • prompts.ts folder helpers (compactFolderStructureSnapshot, resolveFolderStructure, FOLDER_STRUCTURE settings resolution) and the {{FOLDER_STRUCTURE}} var in TemplateEngine, prompt-config types.ts, and the three gemini core.md templates.
  • include-folder-structure across the settings registry, profile types, ProfileManager (including its optionalBoolean helper, which had no other user), and docs.
  • ISkillService.folderStructure, CoreSkillServiceAdapter.folderStructureCache, and the per-skill folder listing in activate-skill.
  • The 13 client*.test.ts getFolderStructure mocks, INITIAL_HISTORY_LENGTH re-export, and a stale test-run.log line.

What was deliberately kept

  • environmentContext.ts survives with getEnvironmentContext and getDirectoryContextString. The helper keeps its exported async/Promise<string> signature and returns only the working-directory preamble (one directory line or a bulleted list), so client.ts and executor-prompt-builder.ts continue to work unmodified; client.ts ended up byte-identical to main.
  • The ./utils/environmentContext.js subpath export stays; only getFolderStructure.js was dropped from the export map.
  • addDirectoryContext still pushes the preamble into history via the shared helper.

Behavior fixes that fell out of review

  • activate-skill's llmContent now includes a <resource_directory> element (omitted when the skill has no resource directory) so the model sees where resources live, matching plan AC-3; previously only the UI-only returnDisplay carried it.

Reviewer Test Plan

bun test ./packages/core/src/utils/environmentContext.test.ts \
  ./packages/tools/src/tools/activate-skill.test.ts \
  ./packages/tools/src/__tests__/interface-contracts.test.ts
bun test ./packages/agents/src/core/client.*.test.ts \
  ./packages/agents/src/core/client.sendMessageStream-*.test.ts \
  ./packages/agents/src/core/__tests__/subagentRun.characterization.test.ts
bun test ./packages/agents/src/agents/executor*.test.ts   # run separately from the env test (see note)
grep -rn "folderStructure\|FOLDER_STRUCTURE\|getFolderStructure" packages/*/src   # no hits

The env-context suites assert the preamble positively (date, OS, working-directory lines, environment memory) and guard against any tree listing returning.

Testing Matrix

🍏 🪟 🐧
npm run ✅*
npx
Docker
Podman - -
Seatbelt ✅* - -

* macOS only, via bun directly. Targeted suites green (executor x5, client core, subagent.create + ChatSessionFactory, settings profiles 139/0, prompts-async, environmentContext, core/tools, api T14b + P23.c); scoped eslint and prettier --check clean on all changed files; smoke test (--profile-load stepfun-37) boots cleanly to the provider call and fails only with the known stepfun 400 "no active step plan subscription".

Pre-existing failures, proven on clean main (eaae3364b), not addressed here:

  • tsc reports exactly 3 errors in packages/cli/src/utils/zipExtract.ts (yauzl typings). No packages/cli file is in this diff. npm run build therefore stops at the same point it stops on main; core/agents/lsp/providers all build green before that.
  • bun test packages/core/src/config flakes 18 tests identically on main; it is order-dependent (vi.mock leakage across files in one bun process — the executor suites' environmentContext automock exhibits the same class of leakage, which is why the env-context test should be run in its own invocation).
  • Full npm run test exceeds the 900 s shell timeout on this machine.

Linked issues / bugs

Fixes #3072

Summary by CodeRabbit

  • Changes

    • Removed automatic folder-tree listings from AI prompt context; only the current working directory is included.
    • Removed the folder-structure configuration option from settings, profiles, and prompt configuration.
    • Updated skill activation messaging to show the relevant resource directory instead of listing available resources.
  • Documentation

    • Updated configuration and reference documentation to reflect the removed setting and folder-structure template variable.

* Harden dependencies and ZIP extraction (Fixes #3324)

Replace extract-zip with staged, resource-bounded yauzl extraction that rejects symlinks, traversal, path aliases, and publication collisions.

Raise vulnerable direct and transitive dependency floors in both lockfiles and preserve the reviewed CodeQL false-positive dispositions.

* Make ZIP collision test portable

Assert the exact preexisting directory entry instead of reopening it with alternate casing, which is not valid on case-sensitive Linux filesystems.

* Verify streamed ZIP entry sizes

* Record security review completion
@github-actions github-actions Bot added the maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run label Aug 26, 2026
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ee8dec3d-1e5c-4e11-a156-50231c13e4b8

📥 Commits

Reviewing files that changed from the base of the PR and between 2ae8def and 8c9ab3b.

📒 Files selected for processing (1)
  • packages/core/src/utils/environmentContext.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change removes folder-structure discovery, configuration, prompt variables, skill APIs, templates, exports, tests, and documentation. Environment context now includes working-directory information without folder-tree listings.

Changes

Folder structure removal

Layer / File(s) Summary
Configuration and prompt contracts
packages/settings/..., packages/core/src/prompt-config/..., docs/...
Removed the include-folder-structure setting, folderStructure fields, FOLDER_STRUCTURE template variable, default prompt placeholder, profile handling, and related documentation.
Prompt context cleanup
packages/core/src/core/prompts.ts, packages/core/src/utils/environmentContext.ts, packages/core/src/core/prompts-async.test.ts, packages/core/src/utils/environmentContext.test.ts, packages/core/package.json, packages/core/src/index.ts, packages/agents/src/agents/executor-prompt-builder.ts
Removed folder snapshot generation and compaction. Environment context now returns working-directory context only. Removed related exports and tests.
Skill activation output
packages/tools/src/interfaces/ISkillService.ts, packages/core/src/tools-adapters/CoreSkillServiceAdapter.ts, packages/tools/src/tools/activate-skill.ts, packages/tools/src/tools/activate-skill.test.ts, packages/tools/src/__tests__/interface-contracts.test.ts
Removed skill folder-structure APIs and caching. Activation output now reports the optional resource directory.
Agent test cleanup
packages/agents/src/core/client.*.test.ts
Removed obsolete getFolderStructure mocks from agent client tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 8c9ab

This change removes an unused folder-structure feature and updates its related settings, prompts, interfaces, tests, and documentation; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #3072 by removing the folder-structure utility, settings, prompt integration, tests, interfaces, mocks, export entry, and documentation. The PR also preserves the required di…
Out of Scope Changes check ✅ Passed The changes are aligned with the linked issue and stated objectives. The directory-context preservation and activate-skill resource-directory update are related behavioral corrections, not unrelated s…
Title check ✅ Passed The title clearly and concisely describes the primary change: removing the obsolete folder-structure feature. It also references the related issue.
Description check ✅ Passed The description is complete and follows the repository template. It includes the change summary, detailed scope, reviewer test plan, testing matrix, linked issue, and known pre-existing failures.
Full details: Linked Issues check

Explanation

The changes satisfy issue #3072 by removing the folder-structure utility, settings, prompt integration, tests, interfaces, mocks, export entry, and documentation. The PR also preserves the required directory-context contract and updates model-facing resource-directory content.

Full details: Out of Scope Changes check

Explanation

The changes are aligned with the linked issue and stated objectives. The directory-context preservation and activate-skill resource-directory update are related behavioral corrections, not unrelated scope.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue3072

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Before this PR, the workspace context path included an optional folder-structure feature: when include-folder-structure was enabled, the prompt path would call getFolderStructure to build a tree snapshot, compact it, and inject it into the prompt via {{FOLDER_STRUCTURE}} and the environment context block. After this PR, that feature is removed. The core prompt path no longer reads or injects folder structure, the utility and its test are deleted, and the related public export is removed from the core barrel. Documentation and prompt templates are also updated so the feature is no longer described or referenced.

Release Notes

Bug Fixes

  • Removed the vestigial folder-structure feature, including getFolderStructure, its prompt injection, and the include-folder-structure setting references in docs.

Documentation

  • Updated prompt configuration and settings docs to remove {{FOLDER_STRUCTURE}} and include-folder-structure references.

Refactor

  • Cleaned up core prompt assembly so it no longer resolves, compacts, or attaches folder-structure context.

Chore

  • Removed the exported getFolderStructure utility and its dedicated test from the core package.
  • Updated prompt template defaults to remove folder-structure placeholders.

Changes

Layer File(s) Summary
project-plans project-plans/issue-3324-security-alert-remediation.md Changes in project-plans
packages/agents packages/agents/package.json Changes in packages/agents
packages/core/src/prompt-config packages/core/src/prompt-config/TemplateEngine.ts, packages/core/src/prompt-config/TemplateEngine.test.ts, packages/core/src/prompt-config/types.ts Changes in packages/core/src/prompt-config
packages/cli packages/cli/package.json Changes in packages/cli
packages/agents/src/core packages/agents/src/core/client.ide-context.test.ts, packages/agents/src/core/client.model-profile.test.ts, packages/agents/src/core/client.sendMessageStream-toolContent400.test.ts, packages/agents/src/core/client.sendMessageStream.test.ts, packages/agents/src/core/client.methods.test.ts, packages/agents/src/core/client.hooks.test.ts, packages/agents/src/core/client.sendMessageStream-thinking.test.ts, packages/agents/src/core/client.sendMessageStream-invalid-stream.test.ts, packages/agents/src/core/client.editor-context.test.ts, packages/agents/src/core/client.lifecycle.test.ts, packages/agents/src/core/client.sendMessageStream-errors.test.ts, packages/agents/src/core/client.sendMessageStream-overflow.test.ts, packages/agents/src/core/client.sendMessageStream-overflow-compression.test.ts Changes in packages/agents/src/core
packages/cli/src/utils packages/cli/src/utils/zipExtract.ts, packages/cli/src/utils/skillUtils.ts, packages/cli/src/utils/zipExtract.test.ts Changes in packages/cli/src/utils
docs/reference docs/reference/ephemerals.md Changes in docs/reference
packages/mcp packages/mcp/package.json Changes in packages/mcp
packages/tools/src/tests packages/tools/src/tests/interface-contracts.test.ts Changes in packages/tools/src/tests
packages/core/src/core packages/core/src/core/prompts.ts, packages/core/src/core/prompts-async.test.ts Changes in packages/core/src/core
packages/tools/src/tools packages/tools/src/tools/activate-skill.ts, packages/tools/src/tools/activate-skill.test.ts Changes in packages/tools/src/tools
packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md Changes in packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash
packages/cli/src/config/extensions packages/cli/src/config/extensions/github.ts Changes in packages/cli/src/config/extensions
packages/core/src/utils packages/core/src/utils/getFolderStructure.ts, packages/core/src/utils/getFolderStructure.test.ts, packages/core/src/utils/environmentContext.ts, packages/core/src/utils/environmentContext.test.ts Changes in packages/core/src/utils
packages/core/src/hooks/tests packages/core/src/hooks/tests/test-run.log Changes in packages/core/src/hooks/tests
packages/settings/src/settings/registry packages/settings/src/settings/registry/registry-entries-2.ts Changes in packages/settings/src/settings/registry
packages/vscode-ide-companion packages/vscode-ide-companion/package.json, packages/vscode-ide-companion/NOTICES.txt Changes in packages/vscode-ide-companion
packages/tools packages/tools/package.json Changes in packages/tools
packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md Changes in packages/core/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash
packages/core/src/prompt-config/defaults/providers/gemini packages/core/src/prompt-config/defaults/providers/gemini/core.md Changes in packages/core/src/prompt-config/defaults/providers/gemini
packages/agents/src/agents packages/agents/src/agents/executor-prompt-builder.ts Changes in packages/agents/src/agents
packages/settings/src/profiles packages/settings/src/profiles/ProfileManager.ts, packages/settings/src/profiles/types.ts Changes in packages/settings/src/profiles
. bun.lock, package.json, package-lock.json Changes in .
packages/a2a-server packages/a2a-server/package.json Changes in packages/a2a-server
docs docs/prompt-configuration.md, docs/settings-and-profiles.md Changes in docs
packages/providers packages/providers/package.json Changes in packages/providers
packages/ide-integration packages/ide-integration/package.json Changes in packages/ide-integration
packages/core/src/tools-adapters packages/core/src/tools-adapters/CoreSkillServiceAdapter.ts Changes in packages/core/src/tools-adapters
packages/core packages/core/package.json Changes in packages/core
project-plans/issue3072 project-plans/issue3072/plan.md Changes in project-plans/issue3072
packages/tools/src/interfaces packages/tools/src/interfaces/ISkillService.ts Changes in packages/tools/src/interfaces
packages/core/src packages/core/src/index.ts Changes in packages/core/src

Sequence Diagram

sequenceDiagram
  participant AgentRuntime
  participant PromptBuilder
  participant PromptService
  participant TemplateEngine
  participant EnvironmentContext
  participant SkillService
  participant ActivateSkillTool

  AgentRuntime->>PromptBuilder: buildAgentSystemPrompt(inputs, runtimeContext, template)
  PromptBuilder->>PromptService: getService()
  PromptService-->>PromptBuilder: PromptService
  PromptBuilder->>EnvironmentContext: getDirectoryContextString(runtimeContext)
  EnvironmentContext->>AgentRuntime: workspace directories
  EnvironmentContext-->>PromptBuilder: working-directory preamble only, no folder tree
  PromptBuilder->>PromptService: getPrompt(context, userMemory, coreMemory)
  PromptService->>TemplateEngine: processTemplate(template, variables)
  TemplateEngine-->>PromptService: rendered prompt without FOLDER_STRUCTURE
  PromptService-->>PromptBuilder: system prompt
  PromptBuilder-->>AgentRuntime: final prompt

  AgentRuntime->>ActivateSkillTool: execute(name)
  ActivateSkillTool->>SkillService: activateSkill(name)
  SkillService-->>ActivateSkillTool: SkillActivationResult without folderStructure
  ActivateSkillTool-->>AgentRuntime: llmContent with resourceDirectory
Loading

Magnitude

🎯 4 (XL)
2445 additions, 1730 deletions, 58 changed files across 10 packages, 0 acceptance criteria

Related

Pre-merge Checks

Check Status Note
Title Clear and descriptive: states the exact feature being removed and references the linked issue number.
Description All required sections are present: TLDR, Dive Deeper, Reviewer Test Plan, Testing Matrix, and Linked issues / bugs.
Linked Issues The changes comprehensively fulfill issue #3072: getFolderStructure utility and test are deleted, {{FOLDER_STRUCTURE}} is removed from templates and TemplateEngine, include-folder-structure is removed from settings registry/profile types/ProfileManager, ISkillService.folderStructure and CoreSkillServiceAdapter.folder structures are removed, activate-skill no longer emits folder listings, and 13 client test mocks are cleaned up. Deliberate preservation of getDirectoryContextString contract and llmContent resource-directory behavior is documented.
Out of Scope Several changes are bundled but unrelated to #3072: a security-alert remediation project plan (issue-3324), multiple dependency version bumps (undici, shell-quote, tar, js-yaml, @lvce-editor/ripgrep, js-yaml override), replacement of extract-zip with yauzl plus a new secure zipExtract utility and its tests, and corresponding package-lock/bun.lock updates. These should be split into a separate dependency/security PR.

Walkthrough generated by LLxprt PR Review. Planner issue: #2256

Comment thread packages/core/src/utils/environmentContext.test.ts
Comment thread packages/core/src/utils/environmentContext.test.ts
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview — PR #3356

  • Reviewed head SHA: 8c9ab3b713a22b39678fd68c643e59d666a05d56
  • Merge base: eaae3364bba789bf734809c3737651114ae0d1cb
  • Range: full from eaae3364bba789bf734809c3737651114ae0d1cb
  • Range fallback: checkpoint-not-ancestor
  • Scope: selected 39 file(s), +453/-471; cumulative 39 file(s), +453/-471
  • Tokens: 660312 total (609436 input, 50876 output, 346752 cache)
  • OCR version: open-code-review v1.8.4 (e78474478) linux/amd64 built at: 2026-08-01T03:27:37Z https://github.com/alibaba/open-code-review
  • Phase: review
  • Exit code: 0
  • Run: https://github.com/vybestack/llxprt-code/actions/runs/32968973824
  • 1 finding(s) (1 posted inline).
  • Artifacts: ocr-review-output contains raw JSON, stdout, stderr, preview, phase, and exit-code diagnostics.
  • WARNING: Changed-file coverage 1/32 preview files covered is below the 90% threshold.

@acoliver

Copy link
Copy Markdown
Collaborator Author

Addressed both inline comments (CI OCR) in 8c9ab3b71: restored direct behavioral tests for the exported getDirectoryContextString in packages/core/src/utils/environmentContext.test.ts — single-directory preamble (exact string), multi-directory bulleted preamble (exact string including newlines), and an async-contract test asserting the function returns a Promise<string>. Suite is 7/7 green.

Comment thread packages/core/src/utils/environmentContext.test.ts
@acoliver

Copy link
Copy Markdown
Collaborator Author

Rejecting this one with reasoning:

  1. Not a behavior introduced by this PR. The if (length === 1) ... else bulleted-list shape is inherited unchanged from main's getDirectoryContextString; the empty-array output would be byte-identical on main. This PR's scope is removing the tree walk, not redesigning the preamble contract.

  2. The empty state is unreachable in production. WorkspaceContext's constructor requires a directory: string and adds it immediately (packages/core/src/utils/workspaceContext.ts:30-35), so getDirectories() always contains at least the initial directory. Reaching zero requires an explicit setDirectories([]), which no production code calls (the setter's only references are the class itself and test doubles).

  3. A guard would be defensive handling for an upstream state that cannot occur, which this codebase deliberately avoids in favor of fixing actual bugs at their source; and adding a test asserting the current empty-input output would cement malformed text as contract.

If the empty-workspace case ever becomes real (e.g. a future caller using setDirectories([])), it warrants its own issue and a deliberate contract decision, not a rider on the folder-structure removal.

@acoliver acoliver added this to the 0.12.0 milestone Aug 26, 2026
@acoliver
acoliver changed the base branch from main to dev/0.12.0 August 26, 2026 14:37
@acoliver
acoliver merged commit 67b3d84 into dev/0.12.0 Aug 30, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the get folder structrure including its settings and any tests or whatever

1 participant