praxis-agent 0.45.0 → 0.45.2
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.
|
@@ -3,7 +3,7 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { writeFileAtomically } from '../../platform/atomic-write.js';
|
|
4
4
|
import { resolveDataPlaneRoot } from '../../persistence/data-plane.js';
|
|
5
5
|
import { loadNativeSharedResources } from '../../persistence/native-resources.js';
|
|
6
|
-
import { permissionRuleValueFromString, permissionRuleValueToString, } from '../../permissions/permission-updates.js';
|
|
6
|
+
import { permissionRuleStringIsValid, permissionRuleValueFromString, permissionRuleValueToString, } from '../../permissions/permission-updates.js';
|
|
7
7
|
function isRecord(value) {
|
|
8
8
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
9
|
}
|
|
@@ -60,7 +60,7 @@ async function sourceUnchanged(path, source) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
export async function addTuiPermissionRule({ cwd, behavior, rule, scope, configRoot, }) {
|
|
63
|
-
if (
|
|
63
|
+
if (!permissionRuleStringIsValid(rule))
|
|
64
64
|
throw new Error(`Invalid permission rule: ${rule}`);
|
|
65
65
|
const path = settingsPath(configRoot ?? configRootPath(), cwd, scope);
|
|
66
66
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
@@ -512,7 +512,7 @@ function estimateRenderedTranscriptEntryLines(entry, width, mode) {
|
|
|
512
512
|
: 0));
|
|
513
513
|
const heading = mode === 'screen-reader'
|
|
514
514
|
? 'Thinking:Thought for a moment'
|
|
515
|
-
:
|
|
515
|
+
: '✻ Thought for a moment';
|
|
516
516
|
return (1 +
|
|
517
517
|
wrappedLineCount(heading, width) +
|
|
518
518
|
wrappedLineCount(item.text, mode === 'screen-reader' ? width : markdownContentWidth(width)));
|
|
@@ -679,7 +679,7 @@ function entryViewportRows(entry, width, mode) {
|
|
|
679
679
|
const summary = item.text.replace(/\s+/gu, ' ').trim();
|
|
680
680
|
const heading = mode === 'screen-reader'
|
|
681
681
|
? 'Thinking:Thought for a moment'
|
|
682
|
-
: `✻ Thought for a moment${summary ? ` · ${summary.slice(0, 160)}` : ''}`;
|
|
682
|
+
: `✻ Thought for a moment${mode === 'normal' && summary ? ` · ${summary.slice(0, 160)}` : ''}`;
|
|
683
683
|
if (mode === 'normal')
|
|
684
684
|
return [
|
|
685
685
|
'',
|
|
@@ -10,7 +10,7 @@ import { shellPermissionMatchCandidates } from './bash-normalization.js';
|
|
|
10
10
|
import { pathIsInsideRoots, validateBashPathSafety, } from './bash-path-safety.js';
|
|
11
11
|
import { validateSedSafety } from './sed-safety.js';
|
|
12
12
|
import { parseShellRule, shellRuleMatches } from './shell-rule-matching.js';
|
|
13
|
-
import { effectiveAdditionalDirectories, effectivePermissionMode, filePermissionSuggestions, permissionRuleValueFromString, permissionRuleValueToString, shellInputIsReadOnly, shellPermissionSuggestions, shellSubcommands, skillPermissionSuggestions, } from './permission-updates.js';
|
|
13
|
+
import { effectiveAdditionalDirectories, effectivePermissionMode, filePermissionSuggestions, permissionRuleValueFromString, permissionRuleStringIsValid, permissionRuleValueToString, shellInputIsReadOnly, shellPermissionSuggestions, shellSubcommands, skillPermissionSuggestions, } from './permission-updates.js';
|
|
14
14
|
const DEFAULT_BEHAVIOR = {
|
|
15
15
|
Agent: 'allow',
|
|
16
16
|
SendMessage: 'allow',
|
|
@@ -144,7 +144,7 @@ export function validateClaudePermissionSettings(settings) {
|
|
|
144
144
|
throw new Error(`permissions.${field} must be an array of strings: ${resource.path}`);
|
|
145
145
|
}
|
|
146
146
|
for (const rule of rules) {
|
|
147
|
-
if (
|
|
147
|
+
if (!permissionRuleStringIsValid(rule)) {
|
|
148
148
|
throw new Error(`Invalid permission rule in ${resource.path}: ${rule}`);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PermissionMode, PermissionRuleValue, PermissionUpdate } from '../core/runtime.js';
|
|
2
2
|
export declare function permissionRuleValueToString(rule: PermissionRuleValue): string;
|
|
3
|
+
export declare function permissionRuleStringIsValid(value: string): boolean;
|
|
3
4
|
export declare function permissionRuleValueFromString(value: string): PermissionRuleValue;
|
|
4
5
|
export declare function parsePermissionUpdates(value: unknown): readonly PermissionUpdate[] | undefined;
|
|
5
6
|
export declare function extractPermissionRules(updates: readonly PermissionUpdate[] | undefined): readonly PermissionRuleValue[];
|
|
@@ -10,6 +10,9 @@ export function permissionRuleValueToString(rule) {
|
|
|
10
10
|
.replaceAll(')', '\\)');
|
|
11
11
|
return `${rule.toolName}(${content})`;
|
|
12
12
|
}
|
|
13
|
+
export function permissionRuleStringIsValid(value) {
|
|
14
|
+
return /^([A-Za-z][\w-]*)(?:\(.*\))?$/su.test(value);
|
|
15
|
+
}
|
|
13
16
|
function unescapedIndex(value, character, fromEnd = false) {
|
|
14
17
|
const start = fromEnd ? value.length - 1 : 0;
|
|
15
18
|
const end = fromEnd ? -1 : value.length;
|