okstra 0.130.3 → 0.131.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.
Files changed (367) hide show
  1. package/README.md +0 -1
  2. package/docs/architecture.md +2 -2
  3. package/docs/cli.md +1 -1
  4. package/docs/for-ai/README.md +0 -2
  5. package/docs/for-ai/skills/okstra-run.md +13 -2
  6. package/docs/for-ai/skills/okstra-setup.md +4 -1
  7. package/docs/project-structure-overview.md +5 -4
  8. package/docs/task-process/implementation-planning.md +13 -0
  9. package/docs/task-process/implementation.md +17 -2
  10. package/package.json +1 -1
  11. package/runtime/BUILD.json +2 -2
  12. package/runtime/agents/workers/report-writer-worker.md +7 -0
  13. package/runtime/bin/lib/okstra/usage.sh +4 -4
  14. package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
  15. package/runtime/prompts/lead/plan-body-verification.md +26 -5
  16. package/runtime/prompts/lead/report-writer.md +6 -2
  17. package/runtime/prompts/profiles/_common-contract.md +2 -1
  18. package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
  19. package/runtime/prompts/profiles/_implementation-executor.md +2 -2
  20. package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
  21. package/runtime/prompts/profiles/final-verification.md +21 -6
  22. package/runtime/prompts/profiles/implementation-planning.md +21 -4
  23. package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
  24. package/runtime/python/okstra_ctl/conformance.py +49 -11
  25. package/runtime/python/okstra_ctl/report_finalize.py +52 -1
  26. package/runtime/python/okstra_ctl/report_views.py +32 -5
  27. package/runtime/python/okstra_ctl/run.py +15 -3
  28. package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
  29. package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
  30. package/runtime/python/okstra_vendor/__init__.py +0 -44
  31. package/runtime/schemas/final-report-v1.0.schema.json +101 -6
  32. package/runtime/skills/okstra-run/SKILL.md +11 -4
  33. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  34. package/runtime/skills/okstra-setup/references/project-config.md +16 -7
  35. package/runtime/templates/reports/final-report.template.md +18 -12
  36. package/runtime/templates/reports/i18n/en.json +1 -0
  37. package/runtime/templates/reports/i18n/ko.json +1 -0
  38. package/runtime/templates/reports/report.css +18 -0
  39. package/runtime/validators/lib/fixtures.sh +6 -0
  40. package/runtime/validators/validate-run.py +1722 -98
  41. package/src/cli-registry.mjs +0 -7
  42. package/src/commands/lifecycle/doctor.mjs +0 -9
  43. package/src/lib/skill-catalog.mjs +0 -1
  44. package/docs/for-ai/skills/okstra-graphify.md +0 -64
  45. package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
  46. package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
  47. package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
  48. package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
  49. package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
  50. package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
  51. package/runtime/python/okstra_vendor/graphify/build.py +0 -107
  52. package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
  53. package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
  54. package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
  55. package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
  56. package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
  57. package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
  58. package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
  59. package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
  60. package/runtime/python/okstra_vendor/graphify/report.py +0 -175
  61. package/runtime/python/okstra_vendor/graphify/security.py +0 -203
  62. package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
  63. package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
  64. package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
  65. package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
  66. package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
  67. package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
  68. package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
  69. package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
  70. package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
  71. package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
  72. package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
  73. package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
  74. package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
  75. package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
  76. package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
  77. package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
  78. package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
  79. package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
  80. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
  81. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
  82. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
  83. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
  84. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
  85. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
  86. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
  87. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
  88. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
  89. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
  90. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
  91. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
  92. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
  93. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
  94. package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
  95. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
  96. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
  97. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
  98. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
  99. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
  100. package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
  101. package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
  102. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
  103. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
  104. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
  105. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
  106. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
  107. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
  108. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
  109. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
  110. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
  111. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
  112. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
  113. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
  114. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
  115. package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
  116. package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
  117. package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
  118. package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
  119. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
  120. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
  121. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
  122. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
  123. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
  124. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
  125. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
  126. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
  127. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
  128. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
  129. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
  130. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
  131. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
  132. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
  133. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
  134. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
  135. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
  136. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
  137. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
  138. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
  139. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
  140. package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
  141. package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
  142. package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
  143. package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
  144. package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
  145. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
  146. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
  147. package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
  148. package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
  149. package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
  150. package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
  151. package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
  152. package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
  153. package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
  154. package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
  155. package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
  156. package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
  157. package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
  158. package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
  159. package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
  160. package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
  161. package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
  162. package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
  163. package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
  164. package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
  165. package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
  166. package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
  167. package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
  168. package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
  169. package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
  170. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
  171. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
  172. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
  173. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
  174. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
  175. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
  176. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
  177. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
  178. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
  179. package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
  180. package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
  181. package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
  182. package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
  183. package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
  184. package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
  185. package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
  186. package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
  187. package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
  188. package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
  189. package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
  190. package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
  191. package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
  192. package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
  193. package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
  194. package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
  195. package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
  196. package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
  197. package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
  198. package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
  199. package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
  200. package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
  201. package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
  202. package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
  203. package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
  204. package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
  205. package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
  206. package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
  207. package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
  208. package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
  209. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
  210. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
  211. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
  212. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
  213. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
  214. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
  215. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
  216. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
  217. package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
  218. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
  219. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
  220. package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
  221. package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
  222. package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
  223. package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
  224. package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
  225. package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
  226. package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
  227. package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
  228. package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
  229. package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
  230. package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
  231. package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
  232. package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
  233. package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
  234. package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
  235. package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
  236. package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
  237. package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
  238. package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
  239. package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
  240. package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
  241. package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
  242. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
  243. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
  244. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
  245. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
  246. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
  247. package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
  248. package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
  249. package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
  250. package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
  251. package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
  252. package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
  253. package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
  254. package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
  255. package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
  256. package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
  257. package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
  258. package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
  259. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
  260. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
  261. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
  262. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
  263. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
  264. package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
  265. package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
  266. package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
  267. package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
  268. package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
  269. package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
  270. package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
  271. package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
  272. package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
  273. package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
  274. package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
  275. package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
  276. package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
  277. package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
  278. package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
  279. package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
  280. package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
  281. package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
  282. package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
  283. package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
  284. package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
  285. package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
  286. package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
  287. package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
  288. package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
  289. package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
  290. package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
  291. package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
  292. package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
  293. package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
  294. package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
  295. package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
  296. package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
  297. package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
  298. package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
  299. package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
  300. package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
  301. package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
  302. package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
  303. package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
  304. package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
  305. package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
  306. package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
  307. package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
  308. package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
  309. package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
  310. package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
  311. package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
  312. package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
  313. package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
  314. package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
  315. package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
  316. package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
  317. package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
  318. package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
  319. package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
  320. package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
  321. package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
  322. package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
  323. package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
  324. package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
  325. package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
  326. package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
  327. package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
  328. package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
  329. package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
  330. package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
  331. package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
  332. package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
  333. package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
  334. package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
  335. package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
  336. package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
  337. package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
  338. package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
  339. package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
  340. package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
  341. package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
  342. package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
  343. package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
  344. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
  345. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
  346. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
  347. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
  348. package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
  349. package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
  350. package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
  351. package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
  352. package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
  353. package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
  354. package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
  355. package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
  356. package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
  357. package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
  358. package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
  359. package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
  360. package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
  361. package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
  362. package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
  363. package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
  364. package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
  365. package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
  366. package/runtime/skills/okstra-graphify/SKILL.md +0 -169
  367. package/src/commands/graphify.mjs +0 -32
@@ -1,1371 +0,0 @@
1
- """graphify CLI - `graphify install` sets up the Claude Code skill."""
2
- from __future__ import annotations
3
- import json
4
- import platform
5
- import re
6
- import shutil
7
- import sys
8
- from pathlib import Path
9
-
10
- try:
11
- from importlib.metadata import version as _pkg_version
12
- __version__ = _pkg_version("graphifyy")
13
- except Exception:
14
- __version__ = "unknown"
15
-
16
-
17
- def _check_skill_version(skill_dst: Path) -> None:
18
- """Warn if the installed skill is from an older graphify version."""
19
- version_file = skill_dst.parent / ".graphify_version"
20
- if not version_file.exists():
21
- return
22
- installed = version_file.read_text(encoding="utf-8").strip()
23
- if installed != __version__:
24
- print(f" warning: skill is from graphify {installed}, package is {__version__}. Run 'graphify install' to update.")
25
-
26
-
27
- def _refresh_all_version_stamps() -> None:
28
- """After a successful install, update .graphify_version in all other known skill dirs.
29
-
30
- Prevents stale-version warnings from platforms that were installed previously
31
- but not explicitly re-installed during this upgrade.
32
- """
33
- for cfg in _PLATFORM_CONFIG.values():
34
- vf = Path.home() / cfg["skill_dst"]
35
- vf = vf.parent / ".graphify_version"
36
- if vf.exists():
37
- vf.write_text(__version__, encoding="utf-8")
38
-
39
- _SETTINGS_HOOK = {
40
- "matcher": "Glob|Grep",
41
- "hooks": [
42
- {
43
- "type": "command",
44
- "command": (
45
- "[ -f graphify-out/graph.json ] && "
46
- r"""echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}' """
47
- "|| true"
48
- ),
49
- }
50
- ],
51
- }
52
-
53
- _SKILL_REGISTRATION = (
54
- "\n# graphify\n"
55
- "- **graphify** (`~/.claude/skills/graphify/SKILL.md`) "
56
- "- any input to knowledge graph. Trigger: `/graphify`\n"
57
- "When the user types `/graphify`, invoke the Skill tool "
58
- "with `skill: \"graphify\"` before doing anything else.\n"
59
- )
60
-
61
-
62
- _PLATFORM_CONFIG: dict[str, dict] = {
63
- "claude": {
64
- "skill_file": "skill.md",
65
- "skill_dst": Path(".claude") / "skills" / "graphify" / "SKILL.md",
66
- "claude_md": True,
67
- },
68
- "codex": {
69
- "skill_file": "skill-codex.md",
70
- "skill_dst": Path(".agents") / "skills" / "graphify" / "SKILL.md",
71
- "claude_md": False,
72
- },
73
- "opencode": {
74
- "skill_file": "skill-opencode.md",
75
- "skill_dst": Path(".config") / "opencode" / "skills" / "graphify" / "SKILL.md",
76
- "claude_md": False,
77
- },
78
- "aider": {
79
- "skill_file": "skill-aider.md",
80
- "skill_dst": Path(".aider") / "graphify" / "SKILL.md",
81
- "claude_md": False,
82
- },
83
- "copilot": {
84
- "skill_file": "skill-copilot.md",
85
- "skill_dst": Path(".copilot") / "skills" / "graphify" / "SKILL.md",
86
- "claude_md": False,
87
- },
88
- "claw": {
89
- "skill_file": "skill-claw.md",
90
- "skill_dst": Path(".openclaw") / "skills" / "graphify" / "SKILL.md",
91
- "claude_md": False,
92
- },
93
- "droid": {
94
- "skill_file": "skill-droid.md",
95
- "skill_dst": Path(".factory") / "skills" / "graphify" / "SKILL.md",
96
- "claude_md": False,
97
- },
98
- "trae": {
99
- "skill_file": "skill-trae.md",
100
- "skill_dst": Path(".trae") / "skills" / "graphify" / "SKILL.md",
101
- "claude_md": False,
102
- },
103
- "trae-cn": {
104
- "skill_file": "skill-trae.md",
105
- "skill_dst": Path(".trae-cn") / "skills" / "graphify" / "SKILL.md",
106
- "claude_md": False,
107
- },
108
- "hermes": {
109
- "skill_file": "skill-claw.md",
110
- "skill_dst": Path(".hermes") / "skills" / "graphify" / "SKILL.md",
111
- "claude_md": False,
112
- },
113
- "kiro": {
114
- "skill_file": "skill-kiro.md",
115
- "skill_dst": Path(".kiro") / "skills" / "graphify" / "SKILL.md",
116
- "claude_md": False,
117
- },
118
- "antigravity": {
119
- "skill_file": "skill.md",
120
- "skill_dst": Path(".agent") / "skills" / "graphify" / "SKILL.md",
121
- "claude_md": False,
122
- },
123
- "windows": {
124
- "skill_file": "skill-windows.md",
125
- "skill_dst": Path(".claude") / "skills" / "graphify" / "SKILL.md",
126
- "claude_md": True,
127
- },
128
- }
129
-
130
-
131
- def install(platform: str = "claude") -> None:
132
- if platform == "gemini":
133
- gemini_install()
134
- return
135
- if platform == "cursor":
136
- _cursor_install(Path("."))
137
- return
138
- if platform not in _PLATFORM_CONFIG:
139
- print(
140
- f"error: unknown platform '{platform}'. Choose from: {', '.join(_PLATFORM_CONFIG)}, gemini, cursor",
141
- file=sys.stderr,
142
- )
143
- sys.exit(1)
144
-
145
- cfg = _PLATFORM_CONFIG[platform]
146
- skill_src = Path(__file__).parent / cfg["skill_file"]
147
- if not skill_src.exists():
148
- print(f"error: {cfg['skill_file']} not found in package - reinstall graphify", file=sys.stderr)
149
- sys.exit(1)
150
-
151
- skill_dst = Path.home() / cfg["skill_dst"]
152
- skill_dst.parent.mkdir(parents=True, exist_ok=True)
153
- shutil.copy(skill_src, skill_dst)
154
- (skill_dst.parent / ".graphify_version").write_text(__version__, encoding="utf-8")
155
- print(f" skill installed -> {skill_dst}")
156
-
157
- if cfg["claude_md"]:
158
- # Register in ~/.claude/CLAUDE.md (Claude Code only)
159
- claude_md = Path.home() / ".claude" / "CLAUDE.md"
160
- if claude_md.exists():
161
- content = claude_md.read_text(encoding="utf-8")
162
- if "graphify" in content:
163
- print(f" CLAUDE.md -> already registered (no change)")
164
- else:
165
- claude_md.write_text(content.rstrip() + _SKILL_REGISTRATION, encoding="utf-8")
166
- print(f" CLAUDE.md -> skill registered in {claude_md}")
167
- else:
168
- claude_md.parent.mkdir(parents=True, exist_ok=True)
169
- claude_md.write_text(_SKILL_REGISTRATION.lstrip(), encoding="utf-8")
170
- print(f" CLAUDE.md -> created at {claude_md}")
171
-
172
- if platform == "opencode":
173
- _install_opencode_plugin(Path("."))
174
-
175
- # Refresh version stamps in all other previously-installed skill dirs so
176
- # stale-version warnings don't fire for platforms not explicitly re-installed.
177
- _refresh_all_version_stamps()
178
-
179
- print()
180
- print("Done. Open your AI coding assistant and type:")
181
- print()
182
- print(" /graphify .")
183
- print()
184
-
185
-
186
- _CLAUDE_MD_SECTION = """\
187
- ## graphify
188
-
189
- This project has a graphify knowledge graph at graphify-out/.
190
-
191
- Rules:
192
- - Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
193
- - If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
194
- - After modifying code files in this session, run `graphify update .` to keep the graph current (AST-only, no API cost)
195
- """
196
-
197
- _CLAUDE_MD_MARKER = "## graphify"
198
-
199
- # AGENTS.md section for Codex, OpenCode, and OpenClaw.
200
- # All three platforms read AGENTS.md in the project root for persistent instructions.
201
- _AGENTS_MD_SECTION = """\
202
- ## graphify
203
-
204
- This project has a graphify knowledge graph at graphify-out/.
205
-
206
- Rules:
207
- - Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
208
- - If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
209
- - After modifying code files in this session, run `graphify update .` to keep the graph current (AST-only, no API cost)
210
- """
211
-
212
- _AGENTS_MD_MARKER = "## graphify"
213
-
214
- _GEMINI_MD_SECTION = """\
215
- ## graphify
216
-
217
- This project has a graphify knowledge graph at graphify-out/.
218
-
219
- Rules:
220
- - Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
221
- - If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
222
- - After modifying code files in this session, run `graphify update .` to keep the graph current (AST-only, no API cost)
223
- """
224
-
225
- _GEMINI_MD_MARKER = "## graphify"
226
-
227
- _GEMINI_HOOK = {
228
- "matcher": "read_file|list_directory",
229
- "hooks": [
230
- {
231
- "type": "command",
232
- "command": (
233
- "[ -f graphify-out/graph.json ] && "
234
- r"""echo '{"decision":"allow","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}' """
235
- r"""|| echo '{"decision":"allow"}'"""
236
- ),
237
- }
238
- ],
239
- }
240
-
241
-
242
- def gemini_install(project_dir: Path | None = None) -> None:
243
- """Copy skill file to ~/.gemini/skills/graphify/, write GEMINI.md section, and install BeforeTool hook."""
244
- # Copy skill file to ~/.gemini/skills/graphify/SKILL.md
245
- # On Windows, Gemini CLI prioritises ~/.agents/skills/ over ~/.gemini/skills/
246
- skill_src = Path(__file__).parent / "skill.md"
247
- if platform.system() == "Windows":
248
- skill_dst = Path.home() / ".agents" / "skills" / "graphify" / "SKILL.md"
249
- else:
250
- skill_dst = Path.home() / ".gemini" / "skills" / "graphify" / "SKILL.md"
251
- skill_dst.parent.mkdir(parents=True, exist_ok=True)
252
- shutil.copy(skill_src, skill_dst)
253
- (skill_dst.parent / ".graphify_version").write_text(__version__, encoding="utf-8")
254
- print(f" skill installed -> {skill_dst}")
255
-
256
- target = (project_dir or Path(".")) / "GEMINI.md"
257
-
258
- if target.exists():
259
- content = target.read_text(encoding="utf-8")
260
- if _GEMINI_MD_MARKER in content:
261
- print("graphify already configured in GEMINI.md")
262
- else:
263
- target.write_text(content.rstrip() + "\n\n" + _GEMINI_MD_SECTION, encoding="utf-8")
264
- print(f"graphify section written to {target.resolve()}")
265
- else:
266
- target.write_text(_GEMINI_MD_SECTION, encoding="utf-8")
267
- print(f"graphify section written to {target.resolve()}")
268
-
269
- _install_gemini_hook(project_dir or Path("."))
270
- print()
271
- print("Gemini CLI will now check the knowledge graph before answering")
272
- print("codebase questions and rebuild it after code changes.")
273
-
274
-
275
- def _install_gemini_hook(project_dir: Path) -> None:
276
- settings_path = project_dir / ".gemini" / "settings.json"
277
- settings_path.parent.mkdir(parents=True, exist_ok=True)
278
- try:
279
- settings = json.loads(settings_path.read_text(encoding="utf-8")) if settings_path.exists() else {}
280
- except json.JSONDecodeError:
281
- settings = {}
282
- before_tool = settings.setdefault("hooks", {}).setdefault("BeforeTool", [])
283
- settings["hooks"]["BeforeTool"] = [h for h in before_tool if "graphify" not in str(h)]
284
- settings["hooks"]["BeforeTool"].append(_GEMINI_HOOK)
285
- settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8")
286
- print(" .gemini/settings.json -> BeforeTool hook registered")
287
-
288
-
289
- def _uninstall_gemini_hook(project_dir: Path) -> None:
290
- settings_path = project_dir / ".gemini" / "settings.json"
291
- if not settings_path.exists():
292
- return
293
- try:
294
- settings = json.loads(settings_path.read_text(encoding="utf-8"))
295
- except json.JSONDecodeError:
296
- return
297
- before_tool = settings.get("hooks", {}).get("BeforeTool", [])
298
- filtered = [h for h in before_tool if "graphify" not in str(h)]
299
- if len(filtered) == len(before_tool):
300
- return
301
- settings["hooks"]["BeforeTool"] = filtered
302
- settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8")
303
- print(" .gemini/settings.json -> BeforeTool hook removed")
304
-
305
-
306
- def gemini_uninstall(project_dir: Path | None = None) -> None:
307
- """Remove the graphify section from GEMINI.md, uninstall hook, and remove skill file."""
308
- # Remove skill file (mirror the install path detection)
309
- if platform.system() == "Windows":
310
- skill_dst = Path.home() / ".agents" / "skills" / "graphify" / "SKILL.md"
311
- else:
312
- skill_dst = Path.home() / ".gemini" / "skills" / "graphify" / "SKILL.md"
313
- if skill_dst.exists():
314
- skill_dst.unlink()
315
- print(f" skill removed -> {skill_dst}")
316
- version_file = skill_dst.parent / ".graphify_version"
317
- if version_file.exists():
318
- version_file.unlink()
319
- for d in (skill_dst.parent, skill_dst.parent.parent):
320
- try:
321
- d.rmdir()
322
- except OSError:
323
- break
324
-
325
- target = (project_dir or Path(".")) / "GEMINI.md"
326
- if not target.exists():
327
- print("No GEMINI.md found in current directory - nothing to do")
328
- return
329
- content = target.read_text(encoding="utf-8")
330
- if _GEMINI_MD_MARKER not in content:
331
- print("graphify section not found in GEMINI.md - nothing to do")
332
- return
333
- cleaned = re.sub(r"\n*## graphify\n.*?(?=\n## |\Z)", "", content, flags=re.DOTALL).rstrip()
334
- if cleaned:
335
- target.write_text(cleaned + "\n", encoding="utf-8")
336
- print(f"graphify section removed from {target.resolve()}")
337
- else:
338
- target.unlink()
339
- print(f"GEMINI.md was empty after removal - deleted {target.resolve()}")
340
- _uninstall_gemini_hook(project_dir or Path("."))
341
-
342
-
343
- _VSCODE_INSTRUCTIONS_MARKER = "## graphify"
344
- _VSCODE_INSTRUCTIONS_SECTION = """\
345
- ## graphify
346
-
347
- Before answering architecture or codebase questions, read `graphify-out/GRAPH_REPORT.md` if it exists.
348
- If `graphify-out/wiki/index.md` exists, navigate it for deep questions.
349
- Type `/graphify` in Copilot Chat to build or update the knowledge graph.
350
- """
351
-
352
-
353
- def vscode_install(project_dir: Path | None = None) -> None:
354
- """Install graphify skill for VS Code Copilot Chat + write .github/copilot-instructions.md."""
355
- skill_src = Path(__file__).parent / "skill-vscode.md"
356
- if not skill_src.exists():
357
- skill_src = Path(__file__).parent / "skill-copilot.md"
358
- skill_dst = Path.home() / ".copilot" / "skills" / "graphify" / "SKILL.md"
359
- skill_dst.parent.mkdir(parents=True, exist_ok=True)
360
- shutil.copy(skill_src, skill_dst)
361
- (skill_dst.parent / ".graphify_version").write_text(__version__, encoding="utf-8")
362
- print(f" skill installed -> {skill_dst}")
363
-
364
- instructions = (project_dir or Path(".")) / ".github" / "copilot-instructions.md"
365
- instructions.parent.mkdir(parents=True, exist_ok=True)
366
- if instructions.exists():
367
- content = instructions.read_text(encoding="utf-8")
368
- if _VSCODE_INSTRUCTIONS_MARKER in content:
369
- print(f" {instructions} -> already configured (no change)")
370
- else:
371
- instructions.write_text(content.rstrip() + "\n\n" + _VSCODE_INSTRUCTIONS_SECTION, encoding="utf-8")
372
- print(f" {instructions} -> graphify section added")
373
- else:
374
- instructions.write_text(_VSCODE_INSTRUCTIONS_SECTION, encoding="utf-8")
375
- print(f" {instructions} -> created")
376
-
377
- print()
378
- print("VS Code Copilot Chat configured. Type /graphify in the chat panel to build the graph.")
379
- print("Note: for GitHub Copilot CLI (terminal), use: graphify copilot install")
380
-
381
-
382
- def vscode_uninstall(project_dir: Path | None = None) -> None:
383
- """Remove graphify VS Code Copilot Chat skill and .github/copilot-instructions.md section."""
384
- skill_dst = Path.home() / ".copilot" / "skills" / "graphify" / "SKILL.md"
385
- if skill_dst.exists():
386
- skill_dst.unlink()
387
- print(f" skill removed -> {skill_dst}")
388
- version_file = skill_dst.parent / ".graphify_version"
389
- if version_file.exists():
390
- version_file.unlink()
391
- for d in (skill_dst.parent, skill_dst.parent.parent, skill_dst.parent.parent.parent):
392
- try:
393
- d.rmdir()
394
- except OSError:
395
- break
396
-
397
- instructions = (project_dir or Path(".")) / ".github" / "copilot-instructions.md"
398
- if not instructions.exists():
399
- return
400
- content = instructions.read_text(encoding="utf-8")
401
- if _VSCODE_INSTRUCTIONS_MARKER not in content:
402
- return
403
- cleaned = re.sub(r"\n*## graphify\n.*?(?=\n## |\Z)", "", content, flags=re.DOTALL).rstrip()
404
- if cleaned:
405
- instructions.write_text(cleaned + "\n", encoding="utf-8")
406
- print(f" graphify section removed from {instructions}")
407
- else:
408
- instructions.unlink()
409
- print(f" {instructions} -> deleted (was empty after removal)")
410
-
411
-
412
- _ANTIGRAVITY_RULES_PATH = Path(".agent") / "rules" / "graphify.md"
413
- _ANTIGRAVITY_WORKFLOW_PATH = Path(".agent") / "workflows" / "graphify.md"
414
-
415
- _ANTIGRAVITY_RULES = """\
416
- ## graphify
417
-
418
- This project has a graphify knowledge graph at graphify-out/.
419
-
420
- Rules:
421
- - Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
422
- - If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
423
- - If the graphify MCP server is active, utilize tools like `query_graph`, `get_node`, and `shortest_path` for precise architecture navigation instead of falling back to `grep`
424
- - After modifying code files in this session, run `graphify update .` to keep the graph current (AST-only, no API cost)
425
- """
426
-
427
- _ANTIGRAVITY_WORKFLOW = """\
428
- # Workflow: graphify
429
- **Command:** /graphify
430
- **Description:** Turn any folder of files into a navigable knowledge graph
431
-
432
- ## Steps
433
- Follow the graphify skill installed at ~/.agent/skills/graphify/SKILL.md to run the full pipeline.
434
-
435
- If no path argument is given, use `.` (current directory).
436
- """
437
-
438
-
439
- _KIRO_STEERING = """\
440
- ---
441
- inclusion: always
442
- ---
443
-
444
- graphify: A knowledge graph of this project lives in `graphify-out/`. \
445
- If `graphify-out/GRAPH_REPORT.md` exists, read it before answering architecture questions, \
446
- tracing dependencies, or searching files — it contains god nodes, community structure, \
447
- and surprising connections the graph found. Navigate by graph structure instead of grepping raw files.
448
- """
449
-
450
- _KIRO_STEERING_MARKER = "graphify: A knowledge graph of this project"
451
-
452
-
453
- def _kiro_install(project_dir: Path) -> None:
454
- """Write graphify skill + steering file for Kiro IDE/CLI."""
455
- project_dir = project_dir or Path(".")
456
-
457
- # Skill file → .kiro/skills/graphify/SKILL.md
458
- skill_src = Path(__file__).parent / "skill-kiro.md"
459
- skill_dst = project_dir / ".kiro" / "skills" / "graphify" / "SKILL.md"
460
- skill_dst.parent.mkdir(parents=True, exist_ok=True)
461
- skill_dst.write_text(skill_src.read_text(encoding="utf-8"), encoding="utf-8")
462
- print(f" {skill_dst.relative_to(project_dir)} -> /graphify skill")
463
-
464
- # Steering file → .kiro/steering/graphify.md (always-on)
465
- steering_dir = project_dir / ".kiro" / "steering"
466
- steering_dir.mkdir(parents=True, exist_ok=True)
467
- steering_dst = steering_dir / "graphify.md"
468
- if steering_dst.exists() and _KIRO_STEERING_MARKER in steering_dst.read_text(encoding="utf-8"):
469
- print(f" .kiro/steering/graphify.md -> already configured")
470
- else:
471
- steering_dst.write_text(_KIRO_STEERING, encoding="utf-8")
472
- print(f" .kiro/steering/graphify.md -> always-on steering written")
473
-
474
- print()
475
- print("Kiro will now read the knowledge graph before every conversation.")
476
- print("Use /graphify to build or update the graph.")
477
-
478
-
479
- def _kiro_uninstall(project_dir: Path) -> None:
480
- """Remove graphify skill + steering file for Kiro."""
481
- project_dir = project_dir or Path(".")
482
- removed = []
483
-
484
- skill_dst = project_dir / ".kiro" / "skills" / "graphify" / "SKILL.md"
485
- if skill_dst.exists():
486
- skill_dst.unlink()
487
- removed.append(str(skill_dst.relative_to(project_dir)))
488
- # Remove parent dir if empty
489
- try:
490
- skill_dst.parent.rmdir()
491
- except OSError:
492
- pass
493
-
494
- steering_dst = project_dir / ".kiro" / "steering" / "graphify.md"
495
- if steering_dst.exists():
496
- steering_dst.unlink()
497
- removed.append(str(steering_dst.relative_to(project_dir)))
498
-
499
- print("Removed: " + (", ".join(removed) if removed else "nothing to remove"))
500
-
501
-
502
- def _antigravity_install(project_dir: Path) -> None:
503
- """Install graphify for Google Antigravity: skill + .agent/rules + .agent/workflows."""
504
- # 1. Copy skill file to ~/.agent/skills/graphify/SKILL.md
505
- install(platform="antigravity")
506
-
507
- # 1.5. Inject YAML frontmatter for native Antigravity tool discovery
508
- skill_dst = Path.home() / _PLATFORM_CONFIG["antigravity"]["skill_dst"]
509
- if skill_dst.exists():
510
- content = skill_dst.read_text(encoding="utf-8")
511
- if not content.startswith("---\n"):
512
- frontmatter = "---\nname: graphify-manager\ndescription: Rebuild the code graph or perform manual CLI queries when MCP server is offline.\n---\n\n"
513
- skill_dst.write_text(frontmatter + content, encoding="utf-8")
514
-
515
- # 2. Write .agent/rules/graphify.md
516
- rules_path = project_dir / _ANTIGRAVITY_RULES_PATH
517
- rules_path.parent.mkdir(parents=True, exist_ok=True)
518
- if rules_path.exists():
519
- print(f"graphify rule already exists at {rules_path} (no change)")
520
- else:
521
- rules_path.write_text(_ANTIGRAVITY_RULES, encoding="utf-8")
522
- print(f"graphify rule written to {rules_path.resolve()}")
523
-
524
- # 3. Write .agent/workflows/graphify.md
525
- wf_path = project_dir / _ANTIGRAVITY_WORKFLOW_PATH
526
- wf_path.parent.mkdir(parents=True, exist_ok=True)
527
- if wf_path.exists():
528
- print(f"graphify workflow already exists at {wf_path} (no change)")
529
- else:
530
- wf_path.write_text(_ANTIGRAVITY_WORKFLOW, encoding="utf-8")
531
- print(f"graphify workflow written to {wf_path.resolve()}")
532
-
533
- print()
534
- print("Antigravity will now check the knowledge graph before answering")
535
- print("codebase questions. Run /graphify first to build the graph.")
536
- print()
537
- print("To enable full MCP architecture navigation, add this to ~/.gemini/antigravity/mcp_config.json:")
538
- print(' "graphify": {')
539
- print(' "command": "uv",')
540
- print(' "args": ["run", "--with", "graphifyy", "--with", "mcp", "-m", "graphify.serve", "${workspace.path}/graphify-out/graph.json"]')
541
- print(' }')
542
-
543
-
544
- def _antigravity_uninstall(project_dir: Path) -> None:
545
- """Remove graphify Antigravity rules, workflow, and skill files."""
546
- # Remove rules file
547
- rules_path = project_dir / _ANTIGRAVITY_RULES_PATH
548
- if rules_path.exists():
549
- rules_path.unlink()
550
- print(f"graphify rule removed from {rules_path.resolve()}")
551
- else:
552
- print("No graphify Antigravity rule found - nothing to do")
553
-
554
- # Remove workflow file
555
- wf_path = project_dir / _ANTIGRAVITY_WORKFLOW_PATH
556
- if wf_path.exists():
557
- wf_path.unlink()
558
- print(f"graphify workflow removed from {wf_path.resolve()}")
559
-
560
- # Remove skill file
561
- skill_dst = Path.home() / _PLATFORM_CONFIG["antigravity"]["skill_dst"]
562
- if skill_dst.exists():
563
- skill_dst.unlink()
564
- print(f"graphify skill removed from {skill_dst}")
565
- version_file = skill_dst.parent / ".graphify_version"
566
- if version_file.exists():
567
- version_file.unlink()
568
- for d in (skill_dst.parent, skill_dst.parent.parent, skill_dst.parent.parent.parent):
569
- try:
570
- d.rmdir()
571
- except OSError:
572
- break
573
-
574
-
575
- _CURSOR_RULE_PATH = Path(".cursor") / "rules" / "graphify.mdc"
576
- _CURSOR_RULE = """\
577
- ---
578
- description: graphify knowledge graph context
579
- alwaysApply: true
580
- ---
581
-
582
- This project has a graphify knowledge graph at graphify-out/.
583
-
584
- - Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
585
- - If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
586
- - After modifying code files in this session, run `graphify update .` to keep the graph current (AST-only, no API cost)
587
- """
588
-
589
-
590
- def _cursor_install(project_dir: Path) -> None:
591
- """Write .cursor/rules/graphify.mdc with alwaysApply: true."""
592
- rule_path = (project_dir or Path(".")) / _CURSOR_RULE_PATH
593
- rule_path.parent.mkdir(parents=True, exist_ok=True)
594
- if rule_path.exists():
595
- print(f"graphify rule already exists at {rule_path} (no change)")
596
- return
597
- rule_path.write_text(_CURSOR_RULE, encoding="utf-8")
598
- print(f"graphify rule written to {rule_path.resolve()}")
599
- print()
600
- print("Cursor will now always include the knowledge graph context.")
601
- print("Run /graphify . first to build the graph if you haven't already.")
602
-
603
-
604
- def _cursor_uninstall(project_dir: Path) -> None:
605
- """Remove .cursor/rules/graphify.mdc."""
606
- rule_path = (project_dir or Path(".")) / _CURSOR_RULE_PATH
607
- if not rule_path.exists():
608
- print("No graphify Cursor rule found - nothing to do")
609
- return
610
- rule_path.unlink()
611
- print(f"graphify Cursor rule removed from {rule_path.resolve()}")
612
-
613
-
614
- # OpenCode tool.execute.before plugin — fires before every tool call.
615
- # Injects a graph reminder into bash command output when graph.json exists.
616
- _OPENCODE_PLUGIN_JS = """\
617
- // graphify OpenCode plugin
618
- // Injects a knowledge graph reminder before bash tool calls when the graph exists.
619
- import { existsSync } from "fs";
620
- import { join } from "path";
621
-
622
- export const GraphifyPlugin = async ({ directory }) => {
623
- let reminded = false;
624
-
625
- return {
626
- "tool.execute.before": async (input, output) => {
627
- if (reminded) return;
628
- if (!existsSync(join(directory, "graphify-out", "graph.json"))) return;
629
-
630
- if (input.tool === "bash") {
631
- output.args.command =
632
- 'echo "[graphify] Knowledge graph available. Read graphify-out/GRAPH_REPORT.md for god nodes and architecture context before searching files." && ' +
633
- output.args.command;
634
- reminded = true;
635
- }
636
- },
637
- };
638
- };
639
- """
640
-
641
- _OPENCODE_PLUGIN_PATH = Path(".opencode") / "plugins" / "graphify.js"
642
- _OPENCODE_CONFIG_PATH = Path("opencode.json")
643
-
644
-
645
- def _install_opencode_plugin(project_dir: Path) -> None:
646
- """Write graphify.js plugin and register it in opencode.json."""
647
- plugin_file = project_dir / _OPENCODE_PLUGIN_PATH
648
- plugin_file.parent.mkdir(parents=True, exist_ok=True)
649
- plugin_file.write_text(_OPENCODE_PLUGIN_JS, encoding="utf-8")
650
- print(f" {_OPENCODE_PLUGIN_PATH} -> tool.execute.before hook written")
651
-
652
- config_file = project_dir / _OPENCODE_CONFIG_PATH
653
- if config_file.exists():
654
- try:
655
- config = json.loads(config_file.read_text(encoding="utf-8"))
656
- except json.JSONDecodeError:
657
- config = {}
658
- else:
659
- config = {}
660
-
661
- plugins = config.setdefault("plugin", [])
662
- entry = _OPENCODE_PLUGIN_PATH.as_posix()
663
- if entry not in plugins:
664
- plugins.append(entry)
665
- config_file.write_text(json.dumps(config, indent=2), encoding="utf-8")
666
- print(f" {_OPENCODE_CONFIG_PATH} -> plugin registered")
667
- else:
668
- print(f" {_OPENCODE_CONFIG_PATH} -> plugin already registered (no change)")
669
-
670
-
671
- def _uninstall_opencode_plugin(project_dir: Path) -> None:
672
- """Remove graphify.js plugin and deregister from opencode.json."""
673
- plugin_file = project_dir / _OPENCODE_PLUGIN_PATH
674
- if plugin_file.exists():
675
- plugin_file.unlink()
676
- print(f" {_OPENCODE_PLUGIN_PATH} -> removed")
677
-
678
- config_file = project_dir / _OPENCODE_CONFIG_PATH
679
- if not config_file.exists():
680
- return
681
- try:
682
- config = json.loads(config_file.read_text(encoding="utf-8"))
683
- except json.JSONDecodeError:
684
- return
685
- plugins = config.get("plugin", [])
686
- entry = _OPENCODE_PLUGIN_PATH.as_posix()
687
- if entry in plugins:
688
- plugins.remove(entry)
689
- if not plugins:
690
- config.pop("plugin")
691
- config_file.write_text(json.dumps(config, indent=2), encoding="utf-8")
692
- print(f" {_OPENCODE_CONFIG_PATH} -> plugin deregistered")
693
-
694
-
695
- _CODEX_HOOK = {
696
- "hooks": {
697
- "PreToolUse": [
698
- {
699
- "matcher": "Bash",
700
- "hooks": [
701
- {
702
- "type": "command",
703
- "command": (
704
- "[ -f graphify-out/graph.json ] && "
705
- r"""echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}' """
706
- "|| true"
707
- ),
708
- }
709
- ],
710
- }
711
- ]
712
- }
713
- }
714
-
715
-
716
- def _install_codex_hook(project_dir: Path) -> None:
717
- """Add graphify PreToolUse hook to .codex/hooks.json."""
718
- hooks_path = project_dir / ".codex" / "hooks.json"
719
- hooks_path.parent.mkdir(parents=True, exist_ok=True)
720
-
721
- if hooks_path.exists():
722
- try:
723
- existing = json.loads(hooks_path.read_text(encoding="utf-8"))
724
- except json.JSONDecodeError:
725
- existing = {}
726
- else:
727
- existing = {}
728
-
729
- pre_tool = existing.setdefault("hooks", {}).setdefault("PreToolUse", [])
730
- existing["hooks"]["PreToolUse"] = [h for h in pre_tool if "graphify" not in str(h)]
731
- existing["hooks"]["PreToolUse"].extend(_CODEX_HOOK["hooks"]["PreToolUse"])
732
- hooks_path.write_text(json.dumps(existing, indent=2), encoding="utf-8")
733
- print(f" .codex/hooks.json -> PreToolUse hook registered")
734
-
735
-
736
- def _uninstall_codex_hook(project_dir: Path) -> None:
737
- """Remove graphify PreToolUse hook from .codex/hooks.json."""
738
- hooks_path = project_dir / ".codex" / "hooks.json"
739
- if not hooks_path.exists():
740
- return
741
- try:
742
- existing = json.loads(hooks_path.read_text(encoding="utf-8"))
743
- except json.JSONDecodeError:
744
- return
745
- pre_tool = existing.get("hooks", {}).get("PreToolUse", [])
746
- filtered = [h for h in pre_tool if "graphify" not in str(h)]
747
- existing["hooks"]["PreToolUse"] = filtered
748
- hooks_path.write_text(json.dumps(existing, indent=2), encoding="utf-8")
749
- print(f" .codex/hooks.json -> PreToolUse hook removed")
750
-
751
-
752
- def _agents_install(project_dir: Path, platform: str) -> None:
753
- """Write the graphify section to the local AGENTS.md (Codex/OpenCode/OpenClaw)."""
754
- target = (project_dir or Path(".")) / "AGENTS.md"
755
-
756
- if target.exists():
757
- content = target.read_text(encoding="utf-8")
758
- if _AGENTS_MD_MARKER in content:
759
- print(f"graphify already configured in AGENTS.md")
760
- else:
761
- target.write_text(content.rstrip() + "\n\n" + _AGENTS_MD_SECTION, encoding="utf-8")
762
- print(f"graphify section written to {target.resolve()}")
763
- else:
764
- target.write_text(_AGENTS_MD_SECTION, encoding="utf-8")
765
- print(f"graphify section written to {target.resolve()}")
766
-
767
- if platform == "codex":
768
- _install_codex_hook(project_dir or Path("."))
769
- elif platform == "opencode":
770
- _install_opencode_plugin(project_dir or Path("."))
771
-
772
- print()
773
- print(f"{platform.capitalize()} will now check the knowledge graph before answering")
774
- print("codebase questions and rebuild it after code changes.")
775
- if platform not in ("codex", "opencode"):
776
- print()
777
- print("Note: unlike Claude Code, there is no PreToolUse hook equivalent for")
778
- print(f"{platform.capitalize()} — the AGENTS.md rules are the always-on mechanism.")
779
-
780
-
781
- def _agents_uninstall(project_dir: Path, platform: str = "") -> None:
782
- """Remove the graphify section from the local AGENTS.md."""
783
- target = (project_dir or Path(".")) / "AGENTS.md"
784
-
785
- if not target.exists():
786
- print("No AGENTS.md found in current directory - nothing to do")
787
- return
788
-
789
- content = target.read_text(encoding="utf-8")
790
- if _AGENTS_MD_MARKER not in content:
791
- print("graphify section not found in AGENTS.md - nothing to do")
792
- return
793
-
794
- cleaned = re.sub(
795
- r"\n*## graphify\n.*?(?=\n## |\Z)",
796
- "",
797
- content,
798
- flags=re.DOTALL,
799
- ).rstrip()
800
- if cleaned:
801
- target.write_text(cleaned + "\n", encoding="utf-8")
802
- print(f"graphify section removed from {target.resolve()}")
803
- else:
804
- target.unlink()
805
- print(f"AGENTS.md was empty after removal - deleted {target.resolve()}")
806
-
807
- if platform == "opencode":
808
- _uninstall_opencode_plugin(project_dir or Path("."))
809
-
810
-
811
- def claude_install(project_dir: Path | None = None) -> None:
812
- """Write the graphify section to the local CLAUDE.md."""
813
- target = (project_dir or Path(".")) / "CLAUDE.md"
814
-
815
- if target.exists():
816
- content = target.read_text(encoding="utf-8")
817
- if _CLAUDE_MD_MARKER in content:
818
- print("graphify already configured in CLAUDE.md")
819
- return
820
- new_content = content.rstrip() + "\n\n" + _CLAUDE_MD_SECTION
821
- else:
822
- new_content = _CLAUDE_MD_SECTION
823
-
824
- target.write_text(new_content, encoding="utf-8")
825
- print(f"graphify section written to {target.resolve()}")
826
-
827
- # Also write Claude Code PreToolUse hook to .claude/settings.json
828
- _install_claude_hook(project_dir or Path("."))
829
-
830
- print()
831
- print("Claude Code will now check the knowledge graph before answering")
832
- print("codebase questions and rebuild it after code changes.")
833
-
834
-
835
- def _install_claude_hook(project_dir: Path) -> None:
836
- """Add graphify PreToolUse hook to .claude/settings.json."""
837
- settings_path = project_dir / ".claude" / "settings.json"
838
- settings_path.parent.mkdir(parents=True, exist_ok=True)
839
-
840
- if settings_path.exists():
841
- try:
842
- settings = json.loads(settings_path.read_text(encoding="utf-8"))
843
- except json.JSONDecodeError:
844
- settings = {}
845
- else:
846
- settings = {}
847
-
848
- hooks = settings.setdefault("hooks", {})
849
- pre_tool = hooks.setdefault("PreToolUse", [])
850
-
851
- hooks["PreToolUse"] = [h for h in pre_tool if not (h.get("matcher") == "Glob|Grep" and "graphify" in str(h))]
852
- hooks["PreToolUse"].append(_SETTINGS_HOOK)
853
- settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8")
854
- print(f" .claude/settings.json -> PreToolUse hook registered")
855
-
856
-
857
- def _uninstall_claude_hook(project_dir: Path) -> None:
858
- """Remove graphify PreToolUse hook from .claude/settings.json."""
859
- settings_path = project_dir / ".claude" / "settings.json"
860
- if not settings_path.exists():
861
- return
862
- try:
863
- settings = json.loads(settings_path.read_text(encoding="utf-8"))
864
- except json.JSONDecodeError:
865
- return
866
- pre_tool = settings.get("hooks", {}).get("PreToolUse", [])
867
- filtered = [h for h in pre_tool if not (h.get("matcher") == "Glob|Grep" and "graphify" in str(h))]
868
- if len(filtered) == len(pre_tool):
869
- return
870
- settings["hooks"]["PreToolUse"] = filtered
871
- settings_path.write_text(json.dumps(settings, indent=2), encoding="utf-8")
872
- print(f" .claude/settings.json -> PreToolUse hook removed")
873
-
874
-
875
- def claude_uninstall(project_dir: Path | None = None) -> None:
876
- """Remove the graphify section from the local CLAUDE.md."""
877
- target = (project_dir or Path(".")) / "CLAUDE.md"
878
-
879
- if not target.exists():
880
- print("No CLAUDE.md found in current directory - nothing to do")
881
- return
882
-
883
- content = target.read_text(encoding="utf-8")
884
- if _CLAUDE_MD_MARKER not in content:
885
- print("graphify section not found in CLAUDE.md - nothing to do")
886
- return
887
-
888
- # Remove the ## graphify section: from the marker to the next ## heading or EOF
889
- cleaned = re.sub(
890
- r"\n*## graphify\n.*?(?=\n## |\Z)",
891
- "",
892
- content,
893
- flags=re.DOTALL,
894
- ).rstrip()
895
- if cleaned:
896
- target.write_text(cleaned + "\n", encoding="utf-8")
897
- print(f"graphify section removed from {target.resolve()}")
898
- else:
899
- target.unlink()
900
- print(f"CLAUDE.md was empty after removal - deleted {target.resolve()}")
901
-
902
- _uninstall_claude_hook(project_dir or Path("."))
903
-
904
-
905
- def main() -> None:
906
- # Check all known skill install locations for a stale version stamp.
907
- # Skip during install/uninstall (hook writes trigger a fresh check anyway).
908
- # Deduplicate paths so platforms sharing the same install dir don't warn twice.
909
- if not any(arg in ("install", "uninstall") for arg in sys.argv):
910
- for skill_dst in {Path.home() / cfg["skill_dst"] for cfg in _PLATFORM_CONFIG.values()}:
911
- _check_skill_version(skill_dst)
912
-
913
- if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
914
- print("Usage: graphify <command>")
915
- print()
916
- print("Commands:")
917
- print(" install [--platform P] copy skill to platform config dir (claude|windows|codex|opencode|aider|claw|droid|trae|trae-cn|gemini|cursor|antigravity|hermes|kiro)")
918
- print(" path \"A\" \"B\" shortest path between two nodes in graph.json")
919
- print(" --graph <path> path to graph.json (default graphify-out/graph.json)")
920
- print(" explain \"X\" plain-language explanation of a node and its neighbors")
921
- print(" --graph <path> path to graph.json (default graphify-out/graph.json)")
922
- print(" add <url> fetch a URL and save it to ./raw, then update the graph")
923
- print(" --author \"Name\" tag the author of the content")
924
- print(" --contributor \"Name\" tag who added it to the corpus")
925
- print(" --dir <path> target directory (default: ./raw)")
926
- print(" watch <path> watch a folder and rebuild the graph on code changes")
927
- print(" update <path> re-extract code files and update the graph (no LLM needed)")
928
- print(" cluster-only <path> rerun clustering on an existing graph.json and regenerate report")
929
- print(" query \"<question>\" BFS traversal of graph.json for a question")
930
- print(" --dfs use depth-first instead of breadth-first")
931
- print(" --budget N cap output at N tokens (default 2000)")
932
- print(" --graph <path> path to graph.json (default graphify-out/graph.json)")
933
- print(" save-result save a Q&A result to graphify-out/memory/ for graph feedback loop")
934
- print(" --question Q the question asked")
935
- print(" --answer A the answer to save")
936
- print(" --type T query type: query|path_query|explain (default: query)")
937
- print(" --nodes N1 N2 ... source node labels cited in the answer")
938
- print(" --memory-dir DIR memory directory (default: graphify-out/memory)")
939
- print(" benchmark [graph.json] measure token reduction vs naive full-corpus approach")
940
- print(" hook install install post-commit/post-checkout git hooks (all platforms)")
941
- print(" hook uninstall remove git hooks")
942
- print(" hook status check if git hooks are installed")
943
- print(" gemini install write GEMINI.md section + BeforeTool hook (Gemini CLI)")
944
- print(" gemini uninstall remove GEMINI.md section + BeforeTool hook")
945
- print(" cursor install write .cursor/rules/graphify.mdc (Cursor)")
946
- print(" cursor uninstall remove .cursor/rules/graphify.mdc")
947
- print(" claude install write graphify section to CLAUDE.md + PreToolUse hook (Claude Code)")
948
- print(" claude uninstall remove graphify section from CLAUDE.md + PreToolUse hook")
949
- print(" codex install write graphify section to AGENTS.md (Codex)")
950
- print(" codex uninstall remove graphify section from AGENTS.md")
951
- print(" opencode install write graphify section to AGENTS.md + tool.execute.before plugin (OpenCode)")
952
- print(" opencode uninstall remove graphify section from AGENTS.md + plugin")
953
- print(" aider install write graphify section to AGENTS.md (Aider)")
954
- print(" aider uninstall remove graphify section from AGENTS.md")
955
- print(" copilot install copy graphify skill to ~/.copilot/skills (GitHub Copilot CLI)")
956
- print(" copilot uninstall remove graphify skill from ~/.copilot/skills")
957
- print(" vscode install configure VS Code Copilot Chat (skill + .github/copilot-instructions.md)")
958
- print(" vscode uninstall remove VS Code Copilot Chat configuration")
959
- print(" claw install write graphify section to AGENTS.md (OpenClaw)")
960
- print(" claw uninstall remove graphify section from AGENTS.md")
961
- print(" droid install write graphify section to AGENTS.md (Factory Droid)")
962
- print(" droid uninstall remove graphify section from AGENTS.md")
963
- print(" trae install write graphify section to AGENTS.md (Trae)")
964
- print(" trae uninstall remove graphify section from AGENTS.md")
965
- print(" trae-cn install write graphify section to AGENTS.md (Trae CN)")
966
- print(" trae-cn uninstall remove graphify section from AGENTS.md")
967
- print(" antigravity install write .agent/rules + .agent/workflows + skill (Google Antigravity)")
968
- print(" antigravity uninstall remove .agent/rules, .agent/workflows, and skill")
969
- print(" hermes install write skill to ~/.hermes/skills/graphify/ (Hermes)")
970
- print(" hermes uninstall remove skill from ~/.hermes/skills/graphify/")
971
- print(" kiro install write skill to .kiro/skills/graphify/ + steering file (Kiro IDE/CLI)")
972
- print(" kiro uninstall remove skill + steering file")
973
- print()
974
- return
975
-
976
- cmd = sys.argv[1]
977
- if cmd == "install":
978
- # Default to windows platform on Windows, claude elsewhere
979
- default_platform = "windows" if platform.system() == "Windows" else "claude"
980
- chosen_platform = default_platform
981
- args = sys.argv[2:]
982
- i = 0
983
- while i < len(args):
984
- if args[i].startswith("--platform="):
985
- chosen_platform = args[i].split("=", 1)[1]
986
- i += 1
987
- elif args[i] == "--platform" and i + 1 < len(args):
988
- chosen_platform = args[i + 1]
989
- i += 2
990
- else:
991
- i += 1
992
- install(platform=chosen_platform)
993
- elif cmd == "claude":
994
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
995
- if subcmd == "install":
996
- claude_install()
997
- elif subcmd == "uninstall":
998
- claude_uninstall()
999
- else:
1000
- print("Usage: graphify claude [install|uninstall]", file=sys.stderr)
1001
- sys.exit(1)
1002
- elif cmd == "gemini":
1003
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1004
- if subcmd == "install":
1005
- gemini_install()
1006
- elif subcmd == "uninstall":
1007
- gemini_uninstall()
1008
- else:
1009
- print("Usage: graphify gemini [install|uninstall]", file=sys.stderr)
1010
- sys.exit(1)
1011
- elif cmd == "cursor":
1012
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1013
- if subcmd == "install":
1014
- _cursor_install(Path("."))
1015
- elif subcmd == "uninstall":
1016
- _cursor_uninstall(Path("."))
1017
- else:
1018
- print("Usage: graphify cursor [install|uninstall]", file=sys.stderr)
1019
- sys.exit(1)
1020
- elif cmd == "vscode":
1021
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1022
- if subcmd == "install":
1023
- vscode_install()
1024
- elif subcmd == "uninstall":
1025
- vscode_uninstall()
1026
- else:
1027
- print("Usage: graphify vscode [install|uninstall]", file=sys.stderr)
1028
- sys.exit(1)
1029
- elif cmd == "copilot":
1030
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1031
- if subcmd == "install":
1032
- install(platform="copilot")
1033
- elif subcmd == "uninstall":
1034
- skill_dst = Path.home() / _PLATFORM_CONFIG["copilot"]["skill_dst"]
1035
- removed = []
1036
- if skill_dst.exists():
1037
- skill_dst.unlink()
1038
- removed.append(f"skill removed: {skill_dst}")
1039
- version_file = skill_dst.parent / ".graphify_version"
1040
- if version_file.exists():
1041
- version_file.unlink()
1042
- for d in (skill_dst.parent, skill_dst.parent.parent, skill_dst.parent.parent.parent):
1043
- try:
1044
- d.rmdir()
1045
- except OSError:
1046
- break
1047
- print("; ".join(removed) if removed else "nothing to remove")
1048
- else:
1049
- print("Usage: graphify copilot [install|uninstall]", file=sys.stderr)
1050
- sys.exit(1)
1051
- elif cmd == "kiro":
1052
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1053
- if subcmd == "install":
1054
- _kiro_install(Path("."))
1055
- elif subcmd == "uninstall":
1056
- _kiro_uninstall(Path("."))
1057
- else:
1058
- print("Usage: graphify kiro [install|uninstall]", file=sys.stderr)
1059
- sys.exit(1)
1060
- elif cmd in ("aider", "codex", "opencode", "claw", "droid", "trae", "trae-cn", "hermes"):
1061
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1062
- if subcmd == "install":
1063
- _agents_install(Path("."), cmd)
1064
- elif subcmd == "uninstall":
1065
- _agents_uninstall(Path("."), platform=cmd)
1066
- if cmd == "codex":
1067
- _uninstall_codex_hook(Path("."))
1068
- else:
1069
- print(f"Usage: graphify {cmd} [install|uninstall]", file=sys.stderr)
1070
- sys.exit(1)
1071
- elif cmd == "antigravity":
1072
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1073
- if subcmd == "install":
1074
- _antigravity_install(Path("."))
1075
- elif subcmd == "uninstall":
1076
- _antigravity_uninstall(Path("."))
1077
- else:
1078
- print("Usage: graphify antigravity [install|uninstall]", file=sys.stderr)
1079
- sys.exit(1)
1080
- elif cmd == "hook":
1081
- from graphify.hooks import install as hook_install, uninstall as hook_uninstall, status as hook_status
1082
- subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
1083
- if subcmd == "install":
1084
- print(hook_install(Path(".")))
1085
- elif subcmd == "uninstall":
1086
- print(hook_uninstall(Path(".")))
1087
- elif subcmd == "status":
1088
- print(hook_status(Path(".")))
1089
- else:
1090
- print("Usage: graphify hook [install|uninstall|status]", file=sys.stderr)
1091
- sys.exit(1)
1092
- elif cmd == "query":
1093
- if len(sys.argv) < 3:
1094
- print("Usage: graphify query \"<question>\" [--dfs] [--budget N] [--graph path]", file=sys.stderr)
1095
- sys.exit(1)
1096
- from graphify.serve import _score_nodes, _bfs, _dfs, _subgraph_to_text
1097
- from graphify.security import sanitize_label
1098
- from networkx.readwrite import json_graph
1099
- question = sys.argv[2]
1100
- use_dfs = "--dfs" in sys.argv
1101
- budget = 2000
1102
- graph_path = "graphify-out/graph.json"
1103
- args = sys.argv[3:]
1104
- i = 0
1105
- while i < len(args):
1106
- if args[i] == "--budget" and i + 1 < len(args):
1107
- try:
1108
- budget = int(args[i + 1])
1109
- except ValueError:
1110
- print(f"error: --budget must be an integer", file=sys.stderr)
1111
- sys.exit(1)
1112
- i += 2
1113
- elif args[i].startswith("--budget="):
1114
- try:
1115
- budget = int(args[i].split("=", 1)[1])
1116
- except ValueError:
1117
- print(f"error: --budget must be an integer", file=sys.stderr)
1118
- sys.exit(1)
1119
- i += 1
1120
- elif args[i] == "--graph" and i + 1 < len(args):
1121
- graph_path = args[i + 1]; i += 2
1122
- else:
1123
- i += 1
1124
- gp = Path(graph_path).resolve()
1125
- if not gp.exists():
1126
- print(f"error: graph file not found: {gp}", file=sys.stderr)
1127
- sys.exit(1)
1128
- if not gp.suffix == ".json":
1129
- print(f"error: graph file must be a .json file", file=sys.stderr)
1130
- sys.exit(1)
1131
- try:
1132
- import json as _json
1133
- import networkx as _nx
1134
- _raw = _json.loads(gp.read_text(encoding="utf-8"))
1135
- try:
1136
- G = json_graph.node_link_graph(_raw, edges="links")
1137
- except TypeError:
1138
- G = json_graph.node_link_graph(_raw)
1139
- except Exception as exc:
1140
- print(f"error: could not load graph: {exc}", file=sys.stderr)
1141
- sys.exit(1)
1142
- terms = [t.lower() for t in question.split() if len(t) > 2]
1143
- scored = _score_nodes(G, terms)
1144
- if not scored:
1145
- print("No matching nodes found.")
1146
- sys.exit(0)
1147
- start = [nid for _, nid in scored[:5]]
1148
- nodes, edges = (_dfs if use_dfs else _bfs)(G, start, depth=2)
1149
- print(_subgraph_to_text(G, nodes, edges, token_budget=budget))
1150
- elif cmd == "save-result":
1151
- # graphify save-result --question Q --answer A --type T [--nodes N1 N2 ...]
1152
- import argparse as _ap
1153
- p = _ap.ArgumentParser(prog="graphify save-result")
1154
- p.add_argument("--question", required=True)
1155
- p.add_argument("--answer", required=True)
1156
- p.add_argument("--type", dest="query_type", default="query")
1157
- p.add_argument("--nodes", nargs="*", default=[])
1158
- p.add_argument("--memory-dir", default="graphify-out/memory")
1159
- opts = p.parse_args(sys.argv[2:])
1160
- from graphify.ingest import save_query_result as _sqr
1161
- out = _sqr(
1162
- question=opts.question,
1163
- answer=opts.answer,
1164
- memory_dir=Path(opts.memory_dir),
1165
- query_type=opts.query_type,
1166
- source_nodes=opts.nodes or None,
1167
- )
1168
- print(f"Saved to {out}")
1169
- elif cmd == "path":
1170
- if len(sys.argv) < 4:
1171
- print("Usage: graphify path \"<source>\" \"<target>\" [--graph path]", file=sys.stderr)
1172
- sys.exit(1)
1173
- from graphify.serve import _score_nodes
1174
- from networkx.readwrite import json_graph
1175
- import networkx as _nx
1176
- source_label = sys.argv[2]
1177
- target_label = sys.argv[3]
1178
- graph_path = "graphify-out/graph.json"
1179
- args = sys.argv[4:]
1180
- for i, a in enumerate(args):
1181
- if a == "--graph" and i + 1 < len(args):
1182
- graph_path = args[i + 1]
1183
- gp = Path(graph_path).resolve()
1184
- if not gp.exists():
1185
- print(f"error: graph file not found: {gp}", file=sys.stderr)
1186
- sys.exit(1)
1187
- _raw = json.loads(gp.read_text(encoding="utf-8"))
1188
- try:
1189
- G = json_graph.node_link_graph(_raw, edges="links")
1190
- except TypeError:
1191
- G = json_graph.node_link_graph(_raw)
1192
- src_scored = _score_nodes(G, [t.lower() for t in source_label.split()])
1193
- tgt_scored = _score_nodes(G, [t.lower() for t in target_label.split()])
1194
- if not src_scored:
1195
- print(f"No node matching '{source_label}' found.", file=sys.stderr)
1196
- sys.exit(1)
1197
- if not tgt_scored:
1198
- print(f"No node matching '{target_label}' found.", file=sys.stderr)
1199
- sys.exit(1)
1200
- src_nid, tgt_nid = src_scored[0][1], tgt_scored[0][1]
1201
- try:
1202
- path_nodes = _nx.shortest_path(G, src_nid, tgt_nid)
1203
- except (_nx.NetworkXNoPath, _nx.NodeNotFound):
1204
- print(f"No path found between '{source_label}' and '{target_label}'.")
1205
- sys.exit(0)
1206
- hops = len(path_nodes) - 1
1207
- segments = []
1208
- for i in range(len(path_nodes) - 1):
1209
- u, v = path_nodes[i], path_nodes[i + 1]
1210
- edata = G.edges[u, v]
1211
- rel = edata.get("relation", "")
1212
- conf = edata.get("confidence", "")
1213
- conf_str = f" [{conf}]" if conf else ""
1214
- if i == 0:
1215
- segments.append(G.nodes[u].get("label", u))
1216
- segments.append(f"--{rel}{conf_str}--> {G.nodes[v].get('label', v)}")
1217
- print(f"Shortest path ({hops} hops):\n " + " ".join(segments))
1218
-
1219
- elif cmd == "explain":
1220
- if len(sys.argv) < 3:
1221
- print("Usage: graphify explain \"<node>\" [--graph path]", file=sys.stderr)
1222
- sys.exit(1)
1223
- from graphify.serve import _find_node
1224
- from networkx.readwrite import json_graph
1225
- label = sys.argv[2]
1226
- graph_path = "graphify-out/graph.json"
1227
- args = sys.argv[3:]
1228
- for i, a in enumerate(args):
1229
- if a == "--graph" and i + 1 < len(args):
1230
- graph_path = args[i + 1]
1231
- gp = Path(graph_path).resolve()
1232
- if not gp.exists():
1233
- print(f"error: graph file not found: {gp}", file=sys.stderr)
1234
- sys.exit(1)
1235
- _raw = json.loads(gp.read_text(encoding="utf-8"))
1236
- try:
1237
- G = json_graph.node_link_graph(_raw, edges="links")
1238
- except TypeError:
1239
- G = json_graph.node_link_graph(_raw)
1240
- matches = _find_node(G, label)
1241
- if not matches:
1242
- print(f"No node matching '{label}' found.")
1243
- sys.exit(0)
1244
- nid = matches[0]
1245
- d = G.nodes[nid]
1246
- print(f"Node: {d.get('label', nid)}")
1247
- print(f" ID: {nid}")
1248
- print(f" Source: {d.get('source_file', '')} {d.get('source_location', '')}".rstrip())
1249
- print(f" Type: {d.get('file_type', '')}")
1250
- print(f" Community: {d.get('community', '')}")
1251
- print(f" Degree: {G.degree(nid)}")
1252
- neighbors = list(G.neighbors(nid))
1253
- if neighbors:
1254
- print(f"\nConnections ({len(neighbors)}):")
1255
- for nb in sorted(neighbors, key=lambda n: G.degree(n), reverse=True)[:20]:
1256
- edata = G.edges[nid, nb]
1257
- rel = edata.get("relation", "")
1258
- conf = edata.get("confidence", "")
1259
- print(f" --> {G.nodes[nb].get('label', nb)} [{rel}] [{conf}]")
1260
- if len(neighbors) > 20:
1261
- print(f" ... and {len(neighbors) - 20} more")
1262
-
1263
- elif cmd == "add":
1264
- if len(sys.argv) < 3:
1265
- print("Usage: graphify add <url> [--author Name] [--contributor Name] [--dir ./raw]", file=sys.stderr)
1266
- sys.exit(1)
1267
- from graphify.ingest import ingest as _ingest
1268
- url = sys.argv[2]
1269
- author: str | None = None
1270
- contributor: str | None = None
1271
- target_dir = Path("raw")
1272
- args = sys.argv[3:]
1273
- i = 0
1274
- while i < len(args):
1275
- if args[i] == "--author" and i + 1 < len(args):
1276
- author = args[i + 1]; i += 2
1277
- elif args[i] == "--contributor" and i + 1 < len(args):
1278
- contributor = args[i + 1]; i += 2
1279
- elif args[i] == "--dir" and i + 1 < len(args):
1280
- target_dir = Path(args[i + 1]); i += 2
1281
- else:
1282
- i += 1
1283
- try:
1284
- saved = _ingest(url, target_dir, author=author, contributor=contributor)
1285
- print(f"Saved to {saved}")
1286
- print("Run /graphify --update in your AI assistant to update the graph.")
1287
- except Exception as exc:
1288
- print(f"error: {exc}", file=sys.stderr)
1289
- sys.exit(1)
1290
-
1291
- elif cmd == "watch":
1292
- watch_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(".")
1293
- if not watch_path.exists():
1294
- print(f"error: path not found: {watch_path}", file=sys.stderr)
1295
- sys.exit(1)
1296
- from graphify.watch import watch as _watch
1297
- try:
1298
- _watch(watch_path)
1299
- except ImportError as exc:
1300
- print(f"error: {exc}", file=sys.stderr)
1301
- sys.exit(1)
1302
-
1303
- elif cmd == "cluster-only":
1304
- watch_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(".")
1305
- graph_json = watch_path / "graphify-out" / "graph.json"
1306
- if not graph_json.exists():
1307
- print(f"error: no graph found at {graph_json} — run /graphify first", file=sys.stderr)
1308
- sys.exit(1)
1309
- from networkx.readwrite import json_graph as _jg
1310
- from graphify.build import build_from_json
1311
- from graphify.cluster import cluster, score_all
1312
- from graphify.analyze import god_nodes, surprising_connections, suggest_questions
1313
- from graphify.report import generate
1314
- from graphify.export import to_json, to_html
1315
- print("Loading existing graph...")
1316
- _raw = json.loads(graph_json.read_text(encoding="utf-8"))
1317
- G = build_from_json(_raw)
1318
- print(f"Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges")
1319
- print("Re-clustering...")
1320
- communities = cluster(G)
1321
- cohesion = score_all(G, communities)
1322
- gods = god_nodes(G)
1323
- surprises = surprising_connections(G, communities)
1324
- labels = {cid: f"Community {cid}" for cid in communities}
1325
- questions = suggest_questions(G, communities, labels)
1326
- tokens = {"input": 0, "output": 0}
1327
- report = generate(G, communities, cohesion, labels, gods, surprises,
1328
- {"warning": "cluster-only mode — file stats not available"},
1329
- tokens, str(watch_path), suggested_questions=questions)
1330
- out = watch_path / "graphify-out"
1331
- (out / "GRAPH_REPORT.md").write_text(report, encoding="utf-8")
1332
- to_json(G, communities, str(out / "graph.json"))
1333
- to_html(G, communities, str(out / "graph.html"), community_labels=labels or None)
1334
- print(f"Done — {len(communities)} communities. GRAPH_REPORT.md, graph.json and graph.html updated.")
1335
-
1336
- elif cmd == "update":
1337
- watch_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(".")
1338
- if not watch_path.exists():
1339
- print(f"error: path not found: {watch_path}", file=sys.stderr)
1340
- sys.exit(1)
1341
- from graphify.watch import _rebuild_code
1342
- print(f"Re-extracting code files in {watch_path} (no LLM needed)...")
1343
- ok = _rebuild_code(watch_path)
1344
- if ok:
1345
- print("Code graph updated. For doc/paper/image changes run /graphify --update in your AI assistant.")
1346
- else:
1347
- print("Nothing to update or rebuild failed — check output above.", file=sys.stderr)
1348
- sys.exit(1)
1349
-
1350
- elif cmd == "benchmark":
1351
- from graphify.benchmark import run_benchmark, print_benchmark
1352
- graph_path = sys.argv[2] if len(sys.argv) > 2 else "graphify-out/graph.json"
1353
- # Try to load corpus_words from detect output
1354
- corpus_words = None
1355
- detect_path = Path(".graphify_detect.json")
1356
- if detect_path.exists():
1357
- try:
1358
- detect_data = json.loads(detect_path.read_text(encoding="utf-8"))
1359
- corpus_words = detect_data.get("total_words")
1360
- except Exception:
1361
- pass
1362
- result = run_benchmark(graph_path, corpus_words=corpus_words)
1363
- print_benchmark(result)
1364
- else:
1365
- print(f"error: unknown command '{cmd}'", file=sys.stderr)
1366
- print("Run 'graphify --help' for usage.", file=sys.stderr)
1367
- sys.exit(1)
1368
-
1369
-
1370
- if __name__ == "__main__":
1371
- main()