@imdeadpool/guardex 7.0.19 → 7.0.21
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 +51 -13
- package/bin/multiagent-safety.js +2 -7861
- package/package.json +2 -1
- package/src/cli/args.js +809 -0
- package/src/cli/dispatch.js +86 -0
- package/src/cli/main.js +5564 -0
- package/src/context.js +517 -0
- package/src/core/runtime.js +119 -0
- package/src/finish/index.js +425 -0
- package/src/git/index.js +122 -0
- package/src/hooks/index.js +74 -0
- package/src/output/index.js +398 -0
- package/src/sandbox/index.js +68 -0
- package/src/scaffold/index.js +148 -0
- package/src/toolchain/index.js +223 -0
- package/templates/scripts/agent-branch-start.sh +52 -8
- package/templates/scripts/codex-agent.sh +155 -7
- package/templates/vscode/guardex-active-agents/README.md +16 -11
- package/templates/vscode/guardex-active-agents/extension.js +908 -65
- package/templates/vscode/guardex-active-agents/package.json +63 -1
- package/templates/vscode/guardex-active-agents/session-schema.js +440 -42
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const {
|
|
2
|
+
TOOL_NAME,
|
|
3
|
+
COMMAND_TYPO_ALIASES,
|
|
4
|
+
DEPRECATED_COMMAND_ALIASES,
|
|
5
|
+
SUGGESTIBLE_COMMANDS,
|
|
6
|
+
} = require('../context');
|
|
7
|
+
|
|
8
|
+
function levenshteinDistance(a, b) {
|
|
9
|
+
const rows = a.length + 1;
|
|
10
|
+
const cols = b.length + 1;
|
|
11
|
+
const matrix = Array.from({ length: rows }, () => Array(cols).fill(0));
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < rows; i += 1) matrix[i][0] = i;
|
|
14
|
+
for (let j = 0; j < cols; j += 1) matrix[0][j] = j;
|
|
15
|
+
|
|
16
|
+
for (let i = 1; i < rows; i += 1) {
|
|
17
|
+
for (let j = 1; j < cols; j += 1) {
|
|
18
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
19
|
+
matrix[i][j] = Math.min(
|
|
20
|
+
matrix[i - 1][j] + 1,
|
|
21
|
+
matrix[i][j - 1] + 1,
|
|
22
|
+
matrix[i - 1][j - 1] + cost,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return matrix[a.length][b.length];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function maybeSuggestCommand(command) {
|
|
30
|
+
let best = null;
|
|
31
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
32
|
+
|
|
33
|
+
for (const candidate of SUGGESTIBLE_COMMANDS) {
|
|
34
|
+
const dist = levenshteinDistance(command, candidate);
|
|
35
|
+
if (dist < bestDistance) {
|
|
36
|
+
bestDistance = dist;
|
|
37
|
+
best = candidate;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (best && bestDistance <= 2) {
|
|
42
|
+
return best;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function normalizeCommandOrThrow(command) {
|
|
49
|
+
if (COMMAND_TYPO_ALIASES.has(command)) {
|
|
50
|
+
const mapped = COMMAND_TYPO_ALIASES.get(command);
|
|
51
|
+
console.log(`[${TOOL_NAME}] Interpreting '${command}' as '${mapped}'.`);
|
|
52
|
+
return mapped;
|
|
53
|
+
}
|
|
54
|
+
return command;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function warnDeprecatedAlias(aliasName) {
|
|
58
|
+
const entry = DEPRECATED_COMMAND_ALIASES.get(aliasName);
|
|
59
|
+
if (!entry) return;
|
|
60
|
+
console.error(
|
|
61
|
+
`[${TOOL_NAME}] '${aliasName}' is deprecated and will be removed in a future major release. ` +
|
|
62
|
+
`Use: ${entry.hint}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function extractFlag(args, ...names) {
|
|
67
|
+
const flagSet = new Set(names);
|
|
68
|
+
let found = false;
|
|
69
|
+
const remaining = [];
|
|
70
|
+
for (const arg of args) {
|
|
71
|
+
if (flagSet.has(arg)) {
|
|
72
|
+
found = true;
|
|
73
|
+
} else {
|
|
74
|
+
remaining.push(arg);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { found, remaining };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
levenshteinDistance,
|
|
82
|
+
maybeSuggestCommand,
|
|
83
|
+
normalizeCommandOrThrow,
|
|
84
|
+
warnDeprecatedAlias,
|
|
85
|
+
extractFlag,
|
|
86
|
+
};
|