Skip to content

feat(openspec): project directory tracking and automatic context loading (#595, #596)#734

Merged
Aaronontheweb merged 8 commits into
devfrom
feature/session-cwd-tracking
Apr 24, 2026
Merged

feat(openspec): project directory tracking and automatic context loading (#595, #596)#734
Aaronontheweb merged 8 commits into
devfrom
feature/session-cwd-tracking

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Refocused from general-purpose CWD tracking to project directory tracking — the session knows which project it's working on, not where shell commands run
  • New set_working_directory tool (profile-managed, audience-gated) for setting the active project directory
  • Automatic [project-instructions] context layer loads project identity files (.netclaw/AGENTS.md, CLAUDE.md, AGENTS.md, CONTEXT.md) from the project root on every LLM call
  • ProjectDirectory persisted in WorkingContext / SessionSnapshot — survives compaction, crash, and restart
  • Session directory path added to [session] block for agent visibility
  • Scoped down from 42 tasks to 21 by removing shell CWD defaulting, file path resolution changes, cd detection, and directory tree walking

OpenSpec Artifacts

  • proposal.md — why, what changes, capabilities, impact
  • design.md — 7 design decisions (two-directory model, null default, standalone tool, single-directory loading, EveryTurn injection, persistence, session dir visibility)
  • specs/ — 4 delta specs (session-cwd, project-instructions, netclaw-tools, netclaw-session)
  • tasks.md — 6 groups, 21 checkboxed tasks

Test plan

  • Review OpenSpec artifacts for coherence and completeness
  • Validate design decisions align with existing patterns
  • Confirm task breakdown is implementable
  • Proceed to implementation after review

Implements #595, #596.

Proposal for tracking a mutable tool CWD per session, separate from the
immutable session directory. Covers project identity file discovery via
directory-tree walk, tool path resolution against session CWD, and
persistence across crash/restart. Implements #595 and #596.
… automatic context loading

Rewrite all OpenSpec artifacts (proposal, design, specs, tasks) to narrow
scope from general-purpose CWD tracking to project directory tracking:

- Replace `CurrentWorkingDirectory` with `ProjectDirectory` in WorkingContext
- Add standalone `set_working_directory` tool (profile-managed, audience-gated)
  instead of `set_cwd` parameter on shell_execute
- Drop shell CWD defaulting, file path resolution changes, cd detection,
  directory tree walker, and ToolExecutionContext.ToolWorkingDirectory
- Project identity files loaded from project root (no walking) and injected
  as [project-instructions] EveryTurn context layer
- Add session_dir to [session] block for agent visibility
- Unified security gate: CWD validated at set-time against audience roots
- 6 task groups, 21 tasks (down from 10 groups, 42 tasks)

Implements #595, #596.
@Aaronontheweb Aaronontheweb changed the title docs(openspec): session CWD tracking proposal (#595, #596) feat(openspec): project directory tracking and automatic context loading (#595, #596) Apr 24, 2026
…context layer

Move project identity file content from EveryTurn context layer (volatile
tail, never cached) to system prompt at position [0] (cached prefix, stable
across turns). This matches how the global AGENTS.md is loaded and gives
prompt-cache stability — cache busts only on project switch, then
re-stabilizes immediately.

Changes:
- D5 rewritten: extend SystemPromptAssembler.Assemble() instead of creating
  ProjectInstructionLayerProvider
- SetSystemPrompt() re-runs on project directory change
- No IContextLayerProvider, no Func<string?> accessor, no volatile tail
- Tasks updated: group 4 is now system prompt assembly, not context layer
…file loading

Sessions now track a mutable ProjectDirectory in WorkingContext that
persists across crash/restart via protobuf (tag 2). When set, the
project's identity file (.netclaw/AGENTS.md, CLAUDE.md, AGENTS.md, or
CONTEXT.md — first match wins) is automatically loaded into the system
prompt alongside global SOUL/AGENTS/TOOLING layers.

New set_working_directory tool validates the target directory exists and
is within the audience's allowed file access roots. Profile-managed so
Public/Team audiences cannot use it by default. The session actor
intercepts successful results (gated by Path.IsPathRooted) to update
WorkingContext and re-assemble the system prompt.

Also adds session_dir to the [session] context block so the agent knows
its full session directory path without inferring from media_dir.

ISystemPromptProvider.GetSystemPrompt() now accepts an optional
projectDirectory parameter — the provider remains stateless, avoiding
race conditions across concurrent session actors sharing the DI
singleton.

Implements openspec change: session-cwd-tracking
…abilities

Patches GHSA-g94r-2vxg-569j (OpenTelemetry.Api), GHSA-mr8r-92fq-pj8p and
GHSA-q834-8qmm-v933 (OpenTelemetry.Exporter.OpenTelemetryProtocol). Also
pins OpenTelemetry.Api explicitly to override the transitive 1.9.0 pulled
by Akka.Hosting.
@Aaronontheweb Aaronontheweb marked this pull request as ready for review April 24, 2026 21:40
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) April 24, 2026 21:40
@Aaronontheweb Aaronontheweb merged commit 2e11631 into dev Apr 24, 2026
4 checks passed
@Aaronontheweb Aaronontheweb deleted the feature/session-cwd-tracking branch April 24, 2026 21:45
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