@shrkcrft/framework-scanners 0.1.0-alpha.10

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 (82) hide show
  1. package/dist/extractor-api/extractor-registry.d.ts +19 -0
  2. package/dist/extractor-api/extractor-registry.d.ts.map +1 -0
  3. package/dist/extractor-api/extractor-registry.js +36 -0
  4. package/dist/extractor-api/framework-extractor.d.ts +48 -0
  5. package/dist/extractor-api/framework-extractor.d.ts.map +1 -0
  6. package/dist/extractor-api/framework-extractor.js +1 -0
  7. package/dist/extractors/angular-extractor.d.ts +18 -0
  8. package/dist/extractors/angular-extractor.d.ts.map +1 -0
  9. package/dist/extractors/angular-extractor.js +175 -0
  10. package/dist/extractors/astro-extractor.d.ts +15 -0
  11. package/dist/extractors/astro-extractor.d.ts.map +1 -0
  12. package/dist/extractors/astro-extractor.js +128 -0
  13. package/dist/extractors/django-extractor.d.ts +24 -0
  14. package/dist/extractors/django-extractor.d.ts.map +1 -0
  15. package/dist/extractors/django-extractor.js +124 -0
  16. package/dist/extractors/express-extractor.d.ts +18 -0
  17. package/dist/extractors/express-extractor.d.ts.map +1 -0
  18. package/dist/extractors/express-extractor.js +193 -0
  19. package/dist/extractors/fastapi-extractor.d.ts +19 -0
  20. package/dist/extractors/fastapi-extractor.d.ts.map +1 -0
  21. package/dist/extractors/fastapi-extractor.js +135 -0
  22. package/dist/extractors/fastify-extractor.d.ts +13 -0
  23. package/dist/extractors/fastify-extractor.d.ts.map +1 -0
  24. package/dist/extractors/fastify-extractor.js +166 -0
  25. package/dist/extractors/flask-extractor.d.ts +16 -0
  26. package/dist/extractors/flask-extractor.d.ts.map +1 -0
  27. package/dist/extractors/flask-extractor.js +142 -0
  28. package/dist/extractors/flutter-extractor.d.ts +26 -0
  29. package/dist/extractors/flutter-extractor.d.ts.map +1 -0
  30. package/dist/extractors/flutter-extractor.js +137 -0
  31. package/dist/extractors/graphql-extractor.d.ts +27 -0
  32. package/dist/extractors/graphql-extractor.d.ts.map +1 -0
  33. package/dist/extractors/graphql-extractor.js +141 -0
  34. package/dist/extractors/laravel-extractor.d.ts +22 -0
  35. package/dist/extractors/laravel-extractor.d.ts.map +1 -0
  36. package/dist/extractors/laravel-extractor.js +208 -0
  37. package/dist/extractors/nestjs-extractor.d.ts +18 -0
  38. package/dist/extractors/nestjs-extractor.d.ts.map +1 -0
  39. package/dist/extractors/nestjs-extractor.js +222 -0
  40. package/dist/extractors/nextjs-extractor.d.ts +19 -0
  41. package/dist/extractors/nextjs-extractor.d.ts.map +1 -0
  42. package/dist/extractors/nextjs-extractor.js +175 -0
  43. package/dist/extractors/phoenix-extractor.d.ts +28 -0
  44. package/dist/extractors/phoenix-extractor.d.ts.map +1 -0
  45. package/dist/extractors/phoenix-extractor.js +212 -0
  46. package/dist/extractors/rails-extractor.d.ts +25 -0
  47. package/dist/extractors/rails-extractor.d.ts.map +1 -0
  48. package/dist/extractors/rails-extractor.js +180 -0
  49. package/dist/extractors/react-extractor.d.ts +19 -0
  50. package/dist/extractors/react-extractor.d.ts.map +1 -0
  51. package/dist/extractors/react-extractor.js +209 -0
  52. package/dist/extractors/solid-extractor.d.ts +19 -0
  53. package/dist/extractors/solid-extractor.d.ts.map +1 -0
  54. package/dist/extractors/solid-extractor.js +164 -0
  55. package/dist/extractors/spring-extractor.d.ts +27 -0
  56. package/dist/extractors/spring-extractor.d.ts.map +1 -0
  57. package/dist/extractors/spring-extractor.js +279 -0
  58. package/dist/extractors/svelte-extractor.d.ts +17 -0
  59. package/dist/extractors/svelte-extractor.d.ts.map +1 -0
  60. package/dist/extractors/svelte-extractor.js +104 -0
  61. package/dist/extractors/vue-extractor.d.ts +18 -0
  62. package/dist/extractors/vue-extractor.d.ts.map +1 -0
  63. package/dist/extractors/vue-extractor.js +125 -0
  64. package/dist/index.d.ts +27 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +26 -0
  67. package/dist/query/framework-query-api.d.ts +39 -0
  68. package/dist/query/framework-query-api.d.ts.map +1 -0
  69. package/dist/query/framework-query-api.js +99 -0
  70. package/dist/runner/load-pack-extractors.d.ts +36 -0
  71. package/dist/runner/load-pack-extractors.d.ts.map +1 -0
  72. package/dist/runner/load-pack-extractors.js +87 -0
  73. package/dist/runner/run-extractors.d.ts +29 -0
  74. package/dist/runner/run-extractors.d.ts.map +1 -0
  75. package/dist/runner/run-extractors.js +144 -0
  76. package/dist/schema/framework-schema.d.ts +36 -0
  77. package/dist/schema/framework-schema.d.ts.map +1 -0
  78. package/dist/schema/framework-schema.js +1 -0
  79. package/dist/store/framework-store.d.ts +17 -0
  80. package/dist/store/framework-store.d.ts.map +1 -0
  81. package/dist/store/framework-store.js +138 -0
  82. package/package.json +55 -0
@@ -0,0 +1,36 @@
1
+ import type { IEdge, INode } from '@shrkcrft/graph';
2
+ export declare const FRAMEWORK_SCHEMA: "sharkcraft.framework/v1";
3
+ export type FrameworkSchemaVersion = typeof FRAMEWORK_SCHEMA;
4
+ /**
5
+ * Known framework tags. Open string union so packs can later contribute
6
+ * additional extractors without touching this enum.
7
+ */
8
+ export type FrameworkName = 'nestjs' | 'react' | 'express' | 'angular' | 'vue' | 'svelte' | string;
9
+ /**
10
+ * NestJS subtypes the built-in extractor emits today.
11
+ */
12
+ export type NestSubtype = 'controller' | 'module' | 'provider' | 'route';
13
+ /**
14
+ * React subtypes the built-in extractor emits today.
15
+ */
16
+ export type ReactSubtype = 'component' | 'hook-usage';
17
+ export interface IFrameworkManifest {
18
+ schema: FrameworkSchemaVersion;
19
+ projectRoot: string;
20
+ lastBuiltAt: string;
21
+ lastBuildDurationMs: number;
22
+ /** SHA-256 of the framework store's JSONL files. */
23
+ digest: string;
24
+ /** Per-framework entity counts. */
25
+ countsByFramework: Readonly<Record<string, number>>;
26
+ /** Per-(framework + subtype) counts. */
27
+ countsBySubtype: Readonly<Record<string, number>>;
28
+ /** Frameworks active in this snapshot. */
29
+ frameworks: readonly string[];
30
+ }
31
+ export interface IFrameworkSnapshot {
32
+ manifest: IFrameworkManifest;
33
+ nodes: ReadonlyMap<string, INode>;
34
+ edges: ReadonlyMap<string, IEdge>;
35
+ }
36
+ //# sourceMappingURL=framework-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-schema.d.ts","sourceRoot":"","sources":["../../src/schema/framework-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,EAAG,yBAAkC,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,OAAO,gBAAgB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnG;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,wCAAwC;IACxC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,0CAA0C;IAC1C,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACnC"}
@@ -0,0 +1 @@
1
+ export const FRAMEWORK_SCHEMA = 'sharkcraft.framework/v1';
@@ -0,0 +1,17 @@
1
+ import type { IEdge, INode } from '@shrkcrft/graph';
2
+ import { type IFrameworkManifest, type IFrameworkSnapshot } from '../schema/framework-schema.js';
3
+ /**
4
+ * On-disk JSONL store for `@shrkcrft/framework-scanners`. Lives at
5
+ * `<root>/.sharkcraft/framework/` alongside the code-graph and bridge
6
+ * stores; merged in memory at query time.
7
+ */
8
+ export declare class FrameworkStore {
9
+ private readonly projectRoot;
10
+ readonly storeDir: string;
11
+ constructor(projectRoot: string);
12
+ exists(): boolean;
13
+ clear(): void;
14
+ writeSnapshot(nodes: readonly INode[], edges: readonly IEdge[], partial: Omit<IFrameworkManifest, 'schema' | 'digest'>): IFrameworkManifest;
15
+ loadSnapshot(): IFrameworkSnapshot;
16
+ }
17
+ //# sourceMappingURL=framework-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-store.d.ts","sourceRoot":"","sources":["../../src/store/framework-store.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AAMvC;;;;GAIG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,WAAW;IAFxC,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAEJ,WAAW,EAAE,MAAM;IAIhD,MAAM,IAAI,OAAO;IAIjB,KAAK,IAAI,IAAI;IAMb,aAAa,CACX,KAAK,EAAE,SAAS,KAAK,EAAE,EACvB,KAAK,EAAE,SAAS,KAAK,EAAE,EACvB,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,QAAQ,CAAC,GACrD,kBAAkB;IA8BrB,YAAY,IAAI,kBAAkB;CAoCnC"}
@@ -0,0 +1,138 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync, } from 'node:fs';
3
+ import * as nodePath from 'node:path';
4
+ import { FRAMEWORK_SCHEMA, } from "../schema/framework-schema.js";
5
+ const NODES_DIR = 'nodes';
6
+ const EDGES_DIR = 'edges';
7
+ const META_FILE = 'meta.json';
8
+ /**
9
+ * On-disk JSONL store for `@shrkcrft/framework-scanners`. Lives at
10
+ * `<root>/.sharkcraft/framework/` alongside the code-graph and bridge
11
+ * stores; merged in memory at query time.
12
+ */
13
+ export class FrameworkStore {
14
+ projectRoot;
15
+ storeDir;
16
+ constructor(projectRoot) {
17
+ this.projectRoot = projectRoot;
18
+ this.storeDir = nodePath.join(projectRoot, '.sharkcraft', 'framework');
19
+ }
20
+ exists() {
21
+ return existsSync(nodePath.join(this.storeDir, META_FILE));
22
+ }
23
+ clear() {
24
+ if (existsSync(this.storeDir)) {
25
+ rmSync(this.storeDir, { recursive: true, force: true });
26
+ }
27
+ }
28
+ writeSnapshot(nodes, edges, partial) {
29
+ const nodesDir = nodePath.join(this.storeDir, NODES_DIR);
30
+ const edgesDir = nodePath.join(this.storeDir, EDGES_DIR);
31
+ if (existsSync(nodesDir))
32
+ rmSync(nodesDir, { recursive: true, force: true });
33
+ if (existsSync(edgesDir))
34
+ rmSync(edgesDir, { recursive: true, force: true });
35
+ mkdirSync(nodesDir, { recursive: true });
36
+ mkdirSync(edgesDir, { recursive: true });
37
+ // Bucket by framework name (one file per framework).
38
+ const nodesByFramework = bucket(nodes, (n) => String(n.data?.['framework'] ?? 'unknown'));
39
+ const edgesByKind = bucket(edges, (e) => e.kind);
40
+ for (const [framework, list] of Object.entries(nodesByFramework)) {
41
+ list.sort((a, b) => a.id.localeCompare(b.id));
42
+ writeJsonl(nodePath.join(nodesDir, `${framework}.jsonl`), list);
43
+ }
44
+ for (const [kind, list] of Object.entries(edgesByKind)) {
45
+ list.sort((a, b) => a.id.localeCompare(b.id));
46
+ writeJsonl(nodePath.join(edgesDir, `${kind}.jsonl`), list);
47
+ }
48
+ const digest = computeDigest(this.storeDir);
49
+ const manifest = {
50
+ schema: FRAMEWORK_SCHEMA,
51
+ digest,
52
+ ...partial,
53
+ };
54
+ writeFileSync(nodePath.join(this.storeDir, META_FILE), JSON.stringify(manifest, null, 2));
55
+ return manifest;
56
+ }
57
+ loadSnapshot() {
58
+ if (!this.exists()) {
59
+ throw new Error(`framework store not found under ${this.storeDir}. Run 'shrk framework index'.`);
60
+ }
61
+ const manifest = JSON.parse(readFileSync(nodePath.join(this.storeDir, META_FILE), 'utf8'));
62
+ if (manifest.schema !== FRAMEWORK_SCHEMA) {
63
+ throw new Error(`framework schema mismatch: store=${manifest.schema}, expected=${FRAMEWORK_SCHEMA}.`);
64
+ }
65
+ const nodes = new Map();
66
+ const nodesDir = nodePath.join(this.storeDir, NODES_DIR);
67
+ if (existsSync(nodesDir)) {
68
+ for (const fname of readdirSync(nodesDir)) {
69
+ if (!fname.endsWith('.jsonl'))
70
+ continue;
71
+ for (const row of readJsonl(nodePath.join(nodesDir, fname))) {
72
+ nodes.set(row.id, row);
73
+ }
74
+ }
75
+ }
76
+ const edges = new Map();
77
+ const edgesDir = nodePath.join(this.storeDir, EDGES_DIR);
78
+ if (existsSync(edgesDir)) {
79
+ for (const fname of readdirSync(edgesDir)) {
80
+ if (!fname.endsWith('.jsonl'))
81
+ continue;
82
+ for (const row of readJsonl(nodePath.join(edgesDir, fname))) {
83
+ edges.set(row.id, row);
84
+ }
85
+ }
86
+ }
87
+ return { manifest, nodes, edges };
88
+ }
89
+ }
90
+ function bucket(list, key) {
91
+ const out = {};
92
+ for (const item of list) {
93
+ const k = key(item);
94
+ if (!out[k])
95
+ out[k] = [];
96
+ out[k].push(item);
97
+ }
98
+ return out;
99
+ }
100
+ function writeJsonl(path, rows) {
101
+ const body = rows.map((r) => JSON.stringify(r)).join('\n');
102
+ writeFileSync(path, body.length > 0 ? body + '\n' : '');
103
+ }
104
+ function readJsonl(path) {
105
+ const raw = readFileSync(path, 'utf8');
106
+ if (!raw)
107
+ return [];
108
+ const out = [];
109
+ for (const line of raw.split('\n')) {
110
+ const t = line.trim();
111
+ if (!t)
112
+ continue;
113
+ out.push(JSON.parse(t));
114
+ }
115
+ return out;
116
+ }
117
+ function computeDigest(storeDir) {
118
+ const hash = createHash('sha256');
119
+ const targets = [];
120
+ for (const sub of [NODES_DIR, EDGES_DIR]) {
121
+ const dir = nodePath.join(storeDir, sub);
122
+ if (!existsSync(dir))
123
+ continue;
124
+ for (const fname of readdirSync(dir).sort()) {
125
+ if (!fname.endsWith('.jsonl'))
126
+ continue;
127
+ targets.push(nodePath.join(dir, fname));
128
+ }
129
+ }
130
+ targets.sort();
131
+ for (const t of targets) {
132
+ hash.update(nodePath.relative(storeDir, t));
133
+ hash.update('\0');
134
+ hash.update(readFileSync(t));
135
+ hash.update('\0');
136
+ }
137
+ return hash.digest('hex');
138
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@shrkcrft/framework-scanners",
3
+ "version": "0.1.0-alpha.10",
4
+ "description": "SharkCraft framework-aware extractors. Plugin-shaped enrichment for the code graph: NestJS controllers/modules/providers, React components/hooks, future Angular/Express/Next.",
5
+ "license": "MIT",
6
+ "author": "SharkCraft contributors",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/sharkcraft/sharkcraft.git",
25
+ "directory": "packages/framework-scanners"
26
+ },
27
+ "homepage": "https://github.com/sharkcraft/sharkcraft",
28
+ "bugs": {
29
+ "url": "https://github.com/sharkcraft/sharkcraft/issues"
30
+ },
31
+ "keywords": [
32
+ "sharkcraft",
33
+ "framework-scanners",
34
+ "nestjs",
35
+ "react",
36
+ "express",
37
+ "code-intelligence"
38
+ ],
39
+ "engines": {
40
+ "bun": ">=1.1.0",
41
+ "node": ">=18"
42
+ },
43
+ "scripts": {
44
+ "typecheck": "tsc --noEmit -p tsconfig.json"
45
+ },
46
+ "dependencies": {
47
+ "@shrkcrft/core": "^0.1.0-alpha.10",
48
+ "@shrkcrft/graph": "^0.1.0-alpha.10",
49
+ "@shrkcrft/packs": "^0.1.0-alpha.10",
50
+ "typescript": "^5.5.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ }
55
+ }