ts-knowledge-graph 0.1.2 → 0.1.6
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/README.md +99 -41
- package/contribs/webview/README.md +83 -0
- package/contribs/webview/web/css/style.css +310 -0
- package/contribs/webview/web/index.html +109 -0
- package/contribs/webview/web/js/app.js +1249 -0
- package/contribs/webview/web/js_autogenerated/.gitignore +3 -0
- package/contribs/webview/web/js_autogenerated/kind_descriptions.js +39 -0
- package/contribs/webview/web/types/app_globals.d.ts +154 -0
- package/dist/benchmark/benchmark_stats.d.ts +41 -0
- package/dist/benchmark/benchmark_stats.d.ts.map +1 -0
- package/dist/benchmark/benchmark_stats.js +61 -0
- package/dist/benchmark/benchmark_stats.js.map +1 -0
- package/dist/benchmark/node_benchmark.d.ts +78 -0
- package/dist/benchmark/node_benchmark.d.ts.map +1 -0
- package/dist/benchmark/node_benchmark.js +112 -0
- package/dist/benchmark/node_benchmark.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -4
- package/dist/cli.js.map +1 -1
- package/dist/cluster/cluster_weights.d.ts +20 -0
- package/dist/cluster/cluster_weights.d.ts.map +1 -0
- package/dist/cluster/cluster_weights.js +32 -0
- package/dist/cluster/cluster_weights.js.map +1 -0
- package/dist/cluster/community_detector.d.ts +61 -0
- package/dist/cluster/community_detector.d.ts.map +1 -0
- package/dist/cluster/community_detector.js +120 -0
- package/dist/cluster/community_detector.js.map +1 -0
- package/dist/cluster/community_labeler.d.ts +84 -0
- package/dist/cluster/community_labeler.d.ts.map +1 -0
- package/dist/cluster/community_labeler.js +194 -0
- package/dist/cluster/community_labeler.js.map +1 -0
- package/dist/cluster/graph_clusterer.d.ts +47 -0
- package/dist/cluster/graph_clusterer.d.ts.map +1 -0
- package/dist/cluster/graph_clusterer.js +126 -0
- package/dist/cluster/graph_clusterer.js.map +1 -0
- package/dist/commands/benchmark_command.d.ts +11 -0
- package/dist/commands/benchmark_command.d.ts.map +1 -0
- package/dist/commands/benchmark_command.js +94 -0
- package/dist/commands/benchmark_command.js.map +1 -0
- package/dist/commands/blast_radius_command.d.ts.map +1 -1
- package/dist/commands/blast_radius_command.js +7 -6
- package/dist/commands/blast_radius_command.js.map +1 -1
- package/dist/commands/cluster_command.d.ts +7 -0
- package/dist/commands/cluster_command.d.ts.map +1 -0
- package/dist/commands/cluster_command.js +55 -0
- package/dist/commands/cluster_command.js.map +1 -0
- package/dist/commands/command_helpers.d.ts +9 -4
- package/dist/commands/command_helpers.d.ts.map +1 -1
- package/dist/commands/command_helpers.js +13 -8
- package/dist/commands/command_helpers.js.map +1 -1
- package/dist/commands/cost_command.d.ts +13 -0
- package/dist/commands/cost_command.d.ts.map +1 -0
- package/dist/commands/cost_command.js +139 -0
- package/dist/commands/cost_command.js.map +1 -0
- package/dist/commands/{load.d.ts → enrich_command.d.ts} +3 -2
- package/dist/commands/enrich_command.d.ts.map +1 -0
- package/dist/commands/enrich_command.js +64 -0
- package/dist/commands/enrich_command.js.map +1 -0
- package/dist/commands/extract_command.d.ts.map +1 -1
- package/dist/commands/extract_command.js +12 -6
- package/dist/commands/extract_command.js.map +1 -1
- package/dist/commands/hotspots_command.d.ts +7 -0
- package/dist/commands/hotspots_command.d.ts.map +1 -0
- package/dist/commands/hotspots_command.js +68 -0
- package/dist/commands/hotspots_command.js.map +1 -0
- package/dist/commands/install_command.d.ts +15 -6
- package/dist/commands/install_command.d.ts.map +1 -1
- package/dist/commands/install_command.js +62 -25
- package/dist/commands/install_command.js.map +1 -1
- package/dist/commands/load_command.d.ts.map +1 -1
- package/dist/commands/load_command.js +20 -13
- package/dist/commands/load_command.js.map +1 -1
- package/dist/commands/neighbors_command.d.ts.map +1 -1
- package/dist/commands/neighbors_command.js +6 -5
- package/dist/commands/neighbors_command.js.map +1 -1
- package/dist/commands/references_command.d.ts.map +1 -1
- package/dist/commands/references_command.js +6 -5
- package/dist/commands/references_command.js.map +1 -1
- package/dist/commands/report_command.d.ts +16 -0
- package/dist/commands/report_command.d.ts.map +1 -0
- package/dist/commands/report_command.js +115 -0
- package/dist/commands/report_command.js.map +1 -0
- package/dist/commands/verify_command.d.ts +8 -0
- package/dist/commands/verify_command.d.ts.map +1 -0
- package/dist/commands/verify_command.js +57 -0
- package/dist/commands/verify_command.js.map +1 -0
- package/dist/commands/web_command.d.ts +27 -0
- package/dist/commands/web_command.d.ts.map +1 -1
- package/dist/commands/web_command.js +109 -3
- package/dist/commands/web_command.js.map +1 -1
- package/dist/commands/webview_command.d.ts +36 -0
- package/dist/commands/webview_command.d.ts.map +1 -0
- package/dist/commands/webview_command.js +186 -0
- package/dist/commands/webview_command.js.map +1 -0
- package/dist/enrich/cpu_profile.d.ts +160 -0
- package/dist/enrich/cpu_profile.d.ts.map +1 -0
- package/dist/enrich/cpu_profile.js +185 -0
- package/dist/enrich/cpu_profile.js.map +1 -0
- package/dist/enrich/runtime_enricher.d.ts +64 -0
- package/dist/enrich/runtime_enricher.d.ts.map +1 -0
- package/dist/enrich/runtime_enricher.js +98 -0
- package/dist/enrich/runtime_enricher.js.map +1 -0
- package/dist/enrich/runtime_join.d.ts +124 -0
- package/dist/enrich/runtime_join.d.ts.map +1 -0
- package/dist/enrich/runtime_join.js +270 -0
- package/dist/enrich/runtime_join.js.map +1 -0
- package/dist/extract/api_extractor.d.ts +24 -0
- package/dist/extract/api_extractor.d.ts.map +1 -0
- package/dist/extract/api_extractor.js +71 -0
- package/dist/extract/api_extractor.js.map +1 -0
- package/dist/extract/config_extractor.d.ts +22 -0
- package/dist/extract/config_extractor.d.ts.map +1 -0
- package/dist/extract/config_extractor.js +61 -0
- package/dist/extract/config_extractor.js.map +1 -0
- package/dist/extract/endpoint_extractor.d.ts +36 -0
- package/dist/extract/endpoint_extractor.d.ts.map +1 -0
- package/dist/extract/endpoint_extractor.js +117 -0
- package/dist/extract/endpoint_extractor.js.map +1 -0
- package/dist/extract/git_source.d.ts +23 -0
- package/dist/extract/git_source.d.ts.map +1 -0
- package/dist/extract/git_source.js +75 -0
- package/dist/extract/git_source.js.map +1 -0
- package/dist/extract/graph_builder.d.ts +8 -0
- package/dist/extract/graph_builder.d.ts.map +1 -1
- package/dist/extract/graph_builder.js +23 -1
- package/dist/extract/graph_builder.js.map +1 -1
- package/dist/extract/node_id.d.ts +16 -0
- package/dist/extract/node_id.d.ts.map +1 -1
- package/dist/extract/node_id.js +22 -0
- package/dist/extract/node_id.js.map +1 -1
- package/dist/extract/scope_resolver.d.ts +22 -0
- package/dist/extract/scope_resolver.d.ts.map +1 -0
- package/dist/extract/scope_resolver.js +53 -0
- package/dist/extract/scope_resolver.js.map +1 -0
- package/dist/extract/semantic_extractor.d.ts +25 -0
- package/dist/extract/semantic_extractor.d.ts.map +1 -1
- package/dist/extract/semantic_extractor.js +96 -2
- package/dist/extract/semantic_extractor.js.map +1 -1
- package/dist/extract/structural_extractor.d.ts +6 -0
- package/dist/extract/structural_extractor.d.ts.map +1 -1
- package/dist/extract/structural_extractor.js +22 -12
- package/dist/extract/structural_extractor.js.map +1 -1
- package/dist/project_root.d.ts +7 -0
- package/dist/project_root.d.ts.map +1 -0
- package/dist/project_root.js +9 -0
- package/dist/project_root.js.map +1 -0
- package/dist/query/graph_query.d.ts +269 -0
- package/dist/query/graph_query.d.ts.map +1 -1
- package/dist/query/graph_query.js +585 -11
- package/dist/query/graph_query.js.map +1 -1
- package/dist/report/graph_report.d.ts +51 -0
- package/dist/report/graph_report.d.ts.map +1 -0
- package/dist/report/graph_report.js +312 -0
- package/dist/report/graph_report.js.map +1 -0
- package/dist/report/pdf_renderer.d.ts +22 -0
- package/dist/report/pdf_renderer.d.ts.map +1 -0
- package/dist/report/pdf_renderer.js +54 -0
- package/dist/report/pdf_renderer.js.map +1 -0
- package/dist/report/report_data.d.ts +128 -0
- package/dist/report/report_data.d.ts.map +1 -0
- package/dist/report/report_data.js +191 -0
- package/dist/report/report_data.js.map +1 -0
- package/dist/schema/edge.d.ts +40 -5
- package/dist/schema/edge.d.ts.map +1 -1
- package/dist/schema/edge.js +73 -0
- package/dist/schema/edge.js.map +1 -1
- package/dist/schema/node.d.ts +20 -5
- package/dist/schema/node.d.ts.map +1 -1
- package/dist/schema/node.js +36 -0
- package/dist/schema/node.js.map +1 -1
- package/dist/schema/runtime_manifest.d.ts +36 -0
- package/dist/schema/runtime_manifest.d.ts.map +1 -0
- package/dist/schema/runtime_manifest.js +23 -0
- package/dist/schema/runtime_manifest.js.map +1 -0
- package/dist/schema/source_manifest.d.ts +30 -0
- package/dist/schema/source_manifest.d.ts.map +1 -0
- package/dist/schema/source_manifest.js +21 -0
- package/dist/schema/source_manifest.js.map +1 -0
- package/dist/store/jsonl_reader.d.ts +4 -0
- package/dist/store/jsonl_reader.d.ts.map +1 -1
- package/dist/store/jsonl_reader.js +13 -1
- package/dist/store/jsonl_reader.js.map +1 -1
- package/dist/store/jsonl_store.d.ts +2 -1
- package/dist/store/jsonl_store.d.ts.map +1 -1
- package/dist/store/jsonl_store.js +4 -1
- package/dist/store/jsonl_store.js.map +1 -1
- package/dist/store/kuzu_store.d.ts +59 -0
- package/dist/store/kuzu_store.d.ts.map +1 -1
- package/dist/store/kuzu_store.js +124 -5
- package/dist/store/kuzu_store.js.map +1 -1
- package/dist/store/output_folder.d.ts +43 -0
- package/dist/store/output_folder.d.ts.map +1 -0
- package/dist/store/output_folder.js +61 -0
- package/dist/store/output_folder.js.map +1 -0
- package/dist/verify/project_verifier.d.ts +85 -0
- package/dist/verify/project_verifier.d.ts.map +1 -0
- package/dist/verify/project_verifier.js +138 -0
- package/dist/verify/project_verifier.js.map +1 -0
- package/dotclaude_folder/commands/code-graph-interview.md +123 -0
- package/dotclaude_folder/commands/code-graph-optimize.md +65 -0
- package/{skills/ts-knowledge-graph → dotclaude_folder/skills/code-graph-query}/SKILL.md +6 -6
- package/package.json +99 -10
- package/.env-sample +0 -34
- package/contribs/web_visualisation/README.md +0 -55
- package/contribs/web_visualisation/web/css/style.css +0 -115
- package/contribs/web_visualisation/web/data/.gitignore +0 -2
- package/contribs/web_visualisation/web/index.html +0 -58
- package/contribs/web_visualisation/web/js/app.js +0 -364
- package/dist/agent/agent-tools.d.ts +0 -13
- package/dist/agent/agent-tools.d.ts.map +0 -1
- package/dist/agent/agent-tools.js +0 -153
- package/dist/agent/agent-tools.js.map +0 -1
- package/dist/agent/agent_tools.d.ts +0 -13
- package/dist/agent/agent_tools.d.ts.map +0 -1
- package/dist/agent/agent_tools.js +0 -153
- package/dist/agent/agent_tools.js.map +0 -1
- package/dist/agent/code-editor.d.ts +0 -18
- package/dist/agent/code-editor.d.ts.map +0 -1
- package/dist/agent/code-editor.js +0 -43
- package/dist/agent/code-editor.js.map +0 -1
- package/dist/agent/code_editor.d.ts +0 -18
- package/dist/agent/code_editor.d.ts.map +0 -1
- package/dist/agent/code_editor.js +0 -43
- package/dist/agent/code_editor.js.map +0 -1
- package/dist/agent/optimizer-agent.d.ts +0 -30
- package/dist/agent/optimizer-agent.d.ts.map +0 -1
- package/dist/agent/optimizer-agent.js +0 -97
- package/dist/agent/optimizer-agent.js.map +0 -1
- package/dist/agent/optimizer_agent.d.ts +0 -30
- package/dist/agent/optimizer_agent.d.ts.map +0 -1
- package/dist/agent/optimizer_agent.js +0 -97
- package/dist/agent/optimizer_agent.js.map +0 -1
- package/dist/agent/verifier.d.ts +0 -9
- package/dist/agent/verifier.d.ts.map +0 -1
- package/dist/agent/verifier.js +0 -19
- package/dist/agent/verifier.js.map +0 -1
- package/dist/commands/blast-radius.d.ts +0 -5
- package/dist/commands/blast-radius.d.ts.map +0 -1
- package/dist/commands/blast-radius.js +0 -18
- package/dist/commands/blast-radius.js.map +0 -1
- package/dist/commands/blast_radius.d.ts +0 -5
- package/dist/commands/blast_radius.d.ts.map +0 -1
- package/dist/commands/blast_radius.js +0 -18
- package/dist/commands/blast_radius.js.map +0 -1
- package/dist/commands/calls.d.ts +0 -5
- package/dist/commands/calls.d.ts.map +0 -1
- package/dist/commands/calls.js +0 -7
- package/dist/commands/calls.js.map +0 -1
- package/dist/commands/command-helpers.d.ts +0 -15
- package/dist/commands/command-helpers.d.ts.map +0 -1
- package/dist/commands/command-helpers.js +0 -61
- package/dist/commands/command-helpers.js.map +0 -1
- package/dist/commands/dead-exports.d.ts +0 -5
- package/dist/commands/dead-exports.d.ts.map +0 -1
- package/dist/commands/dead-exports.js +0 -7
- package/dist/commands/dead-exports.js.map +0 -1
- package/dist/commands/dead_exports.d.ts +0 -5
- package/dist/commands/dead_exports.d.ts.map +0 -1
- package/dist/commands/dead_exports.js +0 -7
- package/dist/commands/dead_exports.js.map +0 -1
- package/dist/commands/extract.d.ts +0 -8
- package/dist/commands/extract.d.ts.map +0 -1
- package/dist/commands/extract.js +0 -49
- package/dist/commands/extract.js.map +0 -1
- package/dist/commands/find.d.ts +0 -5
- package/dist/commands/find.d.ts.map +0 -1
- package/dist/commands/find.js +0 -7
- package/dist/commands/find.js.map +0 -1
- package/dist/commands/load.d.ts.map +0 -1
- package/dist/commands/load.js +0 -28
- package/dist/commands/load.js.map +0 -1
- package/dist/commands/neighbors.d.ts +0 -5
- package/dist/commands/neighbors.d.ts.map +0 -1
- package/dist/commands/neighbors.js +0 -17
- package/dist/commands/neighbors.js.map +0 -1
- package/dist/commands/optimize.d.ts +0 -6
- package/dist/commands/optimize.d.ts.map +0 -1
- package/dist/commands/optimize.js +0 -59
- package/dist/commands/optimize.js.map +0 -1
- package/dist/commands/optimize_command.d.ts +0 -6
- package/dist/commands/optimize_command.d.ts.map +0 -1
- package/dist/commands/optimize_command.js +0 -59
- package/dist/commands/optimize_command.js.map +0 -1
- package/dist/commands/references.d.ts +0 -5
- package/dist/commands/references.d.ts.map +0 -1
- package/dist/commands/references.js +0 -17
- package/dist/commands/references.js.map +0 -1
- package/dist/commands/web.d.ts +0 -19
- package/dist/commands/web.d.ts.map +0 -1
- package/dist/commands/web.js +0 -120
- package/dist/commands/web.js.map +0 -1
- package/dist/commands/who-calls.d.ts +0 -5
- package/dist/commands/who-calls.d.ts.map +0 -1
- package/dist/commands/who-calls.js +0 -7
- package/dist/commands/who-calls.js.map +0 -1
- package/dist/commands/who_calls.d.ts +0 -5
- package/dist/commands/who_calls.d.ts.map +0 -1
- package/dist/commands/who_calls.js +0 -7
- package/dist/commands/who_calls.js.map +0 -1
- package/dist/extract/graph-builder.d.ts +0 -16
- package/dist/extract/graph-builder.d.ts.map +0 -1
- package/dist/extract/graph-builder.js +0 -39
- package/dist/extract/graph-builder.js.map +0 -1
- package/dist/extract/node-id.d.ts +0 -8
- package/dist/extract/node-id.d.ts.map +0 -1
- package/dist/extract/node-id.js +0 -22
- package/dist/extract/node-id.js.map +0 -1
- package/dist/extract/project-loader.d.ts +0 -5
- package/dist/extract/project-loader.d.ts.map +0 -1
- package/dist/extract/project-loader.js +0 -19
- package/dist/extract/project-loader.js.map +0 -1
- package/dist/extract/semantic-extractor.d.ts +0 -22
- package/dist/extract/semantic-extractor.d.ts.map +0 -1
- package/dist/extract/semantic-extractor.js +0 -254
- package/dist/extract/semantic-extractor.js.map +0 -1
- package/dist/extract/structural-extractor.d.ts +0 -18
- package/dist/extract/structural-extractor.d.ts.map +0 -1
- package/dist/extract/structural-extractor.js +0 -97
- package/dist/extract/structural-extractor.js.map +0 -1
- package/dist/query/graph-query.d.ts +0 -28
- package/dist/query/graph-query.d.ts.map +0 -1
- package/dist/query/graph-query.js +0 -93
- package/dist/query/graph-query.js.map +0 -1
- package/dist/store/jsonl-reader.d.ts +0 -11
- package/dist/store/jsonl-reader.d.ts.map +0 -1
- package/dist/store/jsonl-reader.js +0 -19
- package/dist/store/jsonl-reader.js.map +0 -1
- package/dist/store/jsonl-store.d.ts +0 -7
- package/dist/store/jsonl-store.d.ts.map +0 -1
- package/dist/store/jsonl-store.js +0 -13
- package/dist/store/jsonl-store.js.map +0 -1
- package/dist/store/kuzu-store.d.ts +0 -14
- package/dist/store/kuzu-store.d.ts.map +0 -1
- package/dist/store/kuzu-store.js +0 -52
- package/dist/store/kuzu-store.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reusable verify path for the optimization loop: run the project's
|
|
3
|
+
* type-check and test gates and reduce them to one pass/fail verdict, plus the
|
|
4
|
+
* honesty flags an agent needs (was *behaviour* verified, or only types?).
|
|
5
|
+
*
|
|
6
|
+
* A type-check proves the edit compiles; it cannot see a swapped operator, an
|
|
7
|
+
* off-by-one, or a dropped branch. Running the test suite alongside `tsc` is
|
|
8
|
+
* what turns "still compiles" into "still works". When a project has no test
|
|
9
|
+
* script the test gate degrades to skipped and {@link VerifyReport.behaviorVerified}
|
|
10
|
+
* stays false, so the caller can report the change as unverified rather than
|
|
11
|
+
* implying it was behaviourally checked.
|
|
12
|
+
*/
|
|
13
|
+
/** The two correctness gates, run in order. */
|
|
14
|
+
export type CheckName = 'typecheck' | 'test';
|
|
15
|
+
/** A gate ran and passed, ran and failed, or never ran. */
|
|
16
|
+
export type CheckStatus = 'pass' | 'fail' | 'skipped';
|
|
17
|
+
/** A gate resolved from the project's package.json: its command, or why it was skipped. */
|
|
18
|
+
export type PlannedCheck = {
|
|
19
|
+
name: CheckName;
|
|
20
|
+
/** The shell command to run, or `null` when the gate is skipped. */
|
|
21
|
+
command: string | null;
|
|
22
|
+
/** Why the gate will not run (e.g. no matching npm script), set when `command` is null. */
|
|
23
|
+
skippedReason?: string;
|
|
24
|
+
};
|
|
25
|
+
/** The outcome of executing (or skipping) one gate. */
|
|
26
|
+
export type CheckResult = {
|
|
27
|
+
name: CheckName;
|
|
28
|
+
command: string | null;
|
|
29
|
+
status: CheckStatus;
|
|
30
|
+
/** Process exit code; `null` when the gate was skipped or the process died on a signal. */
|
|
31
|
+
exitCode: number | null;
|
|
32
|
+
durationMs: number;
|
|
33
|
+
/** Combined stdout+stderr, tail-bounded to the last `outputTailLines` lines. */
|
|
34
|
+
output: string;
|
|
35
|
+
skippedReason?: string;
|
|
36
|
+
};
|
|
37
|
+
/** The single verdict the optimize loop consumes to keep or revert an edit. */
|
|
38
|
+
export type VerifyReport = {
|
|
39
|
+
/** True when at least one gate ran and no gate that ran failed. */
|
|
40
|
+
ok: boolean;
|
|
41
|
+
/** True only when the test gate actually ran and passed — behaviour, not just types, was checked. */
|
|
42
|
+
behaviorVerified: boolean;
|
|
43
|
+
/** True when a gate was skipped (e.g. the project has no test script), so `ok` is weaker than a full pass. */
|
|
44
|
+
degraded: boolean;
|
|
45
|
+
checks: CheckResult[];
|
|
46
|
+
/** A one-line, quotable verdict that states exactly what was and was not verified. */
|
|
47
|
+
summary: string;
|
|
48
|
+
};
|
|
49
|
+
export type VerifyOptions = {
|
|
50
|
+
/** Project root whose package.json is read and whose scripts are run. Defaults to `process.cwd()`. */
|
|
51
|
+
cwd?: string;
|
|
52
|
+
/** npm script name for the type-check gate. Default `typecheck`. */
|
|
53
|
+
typecheckScript?: string;
|
|
54
|
+
/** npm script name for the test gate. Default `test`. */
|
|
55
|
+
testScript?: string;
|
|
56
|
+
/** Skip the type-check gate entirely. */
|
|
57
|
+
skipTypecheck?: boolean;
|
|
58
|
+
/** Skip the test gate entirely (degrades to type-check-only, reported honestly). */
|
|
59
|
+
skipTests?: boolean;
|
|
60
|
+
/** Keep only the last N lines of each gate's captured output. Default 80. */
|
|
61
|
+
outputTailLines?: number;
|
|
62
|
+
};
|
|
63
|
+
/** How a planned gate is executed. Injectable so tests need not spawn npm. */
|
|
64
|
+
export type CheckExecutor = (command: string, cwd: string) => Promise<{
|
|
65
|
+
exitCode: number | null;
|
|
66
|
+
output: string;
|
|
67
|
+
}>;
|
|
68
|
+
export declare class ProjectVerifier {
|
|
69
|
+
/**
|
|
70
|
+
* Run the project's verify gates and return one verdict. `exec` defaults to a
|
|
71
|
+
* real subprocess spawn; tests inject a fake to avoid running npm.
|
|
72
|
+
*/
|
|
73
|
+
static verify(options?: VerifyOptions, exec?: CheckExecutor): Promise<VerifyReport>;
|
|
74
|
+
/** Resolve each gate against the project's scripts, deciding what will run and what is skipped (pure). */
|
|
75
|
+
static planChecks(scripts: Record<string, string>, options?: VerifyOptions): PlannedCheck[];
|
|
76
|
+
/** Reduce a set of gate results to the single verdict, including the honesty flags (pure). */
|
|
77
|
+
static summarize(checks: CheckResult[]): VerifyReport;
|
|
78
|
+
private static planOne;
|
|
79
|
+
private static runCheck;
|
|
80
|
+
private static buildSummary;
|
|
81
|
+
private static readScripts;
|
|
82
|
+
private static tail;
|
|
83
|
+
private static spawnCommand;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=project_verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project_verifier.d.ts","sourceRoot":"","sources":["../../src/verify/project_verifier.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;AAE7C,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,2FAA2F;AAC3F,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,oEAAoE;IACpE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG;IAC1B,mEAAmE;IACnE,EAAE,EAAE,OAAO,CAAC;IACZ,qGAAqG;IAC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MAAM,CAAC,YAAY;CAkB3B"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
const DEFAULT_TYPECHECK_SCRIPT = 'typecheck';
|
|
6
|
+
const DEFAULT_TEST_SCRIPT = 'test';
|
|
7
|
+
const DEFAULT_TAIL_LINES = 80;
|
|
8
|
+
const PackageJsonSchema = z.object({ scripts: z.record(z.unknown()).optional() });
|
|
9
|
+
export class ProjectVerifier {
|
|
10
|
+
/**
|
|
11
|
+
* Run the project's verify gates and return one verdict. `exec` defaults to a
|
|
12
|
+
* real subprocess spawn; tests inject a fake to avoid running npm.
|
|
13
|
+
*/
|
|
14
|
+
static async verify(options = {}, exec = ProjectVerifier.spawnCommand) {
|
|
15
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
16
|
+
const tailLines = options.outputTailLines ?? DEFAULT_TAIL_LINES;
|
|
17
|
+
const scripts = await ProjectVerifier.readScripts(cwd);
|
|
18
|
+
const plan = ProjectVerifier.planChecks(scripts, options);
|
|
19
|
+
const results = [];
|
|
20
|
+
for (const check of plan) {
|
|
21
|
+
results.push(await ProjectVerifier.runCheck(check, cwd, tailLines, exec));
|
|
22
|
+
}
|
|
23
|
+
return ProjectVerifier.summarize(results);
|
|
24
|
+
}
|
|
25
|
+
/** Resolve each gate against the project's scripts, deciding what will run and what is skipped (pure). */
|
|
26
|
+
static planChecks(scripts, options = {}) {
|
|
27
|
+
const typecheckScript = options.typecheckScript ?? DEFAULT_TYPECHECK_SCRIPT;
|
|
28
|
+
const testScript = options.testScript ?? DEFAULT_TEST_SCRIPT;
|
|
29
|
+
return [
|
|
30
|
+
ProjectVerifier.planOne('typecheck', typecheckScript, scripts, options.skipTypecheck === true),
|
|
31
|
+
ProjectVerifier.planOne('test', testScript, scripts, options.skipTests === true),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
/** Reduce a set of gate results to the single verdict, including the honesty flags (pure). */
|
|
35
|
+
static summarize(checks) {
|
|
36
|
+
const ran = checks.filter((check) => check.status !== 'skipped');
|
|
37
|
+
const failed = ran.filter((check) => check.status === 'fail');
|
|
38
|
+
const test = checks.find((check) => check.name === 'test');
|
|
39
|
+
const behaviorVerified = test !== undefined && test.status === 'pass';
|
|
40
|
+
const ok = ran.length > 0 && failed.length === 0;
|
|
41
|
+
const degraded = checks.some((check) => check.status === 'skipped');
|
|
42
|
+
const summary = ProjectVerifier.buildSummary(ran, failed, test, ok, behaviorVerified);
|
|
43
|
+
return { ok, behaviorVerified, degraded, checks, summary };
|
|
44
|
+
}
|
|
45
|
+
static planOne(name, script, scripts, skip) {
|
|
46
|
+
if (skip === true) {
|
|
47
|
+
return { name, command: null, skippedReason: 'skipped by request' };
|
|
48
|
+
}
|
|
49
|
+
if (typeof scripts[script] !== 'string') {
|
|
50
|
+
return { name, command: null, skippedReason: `no "${script}" script in package.json` };
|
|
51
|
+
}
|
|
52
|
+
return { name, command: `npm run ${script}` };
|
|
53
|
+
}
|
|
54
|
+
static async runCheck(check, cwd, tailLines, exec) {
|
|
55
|
+
if (check.command === null) {
|
|
56
|
+
return {
|
|
57
|
+
name: check.name,
|
|
58
|
+
command: null,
|
|
59
|
+
status: 'skipped',
|
|
60
|
+
exitCode: null,
|
|
61
|
+
durationMs: 0,
|
|
62
|
+
output: '',
|
|
63
|
+
skippedReason: check.skippedReason,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const startedAt = Date.now();
|
|
67
|
+
const { exitCode, output } = await exec(check.command, cwd);
|
|
68
|
+
return {
|
|
69
|
+
name: check.name,
|
|
70
|
+
command: check.command,
|
|
71
|
+
status: exitCode === 0 ? 'pass' : 'fail',
|
|
72
|
+
exitCode,
|
|
73
|
+
durationMs: Date.now() - startedAt,
|
|
74
|
+
output: ProjectVerifier.tail(output, tailLines),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static buildSummary(ran, failed, test, ok, behaviorVerified) {
|
|
78
|
+
if (ran.length === 0) {
|
|
79
|
+
return 'could not verify: no type-check or test script found — change is unverified';
|
|
80
|
+
}
|
|
81
|
+
if (ok === false) {
|
|
82
|
+
return `FAILED: ${failed.map((check) => check.name).join(' and ')} did not pass — revert the edit`;
|
|
83
|
+
}
|
|
84
|
+
if (behaviorVerified === true) {
|
|
85
|
+
return `verified: ${ran.map((check) => check.name).join(' + ')} passed (behaviour checked)`;
|
|
86
|
+
}
|
|
87
|
+
const why = test?.skippedReason ?? 'tests did not run';
|
|
88
|
+
return `type-check passed, but ${why} — behaviour NOT verified`;
|
|
89
|
+
}
|
|
90
|
+
static async readScripts(cwd) {
|
|
91
|
+
try {
|
|
92
|
+
const raw = await readFile(resolve(cwd, 'package.json'), 'utf8');
|
|
93
|
+
const parsed = PackageJsonSchema.safeParse(JSON.parse(raw));
|
|
94
|
+
if (parsed.success === false) {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
const scripts = {};
|
|
98
|
+
for (const [name, value] of Object.entries(parsed.data.scripts ?? {})) {
|
|
99
|
+
if (typeof value === 'string') {
|
|
100
|
+
scripts[name] = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return scripts;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
static tail(text, lines) {
|
|
110
|
+
if (lines <= 0) {
|
|
111
|
+
return text;
|
|
112
|
+
}
|
|
113
|
+
const allLines = text.split('\n');
|
|
114
|
+
if (allLines.length <= lines) {
|
|
115
|
+
return text;
|
|
116
|
+
}
|
|
117
|
+
return allLines.slice(allLines.length - lines).join('\n');
|
|
118
|
+
}
|
|
119
|
+
static spawnCommand(command, cwd) {
|
|
120
|
+
return new Promise((resolvePromise) => {
|
|
121
|
+
const child = spawn(command, { cwd, shell: true });
|
|
122
|
+
let output = '';
|
|
123
|
+
const append = (chunk) => {
|
|
124
|
+
output += chunk.toString();
|
|
125
|
+
};
|
|
126
|
+
child.stdout.on('data', append);
|
|
127
|
+
child.stderr.on('data', append);
|
|
128
|
+
child.on('error', (error) => {
|
|
129
|
+
output += `\n${error.message}`;
|
|
130
|
+
resolvePromise({ exitCode: 1, output });
|
|
131
|
+
});
|
|
132
|
+
child.on('close', (code) => {
|
|
133
|
+
resolvePromise({ exitCode: code, output });
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=project_verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project_verifier.js","sourceRoot":"","sources":["../../src/verify/project_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0ExB,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAC7C,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAElF,MAAM,OAAO,eAAe;IAC3B;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAyB,EAAE,EAAE,OAAsB,eAAe,CAAC,YAAY;QAClG,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,IAAI,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C,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,OAAe,EAAE,GAAW;QACvD,OAAO,IAAI,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,CAAC,KAAa,EAAQ,EAAE;gBACtC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC5B,CAAC,CAAC;YACF,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC3B,MAAM,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC/B,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC1B,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Interview the user to scope an optimization target, using the code knowledge graph to surface and ground candidate tasks.
|
|
3
|
+
argument-hint: [focus]
|
|
4
|
+
allowed-tools: Bash, Read, Skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# code-graph-interview
|
|
8
|
+
|
|
9
|
+
You are a TypeScript optimization analyst. Your job is **not** to change any code.
|
|
10
|
+
It is to interview the user, narrow a vague wish ("optimize this") into one or more
|
|
11
|
+
concrete, measurable, well-scoped optimization tasks, and ground each candidate in
|
|
12
|
+
the code knowledge graph so it points at real symbols. You finish by **presenting
|
|
13
|
+
the tasks** — you do not apply them.
|
|
14
|
+
|
|
15
|
+
Use the code knowledge graph as your eyes: it holds resolved symbols and types, so
|
|
16
|
+
its answers about callers, references, and dead code are precise where text search
|
|
17
|
+
is not. Trust it over `grep` for any question about code structure or impact.
|
|
18
|
+
|
|
19
|
+
## Optional focus
|
|
20
|
+
|
|
21
|
+
$ARGUMENTS
|
|
22
|
+
|
|
23
|
+
If the focus above is non-empty, treat it as the user's starting hint (a dimension,
|
|
24
|
+
a subsystem, or a named symbol) and steer the interview toward it. If it is empty,
|
|
25
|
+
begin the interview from scratch.
|
|
26
|
+
|
|
27
|
+
## What "optimize" means (drive the interview with this)
|
|
28
|
+
|
|
29
|
+
"Optimize" is ambiguous and multi-dimensional. Do not guess which dimension the
|
|
30
|
+
user means — establish it. Optimization starts from a business concern, then
|
|
31
|
+
becomes a measurable target with a scope and constraints. Walk the user through
|
|
32
|
+
these five steps, in order, asking one focused round of questions at a time:
|
|
33
|
+
|
|
34
|
+
1. **Dimension** — what are we optimizing? Offer the choices and let the user pick:
|
|
35
|
+
execution time / latency, memory usage, infrastructure cost (including LLM
|
|
36
|
+
tokens), network usage, scalability, code maintainability, binary / bundle size,
|
|
37
|
+
energy. Execution time is the usual default, but make the user choose.
|
|
38
|
+
2. **Business concern** — capture the pain point, not the metric ("cloud bill too
|
|
39
|
+
high", "users say search is slow", "hitting API rate limits"). The user
|
|
40
|
+
understands the pain; you translate it into a technical goal.
|
|
41
|
+
3. **Measurable target** — turn the goal into a baseline and a target, e.g.
|
|
42
|
+
`800ms → 300ms`, `50 → 10 queries per request`, `10M → 2M tokens/day`. If a
|
|
43
|
+
thing cannot be measured, it cannot be optimized — say so and help define a
|
|
44
|
+
metric.
|
|
45
|
+
4. **Scope** — which part of the system: frontend, backend, database, network,
|
|
46
|
+
cache, queue, external APIs, LLM usage, storage, or a specific module / symbol.
|
|
47
|
+
5. **Constraints** — what must be preserved: same functionality, same security
|
|
48
|
+
guarantees, same API contract, same UX, same accuracy.
|
|
49
|
+
|
|
50
|
+
## Tools you will use
|
|
51
|
+
|
|
52
|
+
Graph queries go through this project's own CLI, which is documented by the
|
|
53
|
+
`code-graph-query` skill. Inside this repository's checkout, run the CLI with
|
|
54
|
+
`npx ts-knowledge-graph`, always pass `--json`, and let it use the default database
|
|
55
|
+
at `./.ts_knowledge_graph/graph.kuzu`:
|
|
56
|
+
|
|
57
|
+
- `npx ts-knowledge-graph dead-exports --json` — exported symbols with no inbound references (maintainability / dead-code candidates).
|
|
58
|
+
- `npx ts-knowledge-graph find <name> --json` — resolve a name to node id(s). Every other query needs an id; never invent one.
|
|
59
|
+
- `npx ts-knowledge-graph references <id> --json` — everything that references a symbol or type.
|
|
60
|
+
- `npx ts-knowledge-graph who-calls <id> --json` — direct callers of a function or method.
|
|
61
|
+
- `npx ts-knowledge-graph calls <id> --json` — what a symbol directly calls.
|
|
62
|
+
- `npx ts-knowledge-graph blast-radius <id> [--depth <n>] --json` — the transitive impact set (a proxy for change risk).
|
|
63
|
+
- `npx ts-knowledge-graph neighbors <id> --json` — the one-hop neighbourhood, inbound and outbound (a proxy for coupling).
|
|
64
|
+
|
|
65
|
+
If `./.ts_knowledge_graph/graph.kuzu` does not exist, build it first with
|
|
66
|
+
`npx ts-knowledge-graph extract . --semantic` followed by `npx ts-knowledge-graph load`
|
|
67
|
+
(the `--semantic` flag is required for caller and heritage edges).
|
|
68
|
+
|
|
69
|
+
For reading exact source text once you have located a symbol, use the Read tool.
|
|
70
|
+
|
|
71
|
+
### What the graph can and cannot ground
|
|
72
|
+
|
|
73
|
+
The graph is a **static** structural / semantic model: it knows symbols, callers,
|
|
74
|
+
references, and dead code. It does **not** hold runtime telemetry (latency, CPU,
|
|
75
|
+
memory, cost, call frequency). So:
|
|
76
|
+
|
|
77
|
+
- For **maintainability and dead-code** work, the graph is decisive: `dead-exports`
|
|
78
|
+
is a direct source of safe candidates.
|
|
79
|
+
- For **structural risk and coupling**, use `references`, `who-calls`,
|
|
80
|
+
`blast-radius`, and `neighbors` to rank how central or entangled a symbol is — a
|
|
81
|
+
high-reference, high-blast-radius symbol is a hotspot to treat carefully; an
|
|
82
|
+
isolated one is safer to refactor.
|
|
83
|
+
- For **runtime dimensions** (latency, memory, cost, tokens), the graph can only
|
|
84
|
+
show you *where* in the structure a hot path lives — the user must supply the
|
|
85
|
+
measurement and baseline. Say this plainly rather than inventing numbers.
|
|
86
|
+
|
|
87
|
+
## Method (follow it in order)
|
|
88
|
+
|
|
89
|
+
1. **Establish the dimension and concern.** Ask the user the step 1–2 questions.
|
|
90
|
+
Do not proceed until you know what is being optimized and why.
|
|
91
|
+
2. **Pin a measurable target and scope.** Ask the step 3–4 questions. Push back on
|
|
92
|
+
unmeasurable goals.
|
|
93
|
+
3. **Capture constraints.** Ask step 5 — what must not change.
|
|
94
|
+
4. **Survey the graph for candidates.** Run the queries above to surface concrete
|
|
95
|
+
targets within the agreed scope: start with `dead-exports`, and use `find` +
|
|
96
|
+
`references` / `who-calls` / `blast-radius` to locate and rank named hotspots.
|
|
97
|
+
Cite real node ids, file paths, and counts — never invent them.
|
|
98
|
+
5. **Draft the tasks.** Turn the findings into one or more concrete optimization
|
|
99
|
+
tasks. Each task must be self-contained and shaped so it could later be handed
|
|
100
|
+
to `/code-graph-optimize`. Include, per task:
|
|
101
|
+
- **Title** — one line.
|
|
102
|
+
- **Dimension** and **scope**.
|
|
103
|
+
- **Target** — the symbol(s) / file(s), with node id(s) and path(s) from the graph.
|
|
104
|
+
- **Measurable goal** — baseline → target (or "structural only" for dead-code).
|
|
105
|
+
- **Constraints** — what to preserve.
|
|
106
|
+
- **Graph evidence** — the reference / caller / blast-radius counts that justify it.
|
|
107
|
+
- **Estimated risk** — low / medium / high, argued from blast radius and coupling.
|
|
108
|
+
6. **Present and stop.** Show the user the ranked list of candidate tasks. **Do not
|
|
109
|
+
apply anything and do not invoke `/code-graph-optimize`.** End by telling the
|
|
110
|
+
user they can run `/code-graph-optimize "<task>"` themselves with whichever task
|
|
111
|
+
they choose.
|
|
112
|
+
|
|
113
|
+
## Rules
|
|
114
|
+
|
|
115
|
+
- This command is read-only. Never edit code, and never call `/code-graph-optimize`.
|
|
116
|
+
- Node ids come from `find` and `dead-exports` output; never invent them, never
|
|
117
|
+
invent file paths, counts, or runtime numbers.
|
|
118
|
+
- Interview the user — ask real questions and wait for answers. Do not assume the
|
|
119
|
+
dimension, target, or constraints.
|
|
120
|
+
- Keep every proposed task measurable and scoped. Reject vague goals like "make it
|
|
121
|
+
faster" until they have a baseline and a target.
|
|
122
|
+
- Present multiple candidates when the graph supports them, ranked by estimated
|
|
123
|
+
value against risk, so the user can choose.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Autonomously find and apply one verified-safe optimization, using the code knowledge graph as its eyes.
|
|
3
|
+
argument-hint: [task]
|
|
4
|
+
allowed-tools: Bash, Read, Edit, Skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# code-graph-optimize
|
|
8
|
+
|
|
9
|
+
You are an autonomous TypeScript optimization agent working on this real codebase.
|
|
10
|
+
Use the code knowledge graph as your eyes: it holds resolved symbols and types, so
|
|
11
|
+
its answers about callers, references, and dead code are precise where text search
|
|
12
|
+
is not. Trust it over `grep` for any question about code structure or impact.
|
|
13
|
+
|
|
14
|
+
## Your task
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
If the task above is empty, default to this mission: **find one genuinely dead
|
|
19
|
+
exported symbol, confirm it has zero inbound references, then remove it safely.**
|
|
20
|
+
|
|
21
|
+
## Tools you will use
|
|
22
|
+
|
|
23
|
+
Graph queries go through this project's own CLI, which is documented by the
|
|
24
|
+
`code-graph-query` skill. Inside this repository's checkout, run the CLI with
|
|
25
|
+
`npx ts-knowledge-graph`, always pass `--json`, and let it use the default database at
|
|
26
|
+
`./.ts_knowledge_graph/graph.kuzu`:
|
|
27
|
+
|
|
28
|
+
- `npx ts-knowledge-graph dead-exports --json` — exported symbols with no inbound references (the safest candidates).
|
|
29
|
+
- `npx ts-knowledge-graph find <name> --json` — resolve a name to node id(s). Every other query needs an id; never invent one.
|
|
30
|
+
- `npx ts-knowledge-graph references <id> --json` — everything that references a symbol or type. This is the decisive safety check.
|
|
31
|
+
- `npx ts-knowledge-graph who-calls <id> --json` — direct callers of a function or method.
|
|
32
|
+
- `npx ts-knowledge-graph blast-radius <id> [--depth <n>] --json` — the transitive impact set.
|
|
33
|
+
- `npx ts-knowledge-graph neighbors <id> --json` — the one-hop neighbourhood, inbound and outbound.
|
|
34
|
+
|
|
35
|
+
If `./.ts_knowledge_graph/graph.kuzu` does not exist, build it first with
|
|
36
|
+
`npx ts-knowledge-graph extract . --semantic` followed by `npx ts-knowledge-graph load`
|
|
37
|
+
(the `--semantic` flag is required for caller and heritage edges).
|
|
38
|
+
|
|
39
|
+
To verify an edit, use this project's own verify gate, which runs the
|
|
40
|
+
type-check **and** the test suite together and returns a single verdict:
|
|
41
|
+
|
|
42
|
+
- `npx ts-knowledge-graph verify --json` — runs the project's `typecheck` + `test` npm scripts and reports one result. `ok: true` means keep the edit; `ok: false` means revert it (the command also exits non-zero on failure). `behaviorVerified: true` means the tests actually ran and passed — not just the type-check. If the project has no `test` script the test gate is skipped, `degraded` is `true`, and the edit is type-checked only.
|
|
43
|
+
|
|
44
|
+
For reading exact source text, use the Read tool. For making the change, use the
|
|
45
|
+
Edit tool.
|
|
46
|
+
|
|
47
|
+
## Method (follow it in order)
|
|
48
|
+
|
|
49
|
+
1. **Find a candidate.** Dead code is the safest win — call `dead-exports` first, or `find` to locate a named target from the task.
|
|
50
|
+
2. **Confirm the blast radius.** Before proposing any change you MUST confirm safety with `references` (and `who-calls` or `blast-radius` when useful). A symbol is safe to remove only when it has zero inbound references.
|
|
51
|
+
3. **Read the exact text** with the Read tool so your edit matches the file precisely.
|
|
52
|
+
4. **Make exactly one edit** with the Edit tool.
|
|
53
|
+
5. **Verify, then keep or revert.** Run `npx ts-knowledge-graph verify --json` — one command that runs the type-check **and** the test suite, so a behaviour-changing edit (a swapped operator, an off-by-one, a dropped branch) is caught, not just a type error.
|
|
54
|
+
- If `ok` is `true`, the edit stands.
|
|
55
|
+
- If `ok` is `false`, revert immediately with `git restore <file>`, then either try a different edit or abandon the change. Never leave a failing verify behind.
|
|
56
|
+
6. **Measure the impact (optional — only when the task targets a runtime metric and a workload exists).** If the point of the edit was to make something *faster*, and the project or task supplies a repeatable workload, you can report the measured delta with `npx ts-knowledge-graph benchmark <name> --workload <path> --runs 5` (capture a `--save-baseline` before the edit, compare with `--baseline` after — rebuild the graph in between). This gate is **advisory**: a noisy median with a spread, not a pass/fail. Never present a benchmark delta as a guarantee, and never let it override the hard `verify` result.
|
|
57
|
+
7. **Stop and summarize.** Report the file changed, the symbol removed, and why removal was safe. State plainly **how the edit was verified**: say the change was type-checked *and* tested only when `behaviorVerified` was `true`; if verify ran `degraded` (type-check only, because the project has no test script), say the change was **not** behaviourally verified rather than implying it was. If you measured impact, report it as an advisory delta, not a promise. If you found no safe change, say so plainly.
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- Node ids come from `find` and `dead-exports` output; never invent them.
|
|
62
|
+
- Act autonomously. Do not ask the user questions — make the call yourself.
|
|
63
|
+
- Prefer removing genuinely dead exports or behavior-preserving simplifications. Never change observable behavior.
|
|
64
|
+
- Before your first edit, confirm the target file has no unrelated uncommitted changes, so that a revert restores a known-good state. If it does, mention it and proceed carefully.
|
|
65
|
+
- Apply at most one verified edit per run, mirroring the original optimizer's discipline.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: code-graph-query
|
|
3
3
|
description: >-
|
|
4
4
|
Query a TypeScript codebase as a knowledge graph to answer impact, caller,
|
|
5
5
|
dependency, and dead-code questions. Use this instead of grep/glob for
|
|
@@ -8,7 +8,7 @@ description: >-
|
|
|
8
8
|
ts-knowledge-graph CLI and a built graph database.
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
#
|
|
11
|
+
# code-graph-query
|
|
12
12
|
|
|
13
13
|
Answer structural questions about a TypeScript project by querying a semantic
|
|
14
14
|
knowledge graph (built with the TypeScript compiler API) rather than reading or
|
|
@@ -32,13 +32,13 @@ still the right choice. Use this skill to decide *which* code matters first.
|
|
|
32
32
|
|
|
33
33
|
## Prerequisite: build the graph once
|
|
34
34
|
|
|
35
|
-
Querying needs a Kùzu database at
|
|
35
|
+
Querying needs a Kùzu database at `./.ts_knowledge_graph/graph.kuzu`. If it is missing,
|
|
36
36
|
build it first (the `--semantic` flag is required for `CALLS` and heritage
|
|
37
37
|
edges, which power `who-calls`, `calls`, and `blast-radius`):
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
npx ts-knowledge-graph extract <path-to-project> --semantic # writes
|
|
41
|
-
npx ts-knowledge-graph load # writes
|
|
40
|
+
npx ts-knowledge-graph extract <path-to-project> --semantic # writes ./.ts_knowledge_graph/graph/*.jsonl
|
|
41
|
+
npx ts-knowledge-graph load # writes ./.ts_knowledge_graph/graph.kuzu
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Inside this repository's own checkout, substitute `npm run dev --` for the
|
|
@@ -59,7 +59,7 @@ Always pass `--json`; consume the JSON, not the human-readable output.
|
|
|
59
59
|
|
|
60
60
|
## Command reference
|
|
61
61
|
|
|
62
|
-
All commands accept `--json` and `-
|
|
62
|
+
All commands accept `--json` and `-o, --output-folder <dir>` (default `./.ts_knowledge_graph`).
|
|
63
63
|
|
|
64
64
|
| Command | Argument | Purpose |
|
|
65
65
|
| --- | --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-knowledge-graph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Parse TypeScript source into a knowledge graph for autonomous code optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,37 +8,126 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
|
-
"contribs/
|
|
12
|
-
"
|
|
11
|
+
"contribs/webview/web",
|
|
12
|
+
"dotclaude_folder",
|
|
13
13
|
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
".env-sample"
|
|
14
|
+
"LICENSE"
|
|
16
15
|
],
|
|
17
16
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
17
|
+
"node": ">=20.12"
|
|
19
18
|
},
|
|
20
19
|
"publishConfig": {
|
|
21
20
|
"access": "public"
|
|
22
21
|
},
|
|
23
22
|
"scripts": {
|
|
24
23
|
"extract": "tsx src/cli.ts extract",
|
|
25
|
-
"
|
|
24
|
+
"webview": "tsx src/cli.ts webview",
|
|
26
25
|
"dev": "tsx src/cli.ts",
|
|
27
26
|
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"clean": "npm run clean:dist && npm run clean:outputs",
|
|
28
|
+
"clean:dist": "rm -rf ./dist",
|
|
29
|
+
"clean:outputs": "rm -rf ./.ts_knowledge_graph/*/",
|
|
30
|
+
"symlink:dotclaude": "bash scripts/symlink_dotclaude.sh",
|
|
28
31
|
"publish:all": "npm run build && npm version patch && npm publish",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"test": "node --import tsx --test \"
|
|
32
|
+
"typecheck": "tsc --noEmit && tsc -p contribs/webview/tsconfig.web.json",
|
|
33
|
+
"test": "node --import tsx --test \"tests/**/*.test.ts\"",
|
|
34
|
+
"verify": "tsx src/cli.ts verify",
|
|
35
|
+
"project01": "npm run project01:rebuild && npm run project01:dead-exports",
|
|
36
|
+
"project01:tour": "bash scripts/project_01_tour.sh",
|
|
37
|
+
"project01:rebuild": "npm run project01:clean && npm run project01:extract && npm run project01:load",
|
|
38
|
+
"project01:clean": "rm -rf ./.ts_knowledge_graph/project_01/graph ./.ts_knowledge_graph/project_01/graph.kuzu ./.ts_knowledge_graph/project_01/prof",
|
|
39
|
+
"project01:extract": "tsx src/cli.ts extract sample_projects/project_01/src --semantic -o ./.ts_knowledge_graph/project_01",
|
|
40
|
+
"project01:load": "tsx src/cli.ts load -o ./.ts_knowledge_graph/project_01",
|
|
41
|
+
"project01:enrich": "bash scripts/profile_and_enrich.sh project_01",
|
|
42
|
+
"project01:benchmark": "tsx src/cli.ts benchmark titleCase --workload scripts/benchmarks/project_01_workload.ts -o ./.ts_knowledge_graph/project_01 --root ./sample_projects/project_01 --runs 5",
|
|
43
|
+
"project01:verify": "tsx src/cli.ts verify --cwd sample_projects/project_01",
|
|
44
|
+
"project01:dead-exports": "tsx src/cli.ts dead-exports -o ./.ts_knowledge_graph/project_01",
|
|
45
|
+
"project01:hotspots": "tsx src/cli.ts hotspots -o ./.ts_knowledge_graph/project_01",
|
|
46
|
+
"project01:cost": "tsx src/cli.ts cost -o ./.ts_knowledge_graph/project_01",
|
|
47
|
+
"project01:cluster": "tsx src/cli.ts cluster -o ./.ts_knowledge_graph/project_01",
|
|
48
|
+
"project01:find": "tsx src/cli.ts find -o ./.ts_knowledge_graph/project_01",
|
|
49
|
+
"project01:who-calls": "tsx src/cli.ts who-calls -o ./.ts_knowledge_graph/project_01",
|
|
50
|
+
"project01:calls": "tsx src/cli.ts calls -o ./.ts_knowledge_graph/project_01",
|
|
51
|
+
"project01:references": "tsx src/cli.ts references -o ./.ts_knowledge_graph/project_01",
|
|
52
|
+
"project01:neighbors": "tsx src/cli.ts neighbors -o ./.ts_knowledge_graph/project_01",
|
|
53
|
+
"project01:blast-radius": "tsx src/cli.ts blast-radius -o ./.ts_knowledge_graph/project_01",
|
|
54
|
+
"project01:webview": "tsx src/cli.ts webview -o ./.ts_knowledge_graph/project_01",
|
|
55
|
+
"project01:report": "tsx src/cli.ts report -o ./.ts_knowledge_graph/project_01",
|
|
56
|
+
"project02": "npm run project02:rebuild && npm run project02:dead-exports",
|
|
57
|
+
"project02:tour": "bash scripts/project_02_tour.sh",
|
|
58
|
+
"project02:rebuild": "npm run project02:clean && npm run project02:extract && npm run project02:load",
|
|
59
|
+
"project02:clean": "rm -rf ./.ts_knowledge_graph/project_02/graph ./.ts_knowledge_graph/project_02/graph.kuzu ./.ts_knowledge_graph/project_02/prof",
|
|
60
|
+
"project02:extract": "tsx src/cli.ts extract sample_projects/project_02/src --semantic -o ./.ts_knowledge_graph/project_02",
|
|
61
|
+
"project02:load": "tsx src/cli.ts load -o ./.ts_knowledge_graph/project_02",
|
|
62
|
+
"project02:enrich": "bash scripts/profile_and_enrich.sh project_02",
|
|
63
|
+
"project02:benchmark": "tsx src/cli.ts benchmark parseTerm --workload scripts/benchmarks/project_02_workload.ts -o ./.ts_knowledge_graph/project_02 --root ./sample_projects/project_02 --runs 5",
|
|
64
|
+
"project02:verify": "tsx src/cli.ts verify --cwd sample_projects/project_02",
|
|
65
|
+
"project02:dead-exports": "tsx src/cli.ts dead-exports -o ./.ts_knowledge_graph/project_02",
|
|
66
|
+
"project02:hotspots": "tsx src/cli.ts hotspots -o ./.ts_knowledge_graph/project_02",
|
|
67
|
+
"project02:cost": "tsx src/cli.ts cost -o ./.ts_knowledge_graph/project_02",
|
|
68
|
+
"project02:cluster": "tsx src/cli.ts cluster -o ./.ts_knowledge_graph/project_02",
|
|
69
|
+
"project02:find": "tsx src/cli.ts find -o ./.ts_knowledge_graph/project_02",
|
|
70
|
+
"project02:who-calls": "tsx src/cli.ts who-calls -o ./.ts_knowledge_graph/project_02",
|
|
71
|
+
"project02:calls": "tsx src/cli.ts calls -o ./.ts_knowledge_graph/project_02",
|
|
72
|
+
"project02:references": "tsx src/cli.ts references -o ./.ts_knowledge_graph/project_02",
|
|
73
|
+
"project02:neighbors": "tsx src/cli.ts neighbors -o ./.ts_knowledge_graph/project_02",
|
|
74
|
+
"project02:blast-radius": "tsx src/cli.ts blast-radius -o ./.ts_knowledge_graph/project_02",
|
|
75
|
+
"project02:webview": "tsx src/cli.ts webview -o ./.ts_knowledge_graph/project_02",
|
|
76
|
+
"project02:report": "tsx src/cli.ts report -o ./.ts_knowledge_graph/project_02",
|
|
77
|
+
"project03": "npm run project03:rebuild && npm run project03:dead-exports",
|
|
78
|
+
"project03:tour": "bash scripts/project_03_tour.sh",
|
|
79
|
+
"project03:rebuild": "npm run project03:clean && npm run project03:extract && npm run project03:load",
|
|
80
|
+
"project03:clean": "rm -rf ./.ts_knowledge_graph/project_03/graph ./.ts_knowledge_graph/project_03/graph.kuzu ./.ts_knowledge_graph/project_03/prof",
|
|
81
|
+
"project03:extract": "tsx src/cli.ts extract sample_projects/project_03/src --semantic -o ./.ts_knowledge_graph/project_03",
|
|
82
|
+
"project03:load": "tsx src/cli.ts load -o ./.ts_knowledge_graph/project_03",
|
|
83
|
+
"project03:enrich": "bash scripts/profile_and_enrich.sh project_03",
|
|
84
|
+
"project03:benchmark": "tsx src/cli.ts benchmark describe --workload scripts/benchmarks/project_03_workload.ts -o ./.ts_knowledge_graph/project_03 --root ./sample_projects/project_03 --runs 5",
|
|
85
|
+
"project03:verify": "tsx src/cli.ts verify --cwd sample_projects/project_03",
|
|
86
|
+
"project03:dead-exports": "tsx src/cli.ts dead-exports -o ./.ts_knowledge_graph/project_03",
|
|
87
|
+
"project03:hotspots": "tsx src/cli.ts hotspots -o ./.ts_knowledge_graph/project_03",
|
|
88
|
+
"project03:cost": "tsx src/cli.ts cost -o ./.ts_knowledge_graph/project_03",
|
|
89
|
+
"project03:cluster": "tsx src/cli.ts cluster -o ./.ts_knowledge_graph/project_03",
|
|
90
|
+
"project03:find": "tsx src/cli.ts find -o ./.ts_knowledge_graph/project_03",
|
|
91
|
+
"project03:who-calls": "tsx src/cli.ts who-calls -o ./.ts_knowledge_graph/project_03",
|
|
92
|
+
"project03:calls": "tsx src/cli.ts calls -o ./.ts_knowledge_graph/project_03",
|
|
93
|
+
"project03:references": "tsx src/cli.ts references -o ./.ts_knowledge_graph/project_03",
|
|
94
|
+
"project03:neighbors": "tsx src/cli.ts neighbors -o ./.ts_knowledge_graph/project_03",
|
|
95
|
+
"project03:blast-radius": "tsx src/cli.ts blast-radius -o ./.ts_knowledge_graph/project_03",
|
|
96
|
+
"project03:webview": "tsx src/cli.ts webview -o ./.ts_knowledge_graph/project_03",
|
|
97
|
+
"project03:report": "tsx src/cli.ts report -o ./.ts_knowledge_graph/project_03",
|
|
98
|
+
"project04": "npm run project04:rebuild && npm run project04:dead-exports",
|
|
99
|
+
"project04:tour": "bash scripts/project_04_tour.sh",
|
|
100
|
+
"project04:rebuild": "npm run project04:clean && npm run project04:extract && npm run project04:load",
|
|
101
|
+
"project04:clean": "rm -rf ./.ts_knowledge_graph/project_04/graph ./.ts_knowledge_graph/project_04/graph.kuzu ./.ts_knowledge_graph/project_04/prof",
|
|
102
|
+
"project04:extract": "tsx src/cli.ts extract sample_projects/project_04/src --semantic -o ./.ts_knowledge_graph/project_04",
|
|
103
|
+
"project04:load": "tsx src/cli.ts load -o ./.ts_knowledge_graph/project_04",
|
|
104
|
+
"project04:enrich": "bash scripts/profile_and_enrich.sh project_04",
|
|
105
|
+
"project04:workload": "tsx scripts/benchmarks/project_04_workload.ts",
|
|
106
|
+
"project04:verify": "tsx src/cli.ts verify --cwd sample_projects/project_04",
|
|
107
|
+
"project04:dead-exports": "tsx src/cli.ts dead-exports -o ./.ts_knowledge_graph/project_04",
|
|
108
|
+
"project04:hotspots": "tsx src/cli.ts hotspots -o ./.ts_knowledge_graph/project_04",
|
|
109
|
+
"project04:cost": "tsx src/cli.ts cost -o ./.ts_knowledge_graph/project_04",
|
|
110
|
+
"project04:cluster": "tsx src/cli.ts cluster -o ./.ts_knowledge_graph/project_04",
|
|
111
|
+
"project04:find": "tsx src/cli.ts find -o ./.ts_knowledge_graph/project_04",
|
|
112
|
+
"project04:who-calls": "tsx src/cli.ts who-calls -o ./.ts_knowledge_graph/project_04",
|
|
113
|
+
"project04:calls": "tsx src/cli.ts calls -o ./.ts_knowledge_graph/project_04",
|
|
114
|
+
"project04:references": "tsx src/cli.ts references -o ./.ts_knowledge_graph/project_04",
|
|
115
|
+
"project04:neighbors": "tsx src/cli.ts neighbors -o ./.ts_knowledge_graph/project_04",
|
|
116
|
+
"project04:blast-radius": "tsx src/cli.ts blast-radius -o ./.ts_knowledge_graph/project_04",
|
|
117
|
+
"project04:webview": "tsx src/cli.ts webview -o ./.ts_knowledge_graph/project_04",
|
|
118
|
+
"project04:report": "tsx src/cli.ts report -o ./.ts_knowledge_graph/project_04"
|
|
31
119
|
},
|
|
32
120
|
"dependencies": {
|
|
33
121
|
"chalk": "^5.3.0",
|
|
34
122
|
"commander": "^12.1.0",
|
|
35
123
|
"kuzu": "^0.11.3",
|
|
36
|
-
"
|
|
124
|
+
"networkanalysis-ts": "^1.0.0",
|
|
37
125
|
"ts-morph": "^23.0.0",
|
|
38
126
|
"zod": "^3.23.8"
|
|
39
127
|
},
|
|
40
128
|
"devDependencies": {
|
|
41
129
|
"@types/node": "^20.14.0",
|
|
130
|
+
"puppeteer": "^25.1.0",
|
|
42
131
|
"tsx": "^4.16.0",
|
|
43
132
|
"typescript": "^5.5.0"
|
|
44
133
|
}
|