@codeyam/codeyam-cli 0.1.0-staging.483fdc2 → 0.1.0-staging.62d4615
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/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +3 -3
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +9 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +154 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +11 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +2 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +70 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +20 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +84 -19
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +14 -0
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +51 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +9 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +194 -15
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +260 -22
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/project/constructMockCode.ts +36 -1
- package/analyzer-template/project/writeMockDataTsx.ts +111 -17
- package/analyzer-template/project/writeScenarioComponents.ts +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/background/src/lib/virtualized/project/constructMockCode.js +30 -1
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +95 -13
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +43 -9
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +12 -21
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +4 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +23 -0
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +128 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +285 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +83 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +96 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +33 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +1 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -1
- package/codeyam-cli/src/utils/rules/parser.js +0 -28
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +14 -9
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-B86KKU7e.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-C6PKeMYR.js} +3 -8
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-BNLaXBHR.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-DD1r_QU0.js} +6 -11
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-C5lqplTC.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-n38keI1k.js} +10 -10
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-Dk8wkAS7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-DXnyr8uP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BUvfJMNR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-d4e77269.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-DCHBwHou.js +76 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{settings-CS5f3WzT.js → settings-B2X7lJgQ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-TD1f-DHV.js → index-C0KrUQp-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-C2h1v1XD.js +260 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-memory-hook.sh +9 -10
- package/codeyam-cli/templates/codeyam:memory.md +10 -9
- package/codeyam-cli/templates/codeyam:new-rule.md +0 -39
- package/codeyam-cli/templates/rule-notification-hook.py +54 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +356 -89
- package/codeyam-cli/templates/rules-instructions.md +19 -22
- package/package.json +2 -2
- package/packages/ai/src/lib/analyzeScope.js +7 -1
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +134 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +11 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +2 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +63 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +15 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +78 -17
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +10 -0
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +39 -3
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +41 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +3 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +5 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +9 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +116 -13
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +231 -22
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/codeyam-cli/src/utils/reviewedRules.js +0 -92
- package/codeyam-cli/src/utils/reviewedRules.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-CX9f-5xM.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-bba56ec1.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-DuTFSyJ2.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/root-DTfSQARG.js +0 -62
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BQ-1XyEa.js +0 -258
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts
CHANGED
|
@@ -152,8 +152,11 @@ export default function fillInSchemaGapsAndUnknowns(
|
|
|
152
152
|
schema[previousSubPath],
|
|
153
153
|
)
|
|
154
154
|
) {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
// When fillInUnknowns=false, add missing gaps as 'unknown' to preserve raw schema.
|
|
156
|
+
// When fillInUnknowns=true, infer the type using checkIfKnownType.
|
|
157
|
+
const newValue = fillInUnknowns
|
|
158
|
+
? (checkIfKnownType(previousSubPath, functionKeysMapping) ?? 'object')
|
|
159
|
+
: 'unknown';
|
|
157
160
|
|
|
158
161
|
if (
|
|
159
162
|
!schema[previousSubPath] ||
|
|
@@ -166,10 +169,14 @@ export default function fillInSchemaGapsAndUnknowns(
|
|
|
166
169
|
|
|
167
170
|
// Handle the wrong function chaining function().function()
|
|
168
171
|
if (isFunction && !existingSchema(previousSubPath)) {
|
|
172
|
+
// When fillInUnknowns=false, use 'unknown' for non-function paths.
|
|
173
|
+
// When fillInUnknowns=true, infer the type.
|
|
169
174
|
schema[previousSubPath] = previousSubPath.endsWith(')')
|
|
170
175
|
? 'function'
|
|
171
|
-
:
|
|
172
|
-
|
|
176
|
+
: fillInUnknowns
|
|
177
|
+
? (checkIfKnownType(previousSubPath, functionKeysMapping) ??
|
|
178
|
+
'object')
|
|
179
|
+
: 'unknown';
|
|
173
180
|
changeMade = true;
|
|
174
181
|
}
|
|
175
182
|
|
|
@@ -458,7 +465,10 @@ export function fillInDirectSchemaGapsAndUnknowns({
|
|
|
458
465
|
}
|
|
459
466
|
} else if (schema[key] === 'unknown') {
|
|
460
467
|
const newType = guessTypeForPath(key, 'string');
|
|
461
|
-
|
|
468
|
+
// Don't convert 'unknown' to 'object' — 'object' is just inferred from
|
|
469
|
+
// having child properties, which isn't more useful than 'unknown' and
|
|
470
|
+
// prevents enrichment from filling in the actual type later.
|
|
471
|
+
if (newType && newType !== 'object' && schema[key] !== newType) {
|
|
462
472
|
schema[key] = newType;
|
|
463
473
|
changeMade = true;
|
|
464
474
|
}
|
|
@@ -481,12 +491,44 @@ export function fillInDirectSchemaGapsAndUnknowns({
|
|
|
481
491
|
// This handles spurious [] paths from components like JsonNode that handle
|
|
482
492
|
// both arrays and objects. When metadata is explicitly typed as 'object',
|
|
483
493
|
// paths like metadata[] (from dynamic iteration) should not change it.
|
|
494
|
+
const existingType = schema[previousSubPath];
|
|
495
|
+
const baseType = existingType?.split(' | ')[0];
|
|
496
|
+
|
|
497
|
+
// Also check if this path has meaningful object property children (non-[] children).
|
|
498
|
+
// If it does, it's an object with mixed access patterns (e.g., agent.entries
|
|
499
|
+
// AND agent[].type), not a pure array. Don't infer 'array' in that case.
|
|
500
|
+
// Exclude .length since it exists on arrays too and is NOT evidence of object-ness.
|
|
501
|
+
let hasObjectPropertyChildren = false;
|
|
502
|
+
if (baseType !== 'array' && baseType !== 'object') {
|
|
503
|
+
const dotPrefix = previousSubPath + '.';
|
|
504
|
+
const lengthPath = previousSubPath + '.length';
|
|
505
|
+
for (const schemaKey in schema) {
|
|
506
|
+
if (
|
|
507
|
+
schemaKey.startsWith(dotPrefix) &&
|
|
508
|
+
schemaKey !== lengthPath
|
|
509
|
+
) {
|
|
510
|
+
hasObjectPropertyChildren = true;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
484
516
|
if (
|
|
485
|
-
|
|
486
|
-
|
|
517
|
+
baseType !== 'array' &&
|
|
518
|
+
baseType !== 'object' &&
|
|
519
|
+
!hasObjectPropertyChildren
|
|
487
520
|
) {
|
|
488
|
-
|
|
489
|
-
|
|
521
|
+
// Preserve nullability from existing type (e.g., 'unknown | undefined' -> 'array | undefined')
|
|
522
|
+
let newType = 'array';
|
|
523
|
+
if (existingType?.includes(' | undefined')) {
|
|
524
|
+
newType = 'array | undefined';
|
|
525
|
+
} else if (existingType?.includes(' | null')) {
|
|
526
|
+
newType = 'array | null';
|
|
527
|
+
}
|
|
528
|
+
if (schema[previousSubPath] !== newType) {
|
|
529
|
+
schema[previousSubPath] = newType;
|
|
530
|
+
changeMade = true;
|
|
531
|
+
}
|
|
490
532
|
}
|
|
491
533
|
}
|
|
492
534
|
}
|
|
@@ -502,14 +544,36 @@ export function fillInDirectSchemaGapsAndUnknowns({
|
|
|
502
544
|
schema[previousSubPath],
|
|
503
545
|
)
|
|
504
546
|
) {
|
|
505
|
-
const
|
|
506
|
-
|
|
547
|
+
const existingType = schema[previousSubPath];
|
|
548
|
+
const baseExistingType = existingType?.split(' | ')[0];
|
|
549
|
+
// Skip if the base type is already a structured type
|
|
507
550
|
if (
|
|
508
|
-
!
|
|
509
|
-
|
|
551
|
+
!['object', 'array', 'function', 'async-function'].includes(
|
|
552
|
+
baseExistingType,
|
|
553
|
+
)
|
|
510
554
|
) {
|
|
511
|
-
|
|
512
|
-
|
|
555
|
+
let newValue = getKnownType(previousSubPath) ?? 'object';
|
|
556
|
+
// Don't overwrite 'unknown' with 'object' — 'object' is just
|
|
557
|
+
// inferred from child properties and isn't more useful than 'unknown'
|
|
558
|
+
if (
|
|
559
|
+
newValue === 'object' &&
|
|
560
|
+
existingType &&
|
|
561
|
+
existingType.split(' | ')[0] === 'unknown'
|
|
562
|
+
) {
|
|
563
|
+
// preserve existing 'unknown' (possibly with nullability)
|
|
564
|
+
} else {
|
|
565
|
+
// Preserve nullability from existing type
|
|
566
|
+
if (existingType?.includes(' | undefined')) {
|
|
567
|
+
newValue = `${newValue} | undefined`;
|
|
568
|
+
} else if (existingType?.includes(' | null')) {
|
|
569
|
+
newValue = `${newValue} | null`;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (!existingType || existingType !== newValue) {
|
|
573
|
+
schema[previousSubPath] = newValue;
|
|
574
|
+
changeMade = true;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
513
577
|
}
|
|
514
578
|
}
|
|
515
579
|
|
|
@@ -778,10 +842,11 @@ function checkIfKnownType(
|
|
|
778
842
|
return 'array';
|
|
779
843
|
}
|
|
780
844
|
|
|
781
|
-
// When .includes() or .indexOf() is called with a variable argument
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
|
|
845
|
+
// When .includes() or .indexOf() is called with a variable argument, prefer array.
|
|
846
|
+
// Pattern: arr.includes(item) -> likely array (checking if item exists in collection)
|
|
847
|
+
// String literals are already filtered by hasStringLiteralArgument, so if we get here
|
|
848
|
+
// with a variable argument, it's strong evidence of array membership testing.
|
|
849
|
+
if (isArray && hasIncludesOrIndexOfWithVariable) {
|
|
785
850
|
return 'array';
|
|
786
851
|
}
|
|
787
852
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Entity } from '~codeyam/types';
|
|
2
2
|
import isolateScopes from './isolateScopes';
|
|
3
3
|
import analyzeScope from './analyzeScope';
|
|
4
|
-
import { FileAnalyzer } from '~codeyam/analyze';
|
|
4
|
+
import { FileAnalyzer, transformationTracer } from '~codeyam/analyze';
|
|
5
5
|
import { AI, SerializableDataStructure } from '~codeyam/ai';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
resetScopeDataStructureMetrics,
|
|
8
|
+
ScopeDataStructure,
|
|
9
|
+
} from './dataStructure/ScopeDataStructure';
|
|
7
10
|
|
|
8
11
|
// import { awsLog } from '~codeyam/utils';
|
|
9
12
|
|
|
@@ -91,8 +94,60 @@ export default async function generateEntityDataStructure({
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
// Inspect the runtime type of dataStructure to see if it must be serialized
|
|
97
|
+
// Note: When worker threads are used, dataStructure is already serialized (no toSerializable).
|
|
98
|
+
// Workers are disabled when CODEYAM_TRACE_TRANSFORMS=1 to enable full tracing.
|
|
94
99
|
if ('toSerializable' in entityScope.dataStructure) {
|
|
95
|
-
|
|
100
|
+
const scopeDataStructure =
|
|
101
|
+
entityScope.dataStructure as unknown as ScopeDataStructure;
|
|
102
|
+
|
|
103
|
+
// Trace the internal state BEFORE serialization - captures what methods return
|
|
104
|
+
if (transformationTracer.isEnabled()) {
|
|
105
|
+
transformationTracer.startEntity({
|
|
106
|
+
name: entity.name,
|
|
107
|
+
entityType: entity.entityType ?? 'unknown',
|
|
108
|
+
filePath: entity.filePath,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Capture internal state - this is what getReturnValue/getFunctionSignature return
|
|
112
|
+
transformationTracer.snapshot(entity.name, 'scopeDataStructure', {
|
|
113
|
+
signatureSchema: scopeDataStructure.getFunctionSignature({
|
|
114
|
+
fillInUnknowns: true,
|
|
115
|
+
}),
|
|
116
|
+
returnValueSchema: scopeDataStructure.getReturnValue({
|
|
117
|
+
fillInUnknowns: true,
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const serialized = scopeDataStructure.toSerializable();
|
|
123
|
+
|
|
124
|
+
// Trace AFTER serialization - shows what gets output
|
|
125
|
+
if (transformationTracer.isEnabled()) {
|
|
126
|
+
// Build schema from external function calls for comparison
|
|
127
|
+
const externalSchemas: Record<string, string> = {};
|
|
128
|
+
for (const efc of serialized.externalFunctionCalls ?? []) {
|
|
129
|
+
for (const [path, type] of Object.entries(efc.schema ?? {})) {
|
|
130
|
+
externalSchemas[path] = type;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
transformationTracer.snapshot(entity.name, 'serialized', {
|
|
135
|
+
signatureSchema:
|
|
136
|
+
serialized.functionResults?.[entity.name]?.signatureWithUnknowns,
|
|
137
|
+
returnValueSchema:
|
|
138
|
+
serialized.functionResults?.[entity.name]?.returnValueWithUnknowns,
|
|
139
|
+
// Include external function schemas to detect serialization gaps
|
|
140
|
+
dependencySchemas: {
|
|
141
|
+
externalFunctions: {
|
|
142
|
+
combined: {
|
|
143
|
+
returnValueSchema: externalSchemas,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return serialized;
|
|
96
151
|
}
|
|
97
152
|
return entityScope.dataStructure;
|
|
98
153
|
}
|
|
@@ -18,6 +18,7 @@ import { AI, parseJsonSafe } from '~codeyam/ai';
|
|
|
18
18
|
import convertNullToUndefinedBySchema from './dataStructure/helpers/convertNullToUndefinedBySchema';
|
|
19
19
|
import convertTypeAnnotationsToValues from './dataStructure/helpers/convertTypeAnnotationsToValues';
|
|
20
20
|
import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
|
|
21
|
+
import coerceObjectsToPrimitivesBySchema from './dataStructure/helpers/coerceObjectsToPrimitivesBySchema';
|
|
21
22
|
import { JsonTypeDefinition } from '~codeyam/types';
|
|
22
23
|
import { deepMerge } from '~codeyam/generate';
|
|
23
24
|
import {
|
|
@@ -1057,6 +1058,19 @@ export async function generateDataForScenario({
|
|
|
1057
1058
|
);
|
|
1058
1059
|
}
|
|
1059
1060
|
|
|
1061
|
+
// Coerce objects/arrays to primitives when the schema expects a primitive type.
|
|
1062
|
+
// The LLM sometimes generates an object where the schema expects "string",
|
|
1063
|
+
// e.g., { body: { "env": "production" } } instead of { body: "some string" }.
|
|
1064
|
+
// This causes runtime errors like "TypeError: body.match is not a function".
|
|
1065
|
+
// Must run BEFORE convertCommaSeparatedStringsToArrays, which intentionally
|
|
1066
|
+
// overrides schema types for array-like field names.
|
|
1067
|
+
if (structure.dataForMocks && fullScenarioData.data.mockData) {
|
|
1068
|
+
coerceObjectsToPrimitivesBySchema(
|
|
1069
|
+
fullScenarioData.data.mockData,
|
|
1070
|
+
structure.dataForMocks,
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1060
1074
|
// Convert comma-separated strings to arrays when appropriate.
|
|
1061
1075
|
// The LLM sometimes generates strings like "color,size" instead of arrays
|
|
1062
1076
|
// like ["color", "size"] when the schema type is incorrectly inferred as
|
|
@@ -743,6 +743,48 @@ function processScope({
|
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Check if a code string contains only type declarations (type aliases, interfaces, etc.)
|
|
748
|
+
* that don't contribute to runtime behavior. This is used to determine if the root scope
|
|
749
|
+
* should be considered "empty" for scope extraction purposes.
|
|
750
|
+
*/
|
|
751
|
+
function containsOnlyTypeDeclarations(code: string): boolean {
|
|
752
|
+
try {
|
|
753
|
+
const sourceFile = ts.createSourceFile(
|
|
754
|
+
'temp.ts',
|
|
755
|
+
code,
|
|
756
|
+
ts.ScriptTarget.Latest,
|
|
757
|
+
true,
|
|
758
|
+
ts.ScriptKind.TS,
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
// Check each statement - if any is NOT a type-only declaration, return false
|
|
762
|
+
for (const statement of sourceFile.statements) {
|
|
763
|
+
if (
|
|
764
|
+
ts.isTypeAliasDeclaration(statement) ||
|
|
765
|
+
ts.isInterfaceDeclaration(statement) ||
|
|
766
|
+
ts.isEnumDeclaration(statement) ||
|
|
767
|
+
// Import declarations that are type-only
|
|
768
|
+
(ts.isImportDeclaration(statement) &&
|
|
769
|
+
statement.importClause?.isTypeOnly) ||
|
|
770
|
+
// Export declarations that are type-only
|
|
771
|
+
(ts.isExportDeclaration(statement) && statement.isTypeOnly)
|
|
772
|
+
) {
|
|
773
|
+
// This is a type-only declaration, continue checking
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
// Found a non-type statement
|
|
777
|
+
return false;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// All statements are type-only (or there are no statements)
|
|
781
|
+
return sourceFile.statements.length > 0;
|
|
782
|
+
} catch {
|
|
783
|
+
// If parsing fails, assume it's not type-only
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
746
788
|
/**
|
|
747
789
|
* Main entry point.
|
|
748
790
|
*
|
|
@@ -792,9 +834,15 @@ export default function isolateScopes(
|
|
|
792
834
|
const jsxLimit = options?.jsxLimit ?? 10;
|
|
793
835
|
processJSXForScope(isolatedScopes, generateSyntheticName, jsxLimit);
|
|
794
836
|
|
|
795
|
-
// If the root scope text is empty and there's
|
|
796
|
-
// return that child scope as the root scope
|
|
797
|
-
|
|
837
|
+
// If the root scope text is empty (or only contains type declarations) and there's
|
|
838
|
+
// only one child scope, return that child scope as the root scope.
|
|
839
|
+
// Type declarations (type aliases, interfaces) don't contribute to runtime behavior,
|
|
840
|
+
// so we treat them as "empty" for scope extraction purposes.
|
|
841
|
+
const rootTextIsEffectivelyEmpty =
|
|
842
|
+
isolatedScopes.text.trim().length === 0 ||
|
|
843
|
+
containsOnlyTypeDeclarations(isolatedScopes.text);
|
|
844
|
+
|
|
845
|
+
if (rootTextIsEffectivelyEmpty) {
|
|
798
846
|
const childScopeArray = Object.values(isolatedScopes.childScopes);
|
|
799
847
|
if (childScopeArray.length === 1) {
|
|
800
848
|
return childScopeArray[0];
|
|
@@ -41,6 +41,8 @@ export { default as mergeValidatedDataStructures } from './src/lib/files/scenari
|
|
|
41
41
|
|
|
42
42
|
export { discoverDirectDependencies } from './src/lib/files/analyze/dependencyResolver';
|
|
43
43
|
|
|
44
|
+
export { transformationTracer } from './src/lib/files/scenarios/TransformationTracer';
|
|
45
|
+
|
|
44
46
|
export { default as getAnalysisError } from './src/lib/utils/getAnalysisError';
|
|
45
47
|
export { default as measureAndReportExecutionTime } from './src/lib/utils/measureAndReportExecutionTime';
|
|
46
48
|
|
|
@@ -555,6 +555,42 @@ async function getEntityDataStructureAndFunctionCalls({
|
|
|
555
555
|
},
|
|
556
556
|
);
|
|
557
557
|
|
|
558
|
+
// Add same-file child components to dependencySchemas.
|
|
559
|
+
// Same-file components (e.g., AgentCard defined in the same file as AgentTranscriptsPage)
|
|
560
|
+
// appear in externalFunctionCalls and functionResults but NOT in importedExports or
|
|
561
|
+
// nodeModuleImports. Without this, their signatures are missing from dependencySchemas
|
|
562
|
+
// and enrichArrayTypesFromChildSignatures can't find child component field accesses.
|
|
563
|
+
const allDependencyNames = new Set(allDependencies.map((d) => d.name));
|
|
564
|
+
|
|
565
|
+
for (const efc of dataStructure.externalFunctionCalls) {
|
|
566
|
+
// Skip if already covered by importedExports or nodeModuleImports
|
|
567
|
+
if (allDependencyNames.has(efc.name)) continue;
|
|
568
|
+
|
|
569
|
+
const signatureSchema = getFunctionSignature(dataStructure, {
|
|
570
|
+
functionName: efc.name,
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
const returnValueSchema = getReturnValue(dataStructure, {
|
|
574
|
+
functionName: efc.name,
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// Only add if we have signature or return value data
|
|
578
|
+
if (!signatureSchema && !returnValueSchema) continue;
|
|
579
|
+
|
|
580
|
+
const clonedSignatureSchema = { ...(signatureSchema ?? {}) };
|
|
581
|
+
const clonedReturnValueSchema = { ...(returnValueSchema ?? {}) };
|
|
582
|
+
|
|
583
|
+
const entityFilePath = entity.filePath;
|
|
584
|
+
dependencySchemas[entityFilePath] ||= {};
|
|
585
|
+
dependencySchemas[entityFilePath][efc.name] = {
|
|
586
|
+
signatureSchema: deduplicateFunctionSchemas(clonedSignatureSchema),
|
|
587
|
+
returnValueSchema: deduplicateFunctionSchemas(clonedReturnValueSchema),
|
|
588
|
+
usageEquivalencies: getUsageEquivalencies(dataStructure, efc.name) ?? {},
|
|
589
|
+
sourceEquivalencies:
|
|
590
|
+
getSourceEquivalencies(dataStructure, efc.name) ?? {},
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
|
|
558
594
|
const rawReturnValue =
|
|
559
595
|
getReturnValue(dataStructure, { fillInUnknowns: false }) ?? {};
|
|
560
596
|
|
|
@@ -870,9 +906,21 @@ export function determineMockedDependencies(entity: Entity) {
|
|
|
870
906
|
// A schema with only "EntityName(): function" just indicates the entity is callable,
|
|
871
907
|
// it doesn't mean there's actual return data to mock
|
|
872
908
|
const hasReturnValue = hasActualReturnValueData(entityReturnValueSchema);
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
909
|
+
// Check for complex return types (object/array), accounting for nullable types
|
|
910
|
+
// e.g., 'object', 'object | null', 'array | undefined' should all count as complex.
|
|
911
|
+
// Also detect when functionCallReturnValue has nested child properties — this
|
|
912
|
+
// proves it's a structured type even if its declared type is still 'unknown'.
|
|
913
|
+
const returnValueKeys = Object.keys(entityReturnValueSchema ?? {});
|
|
914
|
+
const complexReturnValue =
|
|
915
|
+
Object.values(entityReturnValueSchema ?? {}).some((value) => {
|
|
916
|
+
const baseType = value?.split(' | ')[0];
|
|
917
|
+
return baseType === 'object' || baseType === 'array';
|
|
918
|
+
}) ||
|
|
919
|
+
returnValueKeys.some(
|
|
920
|
+
(key) =>
|
|
921
|
+
key.includes('functionCallReturnValue.') ||
|
|
922
|
+
key.includes('functionCallReturnValue['),
|
|
923
|
+
);
|
|
876
924
|
|
|
877
925
|
// Check if this is a validation function that should always be mocked
|
|
878
926
|
const isValidationFn = isValidationFunction(entityName);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
measureAndReportExecutionTime,
|
|
6
6
|
ProjectAnalyzer,
|
|
7
7
|
} from '~codeyam/analyze';
|
|
8
|
+
import { transformationTracer } from '../scenarios/TransformationTracer';
|
|
8
9
|
import { getFileByPathSafe } from '../../utils/getFileByPath';
|
|
9
10
|
import trackEntityCircularDependencies from './trackEntityCircularDependencies';
|
|
10
11
|
import validateDependencyAnalyses from './validateDependencyAnalyses';
|
|
@@ -307,6 +308,10 @@ export default async function analyzeEntities({
|
|
|
307
308
|
awsLog(
|
|
308
309
|
`CodeYam: analyzeEntities: Analysis completed with ${analyses.length} analyses`,
|
|
309
310
|
);
|
|
311
|
+
|
|
312
|
+
// Flush transformation trace if tracing is enabled
|
|
313
|
+
transformationTracer.flush();
|
|
314
|
+
|
|
310
315
|
return analyses;
|
|
311
316
|
|
|
312
317
|
// PHASE 3: Pure graph traversal
|