@zbigniewsobiecki/squint 1.0.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/README.md +1065 -0
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/commands/_shared/db-helper.d.ts +18 -0
- package/dist/commands/_shared/db-helper.d.ts.map +1 -0
- package/dist/commands/_shared/db-helper.js +72 -0
- package/dist/commands/_shared/db-helper.js.map +1 -0
- package/dist/commands/_shared/flags.d.ts +20 -0
- package/dist/commands/_shared/flags.d.ts.map +1 -0
- package/dist/commands/_shared/flags.js +38 -0
- package/dist/commands/_shared/flags.js.map +1 -0
- package/dist/commands/_shared/index.d.ts +6 -0
- package/dist/commands/_shared/index.d.ts.map +1 -0
- package/dist/commands/_shared/index.js +6 -0
- package/dist/commands/_shared/index.js.map +1 -0
- package/dist/commands/_shared/output.d.ts +22 -0
- package/dist/commands/_shared/output.d.ts.map +1 -0
- package/dist/commands/_shared/output.js +36 -0
- package/dist/commands/_shared/output.js.map +1 -0
- package/dist/commands/_shared/source-reader.d.ts +23 -0
- package/dist/commands/_shared/source-reader.d.ts.map +1 -0
- package/dist/commands/_shared/source-reader.js +45 -0
- package/dist/commands/_shared/source-reader.js.map +1 -0
- package/dist/commands/_shared/symbol-resolver.d.ts +35 -0
- package/dist/commands/_shared/symbol-resolver.d.ts.map +1 -0
- package/dist/commands/_shared/symbol-resolver.js +102 -0
- package/dist/commands/_shared/symbol-resolver.js.map +1 -0
- package/dist/commands/browse.d.ts +13 -0
- package/dist/commands/browse.d.ts.map +1 -0
- package/dist/commands/browse.js +106 -0
- package/dist/commands/browse.js.map +1 -0
- package/dist/commands/domains/create.d.ts +15 -0
- package/dist/commands/domains/create.d.ts.map +1 -0
- package/dist/commands/domains/create.js +34 -0
- package/dist/commands/domains/create.js.map +1 -0
- package/dist/commands/domains/delete.d.ts +14 -0
- package/dist/commands/domains/delete.d.ts.map +1 -0
- package/dist/commands/domains/delete.js +41 -0
- package/dist/commands/domains/delete.js.map +1 -0
- package/dist/commands/domains/index.d.ts +2 -0
- package/dist/commands/domains/index.d.ts.map +1 -0
- package/dist/commands/domains/index.js +2 -0
- package/dist/commands/domains/index.js.map +1 -0
- package/dist/commands/domains/list.d.ts +12 -0
- package/dist/commands/domains/list.d.ts.map +1 -0
- package/dist/commands/domains/list.js +67 -0
- package/dist/commands/domains/list.js.map +1 -0
- package/dist/commands/domains/merge.d.ts +14 -0
- package/dist/commands/domains/merge.d.ts.map +1 -0
- package/dist/commands/domains/merge.js +40 -0
- package/dist/commands/domains/merge.js.map +1 -0
- package/dist/commands/domains/rename.d.ts +14 -0
- package/dist/commands/domains/rename.d.ts.map +1 -0
- package/dist/commands/domains/rename.js +33 -0
- package/dist/commands/domains/rename.js.map +1 -0
- package/dist/commands/domains/show.d.ts +14 -0
- package/dist/commands/domains/show.d.ts.map +1 -0
- package/dist/commands/domains/show.js +47 -0
- package/dist/commands/domains/show.js.map +1 -0
- package/dist/commands/domains/sync.d.ts +11 -0
- package/dist/commands/domains/sync.d.ts.map +1 -0
- package/dist/commands/domains/sync.js +33 -0
- package/dist/commands/domains/sync.js.map +1 -0
- package/dist/commands/domains/update.d.ts +14 -0
- package/dist/commands/domains/update.d.ts.map +1 -0
- package/dist/commands/domains/update.js +28 -0
- package/dist/commands/domains/update.js.map +1 -0
- package/dist/commands/features/assign.d.ts +16 -0
- package/dist/commands/features/assign.d.ts.map +1 -0
- package/dist/commands/features/assign.js +51 -0
- package/dist/commands/features/assign.js.map +1 -0
- package/dist/commands/features/create.d.ts +15 -0
- package/dist/commands/features/create.d.ts.map +1 -0
- package/dist/commands/features/create.js +30 -0
- package/dist/commands/features/create.js.map +1 -0
- package/dist/commands/features/delete.d.ts +14 -0
- package/dist/commands/features/delete.d.ts.map +1 -0
- package/dist/commands/features/delete.js +37 -0
- package/dist/commands/features/delete.js.map +1 -0
- package/dist/commands/features/generate.d.ts +34 -0
- package/dist/commands/features/generate.d.ts.map +1 -0
- package/dist/commands/features/generate.js +178 -0
- package/dist/commands/features/generate.js.map +1 -0
- package/dist/commands/features/index.d.ts +2 -0
- package/dist/commands/features/index.d.ts.map +1 -0
- package/dist/commands/features/index.js +2 -0
- package/dist/commands/features/index.js.map +1 -0
- package/dist/commands/features/list.d.ts +11 -0
- package/dist/commands/features/list.d.ts.map +1 -0
- package/dist/commands/features/list.js +45 -0
- package/dist/commands/features/list.js.map +1 -0
- package/dist/commands/features/show.d.ts +15 -0
- package/dist/commands/features/show.d.ts.map +1 -0
- package/dist/commands/features/show.js +61 -0
- package/dist/commands/features/show.js.map +1 -0
- package/dist/commands/features/unassign.d.ts +16 -0
- package/dist/commands/features/unassign.d.ts.map +1 -0
- package/dist/commands/features/unassign.js +55 -0
- package/dist/commands/features/unassign.js.map +1 -0
- package/dist/commands/features/update.d.ts +16 -0
- package/dist/commands/features/update.d.ts.map +1 -0
- package/dist/commands/features/update.js +54 -0
- package/dist/commands/features/update.js.map +1 -0
- package/dist/commands/files/imported-by.d.ts +13 -0
- package/dist/commands/files/imported-by.d.ts.map +1 -0
- package/dist/commands/files/imported-by.js +40 -0
- package/dist/commands/files/imported-by.js.map +1 -0
- package/dist/commands/files/imports.d.ts +14 -0
- package/dist/commands/files/imports.d.ts.map +1 -0
- package/dist/commands/files/imports.js +48 -0
- package/dist/commands/files/imports.js.map +1 -0
- package/dist/commands/files/index.d.ts +2 -0
- package/dist/commands/files/index.d.ts.map +1 -0
- package/dist/commands/files/index.js +2 -0
- package/dist/commands/files/index.js.map +1 -0
- package/dist/commands/files/list.d.ts +11 -0
- package/dist/commands/files/list.d.ts.map +1 -0
- package/dist/commands/files/list.js +35 -0
- package/dist/commands/files/list.js.map +1 -0
- package/dist/commands/files/orphans.d.ts +12 -0
- package/dist/commands/files/orphans.d.ts.map +1 -0
- package/dist/commands/files/orphans.js +43 -0
- package/dist/commands/files/orphans.js.map +1 -0
- package/dist/commands/files/show.d.ts +14 -0
- package/dist/commands/files/show.d.ts.map +1 -0
- package/dist/commands/files/show.js +95 -0
- package/dist/commands/files/show.js.map +1 -0
- package/dist/commands/flows/add-step.d.ts +19 -0
- package/dist/commands/flows/add-step.d.ts.map +1 -0
- package/dist/commands/flows/add-step.js +46 -0
- package/dist/commands/flows/add-step.js.map +1 -0
- package/dist/commands/flows/create.d.ts +17 -0
- package/dist/commands/flows/create.d.ts.map +1 -0
- package/dist/commands/flows/create.js +39 -0
- package/dist/commands/flows/create.js.map +1 -0
- package/dist/commands/flows/delete.d.ts +14 -0
- package/dist/commands/flows/delete.d.ts.map +1 -0
- package/dist/commands/flows/delete.js +37 -0
- package/dist/commands/flows/delete.js.map +1 -0
- package/dist/commands/flows/generate.d.ts +50 -0
- package/dist/commands/flows/generate.d.ts.map +1 -0
- package/dist/commands/flows/generate.js +438 -0
- package/dist/commands/flows/generate.js.map +1 -0
- package/dist/commands/flows/index.d.ts +2 -0
- package/dist/commands/flows/index.d.ts.map +1 -0
- package/dist/commands/flows/index.js +2 -0
- package/dist/commands/flows/index.js.map +1 -0
- package/dist/commands/flows/list.d.ts +12 -0
- package/dist/commands/flows/list.d.ts.map +1 -0
- package/dist/commands/flows/list.js +98 -0
- package/dist/commands/flows/list.js.map +1 -0
- package/dist/commands/flows/remove-step.d.ts +18 -0
- package/dist/commands/flows/remove-step.d.ts.map +1 -0
- package/dist/commands/flows/remove-step.js +41 -0
- package/dist/commands/flows/remove-step.js.map +1 -0
- package/dist/commands/flows/show.d.ts +17 -0
- package/dist/commands/flows/show.d.ts.map +1 -0
- package/dist/commands/flows/show.js +136 -0
- package/dist/commands/flows/show.js.map +1 -0
- package/dist/commands/flows/trace.d.ts +22 -0
- package/dist/commands/flows/trace.d.ts.map +1 -0
- package/dist/commands/flows/trace.js +217 -0
- package/dist/commands/flows/trace.js.map +1 -0
- package/dist/commands/flows/update.d.ts +17 -0
- package/dist/commands/flows/update.d.ts.map +1 -0
- package/dist/commands/flows/update.js +60 -0
- package/dist/commands/flows/update.js.map +1 -0
- package/dist/commands/flows/verify.d.ts +21 -0
- package/dist/commands/flows/verify.d.ts.map +1 -0
- package/dist/commands/flows/verify.js +123 -0
- package/dist/commands/flows/verify.js.map +1 -0
- package/dist/commands/gaps.d.ts +14 -0
- package/dist/commands/gaps.d.ts.map +1 -0
- package/dist/commands/gaps.js +184 -0
- package/dist/commands/gaps.js.map +1 -0
- package/dist/commands/hierarchy/index.d.ts +20 -0
- package/dist/commands/hierarchy/index.d.ts.map +1 -0
- package/dist/commands/hierarchy/index.js +344 -0
- package/dist/commands/hierarchy/index.js.map +1 -0
- package/dist/commands/ingest.d.ts +23 -0
- package/dist/commands/ingest.d.ts.map +1 -0
- package/dist/commands/ingest.js +249 -0
- package/dist/commands/ingest.js.map +1 -0
- package/dist/commands/interactions/create.d.ts +16 -0
- package/dist/commands/interactions/create.d.ts.map +1 -0
- package/dist/commands/interactions/create.js +58 -0
- package/dist/commands/interactions/create.js.map +1 -0
- package/dist/commands/interactions/delete.d.ts +16 -0
- package/dist/commands/interactions/delete.d.ts.map +1 -0
- package/dist/commands/interactions/delete.js +28 -0
- package/dist/commands/interactions/delete.js.map +1 -0
- package/dist/commands/interactions/generate.d.ts +62 -0
- package/dist/commands/interactions/generate.d.ts.map +1 -0
- package/dist/commands/interactions/generate.js +870 -0
- package/dist/commands/interactions/generate.js.map +1 -0
- package/dist/commands/interactions/index.d.ts +2 -0
- package/dist/commands/interactions/index.d.ts.map +1 -0
- package/dist/commands/interactions/index.js +2 -0
- package/dist/commands/interactions/index.js.map +1 -0
- package/dist/commands/interactions/list.d.ts +15 -0
- package/dist/commands/interactions/list.d.ts.map +1 -0
- package/dist/commands/interactions/list.js +127 -0
- package/dist/commands/interactions/list.js.map +1 -0
- package/dist/commands/interactions/show.d.ts +17 -0
- package/dist/commands/interactions/show.d.ts.map +1 -0
- package/dist/commands/interactions/show.js +80 -0
- package/dist/commands/interactions/show.js.map +1 -0
- package/dist/commands/interactions/update.d.ts +20 -0
- package/dist/commands/interactions/update.d.ts.map +1 -0
- package/dist/commands/interactions/update.js +57 -0
- package/dist/commands/interactions/update.js.map +1 -0
- package/dist/commands/interactions/validate.d.ts +12 -0
- package/dist/commands/interactions/validate.d.ts.map +1 -0
- package/dist/commands/interactions/validate.js +94 -0
- package/dist/commands/interactions/validate.js.map +1 -0
- package/dist/commands/interactions/verify.d.ts +18 -0
- package/dist/commands/interactions/verify.d.ts.map +1 -0
- package/dist/commands/interactions/verify.js +127 -0
- package/dist/commands/interactions/verify.js.map +1 -0
- package/dist/commands/llm/_shared/base-llm-command.d.ts +44 -0
- package/dist/commands/llm/_shared/base-llm-command.d.ts.map +1 -0
- package/dist/commands/llm/_shared/base-llm-command.js +73 -0
- package/dist/commands/llm/_shared/base-llm-command.js.map +1 -0
- package/dist/commands/llm/_shared/coverage.d.ts +61 -0
- package/dist/commands/llm/_shared/coverage.d.ts.map +1 -0
- package/dist/commands/llm/_shared/coverage.js +161 -0
- package/dist/commands/llm/_shared/coverage.js.map +1 -0
- package/dist/commands/llm/_shared/csv-utils.d.ts +65 -0
- package/dist/commands/llm/_shared/csv-utils.d.ts.map +1 -0
- package/dist/commands/llm/_shared/csv-utils.js +231 -0
- package/dist/commands/llm/_shared/csv-utils.js.map +1 -0
- package/dist/commands/llm/_shared/csv.d.ts +44 -0
- package/dist/commands/llm/_shared/csv.d.ts.map +1 -0
- package/dist/commands/llm/_shared/csv.js +76 -0
- package/dist/commands/llm/_shared/csv.js.map +1 -0
- package/dist/commands/llm/_shared/entity-utils.d.ts +11 -0
- package/dist/commands/llm/_shared/entity-utils.d.ts.map +1 -0
- package/dist/commands/llm/_shared/entity-utils.js +87 -0
- package/dist/commands/llm/_shared/entity-utils.js.map +1 -0
- package/dist/commands/llm/_shared/flow-csv.d.ts +74 -0
- package/dist/commands/llm/_shared/flow-csv.d.ts.map +1 -0
- package/dist/commands/llm/_shared/flow-csv.js +198 -0
- package/dist/commands/llm/_shared/flow-csv.js.map +1 -0
- package/dist/commands/llm/_shared/flow-prompts.d.ts +61 -0
- package/dist/commands/llm/_shared/flow-prompts.d.ts.map +1 -0
- package/dist/commands/llm/_shared/flow-prompts.js +281 -0
- package/dist/commands/llm/_shared/flow-prompts.js.map +1 -0
- package/dist/commands/llm/_shared/flow-validation.d.ts +69 -0
- package/dist/commands/llm/_shared/flow-validation.d.ts.map +1 -0
- package/dist/commands/llm/_shared/flow-validation.js +176 -0
- package/dist/commands/llm/_shared/flow-validation.js.map +1 -0
- package/dist/commands/llm/_shared/llm-utils.d.ts +88 -0
- package/dist/commands/llm/_shared/llm-utils.d.ts.map +1 -0
- package/dist/commands/llm/_shared/llm-utils.js +256 -0
- package/dist/commands/llm/_shared/llm-utils.js.map +1 -0
- package/dist/commands/llm/_shared/module-csv.d.ts +76 -0
- package/dist/commands/llm/_shared/module-csv.d.ts.map +1 -0
- package/dist/commands/llm/_shared/module-csv.js +196 -0
- package/dist/commands/llm/_shared/module-csv.js.map +1 -0
- package/dist/commands/llm/_shared/module-prompts.d.ts +107 -0
- package/dist/commands/llm/_shared/module-prompts.d.ts.map +1 -0
- package/dist/commands/llm/_shared/module-prompts.js +395 -0
- package/dist/commands/llm/_shared/module-prompts.js.map +1 -0
- package/dist/commands/llm/_shared/process-utils.d.ts +52 -0
- package/dist/commands/llm/_shared/process-utils.d.ts.map +1 -0
- package/dist/commands/llm/_shared/process-utils.js +214 -0
- package/dist/commands/llm/_shared/process-utils.js.map +1 -0
- package/dist/commands/llm/_shared/prompts.d.ts +132 -0
- package/dist/commands/llm/_shared/prompts.d.ts.map +1 -0
- package/dist/commands/llm/_shared/prompts.js +391 -0
- package/dist/commands/llm/_shared/prompts.js.map +1 -0
- package/dist/commands/llm/_shared/pure-check.d.ts +10 -0
- package/dist/commands/llm/_shared/pure-check.d.ts.map +1 -0
- package/dist/commands/llm/_shared/pure-check.js +449 -0
- package/dist/commands/llm/_shared/pure-check.js.map +1 -0
- package/dist/commands/llm/_shared/verify/content-verifier.d.ts +40 -0
- package/dist/commands/llm/_shared/verify/content-verifier.d.ts.map +1 -0
- package/dist/commands/llm/_shared/verify/content-verifier.js +247 -0
- package/dist/commands/llm/_shared/verify/content-verifier.js.map +1 -0
- package/dist/commands/llm/_shared/verify/coverage-checker.d.ts +34 -0
- package/dist/commands/llm/_shared/verify/coverage-checker.d.ts.map +1 -0
- package/dist/commands/llm/_shared/verify/coverage-checker.js +1096 -0
- package/dist/commands/llm/_shared/verify/coverage-checker.js.map +1 -0
- package/dist/commands/llm/_shared/verify/verify-prompts.d.ts +30 -0
- package/dist/commands/llm/_shared/verify/verify-prompts.d.ts.map +1 -0
- package/dist/commands/llm/_shared/verify/verify-prompts.js +118 -0
- package/dist/commands/llm/_shared/verify/verify-prompts.js.map +1 -0
- package/dist/commands/llm/_shared/verify/verify-types.d.ts +47 -0
- package/dist/commands/llm/_shared/verify/verify-types.d.ts.map +1 -0
- package/dist/commands/llm/_shared/verify/verify-types.js +2 -0
- package/dist/commands/llm/_shared/verify/verify-types.js.map +1 -0
- package/dist/commands/llm/annotate.d.ts +7 -0
- package/dist/commands/llm/annotate.d.ts.map +1 -0
- package/dist/commands/llm/annotate.js +11 -0
- package/dist/commands/llm/annotate.js.map +1 -0
- package/dist/commands/llm/features/feature-grouper.d.ts +31 -0
- package/dist/commands/llm/features/feature-grouper.d.ts.map +1 -0
- package/dist/commands/llm/features/feature-grouper.js +223 -0
- package/dist/commands/llm/features/feature-grouper.js.map +1 -0
- package/dist/commands/llm/features/index.d.ts +6 -0
- package/dist/commands/llm/features/index.d.ts.map +1 -0
- package/dist/commands/llm/features/index.js +6 -0
- package/dist/commands/llm/features/index.js.map +1 -0
- package/dist/commands/llm/features/types.d.ts +10 -0
- package/dist/commands/llm/features/types.d.ts.map +1 -0
- package/dist/commands/llm/features/types.js +5 -0
- package/dist/commands/llm/features/types.js.map +1 -0
- package/dist/commands/llm/features.d.ts +7 -0
- package/dist/commands/llm/features.d.ts.map +1 -0
- package/dist/commands/llm/features.js +11 -0
- package/dist/commands/llm/features.js.map +1 -0
- package/dist/commands/llm/flows/atomic-flow-builder.d.ts +51 -0
- package/dist/commands/llm/flows/atomic-flow-builder.d.ts.map +1 -0
- package/dist/commands/llm/flows/atomic-flow-builder.js +247 -0
- package/dist/commands/llm/flows/atomic-flow-builder.js.map +1 -0
- package/dist/commands/llm/flows/dedup.d.ts +18 -0
- package/dist/commands/llm/flows/dedup.d.ts.map +1 -0
- package/dist/commands/llm/flows/dedup.js +76 -0
- package/dist/commands/llm/flows/dedup.js.map +1 -0
- package/dist/commands/llm/flows/entry-point-detector.d.ts +41 -0
- package/dist/commands/llm/flows/entry-point-detector.d.ts.map +1 -0
- package/dist/commands/llm/flows/entry-point-detector.js +388 -0
- package/dist/commands/llm/flows/entry-point-detector.js.map +1 -0
- package/dist/commands/llm/flows/flow-enhancer.d.ts +21 -0
- package/dist/commands/llm/flows/flow-enhancer.d.ts.map +1 -0
- package/dist/commands/llm/flows/flow-enhancer.js +166 -0
- package/dist/commands/llm/flows/flow-enhancer.js.map +1 -0
- package/dist/commands/llm/flows/flow-tracer.d.ts +50 -0
- package/dist/commands/llm/flows/flow-tracer.d.ts.map +1 -0
- package/dist/commands/llm/flows/flow-tracer.js +271 -0
- package/dist/commands/llm/flows/flow-tracer.js.map +1 -0
- package/dist/commands/llm/flows/flow-validator.d.ts +31 -0
- package/dist/commands/llm/flows/flow-validator.d.ts.map +1 -0
- package/dist/commands/llm/flows/flow-validator.js +262 -0
- package/dist/commands/llm/flows/flow-validator.js.map +1 -0
- package/dist/commands/llm/flows/gap-flow-generator.d.ts +13 -0
- package/dist/commands/llm/flows/gap-flow-generator.d.ts.map +1 -0
- package/dist/commands/llm/flows/gap-flow-generator.js +48 -0
- package/dist/commands/llm/flows/gap-flow-generator.js.map +1 -0
- package/dist/commands/llm/flows/index.d.ts +12 -0
- package/dist/commands/llm/flows/index.d.ts.map +1 -0
- package/dist/commands/llm/flows/index.js +12 -0
- package/dist/commands/llm/flows/index.js.map +1 -0
- package/dist/commands/llm/flows/types.d.ts +87 -0
- package/dist/commands/llm/flows/types.d.ts.map +1 -0
- package/dist/commands/llm/flows/types.js +5 -0
- package/dist/commands/llm/flows/types.js.map +1 -0
- package/dist/commands/llm/flows.d.ts +7 -0
- package/dist/commands/llm/flows.d.ts.map +1 -0
- package/dist/commands/llm/flows.js +11 -0
- package/dist/commands/llm/flows.js.map +1 -0
- package/dist/commands/llm/interactions.d.ts +7 -0
- package/dist/commands/llm/interactions.d.ts.map +1 -0
- package/dist/commands/llm/interactions.js +11 -0
- package/dist/commands/llm/interactions.js.map +1 -0
- package/dist/commands/llm/modules.d.ts +7 -0
- package/dist/commands/llm/modules.d.ts.map +1 -0
- package/dist/commands/llm/modules.js +11 -0
- package/dist/commands/llm/modules.js.map +1 -0
- package/dist/commands/llm/relationships.d.ts +7 -0
- package/dist/commands/llm/relationships.d.ts.map +1 -0
- package/dist/commands/llm/relationships.js +11 -0
- package/dist/commands/llm/relationships.js.map +1 -0
- package/dist/commands/modules/assign.d.ts +14 -0
- package/dist/commands/modules/assign.d.ts.map +1 -0
- package/dist/commands/modules/assign.js +54 -0
- package/dist/commands/modules/assign.js.map +1 -0
- package/dist/commands/modules/create.d.ts +16 -0
- package/dist/commands/modules/create.d.ts.map +1 -0
- package/dist/commands/modules/create.js +37 -0
- package/dist/commands/modules/create.js.map +1 -0
- package/dist/commands/modules/delete.d.ts +14 -0
- package/dist/commands/modules/delete.d.ts.map +1 -0
- package/dist/commands/modules/delete.js +54 -0
- package/dist/commands/modules/delete.js.map +1 -0
- package/dist/commands/modules/generate.d.ts +84 -0
- package/dist/commands/modules/generate.d.ts.map +1 -0
- package/dist/commands/modules/generate.js +1234 -0
- package/dist/commands/modules/generate.js.map +1 -0
- package/dist/commands/modules/index.d.ts +2 -0
- package/dist/commands/modules/index.d.ts.map +1 -0
- package/dist/commands/modules/index.js +2 -0
- package/dist/commands/modules/index.js.map +1 -0
- package/dist/commands/modules/list.d.ts +13 -0
- package/dist/commands/modules/list.d.ts.map +1 -0
- package/dist/commands/modules/list.js +92 -0
- package/dist/commands/modules/list.js.map +1 -0
- package/dist/commands/modules/prune.d.ts +10 -0
- package/dist/commands/modules/prune.d.ts.map +1 -0
- package/dist/commands/modules/prune.js +23 -0
- package/dist/commands/modules/prune.js.map +1 -0
- package/dist/commands/modules/show.d.ts +15 -0
- package/dist/commands/modules/show.d.ts.map +1 -0
- package/dist/commands/modules/show.js +95 -0
- package/dist/commands/modules/show.js.map +1 -0
- package/dist/commands/modules/unassign.d.ts +13 -0
- package/dist/commands/modules/unassign.d.ts.map +1 -0
- package/dist/commands/modules/unassign.js +49 -0
- package/dist/commands/modules/unassign.js.map +1 -0
- package/dist/commands/modules/update.d.ts +15 -0
- package/dist/commands/modules/update.d.ts.map +1 -0
- package/dist/commands/modules/update.js +50 -0
- package/dist/commands/modules/update.js.map +1 -0
- package/dist/commands/modules/verify.d.ts +18 -0
- package/dist/commands/modules/verify.d.ts.map +1 -0
- package/dist/commands/modules/verify.js +114 -0
- package/dist/commands/modules/verify.js.map +1 -0
- package/dist/commands/overview.d.ts +12 -0
- package/dist/commands/overview.d.ts.map +1 -0
- package/dist/commands/overview.js +219 -0
- package/dist/commands/overview.js.map +1 -0
- package/dist/commands/parse.d.ts +30 -0
- package/dist/commands/parse.d.ts.map +1 -0
- package/dist/commands/parse.js +211 -0
- package/dist/commands/parse.js.map +1 -0
- package/dist/commands/process-groups/index.d.ts +2 -0
- package/dist/commands/process-groups/index.d.ts.map +1 -0
- package/dist/commands/process-groups/index.js +2 -0
- package/dist/commands/process-groups/index.js.map +1 -0
- package/dist/commands/process-groups/list.d.ts +11 -0
- package/dist/commands/process-groups/list.d.ts.map +1 -0
- package/dist/commands/process-groups/list.js +98 -0
- package/dist/commands/process-groups/list.js.map +1 -0
- package/dist/commands/relationships/annotate.d.ts +27 -0
- package/dist/commands/relationships/annotate.d.ts.map +1 -0
- package/dist/commands/relationships/annotate.js +453 -0
- package/dist/commands/relationships/annotate.js.map +1 -0
- package/dist/commands/relationships/index.d.ts +2 -0
- package/dist/commands/relationships/index.d.ts.map +1 -0
- package/dist/commands/relationships/index.js +2 -0
- package/dist/commands/relationships/index.js.map +1 -0
- package/dist/commands/relationships/list.d.ts +18 -0
- package/dist/commands/relationships/list.d.ts.map +1 -0
- package/dist/commands/relationships/list.js +147 -0
- package/dist/commands/relationships/list.js.map +1 -0
- package/dist/commands/relationships/next.d.ts +17 -0
- package/dist/commands/relationships/next.d.ts.map +1 -0
- package/dist/commands/relationships/next.js +178 -0
- package/dist/commands/relationships/next.js.map +1 -0
- package/dist/commands/relationships/set.d.ts +19 -0
- package/dist/commands/relationships/set.d.ts.map +1 -0
- package/dist/commands/relationships/set.js +65 -0
- package/dist/commands/relationships/set.js.map +1 -0
- package/dist/commands/relationships/show.d.ts +13 -0
- package/dist/commands/relationships/show.d.ts.map +1 -0
- package/dist/commands/relationships/show.js +59 -0
- package/dist/commands/relationships/show.js.map +1 -0
- package/dist/commands/relationships/unset.d.ts +16 -0
- package/dist/commands/relationships/unset.d.ts.map +1 -0
- package/dist/commands/relationships/unset.js +62 -0
- package/dist/commands/relationships/unset.js.map +1 -0
- package/dist/commands/relationships/verify.d.ts +24 -0
- package/dist/commands/relationships/verify.d.ts.map +1 -0
- package/dist/commands/relationships/verify.js +328 -0
- package/dist/commands/relationships/verify.js.map +1 -0
- package/dist/commands/stats.d.ts +11 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +207 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/symbols/annotate.d.ts +32 -0
- package/dist/commands/symbols/annotate.d.ts.map +1 -0
- package/dist/commands/symbols/annotate.js +862 -0
- package/dist/commands/symbols/annotate.js.map +1 -0
- package/dist/commands/symbols/deps.d.ts +18 -0
- package/dist/commands/symbols/deps.d.ts.map +1 -0
- package/dist/commands/symbols/deps.js +104 -0
- package/dist/commands/symbols/deps.js.map +1 -0
- package/dist/commands/symbols/index.d.ts +2 -0
- package/dist/commands/symbols/index.d.ts.map +1 -0
- package/dist/commands/symbols/index.js +2 -0
- package/dist/commands/symbols/index.js.map +1 -0
- package/dist/commands/symbols/list.d.ts +17 -0
- package/dist/commands/symbols/list.d.ts.map +1 -0
- package/dist/commands/symbols/list.js +136 -0
- package/dist/commands/symbols/list.js.map +1 -0
- package/dist/commands/symbols/next.d.ts +15 -0
- package/dist/commands/symbols/next.d.ts.map +1 -0
- package/dist/commands/symbols/next.js +147 -0
- package/dist/commands/symbols/next.js.map +1 -0
- package/dist/commands/symbols/prereqs.d.ts +18 -0
- package/dist/commands/symbols/prereqs.d.ts.map +1 -0
- package/dist/commands/symbols/prereqs.js +107 -0
- package/dist/commands/symbols/prereqs.js.map +1 -0
- package/dist/commands/symbols/ready.d.ts +17 -0
- package/dist/commands/symbols/ready.d.ts.map +1 -0
- package/dist/commands/symbols/ready.js +126 -0
- package/dist/commands/symbols/ready.js.map +1 -0
- package/dist/commands/symbols/set.d.ts +27 -0
- package/dist/commands/symbols/set.d.ts.map +1 -0
- package/dist/commands/symbols/set.js +241 -0
- package/dist/commands/symbols/set.js.map +1 -0
- package/dist/commands/symbols/show.d.ts +19 -0
- package/dist/commands/symbols/show.d.ts.map +1 -0
- package/dist/commands/symbols/show.js +182 -0
- package/dist/commands/symbols/show.js.map +1 -0
- package/dist/commands/symbols/understood.d.ts +15 -0
- package/dist/commands/symbols/understood.d.ts.map +1 -0
- package/dist/commands/symbols/understood.js +101 -0
- package/dist/commands/symbols/understood.js.map +1 -0
- package/dist/commands/symbols/unset.d.ts +16 -0
- package/dist/commands/symbols/unset.d.ts.map +1 -0
- package/dist/commands/symbols/unset.js +48 -0
- package/dist/commands/symbols/unset.js.map +1 -0
- package/dist/commands/symbols/verify.d.ts +25 -0
- package/dist/commands/symbols/verify.d.ts.map +1 -0
- package/dist/commands/symbols/verify.js +360 -0
- package/dist/commands/symbols/verify.js.map +1 -0
- package/dist/db/connection.d.ts +14 -0
- package/dist/db/connection.d.ts.map +1 -0
- package/dist/db/connection.js +37 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/database-facade.d.ts +125 -0
- package/dist/db/database-facade.d.ts.map +1 -0
- package/dist/db/database-facade.js +347 -0
- package/dist/db/database-facade.js.map +1 -0
- package/dist/db/database.d.ts +9 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/database.js +11 -0
- package/dist/db/database.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +11 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/repositories/_shared/call-graph-query.d.ts +10 -0
- package/dist/db/repositories/_shared/call-graph-query.d.ts.map +1 -0
- package/dist/db/repositories/_shared/call-graph-query.js +59 -0
- package/dist/db/repositories/_shared/call-graph-query.js.map +1 -0
- package/dist/db/repositories/call-graph-service.d.ts +28 -0
- package/dist/db/repositories/call-graph-service.d.ts.map +1 -0
- package/dist/db/repositories/call-graph-service.js +223 -0
- package/dist/db/repositories/call-graph-service.js.map +1 -0
- package/dist/db/repositories/definition-repository.d.ts +99 -0
- package/dist/db/repositories/definition-repository.d.ts.map +1 -0
- package/dist/db/repositories/definition-repository.js +317 -0
- package/dist/db/repositories/definition-repository.js.map +1 -0
- package/dist/db/repositories/dependency-repository.d.ts +78 -0
- package/dist/db/repositories/dependency-repository.d.ts.map +1 -0
- package/dist/db/repositories/dependency-repository.js +446 -0
- package/dist/db/repositories/dependency-repository.js.map +1 -0
- package/dist/db/repositories/domain-repository.d.ts +97 -0
- package/dist/db/repositories/domain-repository.d.ts.map +1 -0
- package/dist/db/repositories/domain-repository.js +261 -0
- package/dist/db/repositories/domain-repository.js.map +1 -0
- package/dist/db/repositories/feature-repository.d.ts +64 -0
- package/dist/db/repositories/feature-repository.d.ts.map +1 -0
- package/dist/db/repositories/feature-repository.js +189 -0
- package/dist/db/repositories/feature-repository.js.map +1 -0
- package/dist/db/repositories/file-repository.d.ts +67 -0
- package/dist/db/repositories/file-repository.d.ts.map +1 -0
- package/dist/db/repositories/file-repository.js +179 -0
- package/dist/db/repositories/file-repository.js.map +1 -0
- package/dist/db/repositories/flow-repository.d.ts +172 -0
- package/dist/db/repositories/flow-repository.d.ts.map +1 -0
- package/dist/db/repositories/flow-repository.js +599 -0
- package/dist/db/repositories/flow-repository.js.map +1 -0
- package/dist/db/repositories/graph-repository.d.ts +93 -0
- package/dist/db/repositories/graph-repository.d.ts.map +1 -0
- package/dist/db/repositories/graph-repository.js +413 -0
- package/dist/db/repositories/graph-repository.js.map +1 -0
- package/dist/db/repositories/index.d.ts +20 -0
- package/dist/db/repositories/index.d.ts.map +1 -0
- package/dist/db/repositories/index.js +15 -0
- package/dist/db/repositories/index.js.map +1 -0
- package/dist/db/repositories/interaction-analysis.d.ts +78 -0
- package/dist/db/repositories/interaction-analysis.d.ts.map +1 -0
- package/dist/db/repositories/interaction-analysis.js +340 -0
- package/dist/db/repositories/interaction-analysis.js.map +1 -0
- package/dist/db/repositories/interaction-repository.d.ts +145 -0
- package/dist/db/repositories/interaction-repository.d.ts.map +1 -0
- package/dist/db/repositories/interaction-repository.js +395 -0
- package/dist/db/repositories/interaction-repository.js.map +1 -0
- package/dist/db/repositories/metadata-repository.d.ts +110 -0
- package/dist/db/repositories/metadata-repository.d.ts.map +1 -0
- package/dist/db/repositories/metadata-repository.js +294 -0
- package/dist/db/repositories/metadata-repository.js.map +1 -0
- package/dist/db/repositories/module-repository.d.ts +162 -0
- package/dist/db/repositories/module-repository.d.ts.map +1 -0
- package/dist/db/repositories/module-repository.js +519 -0
- package/dist/db/repositories/module-repository.js.map +1 -0
- package/dist/db/repositories/relationship-repository.d.ts +98 -0
- package/dist/db/repositories/relationship-repository.d.ts.map +1 -0
- package/dist/db/repositories/relationship-repository.js +421 -0
- package/dist/db/repositories/relationship-repository.js.map +1 -0
- package/dist/db/schema-manager.d.ts +31 -0
- package/dist/db/schema-manager.d.ts.map +1 -0
- package/dist/db/schema-manager.js +398 -0
- package/dist/db/schema-manager.js.map +1 -0
- package/dist/db/schema.d.ts +404 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +234 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/utils/tree-builder.d.ts +25 -0
- package/dist/db/utils/tree-builder.d.ts.map +1 -0
- package/dist/db/utils/tree-builder.js +38 -0
- package/dist/db/utils/tree-builder.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/ast-parser.d.ts +23 -0
- package/dist/parser/ast-parser.d.ts.map +1 -0
- package/dist/parser/ast-parser.js +65 -0
- package/dist/parser/ast-parser.js.map +1 -0
- package/dist/parser/definition-extractor.d.ts +29 -0
- package/dist/parser/definition-extractor.d.ts.map +1 -0
- package/dist/parser/definition-extractor.js +379 -0
- package/dist/parser/definition-extractor.js.map +1 -0
- package/dist/parser/reference-extractor.d.ts +72 -0
- package/dist/parser/reference-extractor.d.ts.map +1 -0
- package/dist/parser/reference-extractor.js +759 -0
- package/dist/parser/reference-extractor.js.map +1 -0
- package/dist/utils/file-scanner.d.ts +6 -0
- package/dist/utils/file-scanner.d.ts.map +1 -0
- package/dist/utils/file-scanner.js +33 -0
- package/dist/utils/file-scanner.js.map +1 -0
- package/dist/web/api-transforms.d.ts +4 -0
- package/dist/web/api-transforms.d.ts.map +1 -0
- package/dist/web/api-transforms.js +4 -0
- package/dist/web/api-transforms.js.map +1 -0
- package/dist/web/server.d.ts +16 -0
- package/dist/web/server.d.ts.map +1 -0
- package/dist/web/server.js +229 -0
- package/dist/web/server.js.map +1 -0
- package/dist/web/server.test.d.ts +2 -0
- package/dist/web/server.test.d.ts.map +1 -0
- package/dist/web/server.test.js +505 -0
- package/dist/web/server.test.js.map +1 -0
- package/dist/web/transforms/flow-transforms.d.ts +117 -0
- package/dist/web/transforms/flow-transforms.d.ts.map +1 -0
- package/dist/web/transforms/flow-transforms.js +202 -0
- package/dist/web/transforms/flow-transforms.js.map +1 -0
- package/dist/web/transforms/index.d.ts +4 -0
- package/dist/web/transforms/index.d.ts.map +1 -0
- package/dist/web/transforms/index.js +4 -0
- package/dist/web/transforms/index.js.map +1 -0
- package/dist/web/transforms/module-transforms.d.ts +42 -0
- package/dist/web/transforms/module-transforms.d.ts.map +1 -0
- package/dist/web/transforms/module-transforms.js +64 -0
- package/dist/web/transforms/module-transforms.js.map +1 -0
- package/dist/web/transforms/symbol-transforms.d.ts +31 -0
- package/dist/web/transforms/symbol-transforms.d.ts.map +1 -0
- package/dist/web/transforms/symbol-transforms.js +95 -0
- package/dist/web/transforms/symbol-transforms.js.map +1 -0
- package/package.json +96 -0
- package/ui/dist/assets/index-DP3dRMlh.js +268 -0
- package/ui/dist/assets/index-DP3dRMlh.js.map +1 -0
- package/ui/dist/assets/index-Db204Xn1.css +1 -0
- package/ui/dist/index.html +67 -0
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { LlmFlags, SharedFlags, readSourceAsString } from '../_shared/index.js';
|
|
4
|
+
import { BaseLlmCommand } from '../llm/_shared/base-llm-command.js';
|
|
5
|
+
import { filterCoverageForAspects, formatFinalSummary, formatIterationResults, } from '../llm/_shared/coverage.js';
|
|
6
|
+
import { parseCombinedCsv } from '../llm/_shared/csv.js';
|
|
7
|
+
import { completeWithLogging } from '../llm/_shared/llm-utils.js';
|
|
8
|
+
import { buildSystemPrompt, buildUserPromptEnhanced, } from '../llm/_shared/prompts.js';
|
|
9
|
+
import { detectImpurePatterns } from '../llm/_shared/pure-check.js';
|
|
10
|
+
/**
|
|
11
|
+
* Tracks failed relationship annotations for retry.
|
|
12
|
+
*/
|
|
13
|
+
class RelationshipRetryQueue {
|
|
14
|
+
failures = new Map();
|
|
15
|
+
key(fromId, toId) {
|
|
16
|
+
return `${fromId}:${toId}`;
|
|
17
|
+
}
|
|
18
|
+
add(fromId, toId, error) {
|
|
19
|
+
const k = this.key(fromId, toId);
|
|
20
|
+
const existing = this.failures.get(k);
|
|
21
|
+
this.failures.set(k, {
|
|
22
|
+
fromId,
|
|
23
|
+
toId,
|
|
24
|
+
attempts: (existing?.attempts ?? 0) + 1,
|
|
25
|
+
error,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getRetryable(maxAttempts = 3) {
|
|
29
|
+
const result = [];
|
|
30
|
+
for (const entry of this.failures.values()) {
|
|
31
|
+
if (entry.attempts < maxAttempts) {
|
|
32
|
+
result.push({ fromId: entry.fromId, toId: entry.toId });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
clear() {
|
|
38
|
+
this.failures.clear();
|
|
39
|
+
}
|
|
40
|
+
get size() {
|
|
41
|
+
return this.failures.size;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export default class Annotate extends BaseLlmCommand {
|
|
45
|
+
static description = 'Annotate symbols using an LLM in iterative batches';
|
|
46
|
+
static examples = [
|
|
47
|
+
'<%= config.bin %> symbols annotate --aspect purpose',
|
|
48
|
+
'<%= config.bin %> symbols annotate --aspect purpose --aspect domain',
|
|
49
|
+
'<%= config.bin %> symbols annotate --aspect purpose --model gpt4o --batch-size 10',
|
|
50
|
+
'<%= config.bin %> symbols annotate --aspect purpose --dry-run',
|
|
51
|
+
'<%= config.bin %> symbols annotate --aspect purpose --kind function --max-iterations 5',
|
|
52
|
+
];
|
|
53
|
+
static flags = {
|
|
54
|
+
database: SharedFlags.database,
|
|
55
|
+
json: SharedFlags.json,
|
|
56
|
+
...LlmFlags,
|
|
57
|
+
force: Flags.boolean({
|
|
58
|
+
description: 'Annotate symbols even if dependencies are not annotated',
|
|
59
|
+
default: false,
|
|
60
|
+
}),
|
|
61
|
+
aspect: Flags.string({
|
|
62
|
+
char: 'a',
|
|
63
|
+
description: 'Metadata key to annotate (can be repeated)',
|
|
64
|
+
required: true,
|
|
65
|
+
multiple: true,
|
|
66
|
+
}),
|
|
67
|
+
'batch-size': Flags.integer({
|
|
68
|
+
char: 'b',
|
|
69
|
+
description: 'Number of symbols per LLM call',
|
|
70
|
+
default: 5,
|
|
71
|
+
}),
|
|
72
|
+
'max-iterations': Flags.integer({
|
|
73
|
+
description: 'Maximum iterations (0 = unlimited)',
|
|
74
|
+
default: 0,
|
|
75
|
+
}),
|
|
76
|
+
kind: Flags.string({
|
|
77
|
+
char: 'k',
|
|
78
|
+
description: 'Filter by symbol kind',
|
|
79
|
+
}),
|
|
80
|
+
file: Flags.string({
|
|
81
|
+
char: 'f',
|
|
82
|
+
description: 'Filter by file path pattern',
|
|
83
|
+
}),
|
|
84
|
+
exclude: Flags.string({
|
|
85
|
+
char: 'x',
|
|
86
|
+
description: 'Glob pattern for files to exclude (e.g., **/*.test.ts)',
|
|
87
|
+
}),
|
|
88
|
+
'relationship-limit': Flags.integer({
|
|
89
|
+
description: 'Max relationships per symbol (0 = no limit)',
|
|
90
|
+
default: 50,
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
async execute(ctx, flags) {
|
|
94
|
+
const { db, isJson, dryRun, model } = ctx;
|
|
95
|
+
const aspects = flags.aspect;
|
|
96
|
+
const primaryAspect = aspects[0]; // Use first aspect for readiness check
|
|
97
|
+
const batchSize = flags['batch-size'];
|
|
98
|
+
const maxIterations = flags['max-iterations'];
|
|
99
|
+
const showLlmRequests = ctx.llmOptions.showLlmRequests;
|
|
100
|
+
const showLlmResponses = ctx.llmOptions.showLlmResponses;
|
|
101
|
+
const forceMode = flags.force;
|
|
102
|
+
const excludePattern = flags.exclude;
|
|
103
|
+
const relationshipLimit = flags['relationship-limit'];
|
|
104
|
+
// Build system prompt once
|
|
105
|
+
const systemPrompt = buildSystemPrompt(aspects);
|
|
106
|
+
// Track failed relationship annotations for retry
|
|
107
|
+
const retryQueue = new RelationshipRetryQueue();
|
|
108
|
+
// Tracking
|
|
109
|
+
let iteration = 0;
|
|
110
|
+
let totalAnnotations = 0;
|
|
111
|
+
let totalRelationshipAnnotations = 0;
|
|
112
|
+
let totalErrors = 0;
|
|
113
|
+
const jsonOutput = {
|
|
114
|
+
iterations: [],
|
|
115
|
+
summary: {
|
|
116
|
+
totalIterations: 0,
|
|
117
|
+
totalAnnotations: 0,
|
|
118
|
+
totalRelationshipAnnotations: 0,
|
|
119
|
+
totalErrors: 0,
|
|
120
|
+
coverage: [],
|
|
121
|
+
relationshipCoverage: { annotated: 0, total: 0, percentage: 0 },
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
// Annotate has unique header logic (includes aspects, batch size)
|
|
125
|
+
if (!isJson) {
|
|
126
|
+
this.log(chalk.bold(`LLM Annotation: ${aspects.join(', ')}`));
|
|
127
|
+
this.log(chalk.gray(`Model: ${model}, Batch size: ${batchSize}`));
|
|
128
|
+
if (forceMode) {
|
|
129
|
+
this.log(chalk.yellow('FORCE MODE - ignoring dependency ordering'));
|
|
130
|
+
}
|
|
131
|
+
if (excludePattern) {
|
|
132
|
+
this.log(chalk.gray(`Excluding files matching: ${excludePattern}`));
|
|
133
|
+
}
|
|
134
|
+
if (dryRun) {
|
|
135
|
+
this.log(chalk.yellow('DRY RUN - annotations will not be persisted'));
|
|
136
|
+
}
|
|
137
|
+
this.log('');
|
|
138
|
+
}
|
|
139
|
+
while (true) {
|
|
140
|
+
iteration++;
|
|
141
|
+
// Check max iterations
|
|
142
|
+
if (maxIterations > 0 && iteration > maxIterations) {
|
|
143
|
+
if (!isJson) {
|
|
144
|
+
this.log(chalk.yellow(`Reached maximum iterations (${maxIterations})`));
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
// Get batch of symbols to annotate
|
|
149
|
+
let symbols;
|
|
150
|
+
let totalRemaining;
|
|
151
|
+
let blockedCount;
|
|
152
|
+
if (forceMode) {
|
|
153
|
+
// Force mode: get all unannotated symbols regardless of dependencies
|
|
154
|
+
const result = db.graph.getAllUnannotated(primaryAspect, {
|
|
155
|
+
limit: batchSize,
|
|
156
|
+
kind: flags.kind,
|
|
157
|
+
filePattern: flags.file,
|
|
158
|
+
excludePattern: excludePattern,
|
|
159
|
+
});
|
|
160
|
+
symbols = result.symbols;
|
|
161
|
+
totalRemaining = result.total;
|
|
162
|
+
blockedCount = 0; // No blocking in force mode
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Normal mode: only get symbols with all dependencies annotated
|
|
166
|
+
const result = db.dependencies.getReadySymbols(primaryAspect, {
|
|
167
|
+
limit: batchSize,
|
|
168
|
+
kind: flags.kind,
|
|
169
|
+
filePattern: flags.file,
|
|
170
|
+
});
|
|
171
|
+
symbols = result.symbols;
|
|
172
|
+
totalRemaining = result.totalReady + result.remaining;
|
|
173
|
+
blockedCount = result.remaining;
|
|
174
|
+
}
|
|
175
|
+
if (symbols.length === 0) {
|
|
176
|
+
if (totalRemaining === 0) {
|
|
177
|
+
if (!isJson) {
|
|
178
|
+
this.log(chalk.green(`All symbols have '${primaryAspect}' annotated!`));
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (blockedCount > 0 && !forceMode) {
|
|
183
|
+
// Check for circular dependencies
|
|
184
|
+
const cycles = db.graph.findCycles(primaryAspect);
|
|
185
|
+
if (cycles.length === 0) {
|
|
186
|
+
// No cycles found - truly blocked
|
|
187
|
+
if (!isJson) {
|
|
188
|
+
this.log(chalk.yellow('No symbols ready for annotation.'));
|
|
189
|
+
this.log(chalk.gray(`${blockedCount} symbols have unmet dependencies.`));
|
|
190
|
+
this.log(chalk.gray('Use --force to annotate them anyway.'));
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
// Process circular dependency groups
|
|
195
|
+
if (!isJson) {
|
|
196
|
+
this.log('');
|
|
197
|
+
this.log(chalk.bold(`Found ${cycles.length} circular dependency group(s). Processing as batches...`));
|
|
198
|
+
}
|
|
199
|
+
for (const cycle of cycles) {
|
|
200
|
+
// Get full symbol info for cycle members
|
|
201
|
+
const cycleSymbols = cycle
|
|
202
|
+
.map((id) => db.definitions.getById(id))
|
|
203
|
+
.filter((def) => def !== null)
|
|
204
|
+
.map((def) => ({
|
|
205
|
+
id: def.id,
|
|
206
|
+
name: def.name,
|
|
207
|
+
kind: def.kind,
|
|
208
|
+
filePath: def.filePath,
|
|
209
|
+
line: def.line,
|
|
210
|
+
endLine: def.endLine,
|
|
211
|
+
dependencyCount: 0,
|
|
212
|
+
}));
|
|
213
|
+
if (cycleSymbols.length === 0)
|
|
214
|
+
continue;
|
|
215
|
+
const cycleNames = cycleSymbols.map((s) => s.name).join(', ');
|
|
216
|
+
if (!isJson) {
|
|
217
|
+
this.log(chalk.gray(` Processing cycle: ${cycleNames} (${cycleSymbols.length} symbols)`));
|
|
218
|
+
}
|
|
219
|
+
// Enhance symbols with source code
|
|
220
|
+
const enhancedCycleSymbols = await this.enhanceSymbols(db, cycleSymbols, aspects, relationshipLimit);
|
|
221
|
+
// Get current coverage for the prompt
|
|
222
|
+
const cycleCoverage = db.metadata.getAspectCoverage({
|
|
223
|
+
kind: flags.kind,
|
|
224
|
+
filePattern: flags.file,
|
|
225
|
+
});
|
|
226
|
+
const cycleTotalSymbols = db.metadata.getFilteredCount({
|
|
227
|
+
kind: flags.kind,
|
|
228
|
+
filePattern: flags.file,
|
|
229
|
+
});
|
|
230
|
+
const coverage = filterCoverageForAspects(cycleCoverage, aspects, cycleTotalSymbols);
|
|
231
|
+
// Build prompt with cycle context
|
|
232
|
+
const symbolContexts = enhancedCycleSymbols.map((s) => ({
|
|
233
|
+
id: s.id,
|
|
234
|
+
name: s.name,
|
|
235
|
+
kind: s.kind,
|
|
236
|
+
filePath: s.filePath,
|
|
237
|
+
line: s.line,
|
|
238
|
+
endLine: s.endLine,
|
|
239
|
+
sourceCode: s.sourceCode,
|
|
240
|
+
isExported: s.isExported,
|
|
241
|
+
dependencies: s.dependencies,
|
|
242
|
+
relationshipsToAnnotate: s.relationshipsToAnnotate,
|
|
243
|
+
incomingDependencies: s.incomingDependencies,
|
|
244
|
+
incomingDependencyCount: s.incomingDependencyCount,
|
|
245
|
+
}));
|
|
246
|
+
// Build user prompt with cycle note
|
|
247
|
+
const basePrompt = buildUserPromptEnhanced(symbolContexts, aspects, coverage);
|
|
248
|
+
const cycleNote = '\nNote: These symbols have circular dependencies - they reference each other. Annotate them based on their collective purpose and individual contributions.\n';
|
|
249
|
+
const userPrompt = cycleNote + basePrompt;
|
|
250
|
+
// Call LLM
|
|
251
|
+
let response;
|
|
252
|
+
try {
|
|
253
|
+
response = await completeWithLogging({
|
|
254
|
+
model,
|
|
255
|
+
systemPrompt,
|
|
256
|
+
userPrompt,
|
|
257
|
+
temperature: 0,
|
|
258
|
+
command: this,
|
|
259
|
+
isJson,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
264
|
+
if (!isJson) {
|
|
265
|
+
this.log(chalk.red(` LLM error for cycle: ${message}`));
|
|
266
|
+
}
|
|
267
|
+
totalErrors++;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
// Parse and persist results
|
|
271
|
+
const parseResult = parseCombinedCsv(response);
|
|
272
|
+
const validSymbolIds = new Set(enhancedCycleSymbols.map((s) => s.id));
|
|
273
|
+
// Build valid relationship map for cycle symbols
|
|
274
|
+
const cycleValidRelationships = new Map();
|
|
275
|
+
for (const s of enhancedCycleSymbols) {
|
|
276
|
+
const toIds = new Set();
|
|
277
|
+
for (const rel of s.relationshipsToAnnotate) {
|
|
278
|
+
toIds.add(rel.toId);
|
|
279
|
+
}
|
|
280
|
+
cycleValidRelationships.set(s.id, toIds);
|
|
281
|
+
}
|
|
282
|
+
let cycleAnnotations = 0;
|
|
283
|
+
let cycleRelAnnotations = 0;
|
|
284
|
+
// Build source code and dependency maps for cycle symbols
|
|
285
|
+
const cycleSourceCodeById = new Map(symbolContexts.map((s) => [s.id, s.sourceCode]));
|
|
286
|
+
const cycleDepsById = new Map(enhancedCycleSymbols.map((s) => [s.id, s.dependencies]));
|
|
287
|
+
// Process symbol annotations
|
|
288
|
+
for (const row of parseResult.symbols) {
|
|
289
|
+
if (!validSymbolIds.has(row.symbolId))
|
|
290
|
+
continue;
|
|
291
|
+
if (!aspects.includes(row.aspect))
|
|
292
|
+
continue;
|
|
293
|
+
let value = row.value;
|
|
294
|
+
const validationError = this.validateValue(row.aspect, value, cycleSourceCodeById.get(row.symbolId), cycleDepsById.get(row.symbolId));
|
|
295
|
+
if (validationError?.startsWith('overridden')) {
|
|
296
|
+
if (!isJson && ctx.verbose) {
|
|
297
|
+
this.log(chalk.yellow(` Pure override for #${row.symbolId}: ${validationError}`));
|
|
298
|
+
}
|
|
299
|
+
value = 'false';
|
|
300
|
+
}
|
|
301
|
+
else if (validationError) {
|
|
302
|
+
totalErrors++;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (!dryRun) {
|
|
306
|
+
db.metadata.set(row.symbolId, row.aspect, value);
|
|
307
|
+
}
|
|
308
|
+
cycleAnnotations++;
|
|
309
|
+
totalAnnotations++;
|
|
310
|
+
}
|
|
311
|
+
// Process relationship annotations
|
|
312
|
+
for (const row of parseResult.relationships) {
|
|
313
|
+
const fromId = row.fromId;
|
|
314
|
+
const toId = row.toId;
|
|
315
|
+
if (!validSymbolIds.has(fromId))
|
|
316
|
+
continue;
|
|
317
|
+
const toIds = cycleValidRelationships.get(fromId);
|
|
318
|
+
if (!toIds || !toIds.has(toId))
|
|
319
|
+
continue;
|
|
320
|
+
if (!row.value || row.value.length < 5) {
|
|
321
|
+
totalErrors++;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (!dryRun) {
|
|
325
|
+
db.relationships.set(fromId, toId, row.value);
|
|
326
|
+
}
|
|
327
|
+
cycleRelAnnotations++;
|
|
328
|
+
totalRelationshipAnnotations++;
|
|
329
|
+
}
|
|
330
|
+
if (!isJson) {
|
|
331
|
+
this.log(chalk.green(` ✓ Annotated ${cycleAnnotations} symbols, ${cycleRelAnnotations} relationships`));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// Continue the loop to process any newly unblocked symbols
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
// Enhance symbols with source code and dependency context
|
|
340
|
+
const enhancedSymbols = await this.enhanceSymbols(db, symbols, aspects, relationshipLimit);
|
|
341
|
+
// Get current coverage for the prompt
|
|
342
|
+
const allCoverage = db.metadata.getAspectCoverage({
|
|
343
|
+
kind: flags.kind,
|
|
344
|
+
filePattern: flags.file,
|
|
345
|
+
});
|
|
346
|
+
const totalSymbols = db.metadata.getFilteredCount({
|
|
347
|
+
kind: flags.kind,
|
|
348
|
+
filePattern: flags.file,
|
|
349
|
+
});
|
|
350
|
+
const coverage = filterCoverageForAspects(allCoverage, aspects, totalSymbols);
|
|
351
|
+
// Build prompt
|
|
352
|
+
const symbolContexts = enhancedSymbols.map((s) => ({
|
|
353
|
+
id: s.id,
|
|
354
|
+
name: s.name,
|
|
355
|
+
kind: s.kind,
|
|
356
|
+
filePath: s.filePath,
|
|
357
|
+
line: s.line,
|
|
358
|
+
endLine: s.endLine,
|
|
359
|
+
sourceCode: s.sourceCode,
|
|
360
|
+
isExported: s.isExported,
|
|
361
|
+
dependencies: s.dependencies,
|
|
362
|
+
relationshipsToAnnotate: s.relationshipsToAnnotate,
|
|
363
|
+
incomingDependencies: s.incomingDependencies,
|
|
364
|
+
incomingDependencyCount: s.incomingDependencyCount,
|
|
365
|
+
}));
|
|
366
|
+
const userPrompt = buildUserPromptEnhanced(symbolContexts, aspects, coverage);
|
|
367
|
+
// Show LLM request if requested
|
|
368
|
+
if (showLlmRequests) {
|
|
369
|
+
this.log('');
|
|
370
|
+
this.log(chalk.bold.cyan('═'.repeat(60)));
|
|
371
|
+
this.log(chalk.bold.cyan('LLM REQUEST'));
|
|
372
|
+
this.log(chalk.bold.cyan('═'.repeat(60)));
|
|
373
|
+
this.log('');
|
|
374
|
+
this.log(chalk.bold('SYSTEM PROMPT:'));
|
|
375
|
+
this.log(chalk.dim('─'.repeat(40)));
|
|
376
|
+
this.log(systemPrompt);
|
|
377
|
+
this.log('');
|
|
378
|
+
this.log(chalk.bold('USER PROMPT:'));
|
|
379
|
+
this.log(chalk.dim('─'.repeat(40)));
|
|
380
|
+
this.log(userPrompt);
|
|
381
|
+
this.log(chalk.bold.cyan('═'.repeat(60)));
|
|
382
|
+
this.log('');
|
|
383
|
+
}
|
|
384
|
+
// Call LLM
|
|
385
|
+
let response;
|
|
386
|
+
try {
|
|
387
|
+
response = await completeWithLogging({
|
|
388
|
+
model,
|
|
389
|
+
systemPrompt,
|
|
390
|
+
userPrompt,
|
|
391
|
+
temperature: 0,
|
|
392
|
+
command: this,
|
|
393
|
+
isJson,
|
|
394
|
+
iteration: { current: iteration, max: maxIterations },
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
399
|
+
this.error(chalk.red(`LLM API error: ${message}`));
|
|
400
|
+
}
|
|
401
|
+
// Show LLM response if requested
|
|
402
|
+
if (showLlmResponses) {
|
|
403
|
+
this.log('');
|
|
404
|
+
this.log(chalk.bold.green('═'.repeat(60)));
|
|
405
|
+
this.log(chalk.bold.green('LLM RESPONSE'));
|
|
406
|
+
this.log(chalk.bold.green('═'.repeat(60)));
|
|
407
|
+
this.log('');
|
|
408
|
+
this.log(response);
|
|
409
|
+
this.log('');
|
|
410
|
+
this.log(chalk.bold.green('═'.repeat(60)));
|
|
411
|
+
this.log('');
|
|
412
|
+
}
|
|
413
|
+
// Parse combined CSV response
|
|
414
|
+
const parseResult = parseCombinedCsv(response);
|
|
415
|
+
// Process results
|
|
416
|
+
const iterationResults = [];
|
|
417
|
+
const iterationRelResults = [];
|
|
418
|
+
const validSymbolIds = new Set(enhancedSymbols.map((s) => s.id));
|
|
419
|
+
const symbolNameById = new Map(enhancedSymbols.map((s) => [s.id, s.name]));
|
|
420
|
+
// Build source code and dependency maps for pure validation
|
|
421
|
+
const sourceCodeById = new Map(symbolContexts.map((s) => [s.id, s.sourceCode]));
|
|
422
|
+
const depsById = new Map(enhancedSymbols.map((s) => [s.id, s.dependencies]));
|
|
423
|
+
// Build valid relationship map (from_id -> Set of valid to_ids)
|
|
424
|
+
const validRelationships = new Map();
|
|
425
|
+
for (const s of enhancedSymbols) {
|
|
426
|
+
const toMap = new Map();
|
|
427
|
+
for (const rel of s.relationshipsToAnnotate) {
|
|
428
|
+
toMap.set(rel.toId, rel.toName);
|
|
429
|
+
}
|
|
430
|
+
validRelationships.set(s.id, toMap);
|
|
431
|
+
}
|
|
432
|
+
// Log parse errors
|
|
433
|
+
for (const error of parseResult.errors) {
|
|
434
|
+
if (!isJson) {
|
|
435
|
+
this.log(chalk.yellow(` Warning: ${error}`));
|
|
436
|
+
}
|
|
437
|
+
totalErrors++;
|
|
438
|
+
}
|
|
439
|
+
// Process symbol annotation rows
|
|
440
|
+
for (const row of parseResult.symbols) {
|
|
441
|
+
const symbolId = row.symbolId;
|
|
442
|
+
// Validate symbol ID
|
|
443
|
+
if (!validSymbolIds.has(symbolId)) {
|
|
444
|
+
iterationResults.push({
|
|
445
|
+
symbolId,
|
|
446
|
+
symbolName: String(symbolId),
|
|
447
|
+
aspect: row.aspect,
|
|
448
|
+
value: row.value,
|
|
449
|
+
success: false,
|
|
450
|
+
error: `Invalid symbol ID: ${symbolId}`,
|
|
451
|
+
});
|
|
452
|
+
totalErrors++;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
// Validate aspect
|
|
456
|
+
if (!aspects.includes(row.aspect)) {
|
|
457
|
+
iterationResults.push({
|
|
458
|
+
symbolId,
|
|
459
|
+
symbolName: symbolNameById.get(symbolId) || String(symbolId),
|
|
460
|
+
aspect: row.aspect,
|
|
461
|
+
value: row.value,
|
|
462
|
+
success: false,
|
|
463
|
+
error: `Unexpected aspect: ${row.aspect}`,
|
|
464
|
+
});
|
|
465
|
+
totalErrors++;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
// Validate value (aspect-specific)
|
|
469
|
+
let value = row.value;
|
|
470
|
+
const validationError = this.validateValue(row.aspect, value, sourceCodeById.get(symbolId), depsById.get(symbolId));
|
|
471
|
+
if (validationError?.startsWith('overridden')) {
|
|
472
|
+
// Pure gate triggered — override value to false and log
|
|
473
|
+
if (!isJson && ctx.verbose) {
|
|
474
|
+
this.log(chalk.yellow(` Pure override for #${symbolId}: ${validationError}`));
|
|
475
|
+
}
|
|
476
|
+
value = 'false';
|
|
477
|
+
}
|
|
478
|
+
else if (validationError) {
|
|
479
|
+
iterationResults.push({
|
|
480
|
+
symbolId,
|
|
481
|
+
symbolName: symbolNameById.get(symbolId) || String(symbolId),
|
|
482
|
+
aspect: row.aspect,
|
|
483
|
+
value,
|
|
484
|
+
success: false,
|
|
485
|
+
error: validationError,
|
|
486
|
+
});
|
|
487
|
+
totalErrors++;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
// Persist (unless dry-run)
|
|
491
|
+
if (!dryRun) {
|
|
492
|
+
db.metadata.set(symbolId, row.aspect, value);
|
|
493
|
+
}
|
|
494
|
+
iterationResults.push({
|
|
495
|
+
symbolId,
|
|
496
|
+
symbolName: symbolNameById.get(symbolId) || String(symbolId),
|
|
497
|
+
aspect: row.aspect,
|
|
498
|
+
value,
|
|
499
|
+
success: true,
|
|
500
|
+
});
|
|
501
|
+
totalAnnotations++;
|
|
502
|
+
}
|
|
503
|
+
// Process relationship annotation rows
|
|
504
|
+
for (const row of parseResult.relationships) {
|
|
505
|
+
const fromId = row.fromId;
|
|
506
|
+
const toId = row.toId;
|
|
507
|
+
// Validate from_id
|
|
508
|
+
if (!validSymbolIds.has(fromId)) {
|
|
509
|
+
iterationRelResults.push({
|
|
510
|
+
fromId,
|
|
511
|
+
fromName: String(fromId),
|
|
512
|
+
toId,
|
|
513
|
+
toName: String(toId),
|
|
514
|
+
value: row.value,
|
|
515
|
+
success: false,
|
|
516
|
+
error: `Invalid from_id: ${fromId}`,
|
|
517
|
+
});
|
|
518
|
+
totalErrors++;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
// Validate relationship exists
|
|
522
|
+
const toMap = validRelationships.get(fromId);
|
|
523
|
+
if (!toMap || !toMap.has(toId)) {
|
|
524
|
+
iterationRelResults.push({
|
|
525
|
+
fromId,
|
|
526
|
+
fromName: symbolNameById.get(fromId) || String(fromId),
|
|
527
|
+
toId,
|
|
528
|
+
toName: String(toId),
|
|
529
|
+
value: row.value,
|
|
530
|
+
success: false,
|
|
531
|
+
error: `Unexpected relationship: ${fromId} → ${toId}`,
|
|
532
|
+
});
|
|
533
|
+
totalErrors++;
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
// Validate value is not empty
|
|
537
|
+
if (!row.value || row.value.length < 5) {
|
|
538
|
+
const errorMsg = 'Relationship description must be at least 5 characters';
|
|
539
|
+
iterationRelResults.push({
|
|
540
|
+
fromId,
|
|
541
|
+
fromName: symbolNameById.get(fromId) || String(fromId),
|
|
542
|
+
toId,
|
|
543
|
+
toName: toMap.get(toId) || String(toId),
|
|
544
|
+
value: row.value,
|
|
545
|
+
success: false,
|
|
546
|
+
error: errorMsg,
|
|
547
|
+
});
|
|
548
|
+
retryQueue.add(fromId, toId, errorMsg);
|
|
549
|
+
totalErrors++;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
// Persist (unless dry-run)
|
|
553
|
+
if (!dryRun) {
|
|
554
|
+
db.relationships.set(fromId, toId, row.value);
|
|
555
|
+
}
|
|
556
|
+
iterationRelResults.push({
|
|
557
|
+
fromId,
|
|
558
|
+
fromName: symbolNameById.get(fromId) || String(fromId),
|
|
559
|
+
toId,
|
|
560
|
+
toName: toMap.get(toId) || String(toId),
|
|
561
|
+
value: row.value,
|
|
562
|
+
success: true,
|
|
563
|
+
});
|
|
564
|
+
totalRelationshipAnnotations++;
|
|
565
|
+
}
|
|
566
|
+
// Get updated coverage
|
|
567
|
+
const updatedCoverage = db.metadata.getAspectCoverage({
|
|
568
|
+
kind: flags.kind,
|
|
569
|
+
filePattern: flags.file,
|
|
570
|
+
});
|
|
571
|
+
const finalCoverage = filterCoverageForAspects(updatedCoverage, aspects, totalSymbols);
|
|
572
|
+
// Get relationship coverage (handle missing table in older databases)
|
|
573
|
+
let annotatedRels = 0;
|
|
574
|
+
let unannotatedRels = 0;
|
|
575
|
+
try {
|
|
576
|
+
annotatedRels = db.relationships.getCount();
|
|
577
|
+
unannotatedRels = db.relationships.getUnannotatedCount();
|
|
578
|
+
}
|
|
579
|
+
catch {
|
|
580
|
+
// Table doesn't exist - continue with zeros
|
|
581
|
+
}
|
|
582
|
+
const totalRels = annotatedRels + unannotatedRels;
|
|
583
|
+
const relCoverage = {
|
|
584
|
+
annotated: annotatedRels,
|
|
585
|
+
total: totalRels,
|
|
586
|
+
percentage: totalRels > 0 ? (annotatedRels / totalRels) * 100 : 0,
|
|
587
|
+
};
|
|
588
|
+
// Get ready/blocked counts
|
|
589
|
+
const updatedResult = db.dependencies.getReadySymbols(primaryAspect, {
|
|
590
|
+
limit: 1,
|
|
591
|
+
kind: flags.kind,
|
|
592
|
+
filePattern: flags.file,
|
|
593
|
+
});
|
|
594
|
+
const summary = {
|
|
595
|
+
iteration,
|
|
596
|
+
results: iterationResults,
|
|
597
|
+
relationshipResults: iterationRelResults,
|
|
598
|
+
coverage: finalCoverage,
|
|
599
|
+
relationshipCoverage: relCoverage,
|
|
600
|
+
readyCount: updatedResult.totalReady,
|
|
601
|
+
blockedCount: updatedResult.remaining,
|
|
602
|
+
};
|
|
603
|
+
// Output iteration results
|
|
604
|
+
if (isJson) {
|
|
605
|
+
jsonOutput.iterations.push({
|
|
606
|
+
iteration,
|
|
607
|
+
symbolsProcessed: enhancedSymbols.length,
|
|
608
|
+
results: iterationResults,
|
|
609
|
+
relationshipResults: iterationRelResults,
|
|
610
|
+
coverage: finalCoverage,
|
|
611
|
+
relationshipCoverage: relCoverage,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
for (const line of formatIterationResults(summary)) {
|
|
616
|
+
this.log(line);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
// Retry failed relationship annotations (single pass)
|
|
621
|
+
const retryable = retryQueue.getRetryable(3);
|
|
622
|
+
if (retryable.length > 0 && !dryRun) {
|
|
623
|
+
if (!isJson) {
|
|
624
|
+
this.log('');
|
|
625
|
+
this.log(chalk.bold(`Retrying ${retryable.length} failed relationship annotations...`));
|
|
626
|
+
}
|
|
627
|
+
// Build focused prompt for failed relationships only
|
|
628
|
+
// Group by fromId for context
|
|
629
|
+
const byFromId = new Map();
|
|
630
|
+
for (const { fromId, toId } of retryable) {
|
|
631
|
+
if (!byFromId.has(fromId))
|
|
632
|
+
byFromId.set(fromId, []);
|
|
633
|
+
byFromId.get(fromId).push(toId);
|
|
634
|
+
}
|
|
635
|
+
let retrySuccessCount = 0;
|
|
636
|
+
for (const [fromId, toIds] of byFromId) {
|
|
637
|
+
const def = db.definitions.getById(fromId);
|
|
638
|
+
if (!def)
|
|
639
|
+
continue;
|
|
640
|
+
const sourceCode = await readSourceAsString(db.resolveFilePath(def.filePath), def.line, def.endLine);
|
|
641
|
+
// Build minimal retry prompt
|
|
642
|
+
const retryPrompt = `Please provide relationship annotations for these specific relationships. Be thorough and descriptive (minimum 5 characters).
|
|
643
|
+
|
|
644
|
+
Symbol: ${def.name} (${def.kind})
|
|
645
|
+
File: ${def.filePath}:${def.line}
|
|
646
|
+
|
|
647
|
+
\`\`\`
|
|
648
|
+
${sourceCode}
|
|
649
|
+
\`\`\`
|
|
650
|
+
|
|
651
|
+
Relationships to annotate:
|
|
652
|
+
${toIds
|
|
653
|
+
.map((toId) => {
|
|
654
|
+
const toDef = db.definitions.getById(toId);
|
|
655
|
+
return toDef ? `- ${def.name} → ${toDef.name} (${toDef.kind} in ${toDef.filePath})` : null;
|
|
656
|
+
})
|
|
657
|
+
.filter(Boolean)
|
|
658
|
+
.join('\n')}
|
|
659
|
+
|
|
660
|
+
Format: CSV with columns: from_id,to_id,relationship_annotation
|
|
661
|
+
\`\`\`csv
|
|
662
|
+
from_id,to_id,relationship_annotation
|
|
663
|
+
${toIds.map((toId) => `${fromId},${toId},"<describe how ${def.name} uses this dependency>"`).join('\n')}
|
|
664
|
+
\`\`\``;
|
|
665
|
+
try {
|
|
666
|
+
const response = await completeWithLogging({
|
|
667
|
+
model,
|
|
668
|
+
systemPrompt: 'You are annotating code relationships. Provide clear, concise descriptions of how symbols are related.',
|
|
669
|
+
userPrompt: retryPrompt,
|
|
670
|
+
temperature: 0,
|
|
671
|
+
command: this,
|
|
672
|
+
isJson,
|
|
673
|
+
});
|
|
674
|
+
// Parse response for relationship annotations
|
|
675
|
+
const lines = response.split('\n');
|
|
676
|
+
for (const line of lines) {
|
|
677
|
+
const match = line.match(/^(\d+),(\d+),["']?(.+?)["']?$/);
|
|
678
|
+
if (match) {
|
|
679
|
+
const retryFromId = Number.parseInt(match[1], 10);
|
|
680
|
+
const retryToId = Number.parseInt(match[2], 10);
|
|
681
|
+
const value = match[3].trim();
|
|
682
|
+
if (retryFromId === fromId && toIds.includes(retryToId) && value.length >= 5) {
|
|
683
|
+
db.relationships.set(retryFromId, retryToId, value);
|
|
684
|
+
retrySuccessCount++;
|
|
685
|
+
totalRelationshipAnnotations++;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
catch {
|
|
691
|
+
// Retry failed, continue
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (!isJson && retrySuccessCount > 0) {
|
|
695
|
+
this.log(chalk.green(` Successfully retried ${retrySuccessCount} relationships`));
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
// Final summary
|
|
699
|
+
const finalCoverageData = db.metadata.getAspectCoverage({
|
|
700
|
+
kind: flags.kind,
|
|
701
|
+
filePattern: flags.file,
|
|
702
|
+
});
|
|
703
|
+
const totalSymbols = db.metadata.getFilteredCount({
|
|
704
|
+
kind: flags.kind,
|
|
705
|
+
filePattern: flags.file,
|
|
706
|
+
});
|
|
707
|
+
const coverage = filterCoverageForAspects(finalCoverageData, aspects, totalSymbols);
|
|
708
|
+
// Get final relationship coverage (handle missing table in older databases)
|
|
709
|
+
let finalAnnotatedRels = 0;
|
|
710
|
+
let finalUnannotatedRels = 0;
|
|
711
|
+
try {
|
|
712
|
+
finalAnnotatedRels = db.relationships.getCount();
|
|
713
|
+
finalUnannotatedRels = db.relationships.getUnannotatedCount();
|
|
714
|
+
}
|
|
715
|
+
catch {
|
|
716
|
+
// Table doesn't exist - continue with zeros
|
|
717
|
+
}
|
|
718
|
+
const finalTotalRels = finalAnnotatedRels + finalUnannotatedRels;
|
|
719
|
+
const finalRelCoverage = {
|
|
720
|
+
annotated: finalAnnotatedRels,
|
|
721
|
+
total: finalTotalRels,
|
|
722
|
+
percentage: finalTotalRels > 0 ? (finalAnnotatedRels / finalTotalRels) * 100 : 0,
|
|
723
|
+
};
|
|
724
|
+
if (isJson) {
|
|
725
|
+
jsonOutput.summary = {
|
|
726
|
+
totalIterations: iteration - 1,
|
|
727
|
+
totalAnnotations,
|
|
728
|
+
totalRelationshipAnnotations,
|
|
729
|
+
totalErrors,
|
|
730
|
+
coverage,
|
|
731
|
+
relationshipCoverage: finalRelCoverage,
|
|
732
|
+
};
|
|
733
|
+
this.log(JSON.stringify(jsonOutput, null, 2));
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
for (const line of formatFinalSummary(totalAnnotations, totalRelationshipAnnotations, totalErrors, iteration - 1, coverage, finalRelCoverage)) {
|
|
737
|
+
this.log(line);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Enhance symbols with source code, dependency context, and relationships to annotate.
|
|
743
|
+
*/
|
|
744
|
+
async enhanceSymbols(db, symbols, aspects, relationshipLimit) {
|
|
745
|
+
const enhanced = [];
|
|
746
|
+
for (const symbol of symbols) {
|
|
747
|
+
const sourceCode = await readSourceAsString(db.resolveFilePath(symbol.filePath), symbol.line, symbol.endLine);
|
|
748
|
+
// Get dependencies with all their metadata
|
|
749
|
+
const deps = db.dependencies.getWithMetadata(symbol.id, aspects[0]);
|
|
750
|
+
const dependencies = deps.map((dep) => {
|
|
751
|
+
// Get all metadata for this dependency
|
|
752
|
+
const metadata = db.metadata.get(dep.id);
|
|
753
|
+
let domains = null;
|
|
754
|
+
try {
|
|
755
|
+
if (metadata.domain) {
|
|
756
|
+
domains = JSON.parse(metadata.domain);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
catch {
|
|
760
|
+
/* ignore */
|
|
761
|
+
}
|
|
762
|
+
return {
|
|
763
|
+
id: dep.id,
|
|
764
|
+
name: dep.name,
|
|
765
|
+
kind: dep.kind,
|
|
766
|
+
filePath: dep.filePath,
|
|
767
|
+
line: dep.line,
|
|
768
|
+
purpose: metadata.purpose || null,
|
|
769
|
+
domains,
|
|
770
|
+
role: metadata.role || null,
|
|
771
|
+
pure: metadata.pure ? metadata.pure === 'true' : null,
|
|
772
|
+
};
|
|
773
|
+
});
|
|
774
|
+
// Get unannotated relationships from this symbol (handle missing table)
|
|
775
|
+
let unannotatedRels = [];
|
|
776
|
+
try {
|
|
777
|
+
const limit = relationshipLimit > 0 ? relationshipLimit : undefined;
|
|
778
|
+
unannotatedRels = db.relationships.getUnannotated({ fromDefinitionId: symbol.id, limit });
|
|
779
|
+
}
|
|
780
|
+
catch {
|
|
781
|
+
// Table doesn't exist - continue with empty relationships
|
|
782
|
+
}
|
|
783
|
+
// These are usage-based relationships (calls), so they're all 'uses' type
|
|
784
|
+
const relationshipsToAnnotate = unannotatedRels.map((rel) => ({
|
|
785
|
+
toId: rel.toDefinitionId,
|
|
786
|
+
toName: rel.toName,
|
|
787
|
+
toKind: rel.toKind,
|
|
788
|
+
usageLine: rel.fromLine, // Use fromLine as approximate usage location
|
|
789
|
+
relationshipType: 'uses',
|
|
790
|
+
}));
|
|
791
|
+
// Get incoming dependencies (who uses this symbol)
|
|
792
|
+
const incomingDeps = db.dependencies.getIncoming(symbol.id, 5);
|
|
793
|
+
const incomingDependencyCount = db.dependencies.getIncomingCount(symbol.id);
|
|
794
|
+
const incomingDependencies = incomingDeps.map((inc) => ({
|
|
795
|
+
id: inc.id,
|
|
796
|
+
name: inc.name,
|
|
797
|
+
kind: inc.kind,
|
|
798
|
+
filePath: inc.filePath,
|
|
799
|
+
}));
|
|
800
|
+
// Get the definition to check if it's exported
|
|
801
|
+
const defInfo = db.definitions.getById(symbol.id);
|
|
802
|
+
const isExported = defInfo?.isExported ?? false;
|
|
803
|
+
enhanced.push({
|
|
804
|
+
...symbol,
|
|
805
|
+
sourceCode,
|
|
806
|
+
isExported,
|
|
807
|
+
dependencies,
|
|
808
|
+
relationshipsToAnnotate,
|
|
809
|
+
incomingDependencies,
|
|
810
|
+
incomingDependencyCount,
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
return enhanced;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Validate a value for a specific aspect.
|
|
817
|
+
*/
|
|
818
|
+
validateValue(aspect, value, sourceCode, deps) {
|
|
819
|
+
switch (aspect) {
|
|
820
|
+
case 'domain':
|
|
821
|
+
try {
|
|
822
|
+
const parsed = JSON.parse(value);
|
|
823
|
+
if (!Array.isArray(parsed)) {
|
|
824
|
+
return 'domain must be a JSON array';
|
|
825
|
+
}
|
|
826
|
+
if (!parsed.every((d) => typeof d === 'string')) {
|
|
827
|
+
return 'domain array must contain only strings';
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
catch {
|
|
831
|
+
return 'domain must be valid JSON array';
|
|
832
|
+
}
|
|
833
|
+
break;
|
|
834
|
+
case 'pure':
|
|
835
|
+
if (value !== 'true' && value !== 'false') {
|
|
836
|
+
return 'pure must be "true" or "false"';
|
|
837
|
+
}
|
|
838
|
+
// Gate 1: override LLM's "true" if source code contains impure patterns
|
|
839
|
+
if (value === 'true' && sourceCode) {
|
|
840
|
+
const impureReasons = detectImpurePatterns(sourceCode);
|
|
841
|
+
if (impureReasons.length > 0) {
|
|
842
|
+
return `overridden to false: ${impureReasons[0]}`;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
// Gate 2: transitive impurity — if any dependency is pure:false, this can't be pure:true
|
|
846
|
+
if (value === 'true' && deps && deps.length > 0) {
|
|
847
|
+
const impureDep = deps.find((d) => d.pure === false);
|
|
848
|
+
if (impureDep) {
|
|
849
|
+
return `overridden to false: calls impure dependency '${impureDep.name}'`;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
case 'purpose':
|
|
854
|
+
if (!value || value.length < 5) {
|
|
855
|
+
return 'purpose must be at least 5 characters';
|
|
856
|
+
}
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
return null;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
//# sourceMappingURL=annotate.js.map
|