okstra 0.130.4 → 0.131.1
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 +0 -1
- package/docs/architecture.md +2 -2
- package/docs/cli.md +1 -1
- package/docs/for-ai/README.md +0 -2
- package/docs/for-ai/skills/okstra-run.md +13 -2
- package/docs/for-ai/skills/okstra-setup.md +4 -1
- package/docs/project-structure-overview.md +5 -4
- package/docs/task-process/implementation-planning.md +13 -0
- package/docs/task-process/implementation.md +17 -2
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/workers/report-writer-worker.md +7 -0
- package/runtime/bin/lib/okstra/usage.sh +4 -4
- package/runtime/prompts/lead/okstra-lead-contract.md +2 -2
- package/runtime/prompts/lead/plan-body-verification.md +26 -5
- package/runtime/prompts/lead/report-writer.md +6 -2
- package/runtime/prompts/profiles/_common-contract.md +2 -1
- package/runtime/prompts/profiles/_implementation-deliverable.md +6 -1
- package/runtime/prompts/profiles/_implementation-executor.md +2 -2
- package/runtime/prompts/profiles/_implementation-verifier.md +33 -10
- package/runtime/prompts/profiles/final-verification.md +21 -6
- package/runtime/prompts/profiles/implementation-planning.md +16 -4
- package/runtime/python/okstra_ctl/codex_dispatch.py +31 -0
- package/runtime/python/okstra_ctl/conformance.py +49 -11
- package/runtime/python/okstra_ctl/report_finalize.py +52 -1
- package/runtime/python/okstra_ctl/run.py +15 -3
- package/runtime/python/okstra_ctl/worker_prompt_contract.py +14 -6
- package/runtime/python/okstra_ctl/worker_prompt_policy.py +19 -1
- package/runtime/python/okstra_vendor/__init__.py +0 -44
- package/runtime/schemas/final-report-v1.0.schema.json +99 -5
- package/runtime/skills/okstra-run/SKILL.md +11 -4
- package/runtime/skills/okstra-setup/SKILL.md +3 -2
- package/runtime/skills/okstra-setup/references/project-config.md +16 -7
- package/runtime/templates/reports/final-report.template.md +15 -9
- package/runtime/templates/reports/i18n/en.json +1 -0
- package/runtime/templates/reports/i18n/ko.json +1 -0
- package/runtime/validators/lib/fixtures.sh +6 -0
- package/runtime/validators/validate-run.py +2019 -96
- package/src/cli-registry.mjs +0 -7
- package/src/commands/lifecycle/doctor.mjs +0 -9
- package/src/lib/skill-catalog.mjs +0 -1
- package/docs/for-ai/skills/okstra-graphify.md +0 -64
- package/runtime/python/okstra_ctl/graphify_cmd.py +0 -225
- package/runtime/python/okstra_vendor/graphify/.vendored-version +0 -1
- package/runtime/python/okstra_vendor/graphify/__init__.py +0 -28
- package/runtime/python/okstra_vendor/graphify/__main__.py +0 -1371
- package/runtime/python/okstra_vendor/graphify/analyze.py +0 -540
- package/runtime/python/okstra_vendor/graphify/benchmark.py +0 -129
- package/runtime/python/okstra_vendor/graphify/build.py +0 -107
- package/runtime/python/okstra_vendor/graphify/cache.py +0 -169
- package/runtime/python/okstra_vendor/graphify/cluster.py +0 -137
- package/runtime/python/okstra_vendor/graphify/detect.py +0 -510
- package/runtime/python/okstra_vendor/graphify/export.py +0 -1014
- package/runtime/python/okstra_vendor/graphify/extract.py +0 -3277
- package/runtime/python/okstra_vendor/graphify/hooks.py +0 -220
- package/runtime/python/okstra_vendor/graphify/ingest.py +0 -297
- package/runtime/python/okstra_vendor/graphify/manifest.py +0 -4
- package/runtime/python/okstra_vendor/graphify/report.py +0 -175
- package/runtime/python/okstra_vendor/graphify/security.py +0 -203
- package/runtime/python/okstra_vendor/graphify/serve.py +0 -373
- package/runtime/python/okstra_vendor/graphify/skill-aider.md +0 -1184
- package/runtime/python/okstra_vendor/graphify/skill-claw.md +0 -1184
- package/runtime/python/okstra_vendor/graphify/skill-codex.md +0 -1242
- package/runtime/python/okstra_vendor/graphify/skill-copilot.md +0 -1268
- package/runtime/python/okstra_vendor/graphify/skill-droid.md +0 -1239
- package/runtime/python/okstra_vendor/graphify/skill-kiro.md +0 -1183
- package/runtime/python/okstra_vendor/graphify/skill-opencode.md +0 -1238
- package/runtime/python/okstra_vendor/graphify/skill-trae.md +0 -1208
- package/runtime/python/okstra_vendor/graphify/skill-vscode.md +0 -253
- package/runtime/python/okstra_vendor/graphify/skill-windows.md +0 -1245
- package/runtime/python/okstra_vendor/graphify/skill.md +0 -1319
- package/runtime/python/okstra_vendor/graphify/transcribe.py +0 -182
- package/runtime/python/okstra_vendor/graphify/validate.py +0 -72
- package/runtime/python/okstra_vendor/graphify/watch.py +0 -188
- package/runtime/python/okstra_vendor/graphify/wiki.py +0 -214
- package/runtime/python/okstra_vendor/networkx/__init__.py +0 -62
- package/runtime/python/okstra_vendor/networkx/algorithms/__init__.py +0 -134
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/__init__.py +0 -26
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clique.py +0 -259
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/clustering_coefficient.py +0 -71
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/connectivity.py +0 -412
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/density.py +0 -396
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/distance_measures.py +0 -150
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/dominating_set.py +0 -149
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/kcomponents.py +0 -369
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/matching.py +0 -44
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/maxcut.py +0 -143
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/ramsey.py +0 -53
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/steinertree.py +0 -265
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/traveling_salesman.py +0 -1508
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/treewidth.py +0 -255
- package/runtime/python/okstra_vendor/networkx/algorithms/approximation/vertex_cover.py +0 -83
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/__init__.py +0 -5
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/connectivity.py +0 -122
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/correlation.py +0 -302
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/mixing.py +0 -255
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/neighbor_degree.py +0 -160
- package/runtime/python/okstra_vendor/networkx/algorithms/assortativity/pairs.py +0 -127
- package/runtime/python/okstra_vendor/networkx/algorithms/asteroidal.py +0 -164
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/__init__.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/basic.py +0 -322
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/centrality.py +0 -290
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/cluster.py +0 -289
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/covering.py +0 -57
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/edgelist.py +0 -360
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/extendability.py +0 -105
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/generators.py +0 -603
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/link_analysis.py +0 -316
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matching.py +0 -590
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/matrix.py +0 -232
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/projection.py +0 -526
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/redundancy.py +0 -112
- package/runtime/python/okstra_vendor/networkx/algorithms/bipartite/spectral.py +0 -69
- package/runtime/python/okstra_vendor/networkx/algorithms/boundary.py +0 -168
- package/runtime/python/okstra_vendor/networkx/algorithms/bridges.py +0 -205
- package/runtime/python/okstra_vendor/networkx/algorithms/broadcasting.py +0 -164
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/__init__.py +0 -20
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness.py +0 -591
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/betweenness_subset.py +0 -236
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/closeness.py +0 -282
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness.py +0 -364
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_betweenness_subset.py +0 -227
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/current_flow_closeness.py +0 -96
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/degree_alg.py +0 -150
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/dispersion.py +0 -107
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/eigenvector.py +0 -357
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/flow_matrix.py +0 -130
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/group.py +0 -787
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/harmonic.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/katz.py +0 -331
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/laplacian.py +0 -150
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/load.py +0 -200
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/percolation.py +0 -128
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/reaching.py +0 -209
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/second_order.py +0 -141
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/subgraph_alg.py +0 -361
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/trophic.py +0 -181
- package/runtime/python/okstra_vendor/networkx/algorithms/centrality/voterank_alg.py +0 -95
- package/runtime/python/okstra_vendor/networkx/algorithms/chains.py +0 -172
- package/runtime/python/okstra_vendor/networkx/algorithms/chordal.py +0 -443
- package/runtime/python/okstra_vendor/networkx/algorithms/clique.py +0 -818
- package/runtime/python/okstra_vendor/networkx/algorithms/cluster.py +0 -732
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/__init__.py +0 -4
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/equitable_coloring.py +0 -505
- package/runtime/python/okstra_vendor/networkx/algorithms/coloring/greedy_coloring.py +0 -565
- package/runtime/python/okstra_vendor/networkx/algorithms/communicability_alg.py +0 -163
- package/runtime/python/okstra_vendor/networkx/algorithms/community/__init__.py +0 -28
- package/runtime/python/okstra_vendor/networkx/algorithms/community/asyn_fluid.py +0 -153
- package/runtime/python/okstra_vendor/networkx/algorithms/community/bipartitions.py +0 -354
- package/runtime/python/okstra_vendor/networkx/algorithms/community/centrality.py +0 -171
- package/runtime/python/okstra_vendor/networkx/algorithms/community/community_utils.py +0 -30
- package/runtime/python/okstra_vendor/networkx/algorithms/community/divisive.py +0 -216
- package/runtime/python/okstra_vendor/networkx/algorithms/community/kclique.py +0 -79
- package/runtime/python/okstra_vendor/networkx/algorithms/community/label_propagation.py +0 -338
- package/runtime/python/okstra_vendor/networkx/algorithms/community/leiden.py +0 -162
- package/runtime/python/okstra_vendor/networkx/algorithms/community/local.py +0 -220
- package/runtime/python/okstra_vendor/networkx/algorithms/community/louvain.py +0 -384
- package/runtime/python/okstra_vendor/networkx/algorithms/community/lukes.py +0 -227
- package/runtime/python/okstra_vendor/networkx/algorithms/community/modularity_max.py +0 -452
- package/runtime/python/okstra_vendor/networkx/algorithms/community/quality.py +0 -347
- package/runtime/python/okstra_vendor/networkx/algorithms/components/__init__.py +0 -6
- package/runtime/python/okstra_vendor/networkx/algorithms/components/attracting.py +0 -115
- package/runtime/python/okstra_vendor/networkx/algorithms/components/biconnected.py +0 -394
- package/runtime/python/okstra_vendor/networkx/algorithms/components/connected.py +0 -282
- package/runtime/python/okstra_vendor/networkx/algorithms/components/semiconnected.py +0 -71
- package/runtime/python/okstra_vendor/networkx/algorithms/components/strongly_connected.py +0 -359
- package/runtime/python/okstra_vendor/networkx/algorithms/components/weakly_connected.py +0 -196
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/__init__.py +0 -11
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/connectivity.py +0 -811
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/cuts.py +0 -616
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/disjoint_paths.py +0 -408
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_augmentation.py +0 -1270
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/edge_kcomponents.py +0 -592
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcomponents.py +0 -220
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/kcutsets.py +0 -235
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/stoerwagner.py +0 -152
- package/runtime/python/okstra_vendor/networkx/algorithms/connectivity/utils.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/core.py +0 -588
- package/runtime/python/okstra_vendor/networkx/algorithms/covering.py +0 -142
- package/runtime/python/okstra_vendor/networkx/algorithms/cuts.py +0 -416
- package/runtime/python/okstra_vendor/networkx/algorithms/cycles.py +0 -1234
- package/runtime/python/okstra_vendor/networkx/algorithms/d_separation.py +0 -677
- package/runtime/python/okstra_vendor/networkx/algorithms/dag.py +0 -1392
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_measures.py +0 -1095
- package/runtime/python/okstra_vendor/networkx/algorithms/distance_regular.py +0 -272
- package/runtime/python/okstra_vendor/networkx/algorithms/dominance.py +0 -142
- package/runtime/python/okstra_vendor/networkx/algorithms/dominating.py +0 -268
- package/runtime/python/okstra_vendor/networkx/algorithms/efficiency_measures.py +0 -167
- package/runtime/python/okstra_vendor/networkx/algorithms/euler.py +0 -470
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/__init__.py +0 -11
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/boykovkolmogorov.py +0 -370
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/capacityscaling.py +0 -407
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/dinitz_alg.py +0 -238
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/edmondskarp.py +0 -241
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/gomory_hu.py +0 -178
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/maxflow.py +0 -611
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/mincost.py +0 -356
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/networksimplex.py +0 -662
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/preflowpush.py +0 -425
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/shortestaugmentingpath.py +0 -300
- package/runtime/python/okstra_vendor/networkx/algorithms/flow/utils.py +0 -194
- package/runtime/python/okstra_vendor/networkx/algorithms/graph_hashing.py +0 -435
- package/runtime/python/okstra_vendor/networkx/algorithms/graphical.py +0 -483
- package/runtime/python/okstra_vendor/networkx/algorithms/hierarchy.py +0 -57
- package/runtime/python/okstra_vendor/networkx/algorithms/hybrid.py +0 -196
- package/runtime/python/okstra_vendor/networkx/algorithms/isolate.py +0 -107
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/__init__.py +0 -7
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/ismags.py +0 -1306
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorph.py +0 -336
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/isomorphvf2.py +0 -1262
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/matchhelpers.py +0 -352
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/temporalisomorphvf2.py +0 -308
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/tree_isomorphism.py +0 -264
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2pp.py +0 -1102
- package/runtime/python/okstra_vendor/networkx/algorithms/isomorphism/vf2userfunc.py +0 -192
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/__init__.py +0 -2
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/hits_alg.py +0 -337
- package/runtime/python/okstra_vendor/networkx/algorithms/link_analysis/pagerank_alg.py +0 -498
- package/runtime/python/okstra_vendor/networkx/algorithms/link_prediction.py +0 -687
- package/runtime/python/okstra_vendor/networkx/algorithms/lowest_common_ancestors.py +0 -280
- package/runtime/python/okstra_vendor/networkx/algorithms/matching.py +0 -1148
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/__init__.py +0 -27
- package/runtime/python/okstra_vendor/networkx/algorithms/minors/contraction.py +0 -738
- package/runtime/python/okstra_vendor/networkx/algorithms/mis.py +0 -78
- package/runtime/python/okstra_vendor/networkx/algorithms/moral.py +0 -59
- package/runtime/python/okstra_vendor/networkx/algorithms/node_classification.py +0 -219
- package/runtime/python/okstra_vendor/networkx/algorithms/non_randomness.py +0 -155
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/__init__.py +0 -4
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/all.py +0 -324
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/binary.py +0 -468
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/product.py +0 -633
- package/runtime/python/okstra_vendor/networkx/algorithms/operators/unary.py +0 -77
- package/runtime/python/okstra_vendor/networkx/algorithms/perfect_graph.py +0 -73
- package/runtime/python/okstra_vendor/networkx/algorithms/planar_drawing.py +0 -464
- package/runtime/python/okstra_vendor/networkx/algorithms/planarity.py +0 -1463
- package/runtime/python/okstra_vendor/networkx/algorithms/polynomials.py +0 -306
- package/runtime/python/okstra_vendor/networkx/algorithms/reciprocity.py +0 -98
- package/runtime/python/okstra_vendor/networkx/algorithms/regular.py +0 -167
- package/runtime/python/okstra_vendor/networkx/algorithms/richclub.py +0 -138
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/__init__.py +0 -5
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/astar.py +0 -239
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/dense.py +0 -264
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/generic.py +0 -716
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/unweighted.py +0 -625
- package/runtime/python/okstra_vendor/networkx/algorithms/shortest_paths/weighted.py +0 -2542
- package/runtime/python/okstra_vendor/networkx/algorithms/similarity.py +0 -2107
- package/runtime/python/okstra_vendor/networkx/algorithms/simple_paths.py +0 -966
- package/runtime/python/okstra_vendor/networkx/algorithms/smallworld.py +0 -404
- package/runtime/python/okstra_vendor/networkx/algorithms/smetric.py +0 -30
- package/runtime/python/okstra_vendor/networkx/algorithms/sparsifiers.py +0 -296
- package/runtime/python/okstra_vendor/networkx/algorithms/structuralholes.py +0 -374
- package/runtime/python/okstra_vendor/networkx/algorithms/summarization.py +0 -564
- package/runtime/python/okstra_vendor/networkx/algorithms/swap.py +0 -406
- package/runtime/python/okstra_vendor/networkx/algorithms/threshold.py +0 -981
- package/runtime/python/okstra_vendor/networkx/algorithms/time_dependent.py +0 -142
- package/runtime/python/okstra_vendor/networkx/algorithms/tournament.py +0 -406
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/__init__.py +0 -5
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/beamsearch.py +0 -90
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/breadth_first_search.py +0 -576
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/depth_first_search.py +0 -529
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgebfs.py +0 -185
- package/runtime/python/okstra_vendor/networkx/algorithms/traversal/edgedfs.py +0 -182
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/__init__.py +0 -7
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/branchings.py +0 -1042
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/coding.py +0 -413
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/decomposition.py +0 -88
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/distance_measures.py +0 -219
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/mst.py +0 -1281
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/operations.py +0 -106
- package/runtime/python/okstra_vendor/networkx/algorithms/tree/recognition.py +0 -273
- package/runtime/python/okstra_vendor/networkx/algorithms/triads.py +0 -500
- package/runtime/python/okstra_vendor/networkx/algorithms/vitality.py +0 -76
- package/runtime/python/okstra_vendor/networkx/algorithms/voronoi.py +0 -86
- package/runtime/python/okstra_vendor/networkx/algorithms/walks.py +0 -77
- package/runtime/python/okstra_vendor/networkx/algorithms/wiener.py +0 -278
- package/runtime/python/okstra_vendor/networkx/classes/__init__.py +0 -13
- package/runtime/python/okstra_vendor/networkx/classes/coreviews.py +0 -435
- package/runtime/python/okstra_vendor/networkx/classes/digraph.py +0 -1363
- package/runtime/python/okstra_vendor/networkx/classes/filters.py +0 -95
- package/runtime/python/okstra_vendor/networkx/classes/function.py +0 -1549
- package/runtime/python/okstra_vendor/networkx/classes/graph.py +0 -2082
- package/runtime/python/okstra_vendor/networkx/classes/graphviews.py +0 -269
- package/runtime/python/okstra_vendor/networkx/classes/multidigraph.py +0 -977
- package/runtime/python/okstra_vendor/networkx/classes/multigraph.py +0 -1294
- package/runtime/python/okstra_vendor/networkx/classes/reportviews.py +0 -1447
- package/runtime/python/okstra_vendor/networkx/convert.py +0 -502
- package/runtime/python/okstra_vendor/networkx/convert_matrix.py +0 -1314
- package/runtime/python/okstra_vendor/networkx/drawing/__init__.py +0 -7
- package/runtime/python/okstra_vendor/networkx/drawing/layout.py +0 -2036
- package/runtime/python/okstra_vendor/networkx/drawing/nx_agraph.py +0 -470
- package/runtime/python/okstra_vendor/networkx/drawing/nx_latex.py +0 -570
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pydot.py +0 -361
- package/runtime/python/okstra_vendor/networkx/drawing/nx_pylab.py +0 -2978
- package/runtime/python/okstra_vendor/networkx/exception.py +0 -131
- package/runtime/python/okstra_vendor/networkx/generators/__init__.py +0 -34
- package/runtime/python/okstra_vendor/networkx/generators/atlas.dat.gz +0 -0
- package/runtime/python/okstra_vendor/networkx/generators/atlas.py +0 -227
- package/runtime/python/okstra_vendor/networkx/generators/classic.py +0 -1091
- package/runtime/python/okstra_vendor/networkx/generators/cographs.py +0 -68
- package/runtime/python/okstra_vendor/networkx/generators/community.py +0 -1070
- package/runtime/python/okstra_vendor/networkx/generators/degree_seq.py +0 -886
- package/runtime/python/okstra_vendor/networkx/generators/directed.py +0 -572
- package/runtime/python/okstra_vendor/networkx/generators/duplication.py +0 -174
- package/runtime/python/okstra_vendor/networkx/generators/ego.py +0 -66
- package/runtime/python/okstra_vendor/networkx/generators/expanders.py +0 -499
- package/runtime/python/okstra_vendor/networkx/generators/geometric.py +0 -1037
- package/runtime/python/okstra_vendor/networkx/generators/harary_graph.py +0 -163
- package/runtime/python/okstra_vendor/networkx/generators/internet_as_graphs.py +0 -443
- package/runtime/python/okstra_vendor/networkx/generators/intersection.py +0 -125
- package/runtime/python/okstra_vendor/networkx/generators/interval_graph.py +0 -70
- package/runtime/python/okstra_vendor/networkx/generators/joint_degree_seq.py +0 -664
- package/runtime/python/okstra_vendor/networkx/generators/lattice.py +0 -405
- package/runtime/python/okstra_vendor/networkx/generators/line.py +0 -501
- package/runtime/python/okstra_vendor/networkx/generators/mycielski.py +0 -110
- package/runtime/python/okstra_vendor/networkx/generators/nonisomorphic_trees.py +0 -259
- package/runtime/python/okstra_vendor/networkx/generators/random_clustered.py +0 -117
- package/runtime/python/okstra_vendor/networkx/generators/random_graphs.py +0 -1416
- package/runtime/python/okstra_vendor/networkx/generators/small.py +0 -1070
- package/runtime/python/okstra_vendor/networkx/generators/social.py +0 -554
- package/runtime/python/okstra_vendor/networkx/generators/spectral_graph_forge.py +0 -120
- package/runtime/python/okstra_vendor/networkx/generators/stochastic.py +0 -54
- package/runtime/python/okstra_vendor/networkx/generators/sudoku.py +0 -131
- package/runtime/python/okstra_vendor/networkx/generators/time_series.py +0 -74
- package/runtime/python/okstra_vendor/networkx/generators/trees.py +0 -1070
- package/runtime/python/okstra_vendor/networkx/generators/triads.py +0 -94
- package/runtime/python/okstra_vendor/networkx/lazy_imports.py +0 -188
- package/runtime/python/okstra_vendor/networkx/linalg/__init__.py +0 -13
- package/runtime/python/okstra_vendor/networkx/linalg/algebraicconnectivity.py +0 -650
- package/runtime/python/okstra_vendor/networkx/linalg/attrmatrix.py +0 -466
- package/runtime/python/okstra_vendor/networkx/linalg/bethehessianmatrix.py +0 -77
- package/runtime/python/okstra_vendor/networkx/linalg/graphmatrix.py +0 -168
- package/runtime/python/okstra_vendor/networkx/linalg/laplacianmatrix.py +0 -512
- package/runtime/python/okstra_vendor/networkx/linalg/modularitymatrix.py +0 -166
- package/runtime/python/okstra_vendor/networkx/linalg/spectrum.py +0 -186
- package/runtime/python/okstra_vendor/networkx/readwrite/__init__.py +0 -17
- package/runtime/python/okstra_vendor/networkx/readwrite/adjlist.py +0 -330
- package/runtime/python/okstra_vendor/networkx/readwrite/edgelist.py +0 -489
- package/runtime/python/okstra_vendor/networkx/readwrite/gexf.py +0 -1084
- package/runtime/python/okstra_vendor/networkx/readwrite/gml.py +0 -879
- package/runtime/python/okstra_vendor/networkx/readwrite/graph6.py +0 -427
- package/runtime/python/okstra_vendor/networkx/readwrite/graphml.py +0 -1053
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/__init__.py +0 -19
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/adjacency.py +0 -156
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/cytoscape.py +0 -190
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/node_link.py +0 -261
- package/runtime/python/okstra_vendor/networkx/readwrite/json_graph/tree.py +0 -137
- package/runtime/python/okstra_vendor/networkx/readwrite/leda.py +0 -108
- package/runtime/python/okstra_vendor/networkx/readwrite/multiline_adjlist.py +0 -393
- package/runtime/python/okstra_vendor/networkx/readwrite/p2g.py +0 -113
- package/runtime/python/okstra_vendor/networkx/readwrite/pajek.py +0 -286
- package/runtime/python/okstra_vendor/networkx/readwrite/sparse6.py +0 -379
- package/runtime/python/okstra_vendor/networkx/readwrite/text.py +0 -851
- package/runtime/python/okstra_vendor/networkx/relabel.py +0 -285
- package/runtime/python/okstra_vendor/networkx/utils/__init__.py +0 -8
- package/runtime/python/okstra_vendor/networkx/utils/backends.py +0 -2171
- package/runtime/python/okstra_vendor/networkx/utils/configs.py +0 -396
- package/runtime/python/okstra_vendor/networkx/utils/decorators.py +0 -1233
- package/runtime/python/okstra_vendor/networkx/utils/heaps.py +0 -338
- package/runtime/python/okstra_vendor/networkx/utils/mapped_queue.py +0 -297
- package/runtime/python/okstra_vendor/networkx/utils/misc.py +0 -703
- package/runtime/python/okstra_vendor/networkx/utils/random_sequence.py +0 -198
- package/runtime/python/okstra_vendor/networkx/utils/rcm.py +0 -159
- package/runtime/python/okstra_vendor/networkx/utils/union_find.py +0 -106
- package/runtime/skills/okstra-graphify/SKILL.md +0 -169
- package/src/commands/graphify.mjs +0 -32
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Utilities for generating random numbers, random sequences, and
|
|
3
|
-
random selections.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import networkx as nx
|
|
7
|
-
from networkx.utils import py_random_state
|
|
8
|
-
|
|
9
|
-
__all__ = [
|
|
10
|
-
"powerlaw_sequence",
|
|
11
|
-
"is_valid_tree_degree_sequence",
|
|
12
|
-
"zipf_rv",
|
|
13
|
-
"cumulative_distribution",
|
|
14
|
-
"discrete_sequence",
|
|
15
|
-
"random_weighted_sample",
|
|
16
|
-
"weighted_choice",
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# The same helpers for choosing random sequences from distributions
|
|
21
|
-
# uses Python's random module
|
|
22
|
-
# https://docs.python.org/3/library/random.html
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@py_random_state(2)
|
|
26
|
-
def powerlaw_sequence(n, exponent=2.0, seed=None):
|
|
27
|
-
"""
|
|
28
|
-
Return sample sequence of length n from a power law distribution.
|
|
29
|
-
"""
|
|
30
|
-
return [seed.paretovariate(exponent - 1) for i in range(n)]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def is_valid_tree_degree_sequence(degree_sequence):
|
|
34
|
-
"""Check if a degree sequence is valid for a tree.
|
|
35
|
-
|
|
36
|
-
Two conditions must be met for a degree sequence to be valid for a tree:
|
|
37
|
-
|
|
38
|
-
1. The number of nodes must be one more than the number of edges.
|
|
39
|
-
2. The degree sequence must be trivial or have only strictly positive
|
|
40
|
-
node degrees.
|
|
41
|
-
|
|
42
|
-
Parameters
|
|
43
|
-
----------
|
|
44
|
-
degree_sequence : iterable
|
|
45
|
-
Iterable of node degrees.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
bool
|
|
50
|
-
Whether the degree sequence is valid for a tree.
|
|
51
|
-
str
|
|
52
|
-
Reason for invalidity, or dummy string if valid.
|
|
53
|
-
"""
|
|
54
|
-
seq = list(degree_sequence)
|
|
55
|
-
number_of_nodes = len(seq)
|
|
56
|
-
twice_number_of_edges = sum(seq)
|
|
57
|
-
|
|
58
|
-
if 2 * number_of_nodes - twice_number_of_edges != 2:
|
|
59
|
-
return False, "tree must have one more node than number of edges"
|
|
60
|
-
elif seq != [0] and any(d <= 0 for d in seq):
|
|
61
|
-
return False, "nontrivial tree must have strictly positive node degrees"
|
|
62
|
-
return True, ""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@py_random_state(2)
|
|
66
|
-
def zipf_rv(alpha, xmin=1, seed=None):
|
|
67
|
-
r"""Returns a random value chosen from the Zipf distribution.
|
|
68
|
-
|
|
69
|
-
The return value is an integer drawn from the probability distribution
|
|
70
|
-
|
|
71
|
-
.. math::
|
|
72
|
-
|
|
73
|
-
p(x)=\frac{x^{-\alpha}}{\zeta(\alpha, x_{\min})},
|
|
74
|
-
|
|
75
|
-
where $\zeta(\alpha, x_{\min})$ is the Hurwitz zeta function.
|
|
76
|
-
|
|
77
|
-
Parameters
|
|
78
|
-
----------
|
|
79
|
-
alpha : float
|
|
80
|
-
Exponent value of the distribution
|
|
81
|
-
xmin : int
|
|
82
|
-
Minimum value
|
|
83
|
-
seed : integer, random_state, or None (default)
|
|
84
|
-
Indicator of random number generation state.
|
|
85
|
-
See :ref:`Randomness<randomness>`.
|
|
86
|
-
|
|
87
|
-
Returns
|
|
88
|
-
-------
|
|
89
|
-
x : int
|
|
90
|
-
Random value from Zipf distribution
|
|
91
|
-
|
|
92
|
-
Raises
|
|
93
|
-
------
|
|
94
|
-
ValueError:
|
|
95
|
-
If xmin < 1 or
|
|
96
|
-
If alpha <= 1
|
|
97
|
-
|
|
98
|
-
Notes
|
|
99
|
-
-----
|
|
100
|
-
The rejection algorithm generates random values for a the power-law
|
|
101
|
-
distribution in uniformly bounded expected time dependent on
|
|
102
|
-
parameters. See [1]_ for details on its operation.
|
|
103
|
-
|
|
104
|
-
Examples
|
|
105
|
-
--------
|
|
106
|
-
>>> nx.utils.zipf_rv(alpha=2, xmin=3, seed=42)
|
|
107
|
-
8
|
|
108
|
-
|
|
109
|
-
References
|
|
110
|
-
----------
|
|
111
|
-
.. [1] Luc Devroye, Non-Uniform Random Variate Generation,
|
|
112
|
-
Springer-Verlag, New York, 1986.
|
|
113
|
-
"""
|
|
114
|
-
if xmin < 1:
|
|
115
|
-
raise ValueError("xmin < 1")
|
|
116
|
-
if alpha <= 1:
|
|
117
|
-
raise ValueError("a <= 1.0")
|
|
118
|
-
a1 = alpha - 1.0
|
|
119
|
-
b = 2**a1
|
|
120
|
-
while True:
|
|
121
|
-
u = 1.0 - seed.random() # u in (0,1]
|
|
122
|
-
v = seed.random() # v in [0,1)
|
|
123
|
-
x = int(xmin * u ** -(1.0 / a1))
|
|
124
|
-
t = (1.0 + (1.0 / x)) ** a1
|
|
125
|
-
if v * x * (t - 1.0) / (b - 1.0) <= t / b:
|
|
126
|
-
break
|
|
127
|
-
return x
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def cumulative_distribution(distribution):
|
|
131
|
-
"""Returns normalized cumulative distribution from discrete distribution."""
|
|
132
|
-
|
|
133
|
-
cdf = [0.0]
|
|
134
|
-
cumulative = 0.0
|
|
135
|
-
for element in distribution:
|
|
136
|
-
cumulative += element
|
|
137
|
-
cdf.append(cumulative)
|
|
138
|
-
return [element / cumulative for element in cdf]
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
@py_random_state(3)
|
|
142
|
-
def discrete_sequence(n, distribution=None, cdistribution=None, seed=None):
|
|
143
|
-
"""
|
|
144
|
-
Return sample sequence of length n from a given discrete distribution
|
|
145
|
-
or discrete cumulative distribution.
|
|
146
|
-
|
|
147
|
-
One of the following must be specified.
|
|
148
|
-
|
|
149
|
-
distribution = histogram of values, will be normalized
|
|
150
|
-
|
|
151
|
-
cdistribution = normalized discrete cumulative distribution
|
|
152
|
-
|
|
153
|
-
"""
|
|
154
|
-
import bisect
|
|
155
|
-
|
|
156
|
-
if cdistribution is not None:
|
|
157
|
-
cdf = cdistribution
|
|
158
|
-
elif distribution is not None:
|
|
159
|
-
cdf = cumulative_distribution(distribution)
|
|
160
|
-
else:
|
|
161
|
-
raise nx.NetworkXError(
|
|
162
|
-
"discrete_sequence: distribution or cdistribution missing"
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
# get a uniform random number
|
|
166
|
-
inputseq = [seed.random() for i in range(n)]
|
|
167
|
-
|
|
168
|
-
# choose from CDF
|
|
169
|
-
seq = [bisect.bisect_left(cdf, s) - 1 for s in inputseq]
|
|
170
|
-
return seq
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
@py_random_state(2)
|
|
174
|
-
def random_weighted_sample(mapping, k, seed=None):
|
|
175
|
-
"""Returns k items without replacement from a weighted sample.
|
|
176
|
-
|
|
177
|
-
The input is a dictionary of items with weights as values.
|
|
178
|
-
"""
|
|
179
|
-
if k > len(mapping):
|
|
180
|
-
raise ValueError("sample larger than population")
|
|
181
|
-
sample = set()
|
|
182
|
-
while len(sample) < k:
|
|
183
|
-
sample.add(weighted_choice(mapping, seed))
|
|
184
|
-
return list(sample)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
@py_random_state(1)
|
|
188
|
-
def weighted_choice(mapping, seed=None):
|
|
189
|
-
"""Returns a single element from a weighted sample.
|
|
190
|
-
|
|
191
|
-
The input is a dictionary of items with weights as values.
|
|
192
|
-
"""
|
|
193
|
-
# use roulette method
|
|
194
|
-
rnd = seed.random() * sum(mapping.values())
|
|
195
|
-
for k, w in mapping.items():
|
|
196
|
-
rnd -= w
|
|
197
|
-
if rnd < 0:
|
|
198
|
-
return k
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Cuthill-McKee ordering of graph nodes to produce sparse matrices
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from collections import deque
|
|
6
|
-
from operator import itemgetter
|
|
7
|
-
|
|
8
|
-
import networkx as nx
|
|
9
|
-
|
|
10
|
-
from ..utils import arbitrary_element
|
|
11
|
-
|
|
12
|
-
__all__ = ["cuthill_mckee_ordering", "reverse_cuthill_mckee_ordering"]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def cuthill_mckee_ordering(G, heuristic=None):
|
|
16
|
-
"""Generate an ordering (permutation) of the graph nodes to make
|
|
17
|
-
a sparse matrix.
|
|
18
|
-
|
|
19
|
-
Uses the Cuthill-McKee heuristic (based on breadth-first search) [1]_.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
G : graph
|
|
24
|
-
A NetworkX graph
|
|
25
|
-
|
|
26
|
-
heuristic : function, optional
|
|
27
|
-
Function to choose starting node for RCM algorithm. If None
|
|
28
|
-
a node from a pseudo-peripheral pair is used. A user-defined function
|
|
29
|
-
can be supplied that takes a graph object and returns a single node.
|
|
30
|
-
|
|
31
|
-
Returns
|
|
32
|
-
-------
|
|
33
|
-
nodes : generator
|
|
34
|
-
Generator of nodes in Cuthill-McKee ordering.
|
|
35
|
-
|
|
36
|
-
Examples
|
|
37
|
-
--------
|
|
38
|
-
>>> from networkx.utils import cuthill_mckee_ordering
|
|
39
|
-
>>> G = nx.path_graph(4)
|
|
40
|
-
>>> rcm = list(cuthill_mckee_ordering(G))
|
|
41
|
-
>>> A = nx.adjacency_matrix(G, nodelist=rcm)
|
|
42
|
-
|
|
43
|
-
Smallest degree node as heuristic function:
|
|
44
|
-
|
|
45
|
-
>>> def smallest_degree(G):
|
|
46
|
-
... return min(G, key=G.degree)
|
|
47
|
-
>>> rcm = list(cuthill_mckee_ordering(G, heuristic=smallest_degree))
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
See Also
|
|
51
|
-
--------
|
|
52
|
-
reverse_cuthill_mckee_ordering
|
|
53
|
-
|
|
54
|
-
Notes
|
|
55
|
-
-----
|
|
56
|
-
The optimal solution the bandwidth reduction is NP-complete [2]_.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
References
|
|
60
|
-
----------
|
|
61
|
-
.. [1] E. Cuthill and J. McKee.
|
|
62
|
-
Reducing the bandwidth of sparse symmetric matrices,
|
|
63
|
-
In Proc. 24th Nat. Conf. ACM, pages 157-172, 1969.
|
|
64
|
-
http://doi.acm.org/10.1145/800195.805928
|
|
65
|
-
.. [2] Steven S. Skiena. 1997. The Algorithm Design Manual.
|
|
66
|
-
Springer-Verlag New York, Inc., New York, NY, USA.
|
|
67
|
-
"""
|
|
68
|
-
for c in nx.connected_components(G):
|
|
69
|
-
yield from connected_cuthill_mckee_ordering(G.subgraph(c), heuristic)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def reverse_cuthill_mckee_ordering(G, heuristic=None):
|
|
73
|
-
"""Generate an ordering (permutation) of the graph nodes to make
|
|
74
|
-
a sparse matrix.
|
|
75
|
-
|
|
76
|
-
Uses the reverse Cuthill-McKee heuristic (based on breadth-first search)
|
|
77
|
-
[1]_.
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
G : graph
|
|
82
|
-
A NetworkX graph
|
|
83
|
-
|
|
84
|
-
heuristic : function, optional
|
|
85
|
-
Function to choose starting node for RCM algorithm. If None
|
|
86
|
-
a node from a pseudo-peripheral pair is used. A user-defined function
|
|
87
|
-
can be supplied that takes a graph object and returns a single node.
|
|
88
|
-
|
|
89
|
-
Returns
|
|
90
|
-
-------
|
|
91
|
-
nodes : generator
|
|
92
|
-
Generator of nodes in reverse Cuthill-McKee ordering.
|
|
93
|
-
|
|
94
|
-
Examples
|
|
95
|
-
--------
|
|
96
|
-
>>> from networkx.utils import reverse_cuthill_mckee_ordering
|
|
97
|
-
>>> G = nx.path_graph(4)
|
|
98
|
-
>>> rcm = list(reverse_cuthill_mckee_ordering(G))
|
|
99
|
-
>>> A = nx.adjacency_matrix(G, nodelist=rcm)
|
|
100
|
-
|
|
101
|
-
Smallest degree node as heuristic function:
|
|
102
|
-
|
|
103
|
-
>>> def smallest_degree(G):
|
|
104
|
-
... return min(G, key=G.degree)
|
|
105
|
-
>>> rcm = list(reverse_cuthill_mckee_ordering(G, heuristic=smallest_degree))
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
See Also
|
|
109
|
-
--------
|
|
110
|
-
cuthill_mckee_ordering
|
|
111
|
-
|
|
112
|
-
Notes
|
|
113
|
-
-----
|
|
114
|
-
The optimal solution the bandwidth reduction is NP-complete [2]_.
|
|
115
|
-
|
|
116
|
-
References
|
|
117
|
-
----------
|
|
118
|
-
.. [1] E. Cuthill and J. McKee.
|
|
119
|
-
Reducing the bandwidth of sparse symmetric matrices,
|
|
120
|
-
In Proc. 24th Nat. Conf. ACM, pages 157-72, 1969.
|
|
121
|
-
http://doi.acm.org/10.1145/800195.805928
|
|
122
|
-
.. [2] Steven S. Skiena. 1997. The Algorithm Design Manual.
|
|
123
|
-
Springer-Verlag New York, Inc., New York, NY, USA.
|
|
124
|
-
"""
|
|
125
|
-
return reversed(list(cuthill_mckee_ordering(G, heuristic=heuristic)))
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def connected_cuthill_mckee_ordering(G, heuristic=None):
|
|
129
|
-
# the cuthill mckee algorithm for connected graphs
|
|
130
|
-
if heuristic is None:
|
|
131
|
-
start = pseudo_peripheral_node(G)
|
|
132
|
-
else:
|
|
133
|
-
start = heuristic(G)
|
|
134
|
-
visited = {start}
|
|
135
|
-
queue = deque([start])
|
|
136
|
-
while queue:
|
|
137
|
-
parent = queue.popleft()
|
|
138
|
-
yield parent
|
|
139
|
-
nd = sorted(G.degree(set(G[parent]) - visited), key=itemgetter(1))
|
|
140
|
-
children = [n for n, d in nd]
|
|
141
|
-
visited.update(children)
|
|
142
|
-
queue.extend(children)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def pseudo_peripheral_node(G):
|
|
146
|
-
# helper for cuthill-mckee to find a node in a "pseudo peripheral pair"
|
|
147
|
-
# to use as good starting node
|
|
148
|
-
u = arbitrary_element(G)
|
|
149
|
-
lp = 0
|
|
150
|
-
v = u
|
|
151
|
-
while True:
|
|
152
|
-
spl = nx.shortest_path_length(G, v)
|
|
153
|
-
l = max(spl.values())
|
|
154
|
-
if l <= lp:
|
|
155
|
-
break
|
|
156
|
-
lp = l
|
|
157
|
-
farthest = (n for n, dist in spl.items() if dist == l)
|
|
158
|
-
v, deg = min(G.degree(farthest), key=itemgetter(1))
|
|
159
|
-
return v
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Union-find data structure.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from networkx.utils import groups
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class UnionFind:
|
|
9
|
-
"""Union-find data structure.
|
|
10
|
-
|
|
11
|
-
Each unionFind instance X maintains a family of disjoint sets of
|
|
12
|
-
hashable objects, supporting the following two methods:
|
|
13
|
-
|
|
14
|
-
- X[item] returns a name for the set containing the given item.
|
|
15
|
-
Each set is named by an arbitrarily-chosen one of its members; as
|
|
16
|
-
long as the set remains unchanged it will keep the same name. If
|
|
17
|
-
the item is not yet part of a set in X, a new singleton set is
|
|
18
|
-
created for it.
|
|
19
|
-
|
|
20
|
-
- X.union(item1, item2, ...) merges the sets containing each item
|
|
21
|
-
into a single larger set. If any item is not yet part of a set
|
|
22
|
-
in X, it is added to X as one of the members of the merged set.
|
|
23
|
-
|
|
24
|
-
Union-find data structure. Based on Josiah Carlson's code,
|
|
25
|
-
https://code.activestate.com/recipes/215912/
|
|
26
|
-
with significant additional changes by D. Eppstein.
|
|
27
|
-
http://www.ics.uci.edu/~eppstein/PADS/UnionFind.py
|
|
28
|
-
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
def __init__(self, elements=None):
|
|
32
|
-
"""Create a new empty union-find structure.
|
|
33
|
-
|
|
34
|
-
If *elements* is an iterable, this structure will be initialized
|
|
35
|
-
with the discrete partition on the given set of elements.
|
|
36
|
-
|
|
37
|
-
"""
|
|
38
|
-
if elements is None:
|
|
39
|
-
elements = ()
|
|
40
|
-
self.parents = {}
|
|
41
|
-
self.weights = {}
|
|
42
|
-
for x in elements:
|
|
43
|
-
self.weights[x] = 1
|
|
44
|
-
self.parents[x] = x
|
|
45
|
-
|
|
46
|
-
def __getitem__(self, object):
|
|
47
|
-
"""Find and return the name of the set containing the object."""
|
|
48
|
-
|
|
49
|
-
# check for previously unknown object
|
|
50
|
-
if object not in self.parents:
|
|
51
|
-
self.parents[object] = object
|
|
52
|
-
self.weights[object] = 1
|
|
53
|
-
return object
|
|
54
|
-
|
|
55
|
-
# find path of objects leading to the root
|
|
56
|
-
path = []
|
|
57
|
-
root = self.parents[object]
|
|
58
|
-
while root != object:
|
|
59
|
-
path.append(object)
|
|
60
|
-
object = root
|
|
61
|
-
root = self.parents[object]
|
|
62
|
-
|
|
63
|
-
# compress the path and return
|
|
64
|
-
for ancestor in path:
|
|
65
|
-
self.parents[ancestor] = root
|
|
66
|
-
return root
|
|
67
|
-
|
|
68
|
-
def __iter__(self):
|
|
69
|
-
"""Iterate through all items ever found or unioned by this structure."""
|
|
70
|
-
return iter(self.parents)
|
|
71
|
-
|
|
72
|
-
def to_sets(self):
|
|
73
|
-
"""Iterates over the sets stored in this structure.
|
|
74
|
-
|
|
75
|
-
For example::
|
|
76
|
-
|
|
77
|
-
>>> partition = UnionFind("xyz")
|
|
78
|
-
>>> sorted(map(sorted, partition.to_sets()))
|
|
79
|
-
[['x'], ['y'], ['z']]
|
|
80
|
-
>>> partition.union("x", "y")
|
|
81
|
-
>>> sorted(map(sorted, partition.to_sets()))
|
|
82
|
-
[['x', 'y'], ['z']]
|
|
83
|
-
|
|
84
|
-
"""
|
|
85
|
-
# Ensure fully pruned paths
|
|
86
|
-
for x in self.parents:
|
|
87
|
-
_ = self[x] # Evaluated for side-effect only
|
|
88
|
-
|
|
89
|
-
yield from groups(self.parents).values()
|
|
90
|
-
|
|
91
|
-
def union(self, *objects):
|
|
92
|
-
"""Find the sets containing the objects and merge them all."""
|
|
93
|
-
# Find the heaviest root according to its weight.
|
|
94
|
-
roots = iter(
|
|
95
|
-
sorted(
|
|
96
|
-
{self[x] for x in objects}, key=lambda r: self.weights[r], reverse=True
|
|
97
|
-
)
|
|
98
|
-
)
|
|
99
|
-
try:
|
|
100
|
-
root = next(roots)
|
|
101
|
-
except StopIteration:
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
for r in roots:
|
|
105
|
-
self.weights[root] += self.weights[r]
|
|
106
|
-
self.parents[r] = root
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: okstra-graphify
|
|
3
|
-
description: >-
|
|
4
|
-
Use when the user wants to build, query, or navigate a knowledge graph over an okstra project's own `.okstra/` memory — its reports, decision records, and glossary. Turns that docs corpus into a persistent graph with community detection and an honest EXTRACTED/INFERRED/AMBIGUOUS audit trail, then answers cross-document questions the flat files can't. Trigger phrases include "okstra graphify", "graph the .okstra docs", "build okstra knowledge graph", "query okstra graph", "what connects to X in the okstra docs", "build the okstra graph", "graph the decision records". NOT for graphing arbitrary code or non-okstra folders (that is the standalone /graphify), and NOT for single-task inspection (okstra-inspect) or rollups (okstra-rollup).
|
|
5
|
-
trigger: /okstra-graphify
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# OKSTRA Graphify
|
|
9
|
-
|
|
10
|
-
Build and query a knowledge graph over the project's own okstra memory. The corpus is **fixed** to `<projectRoot>/.okstra` and the outputs land at `<projectRoot>/.okstra/graph/` — the `okstra graphify` CLI enforces both, so this skill never takes a user path argument and never touches files outside `.okstra/`.
|
|
11
|
-
|
|
12
|
-
Only `.okstra/**/*.md` (final reports, `decisions/*.md`, `glossary.md`, briefs) are indexed. This is docs-only — there is no code AST extraction here (that lives in the standalone `/graphify`).
|
|
13
|
-
|
|
14
|
-
| Sub-command | What it does |
|
|
15
|
-
|---|---|
|
|
16
|
-
| `build` | Extract entities/relationships from `.okstra` docs (subagent dispatch), then assemble the graph + report + HTML. |
|
|
17
|
-
| `query` | BFS/DFS traversal to answer a broad question over the graph. |
|
|
18
|
-
| `path` | Shortest path between two named concepts. |
|
|
19
|
-
| `explain` | Plain-language explanation of one node and its connections. |
|
|
20
|
-
| `wiki` | Agent-crawlable wiki (`index.md` + one article per community). |
|
|
21
|
-
| `mcp` | Start a stdio MCP server exposing the graph to other agents (opt-in — additionally needs `pip install mcp`). |
|
|
22
|
-
|
|
23
|
-
## Step 0: Preflight (shared)
|
|
24
|
-
|
|
25
|
-
Before any sub-command:
|
|
26
|
-
|
|
27
|
-
<!-- BEGIN FRAGMENT: bash-invocation-rule -->
|
|
28
|
-
Run one Bash tool call, starting with the literal token `okstra` (never wrapped in `if`/`eval`/`export`/`$(...)`/`VAR=...`/`||`/`&&`/`npx` — a non-literal leading token defeats the `Bash(okstra:*)` permission match):
|
|
29
|
-
<!-- END FRAGMENT: bash-invocation-rule -->
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
okstra preflight --runtime claude-code --json
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Parse the stdout JSON:
|
|
36
|
-
- `ok: true` → carry `projectRoot` as a literal string; it is the `--project-root` value for every sub-command below.
|
|
37
|
-
- `ok: false` → before concluding "no setup", ask whether the user pointed at a specific project directory. If so, re-run `okstra preflight --runtime claude-code --cwd <that-dir> --json`. Only if this **also** returns `ok:false` do you tell the user: "this project has no okstra setup. Run `/okstra-setup` first." Then stop.
|
|
38
|
-
|
|
39
|
-
<!-- BEGIN FRAGMENT: preflight-outdated-cli -->
|
|
40
|
-
If the call fails with `unknown command: preflight`, the `okstra` binary on PATH predates this skill — tell the user to update it (`npm i -g okstra@latest`), then stop (`/okstra-setup` does not update the binary).
|
|
41
|
-
<!-- END FRAGMENT: preflight-outdated-cli -->
|
|
42
|
-
|
|
43
|
-
Every `okstra graphify` call below passes `--project-root <projectRoot>` — `--project-root` is REQUIRED and there is no cwd injection; a bare `okstra graphify build` fails with a usage error.
|
|
44
|
-
|
|
45
|
-
## Step 1: Dispatch by intent
|
|
46
|
-
|
|
47
|
-
Classify the request into one sub-command using the table above. If ambiguous ("show me the okstra graph"), ask which — enumerate the full sub-command table as a numbered text list and let the user pick. `build` is the prerequisite for `query`/`path`/`explain`/`wiki`/`mcp`; if the user asks to query before a graph exists, the CLI will fail cleanly with `no graph … Run \`okstra graphify build\` first` — run `build` first.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## build
|
|
52
|
-
|
|
53
|
-
Two parts: **semantic extraction** (subagents read `.okstra` docs and write chunk JSON), then **assemble** (the CLI clusters and generates outputs).
|
|
54
|
-
|
|
55
|
-
### build.1 — Detect the corpus
|
|
56
|
-
|
|
57
|
-
The corpus is fixed to `<projectRoot>/.okstra`. Glob the doc files yourself:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
find <projectRoot>/.okstra -type f -name '*.md' -not -path '*/graph/*'
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Present a clean summary — `Corpus: N markdown files under <projectRoot>/.okstra` (reports, decisions, glossary, briefs). If zero files, stop with "No `.okstra` docs found — run some okstra tasks first, then graph them." The CLI disables graphify's filename-based sensitive-file skip inside `.okstra` (it is okstra's own generated memory, not a secrets store), so do not drop files whose names contain `token`/`secret`.
|
|
64
|
-
|
|
65
|
-
### build.2 — Semantic extraction (parallel subagents)
|
|
66
|
-
|
|
67
|
-
**MANDATORY: use the Agent tool.** Reading files one-by-one yourself is forbidden — it is far slower.
|
|
68
|
-
|
|
69
|
-
1. Split the doc list into chunks of 20-25 files. Group files from the same directory (e.g. all `decisions/`) together so cross-file relationships surface. Print a one-line estimate: `Semantic extraction: ~N files → X agents`.
|
|
70
|
-
2. Call the Agent tool **once per chunk, all in a single response** so they run in parallel. **`subagent_type="general-purpose"`** always — never `Explore` (it is read-only and cannot write chunk files, silently dropping results).
|
|
71
|
-
3. Each subagent writes its fragment to `<projectRoot>/.okstra/graph/.chunks/chunk-NN.json`.
|
|
72
|
-
|
|
73
|
-
Each subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, OUT_PATH = `<projectRoot>/.okstra/graph/.chunks/chunk-<NN>.json`):
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
You are an okstra-graphify extraction subagent over an okstra project's `.okstra` docs
|
|
77
|
-
(final reports, decision records, glossary, briefs). Read the files listed and extract a
|
|
78
|
-
knowledge-graph fragment. Write ONLY valid JSON (schema below) to OUT_PATH — mkdir -p its
|
|
79
|
-
parent first. No explanation, no markdown fences.
|
|
80
|
-
|
|
81
|
-
Files (chunk CHUNK_NUM of TOTAL_CHUNKS):
|
|
82
|
-
FILE_LIST
|
|
83
|
-
|
|
84
|
-
Rules:
|
|
85
|
-
- EXTRACTED: relationship explicit in source (a report cites a decision, "see DEC-0003", a task references another task-key).
|
|
86
|
-
- INFERRED: reasonable inference (two reports discuss the same subsystem; a glossary term used in a decision).
|
|
87
|
-
- AMBIGUOUS: uncertain — flag, do not omit.
|
|
88
|
-
Extract named concepts, task-keys, decision ids, glossary terms, subsystems, and rationale
|
|
89
|
-
(sections explaining WHY a decision was made) as nodes; link them with the relations below.
|
|
90
|
-
Add a `semantically_similar_to` INFERRED edge (confidence_score 0.6-0.95) when two concepts in
|
|
91
|
-
this chunk address the same problem without any explicit link. Only when genuinely non-obvious.
|
|
92
|
-
|
|
93
|
-
confidence_score is REQUIRED on every edge:
|
|
94
|
-
- EXTRACTED → 1.0 always
|
|
95
|
-
- INFERRED → 0.6-0.9 (0.8-0.9 with clear evidence, 0.6-0.7 with some uncertainty)
|
|
96
|
-
- AMBIGUOUS → 0.1-0.3
|
|
97
|
-
|
|
98
|
-
Node ID: lowercase `[a-z0-9_]` only. Format `{stem}_{entity}` — filename stem + symbol,
|
|
99
|
-
both normalized (non-alphanumeric → `_`).
|
|
100
|
-
|
|
101
|
-
Output exactly this JSON to OUT_PATH:
|
|
102
|
-
{"nodes":[{"id":"dec_0003_stage_isolation","label":"Human Readable Name","file_type":"document","source_file":"relative/path","source_location":null}],"edges":[{"source":"node_id","target":"node_id","relation":"references|cites|conceptually_related_to|shares_data_with|semantically_similar_to|rationale_for","confidence":"EXTRACTED|INFERRED|AMBIGUOUS","confidence_score":1.0,"source_file":"relative/path","weight":1.0}]}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
After all subagents finish, confirm each `chunk-NN.json` exists on disk (the success signal). If a file is missing, warn — the subagent may have been read-only — and re-dispatch with `general-purpose`. If more than half the chunks are missing, stop and tell the user to re-run.
|
|
106
|
-
|
|
107
|
-
### build.3 — Assemble
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
okstra graphify build --project-root <projectRoot>
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
This merges every `graph/.chunks/*.json` (`nodes` + `edges`), builds the graph, runs community detection, and writes to `<projectRoot>/.okstra/graph/`:
|
|
114
|
-
- `graph.json` — raw graph data
|
|
115
|
-
- `GRAPH_REPORT.md` — audit report (god nodes, surprising connections, suggested questions, token/confidence audit)
|
|
116
|
-
- `graph.html` — interactive graph, open in any browser
|
|
117
|
-
|
|
118
|
-
If the CLI errors with `no extraction chunks`, the subagents in build.2 did not write their files — re-dispatch them. After a successful build, paste the God Nodes / Surprising Connections / Suggested Questions sections from `GRAPH_REPORT.md` (not the whole file), then offer to trace the single most interesting suggested question via `query`.
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## query
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
okstra graphify query "<question>" --project-root <projectRoot>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
BFS traversal over the graph; prints the relevant subgraph (nodes, edge relations, confidence tags, source locations). Answer using **only** what the subgraph contains — quote `source_file`/`source_location` when citing a fact, and say so plainly if the graph lacks the information rather than inventing edges.
|
|
129
|
-
|
|
130
|
-
## path
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
okstra graphify path "<ConceptA>" "<ConceptB>" --project-root <projectRoot>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Prints the shortest path between two named concepts (each hop's relation + confidence). Explain in plain language what each hop means and why the bridge is significant.
|
|
137
|
-
|
|
138
|
-
## explain
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
okstra graphify explain "<NodeName>" --project-root <projectRoot>
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Prints one node's source, type, community, degree, and its connections. Write a 3-5 sentence explanation of what it is, what it connects to, and why — cite source locations.
|
|
145
|
-
|
|
146
|
-
## wiki
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
okstra graphify wiki --project-root <projectRoot>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Writes an agent-crawlable wiki to `<projectRoot>/.okstra/graph/wiki/` — `index.md` (entry point) plus one article per community. Point the user at `index.md`.
|
|
153
|
-
|
|
154
|
-
## mcp
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
okstra graphify mcp --project-root <projectRoot>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Starts a stdio MCP server exposing the graph (`query_graph`, `get_node`, `get_neighbors`, `shortest_path`, …) so other agents can query it live. Long-running — the user Ctrl+C's to stop. This sub-command additionally requires `pip install mcp` (opt-in MCP server); the core `build`/`query`/`path`/`explain`/`wiki` sub-commands need no extra install. After doc changes, re-run `build` for LLM semantic re-extraction.
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Output Rules (shared)
|
|
165
|
-
|
|
166
|
-
- Respond concisely in Korean unless the user requests otherwise.
|
|
167
|
-
- Use project-relative paths where possible; outputs live under `<projectRoot>/.okstra/graph/`.
|
|
168
|
-
- Never invent an edge — if unsure, it is AMBIGUOUS. Never hide cohesion/confidence scores.
|
|
169
|
-
- `query`/`path`/`explain`/`wiki`/`mcp` require a built graph; if the CLI says none exists, run `build` first.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { runPythonModule } from "../lib/python-helper.mjs";
|
|
2
|
-
|
|
3
|
-
const USAGE = `okstra graphify — build/query a .okstra-scoped knowledge graph
|
|
4
|
-
|
|
5
|
-
Usage:
|
|
6
|
-
okstra graphify build --project-root <dir> [options]
|
|
7
|
-
okstra graphify query --project-root <dir> [options]
|
|
8
|
-
okstra graphify path --project-root <dir> [options]
|
|
9
|
-
okstra graphify explain --project-root <dir> [options]
|
|
10
|
-
okstra graphify mcp --project-root <dir> [options]
|
|
11
|
-
okstra graphify watch --project-root <dir> [options]
|
|
12
|
-
okstra graphify wiki --project-root <dir> [options]
|
|
13
|
-
|
|
14
|
-
--project-root <dir> targets the project whose .okstra/ subtree holds the graph.
|
|
15
|
-
All arguments are forwarded to the python wrapper (okstra_ctl.graphify_cmd);
|
|
16
|
-
--project-root is required by the wrapper, so a bare 'okstra graphify build'
|
|
17
|
-
fails cleanly with an argparse usage error.
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export async function run(args) {
|
|
21
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
22
|
-
process.stdout.write(USAGE);
|
|
23
|
-
return 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const result = await runPythonModule({
|
|
27
|
-
module: "okstra_ctl.graphify_cmd",
|
|
28
|
-
args,
|
|
29
|
-
stdio: "inherit-stdout",
|
|
30
|
-
});
|
|
31
|
-
return result.code;
|
|
32
|
-
}
|