@c4a/extract 0.5.33-alpha.2 → 0.5.33-alpha.4

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.
@@ -13557,6 +13557,90 @@ var jsonl = (rows) => rows.map((row) => JSON.stringify(row)).join(`
13557
13557
  ` : "");
13558
13558
  var manifestText = (value) => JSON.stringify(value, null, 2) + `
13559
13559
  `;
13560
+ var buildCodeSymbolLocator = (packageName, symbolId, symbol) => `${packageName}:${symbolId}:${symbol.kind}:${symbol.file}:${symbol.line}-${symbol.endLine}`;
13561
+ var buildCodeSymbolIdentityKey = (packageName, rootSymbolId, symbolId, kind, hasParent) => hasParent ? `${packageName}|root:${rootSymbolId}|owned:${symbolId}|${kind}` : `${packageName}|root:${symbolId}|${kind}`;
13562
+ function applyCodeSymbolIdentity(symbol, context) {
13563
+ const segment = symbol.name;
13564
+ const symbolId = symbol.symbol_id ?? (context.parentSymbolId ? `${context.parentSymbolId}.${segment}` : segment);
13565
+ const rootSymbolId = symbol.root_symbol_id ?? context.rootSymbolId ?? symbolId;
13566
+ const memberPath = symbol.member_path ?? [...context.parentPath ?? [], segment];
13567
+ const hasParent = context.parentSymbolId !== undefined || symbol.parent_symbol_id !== undefined;
13568
+ const parentSymbolId = symbol.parent_symbol_id ?? context.parentSymbolId;
13569
+ const members = symbol.members?.map((member) => applyCodeSymbolIdentity(member, {
13570
+ packageName: context.packageName,
13571
+ parentSymbolId: symbolId,
13572
+ rootSymbolId,
13573
+ parentPath: memberPath
13574
+ }));
13575
+ return {
13576
+ ...symbol,
13577
+ symbol_id: symbolId,
13578
+ identity_key: symbol.identity_key ?? buildCodeSymbolIdentityKey(context.packageName, rootSymbolId, symbolId, symbol.kind, hasParent),
13579
+ display_name: symbol.display_name ?? symbol.name,
13580
+ member_path: memberPath,
13581
+ root_symbol_id: rootSymbolId,
13582
+ ...parentSymbolId !== undefined ? { parent_symbol_id: parentSymbolId } : {},
13583
+ symbol_locator: symbol.symbol_locator ?? buildCodeSymbolLocator(context.packageName, symbolId, symbol),
13584
+ ...members && members.length > 0 ? { members } : {}
13585
+ };
13586
+ }
13587
+ function applySymbolIdentities(symbols, packageName) {
13588
+ return symbols.map((symbol) => applyCodeSymbolIdentity(symbol, { packageName }));
13589
+ }
13590
+ function assertIdentityApplied(symbol) {
13591
+ if (!symbol.symbol_id || !symbol.identity_key || !symbol.display_name || !symbol.root_symbol_id || !symbol.symbol_locator || !symbol.member_path || symbol.member_path.length === 0) {
13592
+ throw new Error(`flattenSymbols requires applied code symbol identity fields for "${symbol.name}"`);
13593
+ }
13594
+ }
13595
+ var buildSymbolHashId = (packageName, modulePath, symbol, symbolId, identityKey, locator) => hashStable({
13596
+ packageName,
13597
+ modulePath,
13598
+ symbolId,
13599
+ identityKey,
13600
+ locator,
13601
+ name: symbol.name,
13602
+ kind: symbol.kind,
13603
+ visibility: symbol.visibility,
13604
+ file: symbol.file,
13605
+ line: symbol.line,
13606
+ endLine: symbol.endLine,
13607
+ params: symbol.params ?? null,
13608
+ returnType: symbol.returnType ?? null,
13609
+ typeAnnotation: symbol.typeAnnotation ?? null,
13610
+ extends: symbol.extends ?? null,
13611
+ implements: symbol.implements ?? null,
13612
+ doc: symbol.doc ?? null,
13613
+ propsType: symbol.propsType ?? null,
13614
+ unionValues: symbol.unionValues ?? null
13615
+ });
13616
+ function flattenSymbols(symbols, packageName, modulePath) {
13617
+ const out = [];
13618
+ const walk = (list) => {
13619
+ for (const symbol of list) {
13620
+ assertIdentityApplied(symbol);
13621
+ const { members, ...rest } = symbol;
13622
+ out.push({
13623
+ ...rest,
13624
+ package: packageName,
13625
+ package_name: packageName,
13626
+ symbol_id: symbol.symbol_id,
13627
+ identity_key: symbol.identity_key,
13628
+ display_name: symbol.display_name,
13629
+ member_path: symbol.member_path,
13630
+ root_symbol_id: symbol.root_symbol_id,
13631
+ symbol_locator: symbol.symbol_locator,
13632
+ hash_id: buildSymbolHashId(packageName, modulePath, rest, symbol.symbol_id, symbol.identity_key, symbol.symbol_locator),
13633
+ ...symbol.parent_symbol_id !== undefined ? { parent_symbol_id: symbol.parent_symbol_id } : {},
13634
+ modulePath,
13635
+ module_path: modulePath
13636
+ });
13637
+ if (members && members.length > 0)
13638
+ walk(members);
13639
+ }
13640
+ };
13641
+ walk(symbols);
13642
+ return out;
13643
+ }
13560
13644
  var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
13561
13645
  var canonicalizeCodeVersionLabel = (value) => {
13562
13646
  const trimmed = value.trim();
@@ -13623,26 +13707,6 @@ var metaText = (manifest, source2, rows) => {
13623
13707
  };
13624
13708
  return manifestText(meta);
13625
13709
  };
13626
- function flattenSymbols(symbols, packageName, modulePath) {
13627
- const out = [];
13628
- const walk = (list) => {
13629
- for (const symbol of list) {
13630
- const { members, ...rest } = symbol;
13631
- out.push({
13632
- ...rest,
13633
- package: packageName,
13634
- package_name: packageName,
13635
- symbol_id: symbol.name,
13636
- modulePath,
13637
- module_path: modulePath
13638
- });
13639
- if (members && members.length > 0)
13640
- walk(members);
13641
- }
13642
- };
13643
- walk(symbols);
13644
- return out;
13645
- }
13646
13710
  var buildHashId = (packageName, dirCommit, moduleContentHash, dirty = false) => {
13647
13711
  const base = dirty && moduleContentHash ? `pkg:${packageName}:${dirCommit}:dirty:${moduleContentHash}` : `pkg:${packageName}:${dirCommit}`;
13648
13712
  return sha256(base);
package/index.js CHANGED
@@ -15248,6 +15248,10 @@ var symbolParamSchema = exports_external.object({
15248
15248
  name: exports_external.string().min(1),
15249
15249
  type: exports_external.string().min(1).nullable()
15250
15250
  });
15251
+ var symbolRenameEvidenceSchema = exports_external.object({
15252
+ previous_identity_key: exports_external.string().min(1),
15253
+ reason: exports_external.string().min(1)
15254
+ });
15251
15255
  var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
15252
15256
  name: exports_external.string().min(1),
15253
15257
  kind: symbolKindSchema2,
@@ -15255,6 +15259,14 @@ var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
15255
15259
  file: exports_external.string().min(1),
15256
15260
  line: exports_external.number().int().positive(),
15257
15261
  endLine: exports_external.number().int().positive(),
15262
+ symbol_id: exports_external.string().min(1).optional(),
15263
+ identity_key: exports_external.string().min(1).optional(),
15264
+ display_name: exports_external.string().min(1).optional(),
15265
+ member_path: exports_external.array(exports_external.string().min(1)).optional(),
15266
+ root_symbol_id: exports_external.string().min(1).optional(),
15267
+ parent_symbol_id: exports_external.string().min(1).optional(),
15268
+ symbol_locator: exports_external.string().min(1).optional(),
15269
+ rename_evidence: exports_external.array(symbolRenameEvidenceSchema).optional(),
15258
15270
  members: exports_external.array(symbolInfoSchema).optional(),
15259
15271
  params: exports_external.array(symbolParamSchema).optional(),
15260
15272
  returnType: exports_external.string().min(1).nullable().optional(),
@@ -16011,6 +16023,90 @@ var jsonl = (rows) => rows.map((row) => JSON.stringify(row)).join(`
16011
16023
  ` : "");
16012
16024
  var manifestText = (value) => JSON.stringify(value, null, 2) + `
16013
16025
  `;
16026
+ var buildCodeSymbolLocator = (packageName, symbolId, symbol) => `${packageName}:${symbolId}:${symbol.kind}:${symbol.file}:${symbol.line}-${symbol.endLine}`;
16027
+ var buildCodeSymbolIdentityKey = (packageName, rootSymbolId, symbolId, kind, hasParent) => hasParent ? `${packageName}|root:${rootSymbolId}|owned:${symbolId}|${kind}` : `${packageName}|root:${symbolId}|${kind}`;
16028
+ function applyCodeSymbolIdentity(symbol, context) {
16029
+ const segment = symbol.name;
16030
+ const symbolId = symbol.symbol_id ?? (context.parentSymbolId ? `${context.parentSymbolId}.${segment}` : segment);
16031
+ const rootSymbolId = symbol.root_symbol_id ?? context.rootSymbolId ?? symbolId;
16032
+ const memberPath = symbol.member_path ?? [...context.parentPath ?? [], segment];
16033
+ const hasParent = context.parentSymbolId !== undefined || symbol.parent_symbol_id !== undefined;
16034
+ const parentSymbolId = symbol.parent_symbol_id ?? context.parentSymbolId;
16035
+ const members = symbol.members?.map((member) => applyCodeSymbolIdentity(member, {
16036
+ packageName: context.packageName,
16037
+ parentSymbolId: symbolId,
16038
+ rootSymbolId,
16039
+ parentPath: memberPath
16040
+ }));
16041
+ return {
16042
+ ...symbol,
16043
+ symbol_id: symbolId,
16044
+ identity_key: symbol.identity_key ?? buildCodeSymbolIdentityKey(context.packageName, rootSymbolId, symbolId, symbol.kind, hasParent),
16045
+ display_name: symbol.display_name ?? symbol.name,
16046
+ member_path: memberPath,
16047
+ root_symbol_id: rootSymbolId,
16048
+ ...parentSymbolId !== undefined ? { parent_symbol_id: parentSymbolId } : {},
16049
+ symbol_locator: symbol.symbol_locator ?? buildCodeSymbolLocator(context.packageName, symbolId, symbol),
16050
+ ...members && members.length > 0 ? { members } : {}
16051
+ };
16052
+ }
16053
+ function applySymbolIdentities(symbols, packageName) {
16054
+ return symbols.map((symbol) => applyCodeSymbolIdentity(symbol, { packageName }));
16055
+ }
16056
+ function assertIdentityApplied(symbol) {
16057
+ if (!symbol.symbol_id || !symbol.identity_key || !symbol.display_name || !symbol.root_symbol_id || !symbol.symbol_locator || !symbol.member_path || symbol.member_path.length === 0) {
16058
+ throw new Error(`flattenSymbols requires applied code symbol identity fields for "${symbol.name}"`);
16059
+ }
16060
+ }
16061
+ var buildSymbolHashId = (packageName, modulePath, symbol, symbolId, identityKey, locator) => hashStable({
16062
+ packageName,
16063
+ modulePath,
16064
+ symbolId,
16065
+ identityKey,
16066
+ locator,
16067
+ name: symbol.name,
16068
+ kind: symbol.kind,
16069
+ visibility: symbol.visibility,
16070
+ file: symbol.file,
16071
+ line: symbol.line,
16072
+ endLine: symbol.endLine,
16073
+ params: symbol.params ?? null,
16074
+ returnType: symbol.returnType ?? null,
16075
+ typeAnnotation: symbol.typeAnnotation ?? null,
16076
+ extends: symbol.extends ?? null,
16077
+ implements: symbol.implements ?? null,
16078
+ doc: symbol.doc ?? null,
16079
+ propsType: symbol.propsType ?? null,
16080
+ unionValues: symbol.unionValues ?? null
16081
+ });
16082
+ function flattenSymbols(symbols, packageName, modulePath) {
16083
+ const out2 = [];
16084
+ const walk = (list) => {
16085
+ for (const symbol of list) {
16086
+ assertIdentityApplied(symbol);
16087
+ const { members, ...rest } = symbol;
16088
+ out2.push({
16089
+ ...rest,
16090
+ package: packageName,
16091
+ package_name: packageName,
16092
+ symbol_id: symbol.symbol_id,
16093
+ identity_key: symbol.identity_key,
16094
+ display_name: symbol.display_name,
16095
+ member_path: symbol.member_path,
16096
+ root_symbol_id: symbol.root_symbol_id,
16097
+ symbol_locator: symbol.symbol_locator,
16098
+ hash_id: buildSymbolHashId(packageName, modulePath, rest, symbol.symbol_id, symbol.identity_key, symbol.symbol_locator),
16099
+ ...symbol.parent_symbol_id !== undefined ? { parent_symbol_id: symbol.parent_symbol_id } : {},
16100
+ modulePath,
16101
+ module_path: modulePath
16102
+ });
16103
+ if (members && members.length > 0)
16104
+ walk(members);
16105
+ }
16106
+ };
16107
+ walk(symbols);
16108
+ return out2;
16109
+ }
16014
16110
  var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
16015
16111
  var canonicalizeCodeVersionLabel = (value) => {
16016
16112
  const trimmed = value.trim();
@@ -16077,26 +16173,6 @@ var metaText = (manifest, source2, rows) => {
16077
16173
  };
16078
16174
  return manifestText(meta);
16079
16175
  };
16080
- function flattenSymbols(symbols, packageName, modulePath) {
16081
- const out2 = [];
16082
- const walk = (list) => {
16083
- for (const symbol of list) {
16084
- const { members, ...rest } = symbol;
16085
- out2.push({
16086
- ...rest,
16087
- package: packageName,
16088
- package_name: packageName,
16089
- symbol_id: symbol.name,
16090
- modulePath,
16091
- module_path: modulePath
16092
- });
16093
- if (members && members.length > 0)
16094
- walk(members);
16095
- }
16096
- };
16097
- walk(symbols);
16098
- return out2;
16099
- }
16100
16176
  var buildHashId = (packageName, dirCommit, moduleContentHash, dirty = false) => {
16101
16177
  const base = dirty && moduleContentHash ? `pkg:${packageName}:${dirCommit}:dirty:${moduleContentHash}` : `pkg:${packageName}:${dirCommit}`;
16102
16178
  return sha256(base);
@@ -16548,6 +16624,7 @@ var detectTechStack = async (repoPath) => {
16548
16624
  return labels;
16549
16625
  };
16550
16626
  export {
16627
+ symbolRenameEvidenceSchema,
16551
16628
  symbolParamSchema,
16552
16629
  symbolInfoSchema,
16553
16630
  symbolDiffSchema,
@@ -16603,7 +16680,10 @@ export {
16603
16680
  buildHashId,
16604
16681
  buildEdgeHashId,
16605
16682
  buildDigestData,
16683
+ buildCodeSymbolLocator,
16684
+ buildCodeSymbolIdentityKey,
16606
16685
  buildCodeSnapshot,
16686
+ applySymbolIdentities,
16607
16687
  SCAN_EXCLUDED_DIRS,
16608
16688
  PACKAGE_JSON,
16609
16689
  ExtractionPluginRegistry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract",
3
- "version": "0.5.33-alpha.2",
3
+ "version": "0.5.33-alpha.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "c4a-extract-code": "./bin/c4a-extract-code.js"