aegis-mcp-server 0.1.12 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -100
- package/dist/services/policy-loader.d.ts +22 -0
- package/dist/services/policy-loader.d.ts.map +1 -1
- package/dist/services/policy-loader.js +56 -0
- package/dist/services/policy-loader.js.map +1 -1
- package/dist/tools/file-tools.d.ts +9 -3
- package/dist/tools/file-tools.d.ts.map +1 -1
- package/dist/tools/file-tools.js +126 -25
- package/dist/tools/file-tools.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/services/policy-loader.ts +65 -0
- package/src/tools/file-tools.ts +140 -26
package/README.md
CHANGED
|
@@ -1,141 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# aegis-mcp-server
|
|
2
|
+
<!-- mcp-name: io.github.cleburn/aegis-mcp -->
|
|
3
|
+
**MCP enforcement layer for the [Aegis](https://github.com/cleburn/aegis-spec) agent governance specification.**
|
|
2
4
|
|
|
3
|
-
The
|
|
5
|
+
The spec writes the law. The CLI generates the law. This enforces the law.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
## What It Does
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
`aegis-mcp-server` is an MCP server that validates every agent action against your `.agentpolicy/` files **before** it happens. Path permissions, content scanning, role boundaries, quality gates — all enforced at runtime with zero token overhead to the agent.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
The agent never loads your governance files. The MCP server reads them into its own process memory and validates silently. The agent calls governed tools and gets back either a success or a blocked response with the specific reason.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **Adam Jones** (Anthropic) [@domdomegg](https://github.com/domdomegg)
|
|
13
|
-
- **Tadas Antanavicius** (PulseMCP) [@tadasant](https://github.com/tadasant)
|
|
14
|
-
- **Toby Padilla** (GitHub) [@toby](https://github.com/toby)
|
|
13
|
+
## Quick Start
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
```bash
|
|
16
|
+
# Install globally
|
|
17
|
+
npm install -g aegis-mcp-server
|
|
18
|
+
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
If you generated your policy with [aegis-cli](https://github.com/cleburn/aegis-cli), the `.mcp.json` connection config is already in your project root. Just install the MCP and open your agent — it connects automatically.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- **[Discussions](https://github.com/modelcontextprotocol/registry/discussions)** - Propose and discuss product/technical requirements
|
|
24
|
-
- **[Issues](https://github.com/modelcontextprotocol/registry/issues)** - Track well-scoped technical work
|
|
25
|
-
- **[Pull Requests](https://github.com/modelcontextprotocol/registry/pulls)** - Contribute work towards issues
|
|
22
|
+
### First Prompt
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
When starting a new agent session in a governed project, use this as your first prompt:
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
```
|
|
27
|
+
Call aegis_policy_summary now. This is your governance contract — it defines your
|
|
28
|
+
role, your boundaries, and which tools to use. Do not read files, do not take any
|
|
29
|
+
action, and do not assume your role until you have called this tool.
|
|
30
|
+
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
- **Go 1.24.x**
|
|
33
|
-
- **golangci-lint v2.4.0**
|
|
32
|
+
## How It Works
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
### Universal Mode (Default)
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
# Start full development environment
|
|
39
|
-
make dev-compose
|
|
40
|
-
```
|
|
36
|
+
The MCP starts without a pre-assigned role. When the agent calls `aegis_policy_summary`, it receives the list of available roles from `.agentpolicy/roles/`. The agent presents them to the user, the user picks, and the agent calls `aegis_select_role` to lock in. All enforcement uses the selected role for the rest of the session.
|
|
41
37
|
|
|
42
|
-
This
|
|
38
|
+
This is the default behavior — no configuration needed beyond the `.mcp.json` that `aegis init` creates automatically.
|
|
43
39
|
|
|
44
|
-
|
|
40
|
+
### Fixed Mode
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
<summary>Alternative: Running a pre-built Docker image</summary>
|
|
42
|
+
If you know which role to assign at startup:
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"aegis": {
|
|
48
|
+
"command": "aegis-mcp",
|
|
49
|
+
"args": ["--project", ".", "--role", "backend"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
# Run latest stable release
|
|
53
|
-
docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:latest
|
|
55
|
+
The MCP locks to that role immediately. `aegis_policy_summary` returns the role's boundaries directly, skipping role selection.
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:main
|
|
57
|
+
## Tools
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
| Tool | What it does | Token cost |
|
|
60
|
+
|------|-------------|------------|
|
|
61
|
+
| `aegis_policy_summary` | Role boundaries and governance summary (or available roles in universal mode) | ~200 tokens |
|
|
62
|
+
| `aegis_select_role` | Select a role in universal mode | Tiny |
|
|
63
|
+
| `aegis_check_permissions` | Pre-check if an operation is allowed | Tiny |
|
|
64
|
+
| `aegis_write_file` | Governed write with path + content validation | Same as a normal write |
|
|
65
|
+
| `aegis_read_file` | Governed read with path validation | Same as a normal read |
|
|
66
|
+
| `aegis_delete_file` | Governed delete with path validation | Tiny |
|
|
67
|
+
| `aegis_execute` | Governed command execution | Command output only |
|
|
68
|
+
| `aegis_complete_task` | Run quality gates before marking done | Gate results only |
|
|
69
|
+
| `aegis_request_override` | Execute a blocked action after human confirmation | Tiny |
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:main-20250906-abc123d
|
|
63
|
-
```
|
|
71
|
+
## Zero Token Overhead
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
- **Releases**: `latest`, `v1.0.0`, `v1.1.0`, etc.
|
|
67
|
-
- **Continuous**: `main` (latest main branch build)
|
|
68
|
-
- **Development**: `main-<date>-<sha>` (specific commit builds)
|
|
73
|
+
Traditional approach: load governance files into the agent's context window. Token cost scales with policy complexity.
|
|
69
74
|
|
|
70
|
-
|
|
75
|
+
Aegis MCP approach: the server loads policy into its own process memory. The agent calls tools and gets structured results. A project with 200 lines of governance has the same token cost as one with 20 lines. The complexity is absorbed by the server, not the agent.
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
## Enforcement
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
- **Governance boundaries** — `writable`, `read_only`, `forbidden` path lists
|
|
80
|
+
- **Role scoping** — agents confined to their role's writable and readable paths
|
|
81
|
+
- **Sensitive pattern detection** — content scanned against governance-defined patterns
|
|
82
|
+
- **Cross-domain boundaries** — imports validated against shared interface rules
|
|
83
|
+
- **Quality gate validation** — `pre_commit` flags mapped to `build_commands` and executed
|
|
84
|
+
- **Override logging** — every blocked action logged to append-only `overrides.jsonl`
|
|
85
|
+
- **Immutable policies** — designated rules that cannot be overridden, ever
|
|
75
86
|
|
|
76
|
-
|
|
77
|
-
# Build the latest CLI
|
|
78
|
-
make publisher
|
|
87
|
+
## Override Protocol
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
./bin/mcp-publisher --help
|
|
82
|
-
```
|
|
89
|
+
When an action is blocked and the governance override behavior is `warn_confirm_and_log`:
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
1. The blocked response includes an `override_token` and the specific policy violated
|
|
92
|
+
2. The agent presents the violation to the user
|
|
93
|
+
3. If the user confirms, the agent calls `aegis_request_override` with the token and the user's rationale
|
|
94
|
+
4. The action proceeds — the override is logged with `human_confirmed: true`
|
|
95
|
+
5. Normal governance resumes immediately — the override is a one-time exception
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
Immutable policies (e.g., HIPAA compliance, audit completeness) return `override_available: false` and cannot be overridden. The user must modify the governance through `aegis init`.
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
# Run lint, unit tests and integration tests
|
|
90
|
-
make check
|
|
91
|
-
```
|
|
99
|
+
## Consent-Based Governance
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
The Aegis MCP does not override the agent's native directives. It introduces itself through tool descriptions, explains why governance is active, and asks the agent to seek user permission to route write operations through Aegis tools. The user's authority is the enforcement mechanism.
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
For Claude and other AI tools: Always prefer make targets over custom commands where possible.
|
|
97
|
-
-->
|
|
103
|
+
Native tools for reading, searching, and exploring the codebase work fine without governance gating. Only write, delete, and execute operations benefit from routing through Aegis.
|
|
98
104
|
|
|
99
105
|
## Architecture
|
|
100
106
|
|
|
101
|
-
### Project Structure
|
|
102
|
-
|
|
103
107
|
```
|
|
104
|
-
|
|
105
|
-
│
|
|
106
|
-
├──
|
|
107
|
-
├──
|
|
108
|
-
├──
|
|
109
|
-
├──
|
|
110
|
-
|
|
111
|
-
│ ├── auth/ # Authentication (GitHub OAuth, JWT, namespace blocking)
|
|
112
|
-
│ ├── config/ # Configuration management
|
|
113
|
-
│ ├── database/ # Data persistence (PostgreSQL)
|
|
114
|
-
│ ├── service/ # Business logic
|
|
115
|
-
│ ├── telemetry/ # Metrics and monitoring
|
|
116
|
-
│ └── validators/ # Input validation
|
|
117
|
-
├── pkg/ # Public packages
|
|
118
|
-
│ ├── api/ # API types and structures
|
|
119
|
-
│ │ └── v0/ # Version 0 API types
|
|
120
|
-
│ └── model/ # Data models for server.json
|
|
121
|
-
├── scripts/ # Development and testing scripts
|
|
122
|
-
├── tests/ # Integration tests
|
|
123
|
-
└── tools/ # CLI tools and utilities
|
|
124
|
-
└── validate-*.sh # Schema validation tools
|
|
108
|
+
Agent ──→ aegis-mcp-server ──→ File System
|
|
109
|
+
│
|
|
110
|
+
├── Loads .agentpolicy/ into process memory (once)
|
|
111
|
+
├── Watches for policy changes (auto-reload)
|
|
112
|
+
├── Validates every tool call against policy
|
|
113
|
+
├── Returns success or blocked with override option
|
|
114
|
+
└── Logs all enforcement decisions to overrides.jsonl
|
|
125
115
|
```
|
|
126
116
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Publishing supports multiple authentication methods:
|
|
130
|
-
- **GitHub OAuth** - For publishing by logging into GitHub
|
|
131
|
-
- **GitHub OIDC** - For publishing from GitHub Actions
|
|
132
|
-
- **DNS verification** - For proving ownership of a domain and its subdomains
|
|
133
|
-
- **HTTP verification** - For proving ownership of a domain
|
|
117
|
+
Three artifacts, one governance framework:
|
|
134
118
|
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
119
|
+
- [**aegis-spec**](https://github.com/cleburn/aegis-spec) — Writes the law
|
|
120
|
+
- [**aegis-cli**](https://github.com/cleburn/aegis-cli) — Generates the law
|
|
121
|
+
- **aegis-mcp-server** — Enforces the law
|
|
138
122
|
|
|
139
|
-
##
|
|
123
|
+
## License
|
|
140
124
|
|
|
141
|
-
|
|
125
|
+
MIT
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* Supports "auto" role mode: when config.role is "auto" (or not specified),
|
|
8
8
|
* no role is locked at startup. The agent selects a role at runtime via
|
|
9
9
|
* aegis_select_role, and all enforcement uses the selected role thereafter.
|
|
10
|
+
*
|
|
11
|
+
* Construction mode: The "construction" role is always available for initial
|
|
12
|
+
* builds and major restructuring. It grants full repo access using native
|
|
13
|
+
* tools, with governance files serving as the blueprint. The MCP logs the
|
|
14
|
+
* session start and end to overrides.jsonl for audit trail purposes.
|
|
10
15
|
*/
|
|
11
16
|
import type { PolicyState, ResolvedRole, AegisMcpConfig } from '../types.js';
|
|
12
17
|
export declare class PolicyLoader {
|
|
@@ -15,6 +20,8 @@ export declare class PolicyLoader {
|
|
|
15
20
|
private watcher;
|
|
16
21
|
private onReload?;
|
|
17
22
|
private selectedRole;
|
|
23
|
+
private constructionMode;
|
|
24
|
+
private constructionStartedAt;
|
|
18
25
|
constructor(config: AegisMcpConfig);
|
|
19
26
|
/**
|
|
20
27
|
* Load all policy files into memory. Call once on startup.
|
|
@@ -40,12 +47,27 @@ export declare class PolicyLoader {
|
|
|
40
47
|
* Whether a role has been selected in auto mode.
|
|
41
48
|
*/
|
|
42
49
|
hasSelectedRole(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether construction mode is currently active.
|
|
52
|
+
*/
|
|
53
|
+
isConstructionMode(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Get the timestamp when construction mode was started.
|
|
56
|
+
*/
|
|
57
|
+
getConstructionStartedAt(): string | null;
|
|
43
58
|
/**
|
|
44
59
|
* Select a role in auto mode. Returns the resolved role, or null if not found.
|
|
60
|
+
* Recognizes "construction" as a synthetic role that activates construction mode.
|
|
45
61
|
*/
|
|
46
62
|
selectRole(roleId: string): ResolvedRole | null;
|
|
63
|
+
/**
|
|
64
|
+
* End construction mode. Called when aegis_complete_task fires
|
|
65
|
+
* during a construction session.
|
|
66
|
+
*/
|
|
67
|
+
endConstructionMode(): void;
|
|
47
68
|
/**
|
|
48
69
|
* Get all available roles as a summary list.
|
|
70
|
+
* Always includes the synthetic "construction" role.
|
|
49
71
|
*/
|
|
50
72
|
getAvailableRoles(): Array<{
|
|
51
73
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-loader.d.ts","sourceRoot":"","sources":["../../src/services/policy-loader.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"policy-loader.d.ts","sourceRoot":"","sources":["../../src/services/policy-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,WAAW,EAIX,YAAY,EACZ,cAAc,EACf,MAAM,aAAa,CAAC;AAgBrB,qBAAa,YAAY;IAQX,OAAO,CAAC,MAAM;IAP1B,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,qBAAqB,CAAuB;gBAEhC,MAAM,EAAE,cAAc;IAE1C;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IA4BlC;;OAEG;IACH,QAAQ,IAAI,WAAW;IAOvB;;OAEG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAgB1C;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnC;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,wBAAwB,IAAI,MAAM,GAAG,IAAI;IAIzC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAmB/C;;;OAGG;IACH,mBAAmB,IAAI,IAAI;IAK3B;;;OAGG;IACH,iBAAiB,IAAI,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAmBzE;;;;OAIG;IACH,aAAa,IAAI,YAAY;IAiD7B,OAAO,CAAC,gBAAgB;YAOV,QAAQ;YAYR,SAAS;IAyBvB;;OAEG;IACH,OAAO,CAAC,WAAW;YAoCL,YAAY;YAYZ,YAAY;IAQ1B,OAAO,CAAC,GAAG;CAGZ"}
|
|
@@ -7,16 +7,35 @@
|
|
|
7
7
|
* Supports "auto" role mode: when config.role is "auto" (or not specified),
|
|
8
8
|
* no role is locked at startup. The agent selects a role at runtime via
|
|
9
9
|
* aegis_select_role, and all enforcement uses the selected role thereafter.
|
|
10
|
+
*
|
|
11
|
+
* Construction mode: The "construction" role is always available for initial
|
|
12
|
+
* builds and major restructuring. It grants full repo access using native
|
|
13
|
+
* tools, with governance files serving as the blueprint. The MCP logs the
|
|
14
|
+
* session start and end to overrides.jsonl for audit trail purposes.
|
|
10
15
|
*/
|
|
11
16
|
import { readFile, readdir, access } from 'node:fs/promises';
|
|
12
17
|
import { join, basename } from 'node:path';
|
|
13
18
|
import { watch } from 'chokidar';
|
|
19
|
+
// ─── Construction Role (synthetic, always available) ────────────────────────
|
|
20
|
+
const CONSTRUCTION_ROLE = {
|
|
21
|
+
id: 'construction',
|
|
22
|
+
name: 'Construction',
|
|
23
|
+
purpose: 'Initial build or major restructuring — full repo access using native tools, governance files serve as blueprint. MCP logs the session but does not enforce write restrictions. Select this for greenfield builds or significant overhauls.',
|
|
24
|
+
writable_paths: ['**/*'],
|
|
25
|
+
secondary_paths: [],
|
|
26
|
+
excluded_paths: [],
|
|
27
|
+
readable_paths: ['**/*'],
|
|
28
|
+
autonomy: 'delegated',
|
|
29
|
+
forbidden_actions: [],
|
|
30
|
+
};
|
|
14
31
|
export class PolicyLoader {
|
|
15
32
|
config;
|
|
16
33
|
state = null;
|
|
17
34
|
watcher = null;
|
|
18
35
|
onReload;
|
|
19
36
|
selectedRole = null;
|
|
37
|
+
constructionMode = false;
|
|
38
|
+
constructionStartedAt = null;
|
|
20
39
|
constructor(config) {
|
|
21
40
|
this.config = config;
|
|
22
41
|
}
|
|
@@ -84,10 +103,31 @@ export class PolicyLoader {
|
|
|
84
103
|
hasSelectedRole() {
|
|
85
104
|
return this.selectedRole !== null;
|
|
86
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether construction mode is currently active.
|
|
108
|
+
*/
|
|
109
|
+
isConstructionMode() {
|
|
110
|
+
return this.constructionMode;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the timestamp when construction mode was started.
|
|
114
|
+
*/
|
|
115
|
+
getConstructionStartedAt() {
|
|
116
|
+
return this.constructionStartedAt;
|
|
117
|
+
}
|
|
87
118
|
/**
|
|
88
119
|
* Select a role in auto mode. Returns the resolved role, or null if not found.
|
|
120
|
+
* Recognizes "construction" as a synthetic role that activates construction mode.
|
|
89
121
|
*/
|
|
90
122
|
selectRole(roleId) {
|
|
123
|
+
// Handle construction role selection
|
|
124
|
+
if (roleId === 'construction') {
|
|
125
|
+
this.selectedRole = CONSTRUCTION_ROLE;
|
|
126
|
+
this.constructionMode = true;
|
|
127
|
+
this.constructionStartedAt = new Date().toISOString();
|
|
128
|
+
this.log('Construction mode activated');
|
|
129
|
+
return CONSTRUCTION_ROLE;
|
|
130
|
+
}
|
|
91
131
|
const state = this.getState();
|
|
92
132
|
const role = state.roles.get(roleId);
|
|
93
133
|
if (!role)
|
|
@@ -96,12 +136,28 @@ export class PolicyLoader {
|
|
|
96
136
|
this.log(`Role selected: ${roleId}`);
|
|
97
137
|
return role;
|
|
98
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* End construction mode. Called when aegis_complete_task fires
|
|
141
|
+
* during a construction session.
|
|
142
|
+
*/
|
|
143
|
+
endConstructionMode() {
|
|
144
|
+
this.constructionMode = false;
|
|
145
|
+
this.log('Construction mode ended');
|
|
146
|
+
}
|
|
99
147
|
/**
|
|
100
148
|
* Get all available roles as a summary list.
|
|
149
|
+
* Always includes the synthetic "construction" role.
|
|
101
150
|
*/
|
|
102
151
|
getAvailableRoles() {
|
|
103
152
|
const state = this.getState();
|
|
104
153
|
const roles = [];
|
|
154
|
+
// Construction role is always first in the list
|
|
155
|
+
roles.push({
|
|
156
|
+
id: CONSTRUCTION_ROLE.id,
|
|
157
|
+
name: CONSTRUCTION_ROLE.name,
|
|
158
|
+
purpose: CONSTRUCTION_ROLE.purpose,
|
|
159
|
+
});
|
|
160
|
+
// Then all project-defined roles
|
|
105
161
|
for (const [id, role] of state.roles) {
|
|
106
162
|
roles.push({ id, name: role.name, purpose: role.purpose });
|
|
107
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-loader.js","sourceRoot":"","sources":["../../src/services/policy-loader.ts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;YACH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CACN,4BAA4B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,KAAa;QACpD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,kBAAkB,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAEO,GAAG,CAAC,OAAe;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,OAAO,IAAI,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -5,9 +5,15 @@
|
|
|
5
5
|
* governance, and asks the agent to seek user permission.
|
|
6
6
|
*
|
|
7
7
|
* ROLE SELECTION: In universal/auto mode, aegis_policy_summary returns
|
|
8
|
-
* available roles
|
|
9
|
-
*
|
|
10
|
-
* the selected role thereafter.
|
|
8
|
+
* available roles (including the synthetic "construction" role). The agent
|
|
9
|
+
* presents them to the user, who picks one. The agent calls aegis_select_role
|
|
10
|
+
* to lock in. All enforcement uses the selected role thereafter.
|
|
11
|
+
*
|
|
12
|
+
* CONSTRUCTION MODE: When "construction" is selected, the MCP logs the
|
|
13
|
+
* session start to overrides.jsonl and instructs the agent to use native
|
|
14
|
+
* tools for file operations while following .agentpolicy/ as a blueprint.
|
|
15
|
+
* When aegis_complete_task is called during construction, the MCP logs
|
|
16
|
+
* the session end with a closing timestamp.
|
|
11
17
|
*
|
|
12
18
|
* OVERRIDE HANDSHAKE: Blocked actions return override tokens when policy
|
|
13
19
|
* allows. Human confirms → agent calls aegis_request_override → action
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM7D,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,iBAAiB,EAClC,QAAQ,EAAE,MAAM,WAAW,EAC3B,OAAO,EAAE,MAAM,YAAY,EAC3B,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAC3C,IAAI,CAksBN"}
|
package/dist/tools/file-tools.js
CHANGED
|
@@ -5,9 +5,15 @@
|
|
|
5
5
|
* governance, and asks the agent to seek user permission.
|
|
6
6
|
*
|
|
7
7
|
* ROLE SELECTION: In universal/auto mode, aegis_policy_summary returns
|
|
8
|
-
* available roles
|
|
9
|
-
*
|
|
10
|
-
* the selected role thereafter.
|
|
8
|
+
* available roles (including the synthetic "construction" role). The agent
|
|
9
|
+
* presents them to the user, who picks one. The agent calls aegis_select_role
|
|
10
|
+
* to lock in. All enforcement uses the selected role thereafter.
|
|
11
|
+
*
|
|
12
|
+
* CONSTRUCTION MODE: When "construction" is selected, the MCP logs the
|
|
13
|
+
* session start to overrides.jsonl and instructs the agent to use native
|
|
14
|
+
* tools for file operations while following .agentpolicy/ as a blueprint.
|
|
15
|
+
* When aegis_complete_task is called during construction, the MCP logs
|
|
16
|
+
* the session end with a closing timestamp.
|
|
11
17
|
*
|
|
12
18
|
* OVERRIDE HANDSHAKE: Blocked actions return override tokens when policy
|
|
13
19
|
* allows. Human confirms → agent calls aegis_request_override → action
|
|
@@ -27,8 +33,10 @@ export function registerTools(server, getEngine, getState, getRole, loader, onRo
|
|
|
27
33
|
title: 'Select Role',
|
|
28
34
|
description: `${GOVERNANCE_INTRO}Select a role for this session. Call this after aegis_policy_summary shows available roles and the user has chosen one. The MCP locks to the selected role for the remainder of the session — all enforcement uses this role's boundaries. This is a one-time selection per session.
|
|
29
35
|
|
|
36
|
+
The "construction" role is available for initial builds and major restructuring. It grants full repo access using native tools, with governance files as the blueprint.
|
|
37
|
+
|
|
30
38
|
Args:
|
|
31
|
-
- role_id (string): The role ID to select (e.g., "backend", "frontend", "qa")
|
|
39
|
+
- role_id (string): The role ID to select (e.g., "construction", "backend", "frontend", "qa")
|
|
32
40
|
|
|
33
41
|
Returns:
|
|
34
42
|
{ "status": "role_selected", "role": "...", ... } or { "status": "error", "reason": "..." }`,
|
|
@@ -70,6 +78,34 @@ Returns:
|
|
|
70
78
|
}
|
|
71
79
|
// Notify the main process to update engine references
|
|
72
80
|
onRoleSelected(role);
|
|
81
|
+
// If construction mode was activated, log the opening entry
|
|
82
|
+
if (loader.isConstructionMode()) {
|
|
83
|
+
const engine = getEngine();
|
|
84
|
+
await engine.logOverride({
|
|
85
|
+
timestamp: loader.getConstructionStartedAt() ?? new Date().toISOString(),
|
|
86
|
+
policy_violated: 'construction_mode_activated',
|
|
87
|
+
policy_text: 'Construction mode — governance enforcement suspended for initial build. Agent uses native tools with .agentpolicy/ as blueprint.',
|
|
88
|
+
action_requested: 'construction_mode: start',
|
|
89
|
+
human_confirmed: true,
|
|
90
|
+
agent_role: 'construction',
|
|
91
|
+
rationale: 'Initial build — governance files used as blueprint, native tools for file operations',
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
content: [{
|
|
95
|
+
type: 'text',
|
|
96
|
+
text: JSON.stringify({
|
|
97
|
+
status: 'role_selected',
|
|
98
|
+
role: 'construction',
|
|
99
|
+
role_name: 'Construction',
|
|
100
|
+
construction_mode: true,
|
|
101
|
+
started_at: loader.getConstructionStartedAt(),
|
|
102
|
+
message: 'Construction mode is now active. Read the .agentpolicy/ directory as your blueprint — constitution.json for architecture and principles, governance.json for conventions and quality gates, role files for module ownership and boundaries. Use your native tools for all file operations (not Aegis governed tools). When the build is complete, call aegis_complete_task to close construction mode. All future sessions after construction should select a specialist role for governed operations.',
|
|
103
|
+
instructions: 'Use native file tools for reads, writes, and deletes. Follow the governance files as your blueprint for architecture, conventions, and quality standards. The MCP is logging this construction session for the audit trail.',
|
|
104
|
+
}),
|
|
105
|
+
}],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Normal role selection response
|
|
73
109
|
return {
|
|
74
110
|
content: [{
|
|
75
111
|
type: 'text',
|
|
@@ -428,7 +464,7 @@ Returns:
|
|
|
428
464
|
// ─── aegis_complete_task ──────────────────────────────────────────────────
|
|
429
465
|
server.registerTool('aegis_complete_task', {
|
|
430
466
|
title: 'Complete Task',
|
|
431
|
-
description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates.
|
|
467
|
+
description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates. In construction mode, this also closes the construction session and logs the closing timestamp — all future sessions should select a specialist role for governed operations.
|
|
432
468
|
|
|
433
469
|
Args:
|
|
434
470
|
- task_id (string): Identifier for the task being completed
|
|
@@ -449,6 +485,41 @@ Returns:
|
|
|
449
485
|
}, async ({ task_id, summary }) => {
|
|
450
486
|
const engine = getEngine();
|
|
451
487
|
const state = getState();
|
|
488
|
+
// If construction mode is active, log the closing entry
|
|
489
|
+
if (loader.isConstructionMode()) {
|
|
490
|
+
const startedAt = loader.getConstructionStartedAt();
|
|
491
|
+
const completedAt = new Date().toISOString();
|
|
492
|
+
await engine.logOverride({
|
|
493
|
+
timestamp: completedAt,
|
|
494
|
+
policy_violated: 'construction_mode_completed',
|
|
495
|
+
policy_text: 'Construction mode ended — governance enforcement resumes for all future sessions.',
|
|
496
|
+
action_requested: 'construction_mode: end',
|
|
497
|
+
human_confirmed: true,
|
|
498
|
+
agent_role: 'construction',
|
|
499
|
+
rationale: `Construction complete. Started: ${startedAt}. Summary: ${summary}`,
|
|
500
|
+
});
|
|
501
|
+
loader.endConstructionMode();
|
|
502
|
+
// Still run quality gates if configured
|
|
503
|
+
const gates = engine.getQualityGateCommands();
|
|
504
|
+
const results = await runQualityGates(gates, state.projectRoot);
|
|
505
|
+
const allPassed = results.every((r) => r.passed);
|
|
506
|
+
return {
|
|
507
|
+
content: [{
|
|
508
|
+
type: 'text',
|
|
509
|
+
text: JSON.stringify({
|
|
510
|
+
status: allPassed ? 'passed' : 'failed',
|
|
511
|
+
task_id,
|
|
512
|
+
summary,
|
|
513
|
+
construction_mode_closed: true,
|
|
514
|
+
construction_started_at: startedAt,
|
|
515
|
+
construction_completed_at: completedAt,
|
|
516
|
+
gates_run: results,
|
|
517
|
+
message: 'Construction mode is now closed. All future agent sessions should select a specialist role for governed operations. The construction session has been logged to the audit trail.',
|
|
518
|
+
}),
|
|
519
|
+
}],
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
// Normal (non-construction) task completion
|
|
452
523
|
const gates = engine.getQualityGateCommands();
|
|
453
524
|
if (gates.length === 0) {
|
|
454
525
|
return {
|
|
@@ -464,25 +535,7 @@ Returns:
|
|
|
464
535
|
}],
|
|
465
536
|
};
|
|
466
537
|
}
|
|
467
|
-
const results =
|
|
468
|
-
for (const gate of gates) {
|
|
469
|
-
try {
|
|
470
|
-
const output = execSync(gate.command, {
|
|
471
|
-
cwd: state.projectRoot,
|
|
472
|
-
encoding: 'utf-8',
|
|
473
|
-
timeout: 120_000,
|
|
474
|
-
});
|
|
475
|
-
results.push({ name: gate.name, passed: true, output: output.slice(0, 500) });
|
|
476
|
-
}
|
|
477
|
-
catch (err) {
|
|
478
|
-
const execErr = err;
|
|
479
|
-
results.push({
|
|
480
|
-
name: gate.name,
|
|
481
|
-
passed: false,
|
|
482
|
-
output: (execErr.stderr ?? execErr.message ?? 'Failed').slice(0, 500),
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
}
|
|
538
|
+
const results = await runQualityGates(gates, state.projectRoot);
|
|
486
539
|
const allPassed = results.every((r) => r.passed);
|
|
487
540
|
return {
|
|
488
541
|
content: [{
|
|
@@ -499,10 +552,11 @@ Returns:
|
|
|
499
552
|
// ─── aegis_policy_summary ─────────────────────────────────────────────────
|
|
500
553
|
server.registerTool('aegis_policy_summary', {
|
|
501
554
|
title: 'Policy Summary',
|
|
502
|
-
description: `${GOVERNANCE_INTRO}Get your governance summary. In universal mode (no role pre-assigned), this returns the list of available roles — present them to the user and ask which role to use, then call aegis_select_role. In fixed mode (role pre-assigned), this returns your role boundaries and governance rules. Call this FIRST before doing any work.
|
|
555
|
+
description: `${GOVERNANCE_INTRO}Get your governance summary. In universal mode (no role pre-assigned), this returns the list of available roles (including "construction" for initial builds) — present them to the user and ask which role to use, then call aegis_select_role. In fixed mode (role pre-assigned), this returns your role boundaries and governance rules. Call this FIRST before doing any work.
|
|
503
556
|
|
|
504
557
|
Returns:
|
|
505
558
|
Universal mode: { "mode": "role_selection_required", "available_roles": [...] }
|
|
559
|
+
Construction mode: { "mode": "construction_active", ... }
|
|
506
560
|
Fixed/selected mode: { "governance_notice": "...", "role": "...", "writable_paths": [...], ... }`,
|
|
507
561
|
inputSchema: {},
|
|
508
562
|
annotations: {
|
|
@@ -530,6 +584,27 @@ Returns:
|
|
|
530
584
|
}],
|
|
531
585
|
};
|
|
532
586
|
}
|
|
587
|
+
// Construction mode is active — return construction-specific guidance
|
|
588
|
+
if (loader.isConstructionMode()) {
|
|
589
|
+
return {
|
|
590
|
+
content: [{
|
|
591
|
+
type: 'text',
|
|
592
|
+
text: JSON.stringify({
|
|
593
|
+
mode: 'construction_active',
|
|
594
|
+
governance_notice: 'Construction mode is active. The .agentpolicy/ directory is your blueprint — read it for architecture, conventions, quality standards, and module ownership. Use your native tools for all file operations. When the build is complete, call aegis_complete_task to close construction mode.',
|
|
595
|
+
project: state.constitution.project.name,
|
|
596
|
+
role: 'construction',
|
|
597
|
+
started_at: loader.getConstructionStartedAt(),
|
|
598
|
+
blueprint_files: [
|
|
599
|
+
'.agentpolicy/constitution.json — project identity, tech stack, principles, module map',
|
|
600
|
+
'.agentpolicy/governance.json — conventions, quality gates, escalation rules, permissions',
|
|
601
|
+
'.agentpolicy/roles/ — module ownership and boundaries (reference for build structure)',
|
|
602
|
+
],
|
|
603
|
+
instructions: 'Read the governance files as your blueprint. Use native tools for all file operations. Follow the conventions and quality standards defined in governance.json. When complete, call aegis_complete_task.',
|
|
604
|
+
}),
|
|
605
|
+
}],
|
|
606
|
+
};
|
|
607
|
+
}
|
|
533
608
|
// Role is assigned (fixed mode or selected in auto mode)
|
|
534
609
|
const protocol = state.governance.override_protocol;
|
|
535
610
|
const summary = {
|
|
@@ -592,4 +667,30 @@ async function logBlocked(engine, role, path, operation, reason) {
|
|
|
592
667
|
rationale: 'Blocked by enforcement layer',
|
|
593
668
|
});
|
|
594
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* Run quality gate commands and collect results.
|
|
672
|
+
* Extracted as a shared helper for both normal and construction completion.
|
|
673
|
+
*/
|
|
674
|
+
async function runQualityGates(gates, projectRoot) {
|
|
675
|
+
const results = [];
|
|
676
|
+
for (const gate of gates) {
|
|
677
|
+
try {
|
|
678
|
+
const output = execSync(gate.command, {
|
|
679
|
+
cwd: projectRoot,
|
|
680
|
+
encoding: 'utf-8',
|
|
681
|
+
timeout: 120_000,
|
|
682
|
+
});
|
|
683
|
+
results.push({ name: gate.name, passed: true, output: output.slice(0, 500) });
|
|
684
|
+
}
|
|
685
|
+
catch (err) {
|
|
686
|
+
const execErr = err;
|
|
687
|
+
results.push({
|
|
688
|
+
name: gate.name,
|
|
689
|
+
passed: false,
|
|
690
|
+
output: (execErr.stderr ?? execErr.message ?? 'Failed').slice(0, 500),
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return results;
|
|
695
|
+
}
|
|
595
696
|
//# sourceMappingURL=file-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tools.js","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,+EAA+E;AAE/E,MAAM,gBAAgB,GAAG,m5BAAm5B,CAAC;AAE76B,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,SAAkC,EAClC,QAA2B,EAC3B,OAA2B,EAC3B,MAAoB,EACpB,cAA4C;IAG5C,6EAA6E;IAE7E,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,GAAG,gBAAgB;;;;;;8FAMwD;QACxF,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;SAC/E;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,KAAK;SACrB;KACF,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,OAAO,EAAE,IA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"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.12",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
14
14
|
"identifier": "aegis-mcp-server",
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.12",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
}
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* Supports "auto" role mode: when config.role is "auto" (or not specified),
|
|
8
8
|
* no role is locked at startup. The agent selects a role at runtime via
|
|
9
9
|
* aegis_select_role, and all enforcement uses the selected role thereafter.
|
|
10
|
+
*
|
|
11
|
+
* Construction mode: The "construction" role is always available for initial
|
|
12
|
+
* builds and major restructuring. It grants full repo access using native
|
|
13
|
+
* tools, with governance files serving as the blueprint. The MCP logs the
|
|
14
|
+
* session start and end to overrides.jsonl for audit trail purposes.
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
17
|
import { readFile, readdir, access } from 'node:fs/promises';
|
|
@@ -21,11 +26,27 @@ import type {
|
|
|
21
26
|
AegisMcpConfig,
|
|
22
27
|
} from '../types.js';
|
|
23
28
|
|
|
29
|
+
// ─── Construction Role (synthetic, always available) ────────────────────────
|
|
30
|
+
|
|
31
|
+
const CONSTRUCTION_ROLE: ResolvedRole = {
|
|
32
|
+
id: 'construction',
|
|
33
|
+
name: 'Construction',
|
|
34
|
+
purpose: 'Initial build or major restructuring — full repo access using native tools, governance files serve as blueprint. MCP logs the session but does not enforce write restrictions. Select this for greenfield builds or significant overhauls.',
|
|
35
|
+
writable_paths: ['**/*'],
|
|
36
|
+
secondary_paths: [],
|
|
37
|
+
excluded_paths: [],
|
|
38
|
+
readable_paths: ['**/*'],
|
|
39
|
+
autonomy: 'delegated',
|
|
40
|
+
forbidden_actions: [],
|
|
41
|
+
};
|
|
42
|
+
|
|
24
43
|
export class PolicyLoader {
|
|
25
44
|
private state: PolicyState | null = null;
|
|
26
45
|
private watcher: ReturnType<typeof watch> | null = null;
|
|
27
46
|
private onReload?: () => void;
|
|
28
47
|
private selectedRole: ResolvedRole | null = null;
|
|
48
|
+
private constructionMode = false;
|
|
49
|
+
private constructionStartedAt: string | null = null;
|
|
29
50
|
|
|
30
51
|
constructor(private config: AegisMcpConfig) {}
|
|
31
52
|
|
|
@@ -113,10 +134,34 @@ export class PolicyLoader {
|
|
|
113
134
|
return this.selectedRole !== null;
|
|
114
135
|
}
|
|
115
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Whether construction mode is currently active.
|
|
139
|
+
*/
|
|
140
|
+
isConstructionMode(): boolean {
|
|
141
|
+
return this.constructionMode;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get the timestamp when construction mode was started.
|
|
146
|
+
*/
|
|
147
|
+
getConstructionStartedAt(): string | null {
|
|
148
|
+
return this.constructionStartedAt;
|
|
149
|
+
}
|
|
150
|
+
|
|
116
151
|
/**
|
|
117
152
|
* Select a role in auto mode. Returns the resolved role, or null if not found.
|
|
153
|
+
* Recognizes "construction" as a synthetic role that activates construction mode.
|
|
118
154
|
*/
|
|
119
155
|
selectRole(roleId: string): ResolvedRole | null {
|
|
156
|
+
// Handle construction role selection
|
|
157
|
+
if (roleId === 'construction') {
|
|
158
|
+
this.selectedRole = CONSTRUCTION_ROLE;
|
|
159
|
+
this.constructionMode = true;
|
|
160
|
+
this.constructionStartedAt = new Date().toISOString();
|
|
161
|
+
this.log('Construction mode activated');
|
|
162
|
+
return CONSTRUCTION_ROLE;
|
|
163
|
+
}
|
|
164
|
+
|
|
120
165
|
const state = this.getState();
|
|
121
166
|
const role = state.roles.get(roleId);
|
|
122
167
|
if (!role) return null;
|
|
@@ -126,15 +171,35 @@ export class PolicyLoader {
|
|
|
126
171
|
return role;
|
|
127
172
|
}
|
|
128
173
|
|
|
174
|
+
/**
|
|
175
|
+
* End construction mode. Called when aegis_complete_task fires
|
|
176
|
+
* during a construction session.
|
|
177
|
+
*/
|
|
178
|
+
endConstructionMode(): void {
|
|
179
|
+
this.constructionMode = false;
|
|
180
|
+
this.log('Construction mode ended');
|
|
181
|
+
}
|
|
182
|
+
|
|
129
183
|
/**
|
|
130
184
|
* Get all available roles as a summary list.
|
|
185
|
+
* Always includes the synthetic "construction" role.
|
|
131
186
|
*/
|
|
132
187
|
getAvailableRoles(): Array<{ id: string; name: string; purpose: string }> {
|
|
133
188
|
const state = this.getState();
|
|
134
189
|
const roles: Array<{ id: string; name: string; purpose: string }> = [];
|
|
190
|
+
|
|
191
|
+
// Construction role is always first in the list
|
|
192
|
+
roles.push({
|
|
193
|
+
id: CONSTRUCTION_ROLE.id,
|
|
194
|
+
name: CONSTRUCTION_ROLE.name,
|
|
195
|
+
purpose: CONSTRUCTION_ROLE.purpose,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Then all project-defined roles
|
|
135
199
|
for (const [id, role] of state.roles) {
|
|
136
200
|
roles.push({ id, name: role.name, purpose: role.purpose });
|
|
137
201
|
}
|
|
202
|
+
|
|
138
203
|
return roles;
|
|
139
204
|
}
|
|
140
205
|
|
package/src/tools/file-tools.ts
CHANGED
|
@@ -5,9 +5,15 @@
|
|
|
5
5
|
* governance, and asks the agent to seek user permission.
|
|
6
6
|
*
|
|
7
7
|
* ROLE SELECTION: In universal/auto mode, aegis_policy_summary returns
|
|
8
|
-
* available roles
|
|
9
|
-
*
|
|
10
|
-
* the selected role thereafter.
|
|
8
|
+
* available roles (including the synthetic "construction" role). The agent
|
|
9
|
+
* presents them to the user, who picks one. The agent calls aegis_select_role
|
|
10
|
+
* to lock in. All enforcement uses the selected role thereafter.
|
|
11
|
+
*
|
|
12
|
+
* CONSTRUCTION MODE: When "construction" is selected, the MCP logs the
|
|
13
|
+
* session start to overrides.jsonl and instructs the agent to use native
|
|
14
|
+
* tools for file operations while following .agentpolicy/ as a blueprint.
|
|
15
|
+
* When aegis_complete_task is called during construction, the MCP logs
|
|
16
|
+
* the session end with a closing timestamp.
|
|
11
17
|
*
|
|
12
18
|
* OVERRIDE HANDSHAKE: Blocked actions return override tokens when policy
|
|
13
19
|
* allows. Human confirms → agent calls aegis_request_override → action
|
|
@@ -46,8 +52,10 @@ export function registerTools(
|
|
|
46
52
|
title: 'Select Role',
|
|
47
53
|
description: `${GOVERNANCE_INTRO}Select a role for this session. Call this after aegis_policy_summary shows available roles and the user has chosen one. The MCP locks to the selected role for the remainder of the session — all enforcement uses this role's boundaries. This is a one-time selection per session.
|
|
48
54
|
|
|
55
|
+
The "construction" role is available for initial builds and major restructuring. It grants full repo access using native tools, with governance files as the blueprint.
|
|
56
|
+
|
|
49
57
|
Args:
|
|
50
|
-
- role_id (string): The role ID to select (e.g., "backend", "frontend", "qa")
|
|
58
|
+
- role_id (string): The role ID to select (e.g., "construction", "backend", "frontend", "qa")
|
|
51
59
|
|
|
52
60
|
Returns:
|
|
53
61
|
{ "status": "role_selected", "role": "...", ... } or { "status": "error", "reason": "..." }`,
|
|
@@ -93,6 +101,36 @@ Returns:
|
|
|
93
101
|
// Notify the main process to update engine references
|
|
94
102
|
onRoleSelected(role);
|
|
95
103
|
|
|
104
|
+
// If construction mode was activated, log the opening entry
|
|
105
|
+
if (loader.isConstructionMode()) {
|
|
106
|
+
const engine = getEngine();
|
|
107
|
+
await engine.logOverride({
|
|
108
|
+
timestamp: loader.getConstructionStartedAt() ?? new Date().toISOString(),
|
|
109
|
+
policy_violated: 'construction_mode_activated',
|
|
110
|
+
policy_text: 'Construction mode — governance enforcement suspended for initial build. Agent uses native tools with .agentpolicy/ as blueprint.',
|
|
111
|
+
action_requested: 'construction_mode: start',
|
|
112
|
+
human_confirmed: true,
|
|
113
|
+
agent_role: 'construction',
|
|
114
|
+
rationale: 'Initial build — governance files used as blueprint, native tools for file operations',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
content: [{
|
|
119
|
+
type: 'text' as const,
|
|
120
|
+
text: JSON.stringify({
|
|
121
|
+
status: 'role_selected',
|
|
122
|
+
role: 'construction',
|
|
123
|
+
role_name: 'Construction',
|
|
124
|
+
construction_mode: true,
|
|
125
|
+
started_at: loader.getConstructionStartedAt(),
|
|
126
|
+
message: 'Construction mode is now active. Read the .agentpolicy/ directory as your blueprint — constitution.json for architecture and principles, governance.json for conventions and quality gates, role files for module ownership and boundaries. Use your native tools for all file operations (not Aegis governed tools). When the build is complete, call aegis_complete_task to close construction mode. All future sessions after construction should select a specialist role for governed operations.',
|
|
127
|
+
instructions: 'Use native file tools for reads, writes, and deletes. Follow the governance files as your blueprint for architecture, conventions, and quality standards. The MCP is logging this construction session for the audit trail.',
|
|
128
|
+
}),
|
|
129
|
+
}],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Normal role selection response
|
|
96
134
|
return {
|
|
97
135
|
content: [{
|
|
98
136
|
type: 'text' as const,
|
|
@@ -518,7 +556,7 @@ Returns:
|
|
|
518
556
|
'aegis_complete_task',
|
|
519
557
|
{
|
|
520
558
|
title: 'Complete Task',
|
|
521
|
-
description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates.
|
|
559
|
+
description: `${GOVERNANCE_INTRO}Signal task completion and run required quality gates. In construction mode, this also closes the construction session and logs the closing timestamp — all future sessions should select a specialist role for governed operations.
|
|
522
560
|
|
|
523
561
|
Args:
|
|
524
562
|
- task_id (string): Identifier for the task being completed
|
|
@@ -540,6 +578,47 @@ Returns:
|
|
|
540
578
|
async ({ task_id, summary }) => {
|
|
541
579
|
const engine = getEngine();
|
|
542
580
|
const state = getState();
|
|
581
|
+
|
|
582
|
+
// If construction mode is active, log the closing entry
|
|
583
|
+
if (loader.isConstructionMode()) {
|
|
584
|
+
const startedAt = loader.getConstructionStartedAt();
|
|
585
|
+
const completedAt = new Date().toISOString();
|
|
586
|
+
|
|
587
|
+
await engine.logOverride({
|
|
588
|
+
timestamp: completedAt,
|
|
589
|
+
policy_violated: 'construction_mode_completed',
|
|
590
|
+
policy_text: 'Construction mode ended — governance enforcement resumes for all future sessions.',
|
|
591
|
+
action_requested: 'construction_mode: end',
|
|
592
|
+
human_confirmed: true,
|
|
593
|
+
agent_role: 'construction',
|
|
594
|
+
rationale: `Construction complete. Started: ${startedAt}. Summary: ${summary}`,
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
loader.endConstructionMode();
|
|
598
|
+
|
|
599
|
+
// Still run quality gates if configured
|
|
600
|
+
const gates = engine.getQualityGateCommands();
|
|
601
|
+
const results = await runQualityGates(gates, state.projectRoot);
|
|
602
|
+
const allPassed = results.every((r) => r.passed);
|
|
603
|
+
|
|
604
|
+
return {
|
|
605
|
+
content: [{
|
|
606
|
+
type: 'text' as const,
|
|
607
|
+
text: JSON.stringify({
|
|
608
|
+
status: allPassed ? 'passed' : 'failed',
|
|
609
|
+
task_id,
|
|
610
|
+
summary,
|
|
611
|
+
construction_mode_closed: true,
|
|
612
|
+
construction_started_at: startedAt,
|
|
613
|
+
construction_completed_at: completedAt,
|
|
614
|
+
gates_run: results,
|
|
615
|
+
message: 'Construction mode is now closed. All future agent sessions should select a specialist role for governed operations. The construction session has been logged to the audit trail.',
|
|
616
|
+
}),
|
|
617
|
+
}],
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Normal (non-construction) task completion
|
|
543
622
|
const gates = engine.getQualityGateCommands();
|
|
544
623
|
|
|
545
624
|
if (gates.length === 0) {
|
|
@@ -557,26 +636,7 @@ Returns:
|
|
|
557
636
|
};
|
|
558
637
|
}
|
|
559
638
|
|
|
560
|
-
const results
|
|
561
|
-
|
|
562
|
-
for (const gate of gates) {
|
|
563
|
-
try {
|
|
564
|
-
const output = execSync(gate.command, {
|
|
565
|
-
cwd: state.projectRoot,
|
|
566
|
-
encoding: 'utf-8',
|
|
567
|
-
timeout: 120_000,
|
|
568
|
-
});
|
|
569
|
-
results.push({ name: gate.name, passed: true, output: output.slice(0, 500) });
|
|
570
|
-
} catch (err: unknown) {
|
|
571
|
-
const execErr = err as { stderr?: string; message?: string };
|
|
572
|
-
results.push({
|
|
573
|
-
name: gate.name,
|
|
574
|
-
passed: false,
|
|
575
|
-
output: (execErr.stderr ?? execErr.message ?? 'Failed').slice(0, 500),
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
639
|
+
const results = await runQualityGates(gates, state.projectRoot);
|
|
580
640
|
const allPassed = results.every((r) => r.passed);
|
|
581
641
|
|
|
582
642
|
return {
|
|
@@ -599,10 +659,11 @@ Returns:
|
|
|
599
659
|
'aegis_policy_summary',
|
|
600
660
|
{
|
|
601
661
|
title: 'Policy Summary',
|
|
602
|
-
description: `${GOVERNANCE_INTRO}Get your governance summary. In universal mode (no role pre-assigned), this returns the list of available roles — present them to the user and ask which role to use, then call aegis_select_role. In fixed mode (role pre-assigned), this returns your role boundaries and governance rules. Call this FIRST before doing any work.
|
|
662
|
+
description: `${GOVERNANCE_INTRO}Get your governance summary. In universal mode (no role pre-assigned), this returns the list of available roles (including "construction" for initial builds) — present them to the user and ask which role to use, then call aegis_select_role. In fixed mode (role pre-assigned), this returns your role boundaries and governance rules. Call this FIRST before doing any work.
|
|
603
663
|
|
|
604
664
|
Returns:
|
|
605
665
|
Universal mode: { "mode": "role_selection_required", "available_roles": [...] }
|
|
666
|
+
Construction mode: { "mode": "construction_active", ... }
|
|
606
667
|
Fixed/selected mode: { "governance_notice": "...", "role": "...", "writable_paths": [...], ... }`,
|
|
607
668
|
inputSchema: {},
|
|
608
669
|
annotations: {
|
|
@@ -633,6 +694,28 @@ Returns:
|
|
|
633
694
|
};
|
|
634
695
|
}
|
|
635
696
|
|
|
697
|
+
// Construction mode is active — return construction-specific guidance
|
|
698
|
+
if (loader.isConstructionMode()) {
|
|
699
|
+
return {
|
|
700
|
+
content: [{
|
|
701
|
+
type: 'text' as const,
|
|
702
|
+
text: JSON.stringify({
|
|
703
|
+
mode: 'construction_active',
|
|
704
|
+
governance_notice: 'Construction mode is active. The .agentpolicy/ directory is your blueprint — read it for architecture, conventions, quality standards, and module ownership. Use your native tools for all file operations. When the build is complete, call aegis_complete_task to close construction mode.',
|
|
705
|
+
project: state.constitution.project.name,
|
|
706
|
+
role: 'construction',
|
|
707
|
+
started_at: loader.getConstructionStartedAt(),
|
|
708
|
+
blueprint_files: [
|
|
709
|
+
'.agentpolicy/constitution.json — project identity, tech stack, principles, module map',
|
|
710
|
+
'.agentpolicy/governance.json — conventions, quality gates, escalation rules, permissions',
|
|
711
|
+
'.agentpolicy/roles/ — module ownership and boundaries (reference for build structure)',
|
|
712
|
+
],
|
|
713
|
+
instructions: 'Read the governance files as your blueprint. Use native tools for all file operations. Follow the conventions and quality standards defined in governance.json. When complete, call aegis_complete_task.',
|
|
714
|
+
}),
|
|
715
|
+
}],
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
|
|
636
719
|
// Role is assigned (fixed mode or selected in auto mode)
|
|
637
720
|
const protocol = state.governance.override_protocol;
|
|
638
721
|
|
|
@@ -715,3 +798,34 @@ async function logBlocked(
|
|
|
715
798
|
rationale: 'Blocked by enforcement layer',
|
|
716
799
|
});
|
|
717
800
|
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Run quality gate commands and collect results.
|
|
804
|
+
* Extracted as a shared helper for both normal and construction completion.
|
|
805
|
+
*/
|
|
806
|
+
async function runQualityGates(
|
|
807
|
+
gates: Array<{ name: string; command: string }>,
|
|
808
|
+
projectRoot: string
|
|
809
|
+
): Promise<Array<{ name: string; passed: boolean; output?: string }>> {
|
|
810
|
+
const results: Array<{ name: string; passed: boolean; output?: string }> = [];
|
|
811
|
+
|
|
812
|
+
for (const gate of gates) {
|
|
813
|
+
try {
|
|
814
|
+
const output = execSync(gate.command, {
|
|
815
|
+
cwd: projectRoot,
|
|
816
|
+
encoding: 'utf-8',
|
|
817
|
+
timeout: 120_000,
|
|
818
|
+
});
|
|
819
|
+
results.push({ name: gate.name, passed: true, output: output.slice(0, 500) });
|
|
820
|
+
} catch (err: unknown) {
|
|
821
|
+
const execErr = err as { stderr?: string; message?: string };
|
|
822
|
+
results.push({
|
|
823
|
+
name: gate.name,
|
|
824
|
+
passed: false,
|
|
825
|
+
output: (execErr.stderr ?? execErr.message ?? 'Failed').slice(0, 500),
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
return results;
|
|
831
|
+
}
|