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,438 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uif Contract 0.3
|
|
3
|
+
*
|
|
4
|
+
* Description: pack - Presentational component
|
|
5
|
+
*
|
|
6
|
+
* Version (Component Composition):
|
|
7
|
+
* 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
|
+
/**
|
|
26
|
+
* Pack module - Generate LLM-ready context bundles for components
|
|
27
|
+
* Creates compact, hash-locked bundles with dependency graphs
|
|
28
|
+
*/
|
|
29
|
+
import { readFile } from 'node:fs/promises';
|
|
30
|
+
import { join, resolve, isAbsolute } from 'node:path';
|
|
31
|
+
import { normalizeEntryId } from '../utils/fsx.js';
|
|
32
|
+
import { bundleHash as computeBundleHashStable } from '../utils/hash.js';
|
|
33
|
+
import { createRequire } from 'node:module';
|
|
34
|
+
// Load package.json to get version
|
|
35
|
+
const require = createRequire(import.meta.url);
|
|
36
|
+
const pkg = require('../../package.json');
|
|
37
|
+
const PACKAGE_VERSION = `${pkg.name}@${pkg.version}`;
|
|
38
|
+
/**
|
|
39
|
+
* Load manifest from file
|
|
40
|
+
*/
|
|
41
|
+
export async function loadManifest(basePath) {
|
|
42
|
+
const manifestPath = join(basePath, 'logicstamp.manifest.json');
|
|
43
|
+
try {
|
|
44
|
+
const content = await readFile(manifestPath, 'utf8');
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new Error(`Failed to load manifest at ${manifestPath}: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Load a sidecar contract file
|
|
53
|
+
* Sidecar path is computed from the manifest key (project-relative): resolved from projectRoot + key + '.uif.json'
|
|
54
|
+
*/
|
|
55
|
+
export async function loadContract(entryId, projectRoot) {
|
|
56
|
+
// Resolve relative path from project root
|
|
57
|
+
const absolutePath = isAbsolute(entryId) ? entryId : resolve(projectRoot, entryId);
|
|
58
|
+
const sidecarPath = `${absolutePath}.uif.json`;
|
|
59
|
+
try {
|
|
60
|
+
const content = await readFile(sidecarPath, 'utf8');
|
|
61
|
+
return JSON.parse(content);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Sidecar file doesn't exist or can't be read
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Normalize a file path for cross-platform consistency
|
|
70
|
+
* Re-exports the canonical normalizeEntryId from utils/fsx
|
|
71
|
+
* This ensures all path normalization uses the same function
|
|
72
|
+
*/
|
|
73
|
+
export { normalizeEntryId } from '../utils/fsx.js';
|
|
74
|
+
/**
|
|
75
|
+
* Resolve input (path or name) to a manifest key
|
|
76
|
+
* This is the canonical resolution used by both pack and similar commands
|
|
77
|
+
*/
|
|
78
|
+
export function resolveKey(manifest, input) {
|
|
79
|
+
const normalized = normalizeEntryId(input);
|
|
80
|
+
// Try exact match first (normalized key match)
|
|
81
|
+
if (manifest.components[normalized]) {
|
|
82
|
+
return normalized;
|
|
83
|
+
}
|
|
84
|
+
// Try to find by normalized key match
|
|
85
|
+
const entries = Object.entries(manifest.components);
|
|
86
|
+
for (const [key, node] of entries) {
|
|
87
|
+
if (normalizeEntryId(key) === normalized || normalizeEntryId(node.entryId) === normalized) {
|
|
88
|
+
return key; // Return the manifest key, not the node's entryId
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Look for name match (Button, LoginForm, etc.)
|
|
92
|
+
// Build name → [keys] index for ambiguous cases
|
|
93
|
+
const nameMatches = [];
|
|
94
|
+
for (const [key] of entries) {
|
|
95
|
+
const fileName = key.split(/[/\\]/).pop()?.replace(/\.(tsx?|jsx?)$/, '');
|
|
96
|
+
if (fileName === input || fileName === input.replace(/\.(tsx?|jsx?)$/, '')) {
|
|
97
|
+
nameMatches.push(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (nameMatches.length === 1) {
|
|
101
|
+
return nameMatches[0];
|
|
102
|
+
}
|
|
103
|
+
else if (nameMatches.length > 1) {
|
|
104
|
+
// Ambiguous - return first match but this should be handled by caller
|
|
105
|
+
return nameMatches[0];
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Find a component node by name or path
|
|
111
|
+
* Returns the component node and the manifest key it was found under
|
|
112
|
+
*/
|
|
113
|
+
export function findComponentByName(manifest, nameOrPath) {
|
|
114
|
+
const key = resolveKey(manifest, nameOrPath);
|
|
115
|
+
return key ? manifest.components[key] : null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resolve a dependency name to a manifest key
|
|
119
|
+
* Uses the canonical resolveKey() function for consistent resolution
|
|
120
|
+
* Prioritizes relative paths to avoid cross-directory conflicts
|
|
121
|
+
*/
|
|
122
|
+
export function resolveDependency(manifest, depName, parentId) {
|
|
123
|
+
// parentId is a manifest key (canonical identifier)
|
|
124
|
+
// First, try relative path resolution based on parent directory
|
|
125
|
+
// This ensures we resolve to components in the same directory tree first
|
|
126
|
+
// parentId is a manifest key (normalized path), extract directory
|
|
127
|
+
const parentDir = parentId.substring(0, parentId.lastIndexOf('/'));
|
|
128
|
+
const possiblePaths = [
|
|
129
|
+
`${parentDir}/${depName}.tsx`,
|
|
130
|
+
`${parentDir}/${depName}.ts`,
|
|
131
|
+
`${parentDir}/${depName}/index.tsx`,
|
|
132
|
+
`${parentDir}/${depName}/index.ts`,
|
|
133
|
+
];
|
|
134
|
+
for (const path of possiblePaths) {
|
|
135
|
+
const key = resolveKey(manifest, path);
|
|
136
|
+
if (key) {
|
|
137
|
+
return key; // Return manifest key (canonical identifier)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Only fall back to global name search if relative paths didn't work
|
|
141
|
+
// This prevents cross-directory conflicts (e.g., tests/fixtures vs examples)
|
|
142
|
+
const key = resolveKey(manifest, depName);
|
|
143
|
+
if (key) {
|
|
144
|
+
return key; // Return manifest key (canonical identifier)
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Perform BFS traversal to collect dependencies
|
|
150
|
+
*/
|
|
151
|
+
export function collectDependencies(entryId, manifest, depth, maxNodes) {
|
|
152
|
+
const visited = new Set();
|
|
153
|
+
const missing = [];
|
|
154
|
+
const queue = [{ id: entryId, level: 0 }];
|
|
155
|
+
while (queue.length > 0) {
|
|
156
|
+
const current = queue.shift();
|
|
157
|
+
// Normalize the ID for lookup
|
|
158
|
+
const normalizedId = normalizeEntryId(current.id);
|
|
159
|
+
// Try to find component by normalized ID
|
|
160
|
+
let node = manifest.components[normalizedId];
|
|
161
|
+
let componentKey = normalizedId;
|
|
162
|
+
// If not found, try to find by matching normalized entryIds
|
|
163
|
+
if (!node) {
|
|
164
|
+
for (const [key, comp] of Object.entries(manifest.components)) {
|
|
165
|
+
if (normalizeEntryId(key) === normalizedId || normalizeEntryId(comp.entryId) === normalizedId) {
|
|
166
|
+
node = comp;
|
|
167
|
+
componentKey = key;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Skip if already visited or exceeded depth
|
|
173
|
+
if (visited.has(componentKey) || current.level > depth) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
// Check max nodes limit
|
|
177
|
+
if (visited.size >= maxNodes) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
if (!node) {
|
|
181
|
+
missing.push({
|
|
182
|
+
name: current.id,
|
|
183
|
+
reason: 'Component not found in manifest',
|
|
184
|
+
});
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
visited.add(componentKey);
|
|
188
|
+
// Only traverse deeper if we haven't reached depth limit
|
|
189
|
+
if (current.level < depth) {
|
|
190
|
+
// Add dependencies to queue
|
|
191
|
+
for (const dep of node.dependencies) {
|
|
192
|
+
const resolvedId = resolveDependency(manifest, dep, componentKey);
|
|
193
|
+
if (resolvedId) {
|
|
194
|
+
if (!visited.has(resolvedId)) {
|
|
195
|
+
queue.push({ id: resolvedId, level: current.level + 1 });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// Track missing dependency
|
|
200
|
+
if (!missing.some((m) => m.name === dep)) {
|
|
201
|
+
missing.push({
|
|
202
|
+
name: dep,
|
|
203
|
+
reason: 'No contract found (third-party or not scanned)',
|
|
204
|
+
referencedBy: componentKey, // Use manifest key, not current.id
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { visited, missing };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Extract code header (JSDoc @uif block) from source file
|
|
215
|
+
*/
|
|
216
|
+
export async function extractCodeHeader(entryId, projectRoot) {
|
|
217
|
+
try {
|
|
218
|
+
const absolutePath = isAbsolute(entryId) ? entryId : resolve(projectRoot, entryId);
|
|
219
|
+
const content = await readFile(absolutePath, 'utf8');
|
|
220
|
+
// Look for @uif JSDoc block
|
|
221
|
+
const headerMatch = content.match(/\/\*\*[\s\S]*?@uif[\s\S]*?\*\//);
|
|
222
|
+
if (headerMatch) {
|
|
223
|
+
return headerMatch[0];
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Read full source code
|
|
233
|
+
*/
|
|
234
|
+
export async function readSourceCode(entryId, projectRoot) {
|
|
235
|
+
try {
|
|
236
|
+
const absolutePath = isAbsolute(entryId) ? entryId : resolve(projectRoot, entryId);
|
|
237
|
+
return await readFile(absolutePath, 'utf8');
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Build edges from nodes based on dependencies
|
|
245
|
+
*/
|
|
246
|
+
export function buildEdges(nodes, manifest) {
|
|
247
|
+
const edges = [];
|
|
248
|
+
const nodeIds = new Set(nodes.map((n) => n.entryId));
|
|
249
|
+
for (const node of nodes) {
|
|
250
|
+
const componentNode = manifest.components[node.entryId];
|
|
251
|
+
if (!componentNode)
|
|
252
|
+
continue;
|
|
253
|
+
for (const dep of componentNode.dependencies) {
|
|
254
|
+
const resolvedId = resolveDependency(manifest, dep, node.entryId);
|
|
255
|
+
// Only add edge if both nodes are in the bundle
|
|
256
|
+
if (resolvedId && nodeIds.has(resolvedId)) {
|
|
257
|
+
edges.push([node.entryId, resolvedId]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return edges;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Sort nodes deterministically for stable bundle hashes
|
|
265
|
+
*/
|
|
266
|
+
export function stableSort(nodes) {
|
|
267
|
+
return [...nodes].sort((a, b) => {
|
|
268
|
+
// Sort by entryId for determinism
|
|
269
|
+
return a.entryId.localeCompare(b.entryId);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Compute bundle hash from nodes using stable hashing
|
|
274
|
+
*/
|
|
275
|
+
export function computeBundleHash(nodes, depth) {
|
|
276
|
+
// Use the stable bundleHash function from utils/hash
|
|
277
|
+
const nodeData = nodes.map(n => ({
|
|
278
|
+
entryId: n.entryId,
|
|
279
|
+
semanticHash: n.contract.semanticHash,
|
|
280
|
+
}));
|
|
281
|
+
return computeBundleHashStable(nodeData, depth, '0.1');
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Validate hash-lock: ensure contract hashes match current state
|
|
285
|
+
*
|
|
286
|
+
* Recomputes file hash from source and compares to contract.fileHash from sidecar
|
|
287
|
+
* (authoritative, not from header). fileHash() automatically strips @uif header block
|
|
288
|
+
* before hashing, so header updates won't cause hash churn.
|
|
289
|
+
*/
|
|
290
|
+
export async function validateHashLock(contract, entryId, projectRoot) {
|
|
291
|
+
try {
|
|
292
|
+
// Read the actual source file
|
|
293
|
+
const absolutePath = isAbsolute(entryId) ? entryId : resolve(projectRoot, entryId);
|
|
294
|
+
const sourceContent = await readFile(absolutePath, 'utf8');
|
|
295
|
+
// Recompute file hash (strips @uif header block automatically)
|
|
296
|
+
const { fileHash: computedFileHash } = await import('../utils/hash.js');
|
|
297
|
+
const actualFileHash = computedFileHash(sourceContent);
|
|
298
|
+
// Compare to sidecar contract.fileHash (authoritative, not header)
|
|
299
|
+
if (actualFileHash !== contract.fileHash) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
// Semantic hash should match (derived from structure + signature)
|
|
303
|
+
// If fileHash matches, semantic hash should also match since it's derived from the AST
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
// If we can't read/parse the file, fail validation
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Main pack function - generates a bundle for a component
|
|
313
|
+
*/
|
|
314
|
+
export async function pack(entryId, manifest, options, projectRoot) {
|
|
315
|
+
// Normalize entry ID
|
|
316
|
+
const normalizedEntry = normalizeEntryId(entryId);
|
|
317
|
+
// Find the entry component using canonical resolution
|
|
318
|
+
const manifestKey = resolveKey(manifest, normalizedEntry);
|
|
319
|
+
if (!manifestKey) {
|
|
320
|
+
const componentKeys = Object.keys(manifest.components).slice(0, 5);
|
|
321
|
+
const suggestions = componentKeys.length > 0
|
|
322
|
+
? `\nAvailable components:\n${componentKeys.map(k => ` - ${k}`).join('\n')}${componentKeys.length < manifest.totalComponents ? `\n ... and ${manifest.totalComponents - componentKeys.length} more` : ''}`
|
|
323
|
+
: '';
|
|
324
|
+
throw new Error(`Component not found: ${entryId} (normalized: ${normalizedEntry}).` +
|
|
325
|
+
suggestions);
|
|
326
|
+
}
|
|
327
|
+
// Use manifest key as the canonical identifier (not entryComponent.entryId)
|
|
328
|
+
const actualEntryId = manifestKey;
|
|
329
|
+
// Collect dependencies via BFS
|
|
330
|
+
const { visited, missing } = collectDependencies(actualEntryId, manifest, options.depth, options.maxNodes);
|
|
331
|
+
// Load contracts for all visited nodes
|
|
332
|
+
// visited contains manifest keys (canonical identifiers, now project-relative)
|
|
333
|
+
const nodes = [];
|
|
334
|
+
for (const manifestKey of Array.from(visited)) {
|
|
335
|
+
// Try to get contract from in-memory map first (standalone mode), then from sidecar file
|
|
336
|
+
const contract = options.contractsMap?.get(manifestKey) || await loadContract(manifestKey, projectRoot);
|
|
337
|
+
if (!contract) {
|
|
338
|
+
const absolutePath = isAbsolute(manifestKey) ? manifestKey : resolve(projectRoot, manifestKey);
|
|
339
|
+
const sidecarPath = `${absolutePath}.uif.json`;
|
|
340
|
+
if (options.strict) {
|
|
341
|
+
throw new Error(`Missing contract for ${manifestKey} (strict mode enabled). ` +
|
|
342
|
+
`Expected sidecar at: ${sidecarPath}`);
|
|
343
|
+
}
|
|
344
|
+
if (!options.allowMissing) {
|
|
345
|
+
missing.push({
|
|
346
|
+
name: manifestKey,
|
|
347
|
+
reason: `Contract file not found at ${sidecarPath}`,
|
|
348
|
+
});
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// Validate hash lock if enabled
|
|
353
|
+
if (options.hashLock && contract) {
|
|
354
|
+
const isValid = await validateHashLock(contract, manifestKey, projectRoot);
|
|
355
|
+
if (!isValid) {
|
|
356
|
+
throw new Error(`Hash lock validation failed for ${manifestKey}. ` +
|
|
357
|
+
`The file has been modified since the contract was generated. ` +
|
|
358
|
+
`Run 'logicstamp compile' to regenerate contracts.`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Get code/header based on options
|
|
362
|
+
// Use manifestKey with projectRoot for file operations
|
|
363
|
+
let codeHeader = undefined;
|
|
364
|
+
let code = undefined;
|
|
365
|
+
if (options.includeCode === 'header') {
|
|
366
|
+
codeHeader = await extractCodeHeader(manifestKey, projectRoot);
|
|
367
|
+
}
|
|
368
|
+
else if (options.includeCode === 'full') {
|
|
369
|
+
code = await readSourceCode(manifestKey, projectRoot);
|
|
370
|
+
codeHeader = await extractCodeHeader(manifestKey, projectRoot);
|
|
371
|
+
}
|
|
372
|
+
if (contract) {
|
|
373
|
+
nodes.push({
|
|
374
|
+
entryId: manifestKey, // Use manifest key as the canonical identifier
|
|
375
|
+
contract,
|
|
376
|
+
...(codeHeader !== undefined && { codeHeader }),
|
|
377
|
+
...(code !== undefined && { code }),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// DX & guardrails: If no nodes were packed, provide helpful error
|
|
382
|
+
if (nodes.length === 0) {
|
|
383
|
+
throw new Error(`No nodes packed. ` +
|
|
384
|
+
`Entry component '${actualEntryId}' was found in manifest, but no contracts could be loaded. ` +
|
|
385
|
+
`Run 'logicstamp compile' to generate sidecar files, or check that path/name matches manifest keys.`);
|
|
386
|
+
}
|
|
387
|
+
// Build edges
|
|
388
|
+
const edges = buildEdges(nodes, manifest);
|
|
389
|
+
// Sort nodes for deterministic output
|
|
390
|
+
const sortedNodes = stableSort(nodes);
|
|
391
|
+
// Sort edges for deterministic output
|
|
392
|
+
const sortedEdges = edges.sort((a, b) => {
|
|
393
|
+
const fromCompare = a[0].localeCompare(b[0]);
|
|
394
|
+
return fromCompare !== 0 ? fromCompare : a[1].localeCompare(b[1]);
|
|
395
|
+
});
|
|
396
|
+
// Compute bundle hash
|
|
397
|
+
const bundleHash = computeBundleHash(sortedNodes, options.depth);
|
|
398
|
+
// Create bundle
|
|
399
|
+
const bundle = {
|
|
400
|
+
type: 'LogicStampBundle',
|
|
401
|
+
schemaVersion: '0.1',
|
|
402
|
+
entryId: actualEntryId,
|
|
403
|
+
depth: options.depth,
|
|
404
|
+
createdAt: new Date().toISOString(),
|
|
405
|
+
bundleHash,
|
|
406
|
+
graph: {
|
|
407
|
+
nodes: sortedNodes,
|
|
408
|
+
edges: sortedEdges,
|
|
409
|
+
},
|
|
410
|
+
meta: {
|
|
411
|
+
missing,
|
|
412
|
+
source: PACKAGE_VERSION,
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
// Final check: bundle should have at least the entry node
|
|
416
|
+
if (bundle.graph.nodes.length === 0) {
|
|
417
|
+
throw new Error(`No nodes packed. ` +
|
|
418
|
+
`Run 'logicstamp compile' to generate contracts, or check path/name against manifest keys.`);
|
|
419
|
+
}
|
|
420
|
+
return bundle;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Format bundle for output
|
|
424
|
+
*/
|
|
425
|
+
export function formatBundle(bundle, format) {
|
|
426
|
+
switch (format) {
|
|
427
|
+
case 'json':
|
|
428
|
+
return JSON.stringify(bundle);
|
|
429
|
+
case 'pretty':
|
|
430
|
+
return JSON.stringify(bundle, null, 2);
|
|
431
|
+
case 'ndjson':
|
|
432
|
+
// Each node as a separate line
|
|
433
|
+
return bundle.graph.nodes.map((node) => JSON.stringify(node)).join('\n');
|
|
434
|
+
default:
|
|
435
|
+
return JSON.stringify(bundle, null, 2);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|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AAW;YAClB,KAAK,EAAE,WAAW;SACnB;QACD,IAAI,EAAE;YACJ,OAAO;YACP,MAAM,EAAE,eAAe;SACxB;KACF,CAAC;IAEF,0DAA0D;IAC1D,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,mBAAmB;YACnB,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAwB,EAAE,MAAoB;IACzE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACzC,KAAK,QAAQ;YACX,+BAA+B;YAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3E;YACE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uif Contract 0.3
|
|
3
|
+
*
|
|
4
|
+
* Description: signature - Presentational component
|
|
5
|
+
*
|
|
6
|
+
* Version (Component Composition):
|
|
7
|
+
* variables: []
|
|
8
|
+
* hooks: []
|
|
9
|
+
* components: []
|
|
10
|
+
* functions: ["applyDisplayOnlyPreset","applyNavOnlyPreset","applySubmitOnlyPreset","buildLogicSignature","generateBehavioralPredictions","inferDescription"]
|
|
11
|
+
* imports: ["../types/UIFContract.js","./astParser.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:9a5a412d07f6985e03fda241 (informational)
|
|
23
|
+
* file: uif:64d7d3b1474878658358e5a8
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Logic Signature Builder - Applies contract presets and generates predictions
|
|
27
|
+
*/
|
|
28
|
+
import type { AstExtract } from './astParser.js';
|
|
29
|
+
import type { ContractPreset, LogicSignature } from '../types/UIFContract.js';
|
|
30
|
+
export interface SignatureResult {
|
|
31
|
+
signature: LogicSignature;
|
|
32
|
+
prediction: string[];
|
|
33
|
+
violations: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build logic signature with preset validation
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildLogicSignature(ast: AstExtract, preset: ContractPreset): SignatureResult;
|
|
39
|
+
/**
|
|
40
|
+
* Generate additional behavioral predictions based on common patterns
|
|
41
|
+
*/
|
|
42
|
+
export declare function generateBehavioralPredictions(ast: AstExtract): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Infer component description from file name and structure
|
|
45
|
+
*/
|
|
46
|
+
export declare function inferDescription(filePath: string, ast: AstExtract): string;
|
|
47
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/core/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9E,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,cAAc,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,cAAc,GACrB,eAAe,CA2BjB;AA2FD;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE,CAgDvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAsD1E"}
|