merge: AgentProject membership — the junction is now load-bearing
Merges feat/agent-project-membership (task 166/152). An agent can finally join many projects: membership routes, per-membership role and optional brain override, chat resolving context from the membership, and CLI attach-agent / detach-agent / get memberships. The legacy Agent.projectId fallback is kept for this release as the schema comment promises. Conflict resolved in main.ts: that branch added its RBAC case to mapUrlToPermission inline, while this branch had extracted the function to middleware/url-permission.ts so it could be tested. Kept the extraction and ported the case into it — joining a team is `edit:agents:<name>`, not `create:agents`, which is the authority to mint a whole agent. Also fixes something the extraction makes possible. security.test.ts contained a hand-copied reproduction of mapUrlToPermission, because main.ts self-invokes main() and nothing in it was importable. A security test asserting against a copy stops testing the system the moment the real one changes, and this copy had already drifted. It now imports the real function; all 18 assertions still pass, against the code that actually runs. Local: build clean, workspace 2550 passed, lint unchanged at 794 errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4wNHWf7xSwnZCWpJcyv9p
This commit is contained in:
67
.taskmaster/tasks/task_048.md
Normal file
67
.taskmaster/tasks/task_048.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Task ID: 48
|
||||
|
||||
**Title:** Implement begin_session tool for gated sessions
|
||||
|
||||
**Status:** done
|
||||
|
||||
**Dependencies:** 46 ✓, 47 ✓
|
||||
|
||||
**Priority:** high
|
||||
|
||||
**Description:** Create the begin_session MCP tool that accepts 5 keywords, triggers prompt selection, returns matched content with encouragement, and ungates the session.
|
||||
|
||||
**Details:**
|
||||
|
||||
1. Add begin_session tool definition in `/src/mcplocal/src/router.ts`:
|
||||
```typescript
|
||||
private getBeginSessionTool(): Tool {
|
||||
return {
|
||||
name: 'begin_session',
|
||||
description: 'Start your session by providing 5 keywords that describe your current task. You\'ll receive relevant project context, policies, and guidelines. Required before using other tools.',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
tags: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
maxItems: 10,
|
||||
description: '5 keywords describing your current task'
|
||||
}
|
||||
},
|
||||
required: ['tags']
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
2. Implement begin_session handler:
|
||||
- Validate tags array (1-10 items)
|
||||
- Call LlmPromptSelector or TagMatcher based on LLM availability
|
||||
- Fetch full content for selected prompts
|
||||
- Build response with matched content + index + encouragement
|
||||
- Ungate session
|
||||
- Send `notifications/tools/list_changed`
|
||||
|
||||
3. Response format:
|
||||
```
|
||||
[Priority 10 prompts - full content]
|
||||
|
||||
[Tag-matched prompts - full content, priority-ordered]
|
||||
|
||||
Other prompts available that may become relevant...
|
||||
- name: summary
|
||||
...
|
||||
If any seem related, request them with read_prompts({ tags: [...] }).
|
||||
```
|
||||
|
||||
**Test Strategy:**
|
||||
|
||||
- Unit test: begin_session with valid tags returns matched prompts
|
||||
- Unit test: begin_session includes priority 10 prompts always
|
||||
- Unit test: begin_session response includes encouragement text
|
||||
- Unit test: begin_session response includes prompt index
|
||||
- Unit test: Session ungated after successful begin_session
|
||||
- Unit test: notifications/tools/list_changed sent after ungating
|
||||
- Unit test: Empty tags handled (returns priority 10 only)
|
||||
- Unit test: Invalid tags rejected with error
|
||||
- Unit test: begin_session while already ungated returns error
|
||||
Reference in New Issue
Block a user