@shrkcrft/paths 0.1.0-alpha.2 → 0.1.0-alpha.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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './path-convention.js';
2
+ export * from './path-convention-match.js';
2
3
  export * from './path-query.js';
3
4
  export * from './path-selector.js';
4
5
  export * from './path-service.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./path-convention.js";
2
+ export * from "./path-convention-match.js";
2
3
  export * from "./path-query.js";
3
4
  export * from "./path-selector.js";
4
5
  export * from "./path-service.js";
@@ -0,0 +1,13 @@
1
+ import type { IPathConvention } from './path-convention.js';
2
+ /**
3
+ * Select the path conventions a set of files actually falls under, by STRUCTURED
4
+ * directory-prefix match against each convention's `metadata.path` — not a
5
+ * free-text substring of its title/description (which made common segments like
6
+ * `src` match nearly the whole registry).
7
+ *
8
+ * A convention is "affected" iff some file equals, or lives under, its canonical
9
+ * path. Conventions with no structured `metadata.path` are excluded (they have
10
+ * no anchor to attribute against). Returns conventions in input order.
11
+ */
12
+ export declare function matchAffectedConventions(conventions: readonly IPathConvention[], files: readonly string[]): IPathConvention[];
13
+ //# sourceMappingURL=path-convention-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-convention-match.d.ts","sourceRoot":"","sources":["../src/path-convention-match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAa5D;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,SAAS,eAAe,EAAE,EACvC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,eAAe,EAAE,CAUnB"}
@@ -0,0 +1,33 @@
1
+ /** Normalise a path for prefix comparison: drop leading `./` or `/`, drop a
2
+ * trailing slash, collapse separators to POSIX `/`. */
3
+ function normalizePath(p) {
4
+ return p
5
+ .replace(/^\.?\/+/, '')
6
+ .replace(/\/+$/, '')
7
+ .split(/[\\/]+/)
8
+ .filter(Boolean)
9
+ .join('/');
10
+ }
11
+ /**
12
+ * Select the path conventions a set of files actually falls under, by STRUCTURED
13
+ * directory-prefix match against each convention's `metadata.path` — not a
14
+ * free-text substring of its title/description (which made common segments like
15
+ * `src` match nearly the whole registry).
16
+ *
17
+ * A convention is "affected" iff some file equals, or lives under, its canonical
18
+ * path. Conventions with no structured `metadata.path` are excluded (they have
19
+ * no anchor to attribute against). Returns conventions in input order.
20
+ */
21
+ export function matchAffectedConventions(conventions, files) {
22
+ const normFiles = files.map(normalizePath).filter((f) => f.length > 0);
23
+ const out = [];
24
+ for (const convention of conventions) {
25
+ const normConv = normalizePath(String(convention.metadata?.path ?? ''));
26
+ if (normConv.length === 0)
27
+ continue;
28
+ const affected = normFiles.some((f) => f === normConv || f.startsWith(normConv + '/'));
29
+ if (affected)
30
+ out.push(convention);
31
+ }
32
+ return out;
33
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"path-selector.d.ts","sourceRoot":"","sources":["../src/path-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,eAAe,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,eAAe,EAAE,EACtC,IAAI,EAAE,MAAM,GACX,cAAc,GAAG,IAAI,CAkCvB"}
1
+ {"version":3,"file":"path-selector.d.ts","sourceRoot":"","sources":["../src/path-selector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,eAAe,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,eAAe,EAAE,EACtC,IAAI,EAAE,MAAM,GACX,cAAc,GAAG,IAAI,CAmCvB"}
@@ -1,5 +1,7 @@
1
1
  export function selectBestPath(candidates, task) {
2
- if (candidates.length === 0)
2
+ if (!candidates || candidates.length === 0)
3
+ return null;
4
+ if (typeof task !== 'string' || task.trim() === '')
3
5
  return null;
4
6
  const taskLower = task.toLowerCase();
5
7
  const scored = candidates
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@shrkcrft/paths",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.21",
4
4
  "description": "SharkCraft path-convention service: typed path entries and best-fit selection.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
7
7
  "type": "module",
8
8
  "main": "./dist/index.js",
9
- "types": "./dist/index.d.d.ts",
9
+ "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
@@ -42,8 +42,8 @@
42
42
  "typecheck": "tsc --noEmit -p tsconfig.json"
43
43
  },
44
44
  "dependencies": {
45
- "@shrkcrft/core": "^0.1.0-alpha.2",
46
- "@shrkcrft/knowledge": "^0.1.0-alpha.2"
45
+ "@shrkcrft/core": "^0.1.0-alpha.21",
46
+ "@shrkcrft/knowledge": "^0.1.0-alpha.21"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"