@restranger/repi-lib 0.0.1-44677f3 → 0.0.1-562ada7
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/package.json +1 -1
- package/src/config.ts +4 -7
- package/src/contracts/permissions.ts +17 -1
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { basename, join, resolve } from "node:path";
|
|
|
5
5
|
/**
|
|
6
6
|
* One config layer, lowest priority first.
|
|
7
7
|
*
|
|
8
|
-
* Plugins read a user layer from `<agentDir>/extensions/<ext>.json`
|
|
9
|
-
*
|
|
8
|
+
* Plugins read a user layer from `<agentDir>/extensions/<ext>.json` and a project layer from
|
|
9
|
+
* `<cwd>/.pi/extensions/<ext>.json` (or `<cwd>/.repi`), gated on workspace trust.
|
|
10
10
|
*/
|
|
11
11
|
export interface PluginConfigLayer {
|
|
12
12
|
readonly source: "user" | "project";
|
|
@@ -27,7 +27,7 @@ export interface ConfigLayerOptions {
|
|
|
27
27
|
readonly cwd: string;
|
|
28
28
|
/** Defaults to `os.homedir()`; injectable for tests. */
|
|
29
29
|
readonly homeDir?: string;
|
|
30
|
-
/** Defaults to `process.env`; `
|
|
30
|
+
/** Defaults to `process.env`; `PI_CODING_AGENT_DIR` is honored. */
|
|
31
31
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
32
32
|
/** File name inside the config directory. */
|
|
33
33
|
readonly filename: string;
|
|
@@ -43,7 +43,6 @@ const EXTENSION_NAME_MAP: Record<string, string> = {
|
|
|
43
43
|
"subagents.json": "repi-subagents",
|
|
44
44
|
"permissions.json": "repi-permissions",
|
|
45
45
|
"model-fallback.json": "repi-model-fallback",
|
|
46
|
-
"modes.json": "repi-permission-system-modes",
|
|
47
46
|
"advisor.json": "repi-advisor",
|
|
48
47
|
};
|
|
49
48
|
|
|
@@ -64,7 +63,6 @@ function findLayerPath(baseCandidates: string[], fallbackPath: string): string {
|
|
|
64
63
|
export function resolveConfigLayers(options: ConfigLayerOptions): PluginConfigLayer[] {
|
|
65
64
|
const home = options.homeDir ?? homedir();
|
|
66
65
|
const env = options.env ?? process.env;
|
|
67
|
-
const configHome = env.XDG_CONFIG_HOME ?? join(home, ".config");
|
|
68
66
|
const agentDir = env.PI_CODING_AGENT_DIR ?? join(home, ".pi", "agent");
|
|
69
67
|
const extName = options.extensionName ?? inferExtensionName(options.filename);
|
|
70
68
|
|
|
@@ -74,11 +72,10 @@ export function resolveConfigLayers(options: ConfigLayerOptions): PluginConfigLa
|
|
|
74
72
|
join(agentDir, "extensions", `${extName}.json`),
|
|
75
73
|
join(agentDir, "extensions", extName, "config.json"),
|
|
76
74
|
join(agentDir, "extensions", extName, options.filename),
|
|
77
|
-
join(configHome, "repi", options.filename),
|
|
78
75
|
];
|
|
79
76
|
userPath = findLayerPath(userCandidates, join(agentDir, "extensions", `${extName}.json`));
|
|
80
77
|
} else {
|
|
81
|
-
userPath = join(
|
|
78
|
+
userPath = join(agentDir, "extensions", options.filename);
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
const layers: PluginConfigLayer[] = [{ source: "user", path: userPath }];
|
|
@@ -104,7 +104,7 @@ export function createDecision(action: PermissionAction, opts: CreateDecisionOpt
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export interface PermissionRuleMatch {
|
|
107
|
-
readonly surface: "path" | "bash" | "tool";
|
|
107
|
+
readonly surface: "path" | "bash" | "tool" | "mcp" | "subagent";
|
|
108
108
|
readonly pattern: string;
|
|
109
109
|
readonly action: PermissionAction;
|
|
110
110
|
}
|
|
@@ -204,6 +204,22 @@ export interface PermissionPolicy {
|
|
|
204
204
|
path?: Record<string, PermissionAction>;
|
|
205
205
|
/** Shell command pattern → action (`"ls *": "allow"`). Matched after wrapper unwrapping. */
|
|
206
206
|
bash?: Record<string, PermissionAction>;
|
|
207
|
+
/** MCP tool rules (`{"*": "allow", "mcp__github__*": "allow"}`) or single action (`"allow"`). */
|
|
208
|
+
mcp?: PermissionSurfaceRules;
|
|
209
|
+
/**
|
|
210
|
+
* Verdict for tool calls a subagent makes (`request.source === "subagent"`).
|
|
211
|
+
*
|
|
212
|
+
* Default `allow`: an `ask` from the other surfaces is auto-approved for a child session, because
|
|
213
|
+
* the parent already chose to spawn it and a dialog per child call is noise. Rules here *replace*
|
|
214
|
+
* an `ask`, but can never lift a `deny` from `path`/`bash`/`mcp`/config — so `deny` stays final:
|
|
215
|
+
* `{"subagent": {"*": "allow", "bash": "deny"}}` blocks only the child's shell calls.
|
|
216
|
+
*/
|
|
217
|
+
subagent?: PermissionSurfaceRules;
|
|
218
|
+
/**
|
|
219
|
+
* Set `false` to skip the built-in security defaults (secret paths, catastrophic deletions).
|
|
220
|
+
* A project layer cannot disable them; only a user-level config can.
|
|
221
|
+
*/
|
|
222
|
+
builtinDefaults?: boolean;
|
|
207
223
|
/** Shared rule set for paths outside the project root. */
|
|
208
224
|
external_directory?: PermissionSurfaceRules;
|
|
209
225
|
external_directory_read?: PermissionSurfaceRules;
|