pi-better-sandbox 0.2.0 → 0.3.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.
- package/commands.ts +24 -2
- package/package.json +1 -1
package/commands.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import type { AutocompleteItem } from "@earendil-works/pi-tui";
|
|
15
16
|
|
|
16
17
|
import {
|
|
17
18
|
DenyRuleError,
|
|
@@ -256,8 +257,22 @@ function announce(ctx: ExtensionCommandContext, change: () => DenyRuleReport): v
|
|
|
256
257
|
const SUBCOMMANDS = ["on", "off", "default", "deny", "rules"] as const;
|
|
257
258
|
const DENY_ACTIONS = ["list", "add", "remove", "reset"] as const;
|
|
258
259
|
|
|
260
|
+
const COMPLETION_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
|
261
|
+
on: "Enable confinement for this session",
|
|
262
|
+
off: "Disable confinement for this session",
|
|
263
|
+
default: "Change the persistent activation default",
|
|
264
|
+
"default on": "Enable confinement by default",
|
|
265
|
+
"default off": "Disable confinement by default",
|
|
266
|
+
deny: "Manage write-denied paths",
|
|
267
|
+
"deny list": "Show configured write-denied paths",
|
|
268
|
+
"deny add": "Add a write-denied path",
|
|
269
|
+
"deny remove": "Remove a write-denied path",
|
|
270
|
+
"deny reset": "Restore packaged write-deny defaults",
|
|
271
|
+
rules: "Open the write-deny rule manager",
|
|
272
|
+
};
|
|
273
|
+
|
|
259
274
|
/** Argument completions for `/sandbox`, including the `deny` actions. */
|
|
260
|
-
export function sandboxArgumentCompletions(argumentPrefix: string) {
|
|
275
|
+
export function sandboxArgumentCompletions(argumentPrefix: string): AutocompleteItem[] {
|
|
261
276
|
const prefix = argumentPrefix.trimStart().toLowerCase();
|
|
262
277
|
const denyPrefix = /^deny(\s|$)/.test(prefix) ? prefix.replace(/^deny\s*/, "") : undefined;
|
|
263
278
|
const defaultPrefix = /^default(\s|$)/.test(prefix)
|
|
@@ -275,5 +290,12 @@ export function sandboxArgumentCompletions(argumentPrefix: string) {
|
|
|
275
290
|
.map((value) => `default ${value}`)
|
|
276
291
|
: SUBCOMMANDS.filter((value) => value.startsWith(prefix));
|
|
277
292
|
|
|
278
|
-
return values.map((value) =>
|
|
293
|
+
return values.map((value) => {
|
|
294
|
+
const description = COMPLETION_DESCRIPTIONS[value];
|
|
295
|
+
return {
|
|
296
|
+
value,
|
|
297
|
+
label: value,
|
|
298
|
+
...(description === undefined ? {} : { description }),
|
|
299
|
+
};
|
|
300
|
+
});
|
|
279
301
|
}
|
package/package.json
CHANGED