@agy-daddy/plugin-chat-nav 1.0.0 → 1.1.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/agy-plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "agy-daddy.chat-nav",
4
4
  "publisher": "agy-daddy",
5
- "version": "1.0.0",
5
+ "version": "1.1.0",
6
6
  "license": "MIT",
7
7
  "displayName": {
8
8
  "zh-CN": "对话栏增强",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agy-daddy/plugin-chat-nav",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Agy-Daddy floating chat navigation, thinking expand guard, search slot, copy session ID, multi-format export (MD/HTML/PDF), inline file editor, and safe external link plugin",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "scripts": {
27
- "test": "AGY_DADDY_TEST_MODE=1 node --test test/*.test.js"
27
+ "test": "node -e \"const cp=require('node:child_process'),fs=require('node:fs'),p=require('node:path');const files=fs.readdirSync('test').filter(f=>f.endsWith('.test.js')).sort().map(f=>p.join('test',f));process.exit(cp.spawnSync(process.execPath,['--test',...files],{stdio:'inherit',env:{...process.env,AGY_DADDY_TEST_MODE:'1'}}).status??1)\""
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=22.4.0"
@@ -29,7 +29,7 @@ const BLOCKED_PATH_PREFIXES = Object.freeze([
29
29
  '/Applications/Antigravity.app'
30
30
  ]);
31
31
 
32
- const SENSITIVE_PATH_REGEX = /\/(?:\.ssh|\.gnupg|\.aws|1Password)\//i;
32
+ const SENSITIVE_PATH_REGEX = /[\\/](?:\.ssh|\.gnupg|\.aws|1Password)[\\/]/i;
33
33
 
34
34
  function normalizeFilePathInput(rawPathOrUri) {
35
35
  const s = String(rawPathOrUri || '').trim();
@@ -37,10 +37,19 @@ function normalizeFilePathInput(rawPathOrUri) {
37
37
 
38
38
  let decoded = s;
39
39
  if (/^file:\/\//i.test(s)) {
40
- try {
41
- decoded = decodeURIComponent(new URL(s).pathname);
42
- } catch {
43
- return null;
40
+ if (/^file:\/\/\/?[A-Za-z]:[\\/]/i.test(s)) {
41
+ const stripped = s.replace(/^file:\/\/\/?/i, '');
42
+ try {
43
+ decoded = decodeURIComponent(stripped);
44
+ } catch {
45
+ decoded = stripped;
46
+ }
47
+ } else {
48
+ try {
49
+ decoded = decodeURIComponent(new URL(s).pathname);
50
+ } catch {
51
+ return null;
52
+ }
44
53
  }
45
54
  }
46
55
  if (!path.isAbsolute(decoded)) return null;
@@ -52,11 +61,18 @@ const ALLOWED_VAR_TEMP_PREFIXES = ['/var/folders/', '/private/var/folders/'];
52
61
  function resolveSafeEditablePath(rawPathOrUri) {
53
62
  const resolved = normalizeFilePathInput(rawPathOrUri);
54
63
  if (!resolved) return null;
55
- const isMacUserTemp = ALLOWED_VAR_TEMP_PREFIXES.some((p) => resolved.startsWith(p));
64
+ const slashed = resolved.replace(/\\/g, '/');
65
+ if (/^c:\/windows(?:\/|$)/i.test(slashed)) {
66
+ return null;
67
+ }
68
+ const posixPart = slashed.replace(/^[A-Za-z]:/, '');
69
+ const isMacUserTemp = ALLOWED_VAR_TEMP_PREFIXES.some((p) => slashed.startsWith(p));
56
70
  for (const prefix of BLOCKED_PATH_PREFIXES) {
57
71
  if (isMacUserTemp && prefix === '/var') continue;
58
- if (resolved === prefix || resolved.startsWith(prefix + '/')) {
59
- return null;
72
+ for (const candidate of [slashed, posixPart]) {
73
+ if (candidate === prefix || candidate.startsWith(prefix + '/')) {
74
+ return null;
75
+ }
60
76
  }
61
77
  }
62
78
  if (SENSITIVE_PATH_REGEX.test(resolved)) {