@mrweicodes/dsh-permgate 1.3.9 → 1.3.11

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 (3) hide show
  1. package/client.js +1 -1
  2. package/index.js +28 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: "dsh-permgate",
2
+ id: "@mrweicodes/dsh-permgate",
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
package/index.js CHANGED
@@ -1548,7 +1548,8 @@ export default {
1548
1548
  t = t.replace(/^[.\/\\]/, '').trim()
1549
1549
  if (!t) return ''
1550
1550
  if (t.indexOf('$') !== -1 || t.indexOf('@') !== -1) return ''
1551
- if (!/^[A-Za-z_]/.test(t)) return ''
1551
+ if (t.indexOf(':') !== -1 || t.indexOf('\\') !== -1 || t.indexOf('/') !== -1) return ''
1552
+ if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(t)) return ''
1552
1553
  if (/[()[\]{}'"]/.test(t)) return ''
1553
1554
  return t
1554
1555
  }
@@ -1618,11 +1619,36 @@ export default {
1618
1619
  } catch (e) { return false }
1619
1620
  }
1620
1621
 
1622
+ // 引号感知的命令分段:只把引号外的 | 与 ; 当分段符。
1623
+ // 正则/字符串里常含 |(如匹配盘符的正则),按管道切开会产生 C:\ 这类假命令。
1624
+ function splitCommandSegments(s) {
1625
+ const out = []
1626
+ let cur = ''
1627
+ let quote = null
1628
+ for (let i = 0; i < s.length; i++) {
1629
+ const ch = s[i]
1630
+ if (quote !== null) {
1631
+ cur += ch
1632
+ if (ch === quote) {
1633
+ if (quote === "'" && s[i + 1] === "'") { cur += s[++i]; continue }
1634
+ if (quote === '"' && s[i - 1] === '`') continue
1635
+ quote = null
1636
+ }
1637
+ continue
1638
+ }
1639
+ if (ch === "'" || ch === '"') { quote = ch; cur += ch; continue }
1640
+ if (ch === '|' || ch === ';') { out.push(cur); cur = ''; continue }
1641
+ cur += ch
1642
+ }
1643
+ out.push(cur)
1644
+ return out
1645
+ }
1646
+
1621
1647
  function buildCandidates(entry) {
1622
1648
  const out = []
1623
1649
  const push = (label, value, kind) => out.push({ id: 'c' + Math.random().toString(36).slice(2, 8), label, value, kind })
1624
1650
  if (entry.kind === 'command' && entry.value) {
1625
- const parts = String(entry.value).split(/[|;]/)
1651
+ const parts = splitCommandSegments(String(entry.value))
1626
1652
  const seen = {}
1627
1653
  for (const seg of parts) {
1628
1654
  const toks = commandTokens(seg)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mrweicodes/dsh-permgate",
3
3
  "description": "Permission gateway for DSH (DeepSeek Harness): reviews tool calls per category (directory/command/read/edit/subagent/doom loop) with global/project config, exceptions, quick-tool defaults, custom rules, bilingual approval modal and sandbox-upgrade flow. Config persisted at $DSH_HOME/dsh-permgate/config.json.",
4
- "version": "1.3.9",
4
+ "version": "1.3.11",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/MrWeiCodes/dsh-permgate.git"