logicstamp-context 0.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/LICENSE +21 -0
- package/LLM_CONTEXT.md +260 -0
- package/README.md +949 -0
- package/dist/cli/commands/clean.d.ts +15 -0
- package/dist/cli/commands/clean.d.ts.map +1 -0
- package/dist/cli/commands/clean.js +142 -0
- package/dist/cli/commands/clean.js.map +1 -0
- package/dist/cli/commands/compare.d.ts +88 -0
- package/dist/cli/commands/compare.d.ts.map +1 -0
- package/dist/cli/commands/compare.js +519 -0
- package/dist/cli/commands/compare.js.map +1 -0
- package/dist/cli/commands/context.d.ts +24 -0
- package/dist/cli/commands/context.d.ts.map +1 -0
- package/dist/cli/commands/context.js +576 -0
- package/dist/cli/commands/context.js.map +1 -0
- package/dist/cli/commands/init.d.ts +14 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +71 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +52 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +368 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +223 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/stamp.d.ts +7 -0
- package/dist/cli/stamp.d.ts.map +1 -0
- package/dist/cli/stamp.js +961 -0
- package/dist/cli/stamp.js.map +1 -0
- package/dist/cli/validate-index.d.ts +7 -0
- package/dist/cli/validate-index.d.ts.map +1 -0
- package/dist/cli/validate-index.js +55 -0
- package/dist/cli/validate-index.js.map +1 -0
- package/dist/core/astParser.d.ts +47 -0
- package/dist/core/astParser.d.ts.map +1 -0
- package/dist/core/astParser.js +417 -0
- package/dist/core/astParser.js.map +1 -0
- package/dist/core/contractBuilder.d.ts +48 -0
- package/dist/core/contractBuilder.d.ts.map +1 -0
- package/dist/core/contractBuilder.js +120 -0
- package/dist/core/contractBuilder.js.map +1 -0
- package/dist/core/manifest.d.ts +75 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +173 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/pack.d.ts +190 -0
- package/dist/core/pack.d.ts.map +1 -0
- package/dist/core/pack.js +438 -0
- package/dist/core/pack.js.map +1 -0
- package/dist/core/signature.d.ts +47 -0
- package/dist/core/signature.d.ts.map +1 -0
- package/dist/core/signature.js +208 -0
- package/dist/core/signature.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/types/UIFContract.d.ts +112 -0
- package/dist/types/UIFContract.d.ts.map +1 -0
- package/dist/types/UIFContract.js +36 -0
- package/dist/types/UIFContract.js.map +1 -0
- package/dist/utils/config.d.ts +34 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +62 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/fsx.d.ts +85 -0
- package/dist/utils/fsx.d.ts.map +1 -0
- package/dist/utils/fsx.js +181 -0
- package/dist/utils/fsx.js.map +1 -0
- package/dist/utils/gitignore.d.ts +62 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +183 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/hash.d.ts +73 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +159 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/llmContext.d.ts +34 -0
- package/dist/utils/llmContext.d.ts.map +1 -0
- package/dist/utils/llmContext.js +136 -0
- package/dist/utils/llmContext.js.map +1 -0
- package/dist/utils/tokens.d.ts +23 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +29 -0
- package/dist/utils/tokens.js.map +1 -0
- package/package.json +69 -0
- package/schema/logicstamp.context.schema.json +430 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uif Contract 0.3
|
|
3
|
+
*
|
|
4
|
+
* Description: contractBuilder - Presentational component
|
|
5
|
+
*
|
|
6
|
+
* Version (Component Composition):
|
|
7
|
+
* variables: []
|
|
8
|
+
* hooks: []
|
|
9
|
+
* components: []
|
|
10
|
+
* functions: ["buildContract","mergeContractUpdate"]
|
|
11
|
+
* imports: ["../types/UIFContract.js","../utils/fsx.js","../utils/hash.js","./astParser.js","./signature.js"]
|
|
12
|
+
*
|
|
13
|
+
* Logic Signature:
|
|
14
|
+
* props: {}
|
|
15
|
+
* emits: {}
|
|
16
|
+
* state: {}
|
|
17
|
+
*
|
|
18
|
+
* Predictions:
|
|
19
|
+
* (none)
|
|
20
|
+
*
|
|
21
|
+
* Hashes (informational only - authoritative values in .uif.json):
|
|
22
|
+
* semantic: uif:9e7343c07744633f5dfe4cd9 (informational)
|
|
23
|
+
* file: uif:6885bc3a8a6e6f3a4c0056fb
|
|
24
|
+
*/
|
|
25
|
+
import { buildLogicSignature, generateBehavioralPredictions, inferDescription, } from './signature.js';
|
|
26
|
+
import { semanticHashFromAst, fileHash } from '../utils/hash.js';
|
|
27
|
+
import { normalizeEntryId } from '../utils/fsx.js';
|
|
28
|
+
import { resolve, relative } from 'node:path';
|
|
29
|
+
import { platform } from 'node:os';
|
|
30
|
+
/**
|
|
31
|
+
* Extract export metadata from AST
|
|
32
|
+
*/
|
|
33
|
+
function extractExportsMetadata(ast) {
|
|
34
|
+
// Check if we have any exports at all
|
|
35
|
+
if (!ast.functions || ast.functions.length === 0) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// Check for default export in the component name
|
|
39
|
+
const hasDefaultExport = ast.functions.some(fn => fn.toLowerCase() === 'default');
|
|
40
|
+
// If we have only one function and it matches the file name, assume default export
|
|
41
|
+
const isLikelyDefault = ast.functions.length === 1 && !hasDefaultExport;
|
|
42
|
+
if (hasDefaultExport || isLikelyDefault) {
|
|
43
|
+
return 'default';
|
|
44
|
+
}
|
|
45
|
+
// If multiple exports or clear named exports
|
|
46
|
+
if (ast.functions.length > 1) {
|
|
47
|
+
return { named: ast.functions };
|
|
48
|
+
}
|
|
49
|
+
// Single named export
|
|
50
|
+
return { named: ast.functions };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build a complete UIFContract from extracted AST data
|
|
54
|
+
*/
|
|
55
|
+
export function buildContract(entryId, ast, params) {
|
|
56
|
+
// Build logic signature with preset validation
|
|
57
|
+
const { signature, prediction: presetPredictions, violations } = buildLogicSignature(ast, params.preset);
|
|
58
|
+
// Generate additional behavioral predictions (only if enabled)
|
|
59
|
+
const behavioralPredictions = params.enablePredictions
|
|
60
|
+
? generateBehavioralPredictions(ast)
|
|
61
|
+
: [];
|
|
62
|
+
// Combine all predictions
|
|
63
|
+
const allPredictions = [...presetPredictions, ...behavioralPredictions];
|
|
64
|
+
// Compute path fields
|
|
65
|
+
const entryPathAbs = resolve(entryId);
|
|
66
|
+
const cwd = process.cwd();
|
|
67
|
+
const entryPathRel = relative(cwd, entryId).replace(/\\/g, '/'); // Always use POSIX separators
|
|
68
|
+
const os = platform() === 'win32' ? 'win32' : 'posix';
|
|
69
|
+
// Extract exports
|
|
70
|
+
const exports = extractExportsMetadata(ast);
|
|
71
|
+
// Build the contract (usedIn omitted - computed at manifest time, not persisted)
|
|
72
|
+
const contract = {
|
|
73
|
+
type: 'UIFContract',
|
|
74
|
+
schemaVersion: '0.3',
|
|
75
|
+
kind: ast.kind,
|
|
76
|
+
entryId: normalizeEntryId(entryId),
|
|
77
|
+
entryPathAbs,
|
|
78
|
+
entryPathRel,
|
|
79
|
+
os,
|
|
80
|
+
description: params.description || inferDescription(entryId, ast),
|
|
81
|
+
version: {
|
|
82
|
+
variables: ast.variables,
|
|
83
|
+
hooks: ast.hooks,
|
|
84
|
+
components: ast.components,
|
|
85
|
+
functions: ast.functions,
|
|
86
|
+
imports: ast.imports,
|
|
87
|
+
},
|
|
88
|
+
logicSignature: signature,
|
|
89
|
+
exports,
|
|
90
|
+
prediction: allPredictions.length > 0 ? allPredictions : undefined,
|
|
91
|
+
metrics: undefined,
|
|
92
|
+
links: undefined,
|
|
93
|
+
nextjs: ast.nextjs,
|
|
94
|
+
semanticHash: semanticHashFromAst(ast, signature),
|
|
95
|
+
fileHash: fileHash(params.sourceText),
|
|
96
|
+
};
|
|
97
|
+
return { contract, violations };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Merge contract updates while preserving manual fields
|
|
101
|
+
*/
|
|
102
|
+
export function mergeContractUpdate(existing, updated) {
|
|
103
|
+
return {
|
|
104
|
+
...updated,
|
|
105
|
+
// kind should always use the updated value (auto-detected)
|
|
106
|
+
kind: updated.kind,
|
|
107
|
+
// Preserve manually set fields that shouldn't be auto-updated
|
|
108
|
+
description: existing.description || updated.description,
|
|
109
|
+
metrics: existing.metrics || updated.metrics,
|
|
110
|
+
links: existing.links || updated.links,
|
|
111
|
+
// nextjs metadata should be auto-updated with shallow merge for future extensibility
|
|
112
|
+
nextjs: updated.nextjs ? {
|
|
113
|
+
...(existing.nextjs ?? {}),
|
|
114
|
+
...updated.nextjs
|
|
115
|
+
} : existing.nextjs,
|
|
116
|
+
// usedIn is never persisted (computed at manifest time)
|
|
117
|
+
usedIn: undefined,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=contractBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractBuilder.js","sourceRoot":"","sources":["../../src/core/contractBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,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,MAAM;QAClB,YAAY,EAAE,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC;QACjD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;KACtC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAqB,EACrB,OAAoB;IAEpB,OAAO;QACL,GAAG,OAAO;QACV,2DAA2D;QAC3D,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,8DAA8D;QAC9D,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW;QACxD,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO;QAC5C,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK;QACtC,qFAAqF;QACrF,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACvB,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;YAC1B,GAAG,OAAO,CAAC,MAAM;SAClB,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM;QACnB,wDAAwD;QACxD,MAAM,EAAE,SAAS;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uif Contract 0.3
|
|
3
|
+
*
|
|
4
|
+
* Description: manifest - Presentational component
|
|
5
|
+
*
|
|
6
|
+
* Version (Component Composition):
|
|
7
|
+
* variables: []
|
|
8
|
+
* hooks: []
|
|
9
|
+
* components: []
|
|
10
|
+
* functions: ["buildDependencyGraph","buildHashIndices","findComponentByName","generateStats","writeManifest"]
|
|
11
|
+
* imports: ["../types/UIFContract.js","../utils/hash.js","node:fs/promises","node:path"]
|
|
12
|
+
*
|
|
13
|
+
* Logic Signature:
|
|
14
|
+
* props: {}
|
|
15
|
+
* events: {}
|
|
16
|
+
* state: {}
|
|
17
|
+
*
|
|
18
|
+
* Predictions:
|
|
19
|
+
* (none)
|
|
20
|
+
*
|
|
21
|
+
* Hashes (informational only - authoritative values in .uif.json):
|
|
22
|
+
* semantic: uif:1ddfb5c70a09a2614d47690e (informational)
|
|
23
|
+
* file: uif:179d1c0bb533920680e6417f
|
|
24
|
+
*/
|
|
25
|
+
import type { UIFContract } from '../types/UIFContract.js';
|
|
26
|
+
export interface ComponentNode {
|
|
27
|
+
entryId: string;
|
|
28
|
+
description: string;
|
|
29
|
+
dependencies: string[];
|
|
30
|
+
usedBy: string[];
|
|
31
|
+
imports: string[];
|
|
32
|
+
routes: string[];
|
|
33
|
+
semanticHash: string;
|
|
34
|
+
structureHash?: string;
|
|
35
|
+
signatureHash?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ProjectManifest {
|
|
38
|
+
version: '0.3';
|
|
39
|
+
generatedAt: string;
|
|
40
|
+
totalComponents: number;
|
|
41
|
+
components: Record<string, ComponentNode>;
|
|
42
|
+
graph: {
|
|
43
|
+
roots: string[];
|
|
44
|
+
leaves: string[];
|
|
45
|
+
};
|
|
46
|
+
hashIndex?: {
|
|
47
|
+
structureHash: Record<string, string[]>;
|
|
48
|
+
signatureHash: Record<string, string[]>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build dependency graph from contracts
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildDependencyGraph(contracts: UIFContract[], options?: {
|
|
55
|
+
includeHashIndices?: boolean;
|
|
56
|
+
}): ProjectManifest;
|
|
57
|
+
/**
|
|
58
|
+
* Write manifest to file
|
|
59
|
+
*/
|
|
60
|
+
export declare function writeManifest(manifest: ProjectManifest, outPath: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Generate component usage statistics
|
|
63
|
+
*/
|
|
64
|
+
export declare function generateStats(manifest: ProjectManifest): {
|
|
65
|
+
mostUsed: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
usageCount: number;
|
|
68
|
+
}>;
|
|
69
|
+
mostComplex: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
dependencyCount: number;
|
|
72
|
+
}>;
|
|
73
|
+
isolated: string[];
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/core/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE;QACV,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KACzC,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,EAAE,EACxB,OAAO,CAAC,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,eAAe,CAyEjB;AA4DD;;GAEG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG;IACxD,QAAQ,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,WAAW,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAoBA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uif Contract 0.3
|
|
3
|
+
*
|
|
4
|
+
* Description: manifest - Presentational component
|
|
5
|
+
*
|
|
6
|
+
* Version (Component Composition):
|
|
7
|
+
* variables: []
|
|
8
|
+
* hooks: []
|
|
9
|
+
* components: []
|
|
10
|
+
* functions: ["buildDependencyGraph","buildHashIndices","findComponentByName","generateStats","writeManifest"]
|
|
11
|
+
* imports: ["../types/UIFContract.js","../utils/hash.js","node:fs/promises","node:path"]
|
|
12
|
+
*
|
|
13
|
+
* Logic Signature:
|
|
14
|
+
* props: {}
|
|
15
|
+
* events: {}
|
|
16
|
+
* state: {}
|
|
17
|
+
*
|
|
18
|
+
* Predictions:
|
|
19
|
+
* (none)
|
|
20
|
+
*
|
|
21
|
+
* Hashes (informational only - authoritative values in .uif.json):
|
|
22
|
+
* semantic: uif:1ddfb5c70a09a2614d47690e (informational)
|
|
23
|
+
* file: uif:179d1c0bb533920680e6417f
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Manifest builder - Creates dependency graph for the entire project
|
|
27
|
+
*/
|
|
28
|
+
import { writeFile } from 'node:fs/promises';
|
|
29
|
+
import { join } from 'node:path';
|
|
30
|
+
import { structureHash, signatureHash } from '../utils/hash.js';
|
|
31
|
+
/**
|
|
32
|
+
* Build dependency graph from contracts
|
|
33
|
+
*/
|
|
34
|
+
export function buildDependencyGraph(contracts, options) {
|
|
35
|
+
const components = {};
|
|
36
|
+
// First pass: create nodes
|
|
37
|
+
for (const contract of contracts) {
|
|
38
|
+
// Compute structure and signature hashes from contract data
|
|
39
|
+
// These are computed on-demand rather than stored in contracts
|
|
40
|
+
// Note: structureHash() and signatureHash() already return hashes with uif: prefix
|
|
41
|
+
const structHash = structureHash(contract.version);
|
|
42
|
+
const sigHash = signatureHash(contract.logicSignature);
|
|
43
|
+
components[contract.entryId] = {
|
|
44
|
+
entryId: contract.entryId,
|
|
45
|
+
description: contract.description,
|
|
46
|
+
dependencies: contract.version.components,
|
|
47
|
+
usedBy: [],
|
|
48
|
+
imports: contract.version.imports || [],
|
|
49
|
+
routes: contract.usedIn || [],
|
|
50
|
+
semanticHash: contract.semanticHash,
|
|
51
|
+
structureHash: structHash,
|
|
52
|
+
signatureHash: sigHash,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Second pass: build reverse relationships (usedBy)
|
|
56
|
+
for (const contract of contracts) {
|
|
57
|
+
const componentId = contract.entryId;
|
|
58
|
+
// For each component this one uses
|
|
59
|
+
for (const dependency of contract.version.components) {
|
|
60
|
+
// Find the matching component in our graph
|
|
61
|
+
const depNode = findComponentByName(components, dependency);
|
|
62
|
+
if (depNode) {
|
|
63
|
+
// Add this component to the dependency's usedBy list
|
|
64
|
+
if (!depNode.usedBy.includes(componentId)) {
|
|
65
|
+
depNode.usedBy.push(componentId);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Identify roots and leaves
|
|
71
|
+
const roots = [];
|
|
72
|
+
const leaves = [];
|
|
73
|
+
for (const [id, node] of Object.entries(components)) {
|
|
74
|
+
if (node.usedBy.length === 0) {
|
|
75
|
+
roots.push(id);
|
|
76
|
+
}
|
|
77
|
+
if (node.dependencies.length === 0) {
|
|
78
|
+
leaves.push(id);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Build hash indices if requested
|
|
82
|
+
let hashIndex;
|
|
83
|
+
if (options?.includeHashIndices) {
|
|
84
|
+
hashIndex = buildHashIndices(components);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
version: '0.3',
|
|
88
|
+
generatedAt: new Date().toISOString(),
|
|
89
|
+
totalComponents: contracts.length,
|
|
90
|
+
components,
|
|
91
|
+
graph: {
|
|
92
|
+
roots: roots.sort(),
|
|
93
|
+
leaves: leaves.sort(),
|
|
94
|
+
},
|
|
95
|
+
hashIndex,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build hash indices for similarity detection
|
|
100
|
+
*/
|
|
101
|
+
function buildHashIndices(components) {
|
|
102
|
+
const structureIndex = {};
|
|
103
|
+
const signatureIndex = {};
|
|
104
|
+
for (const [entryId, node] of Object.entries(components)) {
|
|
105
|
+
// Index by structure hash
|
|
106
|
+
if (node.structureHash) {
|
|
107
|
+
if (!structureIndex[node.structureHash]) {
|
|
108
|
+
structureIndex[node.structureHash] = [];
|
|
109
|
+
}
|
|
110
|
+
structureIndex[node.structureHash].push(entryId);
|
|
111
|
+
}
|
|
112
|
+
// Index by signature hash
|
|
113
|
+
if (node.signatureHash) {
|
|
114
|
+
if (!signatureIndex[node.signatureHash]) {
|
|
115
|
+
signatureIndex[node.signatureHash] = [];
|
|
116
|
+
}
|
|
117
|
+
signatureIndex[node.signatureHash].push(entryId);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
structureHash: structureIndex,
|
|
122
|
+
signatureHash: signatureIndex,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Find component by name (handles partial matches)
|
|
127
|
+
*/
|
|
128
|
+
function findComponentByName(components, name) {
|
|
129
|
+
// First try exact match
|
|
130
|
+
const exactMatch = Object.values(components).find((c) => c.entryId.endsWith(`/${name}.tsx`));
|
|
131
|
+
if (exactMatch)
|
|
132
|
+
return exactMatch;
|
|
133
|
+
// Try with .ts extension
|
|
134
|
+
const tsMatch = Object.values(components).find((c) => c.entryId.endsWith(`/${name}.ts`));
|
|
135
|
+
if (tsMatch)
|
|
136
|
+
return tsMatch;
|
|
137
|
+
// Try partial match on component name
|
|
138
|
+
const partialMatch = Object.values(components).find((c) => {
|
|
139
|
+
const componentName = c.entryId.split('/').pop()?.replace(/\.(tsx?|jsx?)$/, '');
|
|
140
|
+
return componentName === name;
|
|
141
|
+
});
|
|
142
|
+
return partialMatch || null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Write manifest to file
|
|
146
|
+
*/
|
|
147
|
+
export async function writeManifest(manifest, outPath) {
|
|
148
|
+
const manifestPath = join(outPath, 'logicstamp.manifest.json');
|
|
149
|
+
const json = JSON.stringify(manifest, null, 2);
|
|
150
|
+
await writeFile(manifestPath, json, 'utf8');
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Generate component usage statistics
|
|
154
|
+
*/
|
|
155
|
+
export function generateStats(manifest) {
|
|
156
|
+
const usageStats = Object.entries(manifest.components).map(([id, node]) => ({
|
|
157
|
+
id,
|
|
158
|
+
usageCount: node.usedBy.length,
|
|
159
|
+
}));
|
|
160
|
+
const complexityStats = Object.entries(manifest.components).map(([id, node]) => ({
|
|
161
|
+
id,
|
|
162
|
+
dependencyCount: node.dependencies.length,
|
|
163
|
+
}));
|
|
164
|
+
const isolated = Object.entries(manifest.components)
|
|
165
|
+
.filter(([_, node]) => node.usedBy.length === 0 && node.dependencies.length === 0)
|
|
166
|
+
.map(([id]) => id);
|
|
167
|
+
return {
|
|
168
|
+
mostUsed: usageStats.sort((a, b) => b.usageCount - a.usageCount).slice(0, 10),
|
|
169
|
+
mostComplex: complexityStats.sort((a, b) => b.dependencyCount - a.dependencyCount).slice(0, 10),
|
|
170
|
+
isolated,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/core/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA6BhE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAwB,EACxB,OAA0C;IAE1C,MAAM,UAAU,GAAkC,EAAE,CAAC;IAErD,2BAA2B;IAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,4DAA4D;QAC5D,+DAA+D;QAC/D,mFAAmF;QACnF,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAEvD,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG;YAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU;YACzC,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE;YACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,EAAE;YAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,aAAa,EAAE,UAAU;YACzB,aAAa,EAAE,OAAO;SACvB,CAAC;I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
+
* variables: []
|
|
8
|
+
* hooks: []
|
|
9
|
+
* components: []
|
|
10
|
+
* functions: ["buildEdges","collectDependencies","computeBundleHash","extractCodeHeader","findComponentByName","formatBundle","loadContract","loadManifest","pack","readSourceCode","resolveDependency","resolveKey","stableSort","validateHashLock"]
|
|
11
|
+
* imports: ["../types/UIFContract.js","../utils/fsx.js","../utils/hash.js","./manifest.js","node:fs/promises","node:path"]
|
|
12
|
+
*
|
|
13
|
+
* Logic Signature:
|
|
14
|
+
* props: {}
|
|
15
|
+
* events: {}
|
|
16
|
+
* state: {}
|
|
17
|
+
*
|
|
18
|
+
* Predictions:
|
|
19
|
+
* Includes form validation logic, Fetches or mutates external data
|
|
20
|
+
*
|
|
21
|
+
* Hashes (informational only - authoritative values in .uif.json):
|
|
22
|
+
* semantic: uif:70da3ed90cc7516abcbbf13b (informational)
|
|
23
|
+
* file: uif:a70a7b698f5520bf49d74a91
|
|
24
|
+
*/
|
|
25
|
+
import type { UIFContract } from '../types/UIFContract.js';
|
|
26
|
+
import type { ProjectManifest, ComponentNode } from './manifest.js';
|
|
27
|
+
/**
|
|
28
|
+
* Code inclusion mode for bundles
|
|
29
|
+
*/
|
|
30
|
+
export type CodeInclusionMode = 'none' | 'header' | 'full';
|
|
31
|
+
/**
|
|
32
|
+
* Output format for bundles
|
|
33
|
+
*/
|
|
34
|
+
export type BundleFormat = 'json' | 'pretty' | 'ndjson';
|
|
35
|
+
/**
|
|
36
|
+
* Options for packing a component
|
|
37
|
+
*/
|
|
38
|
+
export interface PackOptions {
|
|
39
|
+
depth: number;
|
|
40
|
+
includeCode: CodeInclusionMode;
|
|
41
|
+
format: BundleFormat;
|
|
42
|
+
hashLock: boolean;
|
|
43
|
+
strict: boolean;
|
|
44
|
+
allowMissing: boolean;
|
|
45
|
+
maxNodes: number;
|
|
46
|
+
contractsMap?: Map<string, UIFContract>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A node in the bundle graph
|
|
50
|
+
*/
|
|
51
|
+
export interface BundleNode {
|
|
52
|
+
entryId: string;
|
|
53
|
+
contract: UIFContract;
|
|
54
|
+
codeHeader?: string | null;
|
|
55
|
+
code?: string | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Missing dependency information
|
|
59
|
+
*/
|
|
60
|
+
export interface MissingDependency {
|
|
61
|
+
name: string;
|
|
62
|
+
reason: string;
|
|
63
|
+
referencedBy?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Complete bundle structure
|
|
67
|
+
*/
|
|
68
|
+
export interface LogicStampBundle {
|
|
69
|
+
type: 'LogicStampBundle';
|
|
70
|
+
schemaVersion: '0.1';
|
|
71
|
+
entryId: string;
|
|
72
|
+
depth: number;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
bundleHash: string;
|
|
75
|
+
graph: {
|
|
76
|
+
nodes: BundleNode[];
|
|
77
|
+
edges: [string, string][];
|
|
78
|
+
};
|
|
79
|
+
meta: {
|
|
80
|
+
missing: MissingDependency[];
|
|
81
|
+
source: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Folder information in the index
|
|
86
|
+
*/
|
|
87
|
+
export interface FolderInfo {
|
|
88
|
+
path: string;
|
|
89
|
+
contextFile: string;
|
|
90
|
+
bundles: number;
|
|
91
|
+
components: string[];
|
|
92
|
+
isRoot: boolean;
|
|
93
|
+
rootLabel?: string;
|
|
94
|
+
tokenEstimate: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Main index structure - serves as a directory to all context files
|
|
98
|
+
*/
|
|
99
|
+
export interface LogicStampIndex {
|
|
100
|
+
type: 'LogicStampIndex';
|
|
101
|
+
schemaVersion: '0.1';
|
|
102
|
+
projectRoot: string;
|
|
103
|
+
projectRootResolved?: string;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
summary: {
|
|
106
|
+
totalComponents: number;
|
|
107
|
+
totalBundles: number;
|
|
108
|
+
totalFolders: number;
|
|
109
|
+
totalTokenEstimate: number;
|
|
110
|
+
};
|
|
111
|
+
folders: FolderInfo[];
|
|
112
|
+
meta: {
|
|
113
|
+
source: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Load manifest from file
|
|
118
|
+
*/
|
|
119
|
+
export declare function loadManifest(basePath: string): Promise<ProjectManifest>;
|
|
120
|
+
/**
|
|
121
|
+
* Load a sidecar contract file
|
|
122
|
+
* Sidecar path is computed from the manifest key (project-relative): resolved from projectRoot + key + '.uif.json'
|
|
123
|
+
*/
|
|
124
|
+
export declare function loadContract(entryId: string, projectRoot: string): Promise<UIFContract | null>;
|
|
125
|
+
/**
|
|
126
|
+
* Normalize a file path for cross-platform consistency
|
|
127
|
+
* Re-exports the canonical normalizeEntryId from utils/fsx
|
|
128
|
+
* This ensures all path normalization uses the same function
|
|
129
|
+
*/
|
|
130
|
+
export { normalizeEntryId } from '../utils/fsx.js';
|
|
131
|
+
/**
|
|
132
|
+
* Resolve input (path or name) to a manifest key
|
|
133
|
+
* This is the canonical resolution used by both pack and similar commands
|
|
134
|
+
*/
|
|
135
|
+
export declare function resolveKey(manifest: ProjectManifest, input: string): string | null;
|
|
136
|
+
/**
|
|
137
|
+
* Find a component node by name or path
|
|
138
|
+
* Returns the component node and the manifest key it was found under
|
|
139
|
+
*/
|
|
140
|
+
export declare function findComponentByName(manifest: ProjectManifest, nameOrPath: string): ComponentNode | null;
|
|
141
|
+
/**
|
|
142
|
+
* Resolve a dependency name to a manifest key
|
|
143
|
+
* Uses the canonical resolveKey() function for consistent resolution
|
|
144
|
+
* Prioritizes relative paths to avoid cross-directory conflicts
|
|
145
|
+
*/
|
|
146
|
+
export declare function resolveDependency(manifest: ProjectManifest, depName: string, parentId: string): string | null;
|
|
147
|
+
/**
|
|
148
|
+
* Perform BFS traversal to collect dependencies
|
|
149
|
+
*/
|
|
150
|
+
export declare function collectDependencies(entryId: string, manifest: ProjectManifest, depth: number, maxNodes: number): {
|
|
151
|
+
visited: Set<string>;
|
|
152
|
+
missing: MissingDependency[];
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Extract code header (JSDoc @uif block) from source file
|
|
156
|
+
*/
|
|
157
|
+
export declare function extractCodeHeader(entryId: string, projectRoot: string): Promise<string | null>;
|
|
158
|
+
/**
|
|
159
|
+
* Read full source code
|
|
160
|
+
*/
|
|
161
|
+
export declare function readSourceCode(entryId: string, projectRoot: string): Promise<string | null>;
|
|
162
|
+
/**
|
|
163
|
+
* Build edges from nodes based on dependencies
|
|
164
|
+
*/
|
|
165
|
+
export declare function buildEdges(nodes: BundleNode[], manifest: ProjectManifest): [string, string][];
|
|
166
|
+
/**
|
|
167
|
+
* Sort nodes deterministically for stable bundle hashes
|
|
168
|
+
*/
|
|
169
|
+
export declare function stableSort(nodes: BundleNode[]): BundleNode[];
|
|
170
|
+
/**
|
|
171
|
+
* Compute bundle hash from nodes using stable hashing
|
|
172
|
+
*/
|
|
173
|
+
export declare function computeBundleHash(nodes: BundleNode[], depth: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Validate hash-lock: ensure contract hashes match current state
|
|
176
|
+
*
|
|
177
|
+
* Recomputes file hash from source and compares to contract.fileHash from sidecar
|
|
178
|
+
* (authoritative, not from header). fileHash() automatically strips @uif header block
|
|
179
|
+
* before hashing, so header updates won't cause hash churn.
|
|
180
|
+
*/
|
|
181
|
+
export declare function validateHashLock(contract: UIFContract, entryId: string, projectRoot: string): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Main pack function - generates a bundle for a component
|
|
184
|
+
*/
|
|
185
|
+
export declare function pack(entryId: string, manifest: ProjectManifest, options: PackOptions, projectRoot: string): Promise<LogicStampBundle>;
|
|
186
|
+
/**
|
|
187
|
+
* Format bundle for output
|
|
188
|
+
*/
|
|
189
|
+
export declare function formatBundle(bundle: LogicStampBundle, format: BundleFormat): string;
|
|
190
|
+
//# sourceMappingURL=pack.d.ts.map
|
|
@@ -0,0 +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