@codemcp/ade-harnesses 0.0.2 → 0.1.0

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.
Files changed (37) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-format.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/.turbo/turbo-test.log +15 -12
  5. package/.turbo/turbo-typecheck.log +1 -1
  6. package/dist/permission-policy.d.ts +7 -0
  7. package/dist/permission-policy.js +152 -0
  8. package/dist/writers/claude-code.js +50 -18
  9. package/dist/writers/cline.js +2 -2
  10. package/dist/writers/copilot.js +61 -8
  11. package/dist/writers/cursor.js +48 -2
  12. package/dist/writers/kiro.js +54 -38
  13. package/dist/writers/opencode.js +26 -23
  14. package/dist/writers/roo-code.js +38 -2
  15. package/dist/writers/universal.js +41 -3
  16. package/dist/writers/windsurf.js +43 -1
  17. package/package.json +2 -2
  18. package/src/permission-policy.ts +173 -0
  19. package/src/writers/claude-code.spec.ts +160 -3
  20. package/src/writers/claude-code.ts +63 -18
  21. package/src/writers/cline.spec.ts +146 -3
  22. package/src/writers/cline.ts +2 -2
  23. package/src/writers/copilot.spec.ts +157 -1
  24. package/src/writers/copilot.ts +76 -9
  25. package/src/writers/cursor.spec.ts +104 -1
  26. package/src/writers/cursor.ts +65 -3
  27. package/src/writers/kiro.spec.ts +228 -0
  28. package/src/writers/kiro.ts +77 -40
  29. package/src/writers/opencode.spec.ts +258 -0
  30. package/src/writers/opencode.ts +40 -27
  31. package/src/writers/roo-code.spec.ts +129 -1
  32. package/src/writers/roo-code.ts +49 -2
  33. package/src/writers/universal.spec.ts +134 -0
  34. package/src/writers/universal.ts +57 -4
  35. package/src/writers/windsurf.spec.ts +111 -3
  36. package/src/writers/windsurf.ts +64 -2
  37. package/tsconfig.tsbuildinfo +1 -1
@@ -2,9 +2,57 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
2
  import { mkdtemp, rm, readFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
- import type { LogicalConfig } from "@codemcp/ade-core";
5
+ import type {
6
+ AutonomyProfile,
7
+ LogicalConfig,
8
+ PermissionPolicy
9
+ } from "@codemcp/ade-core";
6
10
  import { rooCodeWriter } from "./roo-code.js";
7
11
 
12
+ function autonomyPolicy(profile: AutonomyProfile): PermissionPolicy {
13
+ switch (profile) {
14
+ case "rigid":
15
+ return {
16
+ profile,
17
+ capabilities: {
18
+ read: "ask",
19
+ edit_write: "ask",
20
+ search_list: "ask",
21
+ bash_safe: "ask",
22
+ bash_unsafe: "ask",
23
+ web: "ask",
24
+ task_agent: "ask"
25
+ }
26
+ };
27
+ case "sensible-defaults":
28
+ return {
29
+ profile,
30
+ capabilities: {
31
+ read: "allow",
32
+ edit_write: "allow",
33
+ search_list: "allow",
34
+ bash_safe: "allow",
35
+ bash_unsafe: "ask",
36
+ web: "ask",
37
+ task_agent: "allow"
38
+ }
39
+ };
40
+ case "max-autonomy":
41
+ return {
42
+ profile,
43
+ capabilities: {
44
+ read: "allow",
45
+ edit_write: "allow",
46
+ search_list: "allow",
47
+ bash_safe: "allow",
48
+ bash_unsafe: "allow",
49
+ web: "ask",
50
+ task_agent: "allow"
51
+ }
52
+ };
53
+ }
54
+ }
55
+
8
56
  describe("rooCodeWriter", () => {
9
57
  let dir: string;
10
58
 
@@ -19,6 +67,7 @@ describe("rooCodeWriter", () => {
19
67
  it("has correct metadata", () => {
20
68
  expect(rooCodeWriter.id).toBe("roo-code");
21
69
  expect(rooCodeWriter.label).toBe("Roo Code");
70
+ expect(rooCodeWriter.description).toContain(".roomodes");
22
71
  });
23
72
 
24
73
  it("writes .roo/mcp.json with MCP servers", async () => {
@@ -66,4 +115,83 @@ describe("rooCodeWriter", () => {
66
115
  const content = await readFile(join(dir, ".roorules"), "utf-8");
67
116
  expect(content).toContain("Follow TDD.");
68
117
  });
118
+
119
+ it("maps autonomy to Roo mode groups conservatively while forwarding MCP approvals separately", async () => {
120
+ const rigidRoot = join(dir, "rigid");
121
+ const defaultsRoot = join(dir, "defaults");
122
+ const maxRoot = join(dir, "max");
123
+
124
+ const baseConfig = {
125
+ mcp_servers: [
126
+ {
127
+ ref: "workflows",
128
+ command: "npx",
129
+ args: ["-y", "@codemcp/workflows"],
130
+ env: {},
131
+ allowedTools: ["whats_next"]
132
+ }
133
+ ],
134
+ instructions: [],
135
+ cli_actions: [],
136
+ knowledge_sources: [],
137
+ skills: [],
138
+ git_hooks: [],
139
+ setup_notes: []
140
+ } satisfies LogicalConfig;
141
+
142
+ await rooCodeWriter.install(
143
+ {
144
+ ...baseConfig,
145
+ permission_policy: autonomyPolicy("rigid")
146
+ },
147
+ rigidRoot
148
+ );
149
+ await rooCodeWriter.install(
150
+ {
151
+ ...baseConfig,
152
+ permission_policy: autonomyPolicy("sensible-defaults")
153
+ },
154
+ defaultsRoot
155
+ );
156
+ await rooCodeWriter.install(
157
+ {
158
+ ...baseConfig,
159
+ permission_policy: autonomyPolicy("max-autonomy")
160
+ },
161
+ maxRoot
162
+ );
163
+
164
+ const rigidModes = JSON.parse(
165
+ await readFile(join(rigidRoot, ".roomodes"), "utf-8")
166
+ );
167
+ const defaultsModes = JSON.parse(
168
+ await readFile(join(defaultsRoot, ".roomodes"), "utf-8")
169
+ );
170
+ const maxModes = JSON.parse(
171
+ await readFile(join(maxRoot, ".roomodes"), "utf-8")
172
+ );
173
+ const rigidMcp = JSON.parse(
174
+ await readFile(join(rigidRoot, ".roo", "mcp.json"), "utf-8")
175
+ );
176
+
177
+ expect(rigidModes.customModes.ade.groups).toEqual(["mcp"]);
178
+ expect(defaultsModes.customModes.ade.groups).toEqual([
179
+ "read",
180
+ "edit",
181
+ "mcp"
182
+ ]);
183
+ expect(maxModes.customModes.ade.groups).toEqual([
184
+ "read",
185
+ "edit",
186
+ "command",
187
+ "mcp"
188
+ ]);
189
+
190
+ expect(defaultsModes.customModes.ade.groups).not.toContain("command");
191
+ expect(rigidModes.customModes.ade.groups).not.toContain("web");
192
+ expect(defaultsModes.customModes.ade.groups).not.toContain("web");
193
+ expect(maxModes.customModes.ade.groups).not.toContain("web");
194
+
195
+ expect(rigidMcp.mcpServers.workflows.alwaysAllow).toEqual(["whats_next"]);
196
+ });
69
197
  });
@@ -2,23 +2,70 @@ import { join } from "node:path";
2
2
  import type { LogicalConfig } from "@codemcp/ade-core";
3
3
  import type { HarnessWriter } from "../types.js";
4
4
  import {
5
+ readJsonOrEmpty,
5
6
  writeMcpServers,
6
7
  alwaysAllowEntry,
7
8
  writeRulesFile,
8
- writeGitHooks
9
+ writeGitHooks,
10
+ writeJson
9
11
  } from "../util.js";
12
+ import { allowsCapability, hasPermissionPolicy } from "../permission-policy.js";
10
13
 
11
14
  export const rooCodeWriter: HarnessWriter = {
12
15
  id: "roo-code",
13
16
  label: "Roo Code",
14
- description: "AI coding agent — .roo/mcp.json + .roorules",
17
+ description: "AI coding agent — .roo/mcp.json + .roomodes + .roorules",
15
18
  async install(config: LogicalConfig, projectRoot: string) {
16
19
  await writeMcpServers(config.mcp_servers, {
17
20
  path: join(projectRoot, ".roo", "mcp.json"),
18
21
  transform: alwaysAllowEntry
19
22
  });
20
23
 
24
+ await writeRooModes(config, projectRoot);
21
25
  await writeRulesFile(config.instructions, join(projectRoot, ".roorules"));
22
26
  await writeGitHooks(config.git_hooks, projectRoot);
23
27
  }
24
28
  };
29
+
30
+ async function writeRooModes(
31
+ config: LogicalConfig,
32
+ projectRoot: string
33
+ ): Promise<void> {
34
+ if (!hasPermissionPolicy(config)) {
35
+ return;
36
+ }
37
+
38
+ const roomodesPath = join(projectRoot, ".roomodes");
39
+ const existing = await readJsonOrEmpty(roomodesPath);
40
+ const existingCustomModes = asRecord(existing.customModes);
41
+
42
+ await writeJson(roomodesPath, {
43
+ ...existing,
44
+ customModes: {
45
+ ...existingCustomModes,
46
+ ade: {
47
+ slug: "ade",
48
+ name: "ADE",
49
+ roleDefinition:
50
+ "ADE — Agentic Development Environment mode generated by ADE.",
51
+ groups: getRooModeGroups(config),
52
+ source: "project"
53
+ }
54
+ }
55
+ });
56
+ }
57
+
58
+ function asRecord(value: unknown): Record<string, unknown> {
59
+ return value !== null && typeof value === "object" && !Array.isArray(value)
60
+ ? (value as Record<string, unknown>)
61
+ : {};
62
+ }
63
+
64
+ function getRooModeGroups(config: LogicalConfig): string[] {
65
+ return [
66
+ ...(allowsCapability(config, "read") ? ["read"] : []),
67
+ ...(allowsCapability(config, "edit_write") ? ["edit"] : []),
68
+ ...(allowsCapability(config, "bash_unsafe") ? ["command"] : []),
69
+ ...(config.mcp_servers.length > 0 ? ["mcp"] : [])
70
+ ];
71
+ }
@@ -0,0 +1,134 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdtemp, rm, readFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import type {
6
+ AutonomyProfile,
7
+ LogicalConfig,
8
+ PermissionPolicy
9
+ } from "@codemcp/ade-core";
10
+ import { universalWriter } from "./universal.js";
11
+
12
+ function autonomyPolicy(profile: AutonomyProfile): PermissionPolicy {
13
+ switch (profile) {
14
+ case "rigid":
15
+ return {
16
+ profile,
17
+ capabilities: {
18
+ read: "ask",
19
+ edit_write: "ask",
20
+ search_list: "ask",
21
+ bash_safe: "ask",
22
+ bash_unsafe: "ask",
23
+ web: "ask",
24
+ task_agent: "ask"
25
+ }
26
+ };
27
+ case "sensible-defaults":
28
+ return {
29
+ profile,
30
+ capabilities: {
31
+ read: "allow",
32
+ edit_write: "allow",
33
+ search_list: "allow",
34
+ bash_safe: "allow",
35
+ bash_unsafe: "ask",
36
+ web: "ask",
37
+ task_agent: "allow"
38
+ }
39
+ };
40
+ case "max-autonomy":
41
+ return {
42
+ profile,
43
+ capabilities: {
44
+ read: "allow",
45
+ edit_write: "allow",
46
+ search_list: "allow",
47
+ bash_safe: "allow",
48
+ bash_unsafe: "allow",
49
+ web: "ask",
50
+ task_agent: "allow"
51
+ }
52
+ };
53
+ }
54
+ }
55
+
56
+ describe("universalWriter", () => {
57
+ let dir: string;
58
+
59
+ beforeEach(async () => {
60
+ dir = await mkdtemp(join(tmpdir(), "ade-harness-universal-"));
61
+ });
62
+
63
+ afterEach(async () => {
64
+ await rm(dir, { recursive: true, force: true });
65
+ });
66
+
67
+ it("has correct metadata", () => {
68
+ expect(universalWriter.id).toBe("universal");
69
+ expect(universalWriter.label).toBe("Universal (AGENTS.md + .mcp.json)");
70
+ expect(universalWriter.description).toContain("AGENTS.md");
71
+ });
72
+
73
+ it("writes AGENTS.md instructions when provided", async () => {
74
+ const config: LogicalConfig = {
75
+ mcp_servers: [],
76
+ instructions: ["Follow the workflow.", "Keep changes focused."],
77
+ cli_actions: [],
78
+ knowledge_sources: [],
79
+ skills: [],
80
+ git_hooks: [],
81
+ setup_notes: []
82
+ };
83
+
84
+ await universalWriter.install(config, dir);
85
+
86
+ const content = await readFile(join(dir, "AGENTS.md"), "utf-8");
87
+ expect(content).toContain("# AGENTS");
88
+ expect(content).toContain("Follow the workflow.");
89
+ expect(content).toContain("Keep changes focused.");
90
+ });
91
+
92
+ it("documents autonomy as guidance only because Universal has no enforceable permission schema", async () => {
93
+ const config: LogicalConfig = {
94
+ mcp_servers: [
95
+ {
96
+ ref: "workflows",
97
+ command: "npx",
98
+ args: ["-y", "@codemcp/workflows"],
99
+ env: {},
100
+ allowedTools: ["whats_next"]
101
+ }
102
+ ],
103
+ instructions: [],
104
+ cli_actions: [],
105
+ knowledge_sources: [],
106
+ skills: [],
107
+ git_hooks: [],
108
+ setup_notes: [],
109
+ permission_policy: autonomyPolicy("sensible-defaults")
110
+ };
111
+
112
+ await universalWriter.install(config, dir);
113
+
114
+ const agents = await readFile(join(dir, "AGENTS.md"), "utf-8");
115
+ expect(agents).toContain("## Autonomy");
116
+ expect(agents).toContain("documentation-only guidance");
117
+ expect(agents).toContain("no enforceable harness-level permission schema");
118
+ expect(agents).toContain("Profile: `sensible-defaults`");
119
+ expect(agents).toContain("- `read`: allow");
120
+ expect(agents).toContain("- `bash_unsafe`: ask");
121
+ expect(agents).toContain("- `web`: ask");
122
+ expect(agents).toContain(
123
+ "MCP permissions are not re-modeled by autonomy here"
124
+ );
125
+
126
+ const mcpRaw = await readFile(join(dir, ".mcp.json"), "utf-8");
127
+ const mcp = JSON.parse(mcpRaw);
128
+ expect(mcp.mcpServers.workflows).toEqual({
129
+ command: "npx",
130
+ args: ["-y", "@codemcp/workflows"]
131
+ });
132
+ expect(mcp.mcpServers.workflows).not.toHaveProperty("allowedTools");
133
+ });
134
+ });
@@ -1,20 +1,73 @@
1
1
  import { join } from "node:path";
2
2
  import { writeFile } from "node:fs/promises";
3
- import type { LogicalConfig } from "@codemcp/ade-core";
3
+ import type {
4
+ AutonomyCapability,
5
+ LogicalConfig,
6
+ PermissionDecision
7
+ } from "@codemcp/ade-core";
4
8
  import type { HarnessWriter } from "../types.js";
5
9
  import { writeMcpServers, writeGitHooks } from "../util.js";
6
10
 
11
+ const CAPABILITY_ORDER: AutonomyCapability[] = [
12
+ "read",
13
+ "edit_write",
14
+ "search_list",
15
+ "bash_safe",
16
+ "bash_unsafe",
17
+ "web",
18
+ "task_agent"
19
+ ];
20
+
21
+ function formatCapabilityGuidance(
22
+ capability: AutonomyCapability,
23
+ decision: PermissionDecision
24
+ ): string {
25
+ return `- \`${capability}\`: ${decision}`;
26
+ }
27
+
28
+ function renderAutonomyGuidance(config: LogicalConfig): string | undefined {
29
+ const policy = config.permission_policy;
30
+ if (!policy) {
31
+ return undefined;
32
+ }
33
+
34
+ const capabilityLines = CAPABILITY_ORDER.map((capability) =>
35
+ formatCapabilityGuidance(capability, policy.capabilities[capability])
36
+ );
37
+
38
+ return [
39
+ "## Autonomy",
40
+ "",
41
+ "Universal harness limitation: `AGENTS.md` + `.mcp.json` provide documentation and server registration only; there is no enforceable harness-level permission schema here.",
42
+ "",
43
+ "Treat this autonomy profile as documentation-only guidance for built-in/basic operations.",
44
+ "",
45
+ `Profile: \`${policy.profile}\``,
46
+ "",
47
+ "Built-in/basic capability guidance:",
48
+ ...capabilityLines,
49
+ "",
50
+ "MCP permissions are not re-modeled by autonomy here; any MCP approvals must come from provisioning-aware consuming harnesses rather than the Universal writer."
51
+ ].join("\n");
52
+ }
53
+
7
54
  export const universalWriter: HarnessWriter = {
8
55
  id: "universal",
9
56
  label: "Universal (AGENTS.md + .mcp.json)",
10
57
  description:
11
- "Cross-tool standard — AGENTS.md + .mcp.json (works with any agent)",
58
+ "Cross-tool standard — AGENTS.md + .mcp.json (portable instructions and MCP registration, not enforceable permissions)",
12
59
  async install(config: LogicalConfig, projectRoot: string) {
13
- if (config.instructions.length > 0) {
60
+ const autonomyGuidance = renderAutonomyGuidance(config);
61
+ const instructionSections = [...config.instructions];
62
+ if (autonomyGuidance) {
63
+ instructionSections.push(autonomyGuidance);
64
+ }
65
+
66
+ if (instructionSections.length > 0) {
14
67
  const lines = [
15
68
  "# AGENTS",
16
69
  "",
17
- ...config.instructions.flatMap((i) => [i, ""])
70
+ ...instructionSections.flatMap((instruction) => [instruction, ""])
18
71
  ];
19
72
  await writeFile(
20
73
  join(projectRoot, "AGENTS.md"),
@@ -21,14 +21,15 @@ describe("windsurfWriter", () => {
21
21
  expect(windsurfWriter.label).toBe("Windsurf");
22
22
  });
23
23
 
24
- it("writes .windsurf/mcp.json with MCP servers", async () => {
24
+ it("writes .windsurf/mcp.json with forwarded MCP approvals", async () => {
25
25
  const config: LogicalConfig = {
26
26
  mcp_servers: [
27
27
  {
28
28
  ref: "workflows",
29
29
  command: "npx",
30
30
  args: ["-y", "@codemcp/workflows"],
31
- env: { API_KEY: "test" }
31
+ env: { API_KEY: "test" },
32
+ allowedTools: ["whats_next", "proceed_to_phase"]
32
33
  }
33
34
  ],
34
35
  instructions: [],
@@ -47,10 +48,71 @@ describe("windsurfWriter", () => {
47
48
  command: "npx",
48
49
  args: ["-y", "@codemcp/workflows"],
49
50
  env: { API_KEY: "test" },
50
- alwaysAllow: ["*"]
51
+ alwaysAllow: ["whats_next", "proceed_to_phase"]
51
52
  });
52
53
  });
53
54
 
55
+ it("records autonomy as advisory guidance because Windsurf has no verified committed built-in permission schema", async () => {
56
+ const rigidRoot = join(dir, "rigid");
57
+ const sensibleRoot = join(dir, "sensible");
58
+ const maxRoot = join(dir, "max");
59
+
60
+ const rigidConfig: LogicalConfig = {
61
+ mcp_servers: [],
62
+ instructions: [],
63
+ cli_actions: [],
64
+ knowledge_sources: [],
65
+ skills: [],
66
+ git_hooks: [],
67
+ setup_notes: [],
68
+ permission_policy: autonomyPolicy("rigid")
69
+ };
70
+
71
+ const sensibleConfig: LogicalConfig = {
72
+ ...rigidConfig,
73
+ permission_policy: autonomyPolicy("sensible-defaults")
74
+ };
75
+
76
+ const maxConfig: LogicalConfig = {
77
+ ...rigidConfig,
78
+ permission_policy: autonomyPolicy("max-autonomy")
79
+ };
80
+
81
+ await windsurfWriter.install(rigidConfig, rigidRoot);
82
+ await windsurfWriter.install(sensibleConfig, sensibleRoot);
83
+ await windsurfWriter.install(maxConfig, maxRoot);
84
+
85
+ const rigidRules = await readFile(
86
+ join(rigidRoot, ".windsurfrules"),
87
+ "utf-8"
88
+ );
89
+ const sensibleRules = await readFile(
90
+ join(sensibleRoot, ".windsurfrules"),
91
+ "utf-8"
92
+ );
93
+ const maxRules = await readFile(join(maxRoot, ".windsurfrules"), "utf-8");
94
+
95
+ expect(rigidRules).toContain("Windsurf limitation:");
96
+ expect(rigidRules).toContain("advisory only");
97
+ expect(rigidRules).toContain(
98
+ "Ask before: read files, edit and write files, search and list files, safe local shell commands, unsafe local shell commands, web and network access, task or agent delegation."
99
+ );
100
+
101
+ expect(sensibleRules).toContain("Windsurf limitation:");
102
+ expect(sensibleRules).toContain(
103
+ "May proceed without extra approval: read files, edit and write files, search and list files, safe local shell commands, task or agent delegation."
104
+ );
105
+ expect(sensibleRules).toContain(
106
+ "Ask before: unsafe local shell commands, web and network access."
107
+ );
108
+
109
+ expect(maxRules).toContain("Windsurf limitation:");
110
+ expect(maxRules).toContain(
111
+ "May proceed without extra approval: read files, edit and write files, search and list files, safe local shell commands, unsafe local shell commands, task or agent delegation."
112
+ );
113
+ expect(maxRules).toContain("Ask before: web and network access.");
114
+ });
115
+
54
116
  it("writes .windsurfrules with instructions", async () => {
55
117
  const config: LogicalConfig = {
56
118
  mcp_servers: [],
@@ -68,3 +130,49 @@ describe("windsurfWriter", () => {
68
130
  expect(content).toContain("Follow TDD.");
69
131
  });
70
132
  });
133
+
134
+ function autonomyPolicy(
135
+ profile: "rigid" | "sensible-defaults" | "max-autonomy"
136
+ ): LogicalConfig["permission_policy"] {
137
+ switch (profile) {
138
+ case "rigid":
139
+ return {
140
+ profile,
141
+ capabilities: {
142
+ read: "ask",
143
+ edit_write: "ask",
144
+ search_list: "ask",
145
+ bash_safe: "ask",
146
+ bash_unsafe: "ask",
147
+ web: "ask",
148
+ task_agent: "ask"
149
+ }
150
+ };
151
+ case "sensible-defaults":
152
+ return {
153
+ profile,
154
+ capabilities: {
155
+ read: "allow",
156
+ edit_write: "allow",
157
+ search_list: "allow",
158
+ bash_safe: "allow",
159
+ bash_unsafe: "ask",
160
+ web: "ask",
161
+ task_agent: "allow"
162
+ }
163
+ };
164
+ case "max-autonomy":
165
+ return {
166
+ profile,
167
+ capabilities: {
168
+ read: "allow",
169
+ edit_write: "allow",
170
+ search_list: "allow",
171
+ bash_safe: "allow",
172
+ bash_unsafe: "allow",
173
+ web: "ask",
174
+ task_agent: "allow"
175
+ }
176
+ };
177
+ }
178
+ }
@@ -1,5 +1,5 @@
1
1
  import { join } from "node:path";
2
- import type { LogicalConfig } from "@codemcp/ade-core";
2
+ import type { AutonomyCapability, LogicalConfig } from "@codemcp/ade-core";
3
3
  import type { HarnessWriter } from "../types.js";
4
4
  import {
5
5
  writeMcpServers,
@@ -7,6 +7,7 @@ import {
7
7
  writeRulesFile,
8
8
  writeGitHooks
9
9
  } from "../util.js";
10
+ import { hasPermissionPolicy } from "../permission-policy.js";
10
11
 
11
12
  export const windsurfWriter: HarnessWriter = {
12
13
  id: "windsurf",
@@ -19,9 +20,70 @@ export const windsurfWriter: HarnessWriter = {
19
20
  });
20
21
 
21
22
  await writeRulesFile(
22
- config.instructions,
23
+ getWindsurfRules(config),
23
24
  join(projectRoot, ".windsurfrules")
24
25
  );
25
26
  await writeGitHooks(config.git_hooks, projectRoot);
26
27
  }
27
28
  };
29
+
30
+ function getWindsurfRules(config: LogicalConfig): string[] {
31
+ if (!hasPermissionPolicy(config)) {
32
+ return config.instructions;
33
+ }
34
+
35
+ const { capabilities } = config.permission_policy!;
36
+ const allow = listCapabilities(capabilities, "allow");
37
+ const ask = listCapabilities(capabilities, "ask");
38
+ const deny = listCapabilities(capabilities, "deny");
39
+
40
+ const autonomyGuidance = [
41
+ "Windsurf limitation: ADE could not verify a stable committed project-local permission schema for Windsurf built-in tools, so this autonomy policy is advisory only and should be applied conservatively.",
42
+ formatGuidance(allow, ask, deny)
43
+ ];
44
+
45
+ return [...autonomyGuidance, ...config.instructions];
46
+ }
47
+
48
+ function listCapabilities(
49
+ capabilities: NonNullable<LogicalConfig["permission_policy"]>["capabilities"],
50
+ decision: "ask" | "allow" | "deny"
51
+ ): string[] {
52
+ return (Object.entries(capabilities) as Array<[AutonomyCapability, string]>)
53
+ .filter(([, value]) => value === decision)
54
+ .map(([capability]) => CAPABILITY_LABELS[capability]);
55
+ }
56
+
57
+ function formatGuidance(
58
+ allow: string[],
59
+ ask: string[],
60
+ deny: string[]
61
+ ): string {
62
+ const lines = ["Autonomy guidance for Windsurf built-in capabilities:"];
63
+
64
+ if (allow.length > 0) {
65
+ lines.push(`- May proceed without extra approval: ${allow.join(", ")}.`);
66
+ }
67
+
68
+ if (ask.length > 0) {
69
+ lines.push(`- Ask before: ${ask.join(", ")}.`);
70
+ }
71
+
72
+ if (deny.length > 0) {
73
+ lines.push(
74
+ `- Do not use unless the user explicitly overrides: ${deny.join(", ")}.`
75
+ );
76
+ }
77
+
78
+ return lines.join("\n");
79
+ }
80
+
81
+ const CAPABILITY_LABELS: Record<AutonomyCapability, string> = {
82
+ read: "read files",
83
+ edit_write: "edit and write files",
84
+ search_list: "search and list files",
85
+ bash_safe: "safe local shell commands",
86
+ bash_unsafe: "unsafe local shell commands",
87
+ web: "web and network access",
88
+ task_agent: "task or agent delegation"
89
+ };