@coralai/sps-plugin-api 0.15.0 → 0.16.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/dist/index.d.ts +7 -0
- package/dist/index.js +17 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -406,6 +406,13 @@ export interface SpsWorkspace {
|
|
|
406
406
|
*/
|
|
407
407
|
declaredOutDir(repoDir: string): string | null | undefined;
|
|
408
408
|
}
|
|
409
|
+
export type SyncRejectCode = 'EMPTY_SEGMENT' | 'ABSOLUTE' | 'PARENT_SEGMENT' | 'DOT_SEGMENT';
|
|
410
|
+
export interface SyncRejection {
|
|
411
|
+
code: SyncRejectCode;
|
|
412
|
+
rel: string;
|
|
413
|
+
}
|
|
414
|
+
/** 相对路径的形状判据。返回 `null` = 形状没问题(**不代表可同步**,还要过软链围栏)。 */
|
|
415
|
+
export declare function syncableShape(rel: string): SyncRejection | null;
|
|
409
416
|
/**
|
|
410
417
|
* `p` 是否在 `root` 之内(含 root 自身)。
|
|
411
418
|
*
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,23 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { realpath } from 'node:fs/promises';
|
|
15
15
|
import { dirname, join, resolve as nodeResolve, sep } from 'node:path';
|
|
16
|
+
/** 相对路径的形状判据。返回 `null` = 形状没问题(**不代表可同步**,还要过软链围栏)。 */
|
|
17
|
+
export function syncableShape(rel) {
|
|
18
|
+
if (!rel)
|
|
19
|
+
return { code: 'EMPTY_SEGMENT', rel };
|
|
20
|
+
if (rel.startsWith('/'))
|
|
21
|
+
return { code: 'ABSOLUTE', rel };
|
|
22
|
+
for (const seg of rel.split('/')) {
|
|
23
|
+
if (!seg)
|
|
24
|
+
return { code: 'EMPTY_SEGMENT', rel };
|
|
25
|
+
if (seg === '..')
|
|
26
|
+
return { code: 'PARENT_SEGMENT', rel };
|
|
27
|
+
// ← 承重的是这条:`.claude/`、`.git/`、`.sps/` 全靠它
|
|
28
|
+
if (seg.startsWith('.'))
|
|
29
|
+
return { code: 'DOT_SEGMENT', rel };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
16
33
|
// ── 路径围栏:所有插件共用的安全下限 ──────────────────────────────────────
|
|
17
34
|
//
|
|
18
35
|
// 🔴 **安全判据不能有第二份。** 本仓已经为这个形状付过三次代价:
|