homegraph 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +268 -243
- package/dist/arkts/ohos-api-index.d.ts +15 -0
- package/dist/arkts/ohos-api-index.d.ts.map +1 -0
- package/dist/arkts/ohos-api-index.js +190 -0
- package/dist/arkts/ohos-api-index.js.map +1 -0
- package/dist/arkts/ohos-sdk-input.d.ts +36 -0
- package/dist/arkts/ohos-sdk-input.d.ts.map +1 -0
- package/dist/arkts/ohos-sdk-input.js +214 -0
- package/dist/arkts/ohos-sdk-input.js.map +1 -0
- package/dist/bin/command-supervision.d.ts +12 -0
- package/dist/bin/command-supervision.d.ts.map +1 -0
- package/dist/bin/command-supervision.js +86 -0
- package/dist/bin/command-supervision.js.map +1 -0
- package/dist/bin/homegraph.d.ts +1 -1
- package/dist/bin/homegraph.js +971 -71
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/db/index.d.ts +20 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +39 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +58 -19
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +14 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +314 -143
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +172 -152
- package/dist/directory.d.ts +32 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +88 -5
- package/dist/directory.js.map +1 -1
- package/dist/extraction/arkts-batch-worker.d.ts +2 -0
- package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
- package/dist/extraction/arkts-batch-worker.js +28 -0
- package/dist/extraction/arkts-batch-worker.js.map +1 -0
- package/dist/extraction/context.d.ts +11 -0
- package/dist/extraction/context.d.ts.map +1 -1
- package/dist/extraction/context.js +20 -0
- package/dist/extraction/context.js.map +1 -1
- package/dist/extraction/index.d.ts +16 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +619 -380
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
- package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
- package/dist/extraction/languages/arkts-state-decorators.js +26 -0
- package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
- package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
- package/dist/extraction/languages/arkts-viewtree.js +21 -6
- package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +98 -2
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +1290 -61
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +56 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +198 -1
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
- package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
- package/dist/extraction/languages/ohos-api-consumer.js +283 -0
- package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
- package/dist/extraction/parse-pool.d.ts +126 -0
- package/dist/extraction/parse-pool.d.ts.map +1 -0
- package/dist/extraction/parse-pool.js +319 -0
- package/dist/extraction/parse-pool.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +17 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +21 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +198 -27
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +76 -17
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -4
- package/dist/index.js.map +1 -1
- package/dist/installer/instructions-template.js +9 -9
- package/dist/installer/targets/shared.d.ts +5 -6
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +5 -6
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +30 -3
- package/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.js +50 -10
- package/dist/mcp/daemon-paths.js.map +1 -1
- package/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/dist/mcp/daemon-registry.js +7 -3
- package/dist/mcp/daemon-registry.js.map +1 -1
- package/dist/mcp/daemon.d.ts +48 -0
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +196 -32
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/engine.d.ts +17 -0
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +73 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +25 -43
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.js +16 -16
- package/dist/mcp/ppid-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
- package/dist/mcp/ppid-watchdog.js +37 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +25 -0
- package/dist/mcp/query-cache.d.ts.map +1 -0
- package/dist/mcp/query-cache.js +191 -0
- package/dist/mcp/query-cache.js.map +1 -0
- package/dist/mcp/query-pool.d.ts +94 -0
- package/dist/mcp/query-pool.d.ts.map +1 -0
- package/dist/mcp/query-pool.js +297 -0
- package/dist/mcp/query-pool.js.map +1 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/query-worker.d.ts.map +1 -0
- package/dist/mcp/query-worker.js +87 -0
- package/dist/mcp/query-worker.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +5 -7
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +72 -74
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/tools.d.ts +94 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +877 -71
- package/dist/mcp/tools.js.map +1 -1
- package/dist/project-config.d.ts +20 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +42 -2
- package/dist/project-config.js.map +1 -1
- package/dist/reasoning/login.js +1 -1
- package/dist/reasoning/login.js.map +1 -1
- package/dist/reasoning/reasoner.js +32 -32
- package/dist/resolution/c-fnptr-synthesizer.d.ts +0 -28
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +765 -79
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +72 -11
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/dist/resolution/cooperative-yield.js +42 -0
- package/dist/resolution/cooperative-yield.js.map +1 -0
- package/dist/resolution/index.d.ts +11 -2
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +72 -4
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts +22 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +317 -20
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/spec/config.d.ts +39 -0
- package/dist/spec/config.d.ts.map +1 -0
- package/dist/spec/config.js +304 -0
- package/dist/spec/config.js.map +1 -0
- package/dist/spec/db/commit-node.d.ts +23 -0
- package/dist/spec/db/commit-node.d.ts.map +1 -0
- package/dist/spec/db/commit-node.js +62 -0
- package/dist/spec/db/commit-node.js.map +1 -0
- package/dist/spec/db/fragment-node.d.ts +24 -0
- package/dist/spec/db/fragment-node.d.ts.map +1 -0
- package/dist/spec/db/fragment-node.js +128 -0
- package/dist/spec/db/fragment-node.js.map +1 -0
- package/dist/spec/db/fts.d.ts +74 -0
- package/dist/spec/db/fts.d.ts.map +1 -0
- package/dist/spec/db/fts.js +324 -0
- package/dist/spec/db/fts.js.map +1 -0
- package/dist/spec/db/index.d.ts +13 -0
- package/dist/spec/db/index.d.ts.map +1 -0
- package/dist/spec/db/index.js +50 -0
- package/dist/spec/db/index.js.map +1 -0
- package/dist/spec/db/relations.d.ts +55 -0
- package/dist/spec/db/relations.d.ts.map +1 -0
- package/dist/spec/db/relations.js +158 -0
- package/dist/spec/db/relations.js.map +1 -0
- package/dist/spec/db/schema.d.ts +33 -0
- package/dist/spec/db/schema.d.ts.map +1 -0
- package/dist/spec/db/schema.js +119 -0
- package/dist/spec/db/schema.js.map +1 -0
- package/dist/spec/db/schema.sql +117 -0
- package/dist/spec/db/spec-node.d.ts +41 -0
- package/dist/spec/db/spec-node.d.ts.map +1 -0
- package/dist/spec/db/spec-node.js +114 -0
- package/dist/spec/db/spec-node.js.map +1 -0
- package/dist/spec/evolve/impact-locator.d.ts +13 -0
- package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
- package/dist/spec/evolve/impact-locator.js +25 -0
- package/dist/spec/evolve/impact-locator.js.map +1 -0
- package/dist/spec/evolve/llm-client.d.ts +50 -0
- package/dist/spec/evolve/llm-client.d.ts.map +1 -0
- package/dist/spec/evolve/llm-client.js +176 -0
- package/dist/spec/evolve/llm-client.js.map +1 -0
- package/dist/spec/evolve/logic-checker.d.ts +12 -0
- package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
- package/dist/spec/evolve/logic-checker.js +24 -0
- package/dist/spec/evolve/logic-checker.js.map +1 -0
- package/dist/spec/evolve/pipeline.d.ts +42 -0
- package/dist/spec/evolve/pipeline.d.ts.map +1 -0
- package/dist/spec/evolve/pipeline.js +567 -0
- package/dist/spec/evolve/pipeline.js.map +1 -0
- package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
- package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
- package/dist/spec/evolve/spec-rewriter.js +230 -0
- package/dist/spec/evolve/spec-rewriter.js.map +1 -0
- package/dist/spec/graph/queries.d.ts +155 -0
- package/dist/spec/graph/queries.d.ts.map +1 -0
- package/dist/spec/graph/queries.js +440 -0
- package/dist/spec/graph/queries.js.map +1 -0
- package/dist/spec/llm/client.d.ts +29 -0
- package/dist/spec/llm/client.d.ts.map +1 -0
- package/dist/spec/llm/client.js +123 -0
- package/dist/spec/llm/client.js.map +1 -0
- package/dist/spec/llm/index.d.ts +3 -0
- package/dist/spec/llm/index.d.ts.map +1 -0
- package/dist/spec/llm/index.js +11 -0
- package/dist/spec/llm/index.js.map +1 -0
- package/dist/spec/llm/prompts.d.ts +13 -0
- package/dist/spec/llm/prompts.d.ts.map +1 -0
- package/dist/spec/llm/prompts.js +75 -0
- package/dist/spec/llm/prompts.js.map +1 -0
- package/dist/spec/mining/diff-parser.d.ts +33 -0
- package/dist/spec/mining/diff-parser.d.ts.map +1 -0
- package/dist/spec/mining/diff-parser.js +166 -0
- package/dist/spec/mining/diff-parser.js.map +1 -0
- package/dist/spec/mining/git-scanner.d.ts +103 -0
- package/dist/spec/mining/git-scanner.d.ts.map +1 -0
- package/dist/spec/mining/git-scanner.js +307 -0
- package/dist/spec/mining/git-scanner.js.map +1 -0
- package/dist/spec/mining/pipeline.d.ts +53 -0
- package/dist/spec/mining/pipeline.d.ts.map +1 -0
- package/dist/spec/mining/pipeline.js +178 -0
- package/dist/spec/mining/pipeline.js.map +1 -0
- package/dist/spec/mining/scope-resolver.d.ts +45 -0
- package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
- package/dist/spec/mining/scope-resolver.js +103 -0
- package/dist/spec/mining/scope-resolver.js.map +1 -0
- package/dist/spec/mining/spec-extractor.d.ts +69 -0
- package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
- package/dist/spec/mining/spec-extractor.js +369 -0
- package/dist/spec/mining/spec-extractor.js.map +1 -0
- package/dist/spec/types.d.ts +149 -0
- package/dist/spec/types.d.ts.map +1 -0
- package/dist/spec/types.js +15 -0
- package/dist/spec/types.js.map +1 -0
- package/dist/spec/utils.d.ts +167 -0
- package/dist/spec/utils.d.ts.map +1 -0
- package/dist/spec/utils.js +463 -0
- package/dist/spec/utils.js.map +1 -0
- package/dist/sync/worktree.d.ts +9 -0
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +40 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.d.ts +2 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.js +19 -2
- package/dist/ui/shimmer-progress.js.map +1 -1
- package/dist/upgrade/index.js +1 -1
- package/dist/upgrade/index.js.map +1 -1
- package/package.json +58 -57
- package/scripts/add-lang/bench.sh +60 -60
- package/scripts/add-lang/check-grammar.mjs +75 -75
- package/scripts/add-lang/dump-ast.mjs +103 -103
- package/scripts/add-lang/verify-extraction.mjs +70 -70
- package/scripts/agent-eval/ab-adoption.sh +91 -91
- package/scripts/agent-eval/ab-hook.sh +86 -86
- package/scripts/agent-eval/ab-impl.sh +78 -78
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
- package/scripts/agent-eval/ab-sufficiency.sh +78 -78
- package/scripts/agent-eval/arms-F.sh +21 -21
- package/scripts/agent-eval/arms-matrix.sh +37 -37
- package/scripts/agent-eval/audit.sh +68 -68
- package/scripts/agent-eval/bench-readme.sh +28 -28
- package/scripts/agent-eval/bench-why-repo.sh +22 -22
- package/scripts/agent-eval/block-read-hook.sh +19 -19
- package/scripts/agent-eval/hook-settings.json +15 -15
- package/scripts/agent-eval/itrun.sh +120 -120
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
- package/scripts/agent-eval/offload-eval-setup.sh +24 -24
- package/scripts/agent-eval/offload-eval-styles.sh +71 -71
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
- package/scripts/agent-eval/offload-eval.md +76 -76
- package/scripts/agent-eval/parse-arms.mjs +116 -116
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
- package/scripts/agent-eval/parse-run.mjs +45 -45
- package/scripts/agent-eval/parse-session.mjs +93 -93
- package/scripts/agent-eval/probe-context.mjs +21 -21
- package/scripts/agent-eval/probe-explore.mjs +40 -40
- package/scripts/agent-eval/probe-node.mjs +20 -20
- package/scripts/agent-eval/probe-sweep.mjs +119 -119
- package/scripts/agent-eval/probe-trace.mjs +20 -20
- package/scripts/agent-eval/redirect-read-hook.sh +38 -38
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -34
- package/scripts/agent-eval/run-all.sh +69 -69
- package/scripts/agent-eval/run-arms.sh +56 -56
- package/scripts/agent-eval/seq-matrix.mjs +137 -137
- package/scripts/build-bundle.sh +118 -118
- package/scripts/exp_boundary_eval/README.md +247 -0
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
- package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
- package/scripts/exp_boundary_eval/_utils.py +1116 -0
- package/scripts/exp_boundary_eval/analyze.py +1313 -0
- package/scripts/exp_boundary_eval/data/agents.json +109 -0
- package/scripts/exp_boundary_eval/data/experiments.json +140 -0
- package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
- package/scripts/exp_boundary_eval/run_all.py +378 -0
- package/scripts/exp_boundary_eval/run_one.py +165 -0
- package/scripts/exp_boundary_eval/run_session.py +158 -0
- package/scripts/exp_boundary_eval/setup.py +120 -0
- package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
- package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
- package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
- package/scripts/extract-release-notes.mjs +130 -130
- package/scripts/local-install.sh +41 -41
- package/scripts/npm-sdk.js +75 -75
- package/scripts/npm-shim.js +268 -246
- package/scripts/ohos-sdk-publish.mjs +133 -0
- package/scripts/pack-npm.sh +119 -119
- package/scripts/prepare-release.mjs +270 -270
- package/scripts/qa_eval/README.md +407 -404
- package/scripts/qa_eval/_test_deveco_probe.py +41 -41
- package/scripts/qa_eval/agent_runner.py +526 -526
- package/scripts/qa_eval/data/.gitignore +4 -4
- package/scripts/qa_eval/data/test-set.jsonl +2 -22
- package/scripts/qa_eval/eval_metrics.py +274 -233
- package/scripts/qa_eval/external_agent.py +976 -671
- package/scripts/qa_eval/llm_config.py +92 -92
- package/scripts/qa_eval/memory_monitor.py +132 -132
- package/scripts/qa_eval/my_answer_accuracy.py +187 -187
- package/scripts/qa_eval/requirements.txt +2 -2
- package/scripts/qa_eval/run_pipeline.py +804 -711
- package/scripts/qa_eval/stats_efficiency.py +279 -279
- package/scripts/qa_eval/stats_scores.py +207 -207
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface SpecDiscoveryConfig {
|
|
2
|
+
primaryDocCandidates: string[];
|
|
3
|
+
supplementaryGlobs: string[];
|
|
4
|
+
commitInfoCandidates: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface CommitScopeConfig {
|
|
7
|
+
scopeRegex: string;
|
|
8
|
+
normalize: {
|
|
9
|
+
stripPrefixes: string[];
|
|
10
|
+
lowercase: boolean;
|
|
11
|
+
padSpecNumber: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface LLMConfig {
|
|
15
|
+
provider: 'openai' | 'anthropic';
|
|
16
|
+
apiKey: string;
|
|
17
|
+
apiKeyEnv?: string;
|
|
18
|
+
model: string;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
temperature: number;
|
|
21
|
+
maxTokens: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SpecConfig {
|
|
24
|
+
discovery: SpecDiscoveryConfig;
|
|
25
|
+
commitScope: CommitScopeConfig;
|
|
26
|
+
llm: LLMConfig | null;
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_CONFIG: SpecConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Load spec config from `${SPEC_DATA_DIR}/configs.json` in the given repo path.
|
|
31
|
+
*
|
|
32
|
+
* Discovery and commitScope sections fall back to code defaults when the config
|
|
33
|
+
* file is missing or invalid. The `llm` section has NO defaults — it is `null`
|
|
34
|
+
* unless the user explicitly provides a valid `llm` block in the config file.
|
|
35
|
+
*
|
|
36
|
+
* When `llm.apiKeyEnv` is set, `llm.apiKey` is resolved from `process.env`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadSpecConfig(repoPath: string): SpecConfig;
|
|
39
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/spec/config.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QACT,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;CACvB;AAMD,eAAO,MAAM,cAAc,EAAE,UAuBb,CAAC;AAmCjB;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAkD3D"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DEFAULT_CONFIG = void 0;
|
|
37
|
+
exports.loadSpecConfig = loadSpecConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Spec configuration module — replaces `commit4spec/utils/config.py`.
|
|
40
|
+
*
|
|
41
|
+
* Loads spec mining/evolve configuration from `${SPEC_DATA_DIR}/configs.json`
|
|
42
|
+
* within a repository. Discovery and commitScope sections fall back to code
|
|
43
|
+
* defaults; the `llm` section must be explicitly configured by the user —
|
|
44
|
+
* there are no hard-coded LLM defaults.
|
|
45
|
+
*
|
|
46
|
+
* The config file is JSON, e.g.:
|
|
47
|
+
*
|
|
48
|
+
* {
|
|
49
|
+
* "discovery": {
|
|
50
|
+
* "primaryDocCandidates": ["plan.md", "README.md"]
|
|
51
|
+
* },
|
|
52
|
+
* "commitScope": {
|
|
53
|
+
* "scopeRegex": "^(feat|fix)\\((.+)\\)"
|
|
54
|
+
* },
|
|
55
|
+
* "llm": {
|
|
56
|
+
* "provider": "openai",
|
|
57
|
+
* "apiKeyEnv": "OPENAI_API_KEY",
|
|
58
|
+
* "model": "gpt-4o"
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* When `apiKeyEnv` is set in `llm`, the actual key is read from that
|
|
63
|
+
* environment variable at load time (process.env lookup).
|
|
64
|
+
*/
|
|
65
|
+
const fs = __importStar(require("fs"));
|
|
66
|
+
const path = __importStar(require("path"));
|
|
67
|
+
const errors_1 = require("../errors");
|
|
68
|
+
const utils_1 = require("./utils");
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Defaults (match commit4spec/utils/config.py exactly)
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
exports.DEFAULT_CONFIG = Object.freeze({
|
|
73
|
+
discovery: Object.freeze({
|
|
74
|
+
primaryDocCandidates: Object.freeze([
|
|
75
|
+
'plan.md',
|
|
76
|
+
'README.md',
|
|
77
|
+
'spec.md',
|
|
78
|
+
'design.md',
|
|
79
|
+
'{spec_dir}.md',
|
|
80
|
+
'spec-{spec_dir}.md',
|
|
81
|
+
]),
|
|
82
|
+
supplementaryGlobs: Object.freeze(['logic/**/*.md', 'design/**/*.md']),
|
|
83
|
+
commitInfoCandidates: Object.freeze(['commit-info.md']),
|
|
84
|
+
}),
|
|
85
|
+
commitScope: Object.freeze({
|
|
86
|
+
scopeRegex: '^(?:feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)\\((?:review\\/)?(spec\\d+)\\)',
|
|
87
|
+
normalize: Object.freeze({
|
|
88
|
+
stripPrefixes: Object.freeze(['review/']),
|
|
89
|
+
lowercase: true,
|
|
90
|
+
padSpecNumber: true,
|
|
91
|
+
}),
|
|
92
|
+
}),
|
|
93
|
+
llm: null,
|
|
94
|
+
});
|
|
95
|
+
/** Config file path relative to the repo root. */
|
|
96
|
+
const CONFIG_FILE = `${utils_1.SPEC_DATA_DIR}/configs.json`;
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// Deep merge
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
/**
|
|
101
|
+
* Recursively merge `source` into `target`, returning a new object. Arrays and
|
|
102
|
+
* primitives from `source` replace `target` wholesale (no array concatenation).
|
|
103
|
+
* Only plain objects are recursed into.
|
|
104
|
+
*/
|
|
105
|
+
function deepMerge(target, source) {
|
|
106
|
+
if (source === null || source === undefined)
|
|
107
|
+
return target;
|
|
108
|
+
if (typeof source !== 'object' || Array.isArray(source))
|
|
109
|
+
return source;
|
|
110
|
+
const out = target && typeof target === 'object' && !Array.isArray(target)
|
|
111
|
+
? { ...target }
|
|
112
|
+
: {};
|
|
113
|
+
for (const [key, val] of Object.entries(source)) {
|
|
114
|
+
if (val === undefined)
|
|
115
|
+
continue;
|
|
116
|
+
out[key] = deepMerge(out[key], val);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Load
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
/**
|
|
124
|
+
* Load spec config from `${SPEC_DATA_DIR}/configs.json` in the given repo path.
|
|
125
|
+
*
|
|
126
|
+
* Discovery and commitScope sections fall back to code defaults when the config
|
|
127
|
+
* file is missing or invalid. The `llm` section has NO defaults — it is `null`
|
|
128
|
+
* unless the user explicitly provides a valid `llm` block in the config file.
|
|
129
|
+
*
|
|
130
|
+
* When `llm.apiKeyEnv` is set, `llm.apiKey` is resolved from `process.env`.
|
|
131
|
+
*/
|
|
132
|
+
function loadSpecConfig(repoPath) {
|
|
133
|
+
const file = path.join(repoPath, CONFIG_FILE);
|
|
134
|
+
let raw;
|
|
135
|
+
try {
|
|
136
|
+
raw = fs.readFileSync(file, 'utf-8');
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// No config file — return defaults for discovery/commitScope, null for llm.
|
|
140
|
+
return cloneDefaults();
|
|
141
|
+
}
|
|
142
|
+
let parsed;
|
|
143
|
+
try {
|
|
144
|
+
parsed = JSON.parse(raw);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
(0, errors_1.logWarn)(`Ignoring ${CONFIG_FILE}: not valid JSON`, {
|
|
148
|
+
file,
|
|
149
|
+
error: err instanceof Error ? err.message : String(err),
|
|
150
|
+
});
|
|
151
|
+
return cloneDefaults();
|
|
152
|
+
}
|
|
153
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
154
|
+
(0, errors_1.logWarn)(`Ignoring ${CONFIG_FILE}: top-level value must be a JSON object`, { file });
|
|
155
|
+
return cloneDefaults();
|
|
156
|
+
}
|
|
157
|
+
// Deep merge user config over defaults (discovery and commitScope have defaults;
|
|
158
|
+
// llm is null in the default — it must come from the user file.)
|
|
159
|
+
const merged = deepMerge(exports.DEFAULT_CONFIG, parsed);
|
|
160
|
+
// Normalize sub-objects that fail the type guard
|
|
161
|
+
merged.discovery = normalizeDiscovery(merged.discovery, file);
|
|
162
|
+
merged.commitScope = normalizeCommitScope(merged.commitScope, file);
|
|
163
|
+
// Validate LLM section. No defaults — user must provide provider, model, apiKey.
|
|
164
|
+
merged.llm = validateLLM(parsed.llm, file);
|
|
165
|
+
// Resolve apiKey from env if apiKeyEnv is set
|
|
166
|
+
if (merged.llm?.apiKeyEnv) {
|
|
167
|
+
const envKey = process.env[merged.llm.apiKeyEnv];
|
|
168
|
+
if (envKey !== undefined) {
|
|
169
|
+
merged.llm.apiKey = envKey;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return merged;
|
|
173
|
+
}
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
// Normalizers / Validators — ensure sub-configs are well-formed after merge
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
function normalizeDiscovery(val, file) {
|
|
178
|
+
if (!val || typeof val !== 'object' || Array.isArray(val)) {
|
|
179
|
+
(0, errors_1.logWarn)(`Ignoring "discovery" in ${CONFIG_FILE}: must be an object`, { file });
|
|
180
|
+
return { ...exports.DEFAULT_CONFIG.discovery };
|
|
181
|
+
}
|
|
182
|
+
const def = exports.DEFAULT_CONFIG.discovery;
|
|
183
|
+
return {
|
|
184
|
+
primaryDocCandidates: normalizeStringArray(val.primaryDocCandidates, def.primaryDocCandidates, 'discovery.primaryDocCandidates', file),
|
|
185
|
+
supplementaryGlobs: normalizeStringArray(val.supplementaryGlobs, def.supplementaryGlobs, 'discovery.supplementaryGlobs', file),
|
|
186
|
+
commitInfoCandidates: normalizeStringArray(val.commitInfoCandidates, def.commitInfoCandidates, 'discovery.commitInfoCandidates', file),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function normalizeCommitScope(val, file) {
|
|
190
|
+
if (!val || typeof val !== 'object' || Array.isArray(val)) {
|
|
191
|
+
(0, errors_1.logWarn)(`Ignoring "commitScope" in ${CONFIG_FILE}: must be an object`, { file });
|
|
192
|
+
return { ...exports.DEFAULT_CONFIG.commitScope, normalize: { ...exports.DEFAULT_CONFIG.commitScope.normalize } };
|
|
193
|
+
}
|
|
194
|
+
const def = exports.DEFAULT_CONFIG.commitScope;
|
|
195
|
+
const normalizeRaw = val.normalize && typeof val.normalize === 'object' && !Array.isArray(val.normalize)
|
|
196
|
+
? val.normalize
|
|
197
|
+
: {};
|
|
198
|
+
return {
|
|
199
|
+
scopeRegex: typeof val.scopeRegex === 'string' && val.scopeRegex.length > 0
|
|
200
|
+
? val.scopeRegex
|
|
201
|
+
: def.scopeRegex,
|
|
202
|
+
normalize: {
|
|
203
|
+
stripPrefixes: normalizeStringArray(normalizeRaw.stripPrefixes, def.normalize.stripPrefixes, 'commitScope.normalize.stripPrefixes', file),
|
|
204
|
+
lowercase: typeof normalizeRaw.lowercase === 'boolean'
|
|
205
|
+
? normalizeRaw.lowercase
|
|
206
|
+
: def.normalize.lowercase,
|
|
207
|
+
padSpecNumber: typeof normalizeRaw.padSpecNumber === 'boolean'
|
|
208
|
+
? normalizeRaw.padSpecNumber
|
|
209
|
+
: def.normalize.padSpecNumber,
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const LLM_CONFIG_EXAMPLE = [
|
|
214
|
+
'',
|
|
215
|
+
'Example minimal llm config:',
|
|
216
|
+
'{',
|
|
217
|
+
' "llm": {',
|
|
218
|
+
' "provider": "openai",',
|
|
219
|
+
' "apiKeyEnv": "OPENAI_API_KEY",',
|
|
220
|
+
' "model": "gpt-4o"',
|
|
221
|
+
' }',
|
|
222
|
+
'}',
|
|
223
|
+
].join('\n');
|
|
224
|
+
/**
|
|
225
|
+
* Validate an `llm` section from the user config file.
|
|
226
|
+
*
|
|
227
|
+
* Required fields (no defaults — user must provide them):
|
|
228
|
+
* - `provider`: must be `"openai"` or `"anthropic"`
|
|
229
|
+
* - `model`: non-empty string
|
|
230
|
+
* - `apiKey` or `apiKeyEnv`: at least one must be set (env var is resolved later)
|
|
231
|
+
*
|
|
232
|
+
* Optional fields with defaults:
|
|
233
|
+
* - `temperature`: defaults to 0.2
|
|
234
|
+
* - `maxTokens`: defaults to 4096
|
|
235
|
+
*
|
|
236
|
+
* Returns a valid LLMConfig, or `null` if the user did not provide an `llm`
|
|
237
|
+
* section at all (no error in that case — callers decide how to handle it).
|
|
238
|
+
*/
|
|
239
|
+
function validateLLM(val, file) {
|
|
240
|
+
if (!val || typeof val !== 'object' || Array.isArray(val)) {
|
|
241
|
+
// No llm section provided — null, not an error.
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
// --- provider ---
|
|
245
|
+
const provider = val.provider;
|
|
246
|
+
if (provider !== 'openai' && provider !== 'anthropic') {
|
|
247
|
+
throw new Error(`Invalid llm.provider in ${file}: must be "openai" or "anthropic", ` +
|
|
248
|
+
`got ${JSON.stringify(provider)}.${LLM_CONFIG_EXAMPLE}`);
|
|
249
|
+
}
|
|
250
|
+
// --- model ---
|
|
251
|
+
if (typeof val.model !== 'string' || val.model.length === 0) {
|
|
252
|
+
throw new Error(`Missing llm.model in ${file}. Specify a model name, e.g. "gpt-4o".${LLM_CONFIG_EXAMPLE}`);
|
|
253
|
+
}
|
|
254
|
+
// --- apiKey / apiKeyEnv ---
|
|
255
|
+
const directKey = typeof val.apiKey === 'string' ? val.apiKey : '';
|
|
256
|
+
const apiKeyEnv = typeof val.apiKeyEnv === 'string' ? val.apiKeyEnv : undefined;
|
|
257
|
+
if (!directKey && !apiKeyEnv) {
|
|
258
|
+
throw new Error(`Missing llm.apiKey or llm.apiKeyEnv in ${file}. ` +
|
|
259
|
+
`Set "apiKey" directly or use "apiKeyEnv" to reference an environment variable.${LLM_CONFIG_EXAMPLE}`);
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
provider: provider,
|
|
263
|
+
apiKey: directKey,
|
|
264
|
+
apiKeyEnv,
|
|
265
|
+
model: val.model,
|
|
266
|
+
baseUrl: typeof val.baseUrl === 'string' ? val.baseUrl : undefined,
|
|
267
|
+
temperature: typeof val.temperature === 'number' && !isNaN(val.temperature)
|
|
268
|
+
? val.temperature
|
|
269
|
+
: 0.2,
|
|
270
|
+
maxTokens: typeof val.maxTokens === 'number' && Number.isInteger(val.maxTokens) && val.maxTokens > 0
|
|
271
|
+
? val.maxTokens
|
|
272
|
+
: 4096,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
// Helpers
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
/**
|
|
279
|
+
* Validate a user-provided array of strings, falling back to `defaultVal` when
|
|
280
|
+
* the input is not an array. Individual non-string entries are filtered out
|
|
281
|
+
* with a warning.
|
|
282
|
+
*/
|
|
283
|
+
function normalizeStringArray(raw, defaultVal, label, file) {
|
|
284
|
+
if (!Array.isArray(raw))
|
|
285
|
+
return [...defaultVal];
|
|
286
|
+
const out = [];
|
|
287
|
+
for (const entry of raw) {
|
|
288
|
+
if (typeof entry === 'string' && entry.length > 0) {
|
|
289
|
+
out.push(entry);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
(0, errors_1.logWarn)(`Ignoring "${label}" entry in ${CONFIG_FILE}: each value must be a non-empty string`, { file, entry: String(entry) });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return out.length > 0 ? out : [...defaultVal];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Return a shallow clone of DEFAULT_CONFIG so callers receive a mutable object
|
|
299
|
+
* (the DEFAULT_CONFIG global itself is frozen).
|
|
300
|
+
*/
|
|
301
|
+
function cloneDefaults() {
|
|
302
|
+
return JSON.parse(JSON.stringify(exports.DEFAULT_CONFIG));
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/spec/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,wCAkDC;AA5LD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,sCAAoC;AACpC,mCAAwC;AAqCxC,8EAA8E;AAC9E,uDAAuD;AACvD,8EAA8E;AAEjE,QAAA,cAAc,GAAe,MAAM,CAAC,MAAM,CAAC;IAC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AAG,EAAE,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,IAAA,gBAAO,EACL,aAAa,KAAK,cAAc,WAAW,yCAAyC,EACpF,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAC/B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,sBAAc,CAAC,CAAe,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommitNode CRUD — persistence operations for ``commit_nodes``.
|
|
3
|
+
*/
|
|
4
|
+
import { SqliteDatabase } from '../../db/sqlite-adapter';
|
|
5
|
+
import { CommitNode } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Insert or replace a CommitNode.
|
|
8
|
+
*/
|
|
9
|
+
export declare function insertCommitNode(db: SqliteDatabase, node: CommitNode): CommitNode;
|
|
10
|
+
/**
|
|
11
|
+
* Look up a CommitNode by its full commit hash (40-char hex).
|
|
12
|
+
* Returns null when not found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function findCommitByHash(db: SqliteDatabase, commitHash: string): CommitNode | null;
|
|
15
|
+
/**
|
|
16
|
+
* List all commits, most recent first.
|
|
17
|
+
*/
|
|
18
|
+
export declare function listAllCommits(db: SqliteDatabase): CommitNode[];
|
|
19
|
+
/**
|
|
20
|
+
* Count total commits.
|
|
21
|
+
*/
|
|
22
|
+
export declare function countCommits(db: SqliteDatabase): number;
|
|
23
|
+
//# sourceMappingURL=commit-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-node.d.ts","sourceRoot":"","sources":["../../../src/spec/db/commit-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA8BtC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAYjF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAM1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,UAAU,EAAE,CAK/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAKvD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CommitNode CRUD — persistence operations for ``commit_nodes``.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.insertCommitNode = insertCommitNode;
|
|
7
|
+
exports.findCommitByHash = findCommitByHash;
|
|
8
|
+
exports.listAllCommits = listAllCommits;
|
|
9
|
+
exports.countCommits = countCommits;
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Helpers
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
function rowToCommit(row) {
|
|
14
|
+
return {
|
|
15
|
+
hash: row.hash,
|
|
16
|
+
message: row.message,
|
|
17
|
+
author: row.author,
|
|
18
|
+
timestamp: row.timestamp,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Persistence
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* Insert or replace a CommitNode.
|
|
26
|
+
*/
|
|
27
|
+
function insertCommitNode(db, node) {
|
|
28
|
+
db.prepare(`
|
|
29
|
+
INSERT OR REPLACE INTO commit_nodes
|
|
30
|
+
(hash, message, author, timestamp)
|
|
31
|
+
VALUES (@hash, @message, @author, @timestamp)
|
|
32
|
+
`).run({
|
|
33
|
+
hash: node.hash,
|
|
34
|
+
message: node.message,
|
|
35
|
+
author: node.author,
|
|
36
|
+
timestamp: node.timestamp,
|
|
37
|
+
});
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Look up a CommitNode by its full commit hash (40-char hex).
|
|
42
|
+
* Returns null when not found.
|
|
43
|
+
*/
|
|
44
|
+
function findCommitByHash(db, commitHash) {
|
|
45
|
+
const row = db.prepare('SELECT hash, message, author, timestamp FROM commit_nodes WHERE hash = ?').get(commitHash);
|
|
46
|
+
return row ? rowToCommit(row) : null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* List all commits, most recent first.
|
|
50
|
+
*/
|
|
51
|
+
function listAllCommits(db) {
|
|
52
|
+
const rows = db.prepare('SELECT hash, message, author, timestamp FROM commit_nodes ORDER BY timestamp DESC').all();
|
|
53
|
+
return rows.map(rowToCommit);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Count total commits.
|
|
57
|
+
*/
|
|
58
|
+
function countCommits(db) {
|
|
59
|
+
const row = db.prepare('SELECT COUNT(*) as cnt FROM commit_nodes').get();
|
|
60
|
+
return row?.cnt ?? 0;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=commit-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-node.js","sourceRoot":"","sources":["../../../src/spec/db/commit-node.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAoCH,4CAYC;AAMD,4CAMC;AAKD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ACd,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeFragmentNode CRUD — persistence operations for ``code_fragment_nodes``.
|
|
3
|
+
*/
|
|
4
|
+
import { SqliteDatabase } from '../../db/sqlite-adapter';
|
|
5
|
+
import { CodeFragmentNode } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Insert a CodeFragmentNode, auto-generating an ID if the `id` field is empty.
|
|
8
|
+
* Also writes to the code_fragments_fts index for content-based search.
|
|
9
|
+
*/
|
|
10
|
+
export declare function insertCodeFragment(db: SqliteDatabase, node: CodeFragmentNode): CodeFragmentNode;
|
|
11
|
+
/**
|
|
12
|
+
* Look up a CodeFragmentNode by primary key.
|
|
13
|
+
* Returns null when not found.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findFragmentById(db: SqliteDatabase, fragmentId: string): CodeFragmentNode | null;
|
|
16
|
+
/**
|
|
17
|
+
* Find all fragments for a given commit hash, via the join table.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findFragmentsByCommit(db: SqliteDatabase, commitHash: string): CodeFragmentNode[];
|
|
20
|
+
/**
|
|
21
|
+
* Count total fragments.
|
|
22
|
+
*/
|
|
23
|
+
export declare function countFragments(db: SqliteDatabase): number;
|
|
24
|
+
//# sourceMappingURL=fragment-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-node.d.ts","sourceRoot":"","sources":["../../../src/spec/db/fragment-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AA8C5C;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,gBAAgB,GACrB,gBAAgB,CA4BlB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,cAAc,EAClB,UAAU,EAAE,MAAM,GACjB,gBAAgB,GAAG,IAAI,CAMzB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,cAAc,EAClB,UAAU,EAAE,MAAM,GACjB,gBAAgB,EAAE,CAUpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAKzD"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CodeFragmentNode CRUD — persistence operations for ``code_fragment_nodes``.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.insertCodeFragment = insertCodeFragment;
|
|
40
|
+
exports.findFragmentById = findFragmentById;
|
|
41
|
+
exports.findFragmentsByCommit = findFragmentsByCommit;
|
|
42
|
+
exports.countFragments = countFragments;
|
|
43
|
+
const crypto = __importStar(require("crypto"));
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// ID generation
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Generate a 12-character hex identifier (first 12 chars of a UUID v4).
|
|
49
|
+
* Matches the Python `uuid.uuid4().hex[:12]` convention from Commit4Spec.
|
|
50
|
+
*/
|
|
51
|
+
function makeId() {
|
|
52
|
+
return crypto.randomUUID().replace(/-/g, '').slice(0, 12);
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Helpers
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
function rowToFragment(row) {
|
|
58
|
+
return {
|
|
59
|
+
id: row.id,
|
|
60
|
+
changeType: row.change_type,
|
|
61
|
+
filePath: row.file_path,
|
|
62
|
+
startLine: row.start_line,
|
|
63
|
+
endLine: row.end_line,
|
|
64
|
+
codeDiff: row.code_diff,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Persistence
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Insert a CodeFragmentNode, auto-generating an ID if the `id` field is empty.
|
|
72
|
+
* Also writes to the code_fragments_fts index for content-based search.
|
|
73
|
+
*/
|
|
74
|
+
function insertCodeFragment(db, node) {
|
|
75
|
+
const fragment = { ...node };
|
|
76
|
+
if (!fragment.id) {
|
|
77
|
+
fragment.id = makeId();
|
|
78
|
+
}
|
|
79
|
+
db.prepare(`
|
|
80
|
+
INSERT OR REPLACE INTO code_fragment_nodes
|
|
81
|
+
(id, change_type, file_path, start_line, end_line, code_diff)
|
|
82
|
+
VALUES (@id, @changeType, @filePath, @startLine, @endLine, @codeDiff)
|
|
83
|
+
`).run({
|
|
84
|
+
id: fragment.id,
|
|
85
|
+
changeType: fragment.changeType,
|
|
86
|
+
filePath: fragment.filePath,
|
|
87
|
+
startLine: fragment.startLine,
|
|
88
|
+
endLine: fragment.endLine,
|
|
89
|
+
codeDiff: fragment.codeDiff,
|
|
90
|
+
});
|
|
91
|
+
// Sync to FTS5 index for content-based search.
|
|
92
|
+
// DELETE + INSERT (not INSERT OR REPLACE) because code_fragments_fts is a
|
|
93
|
+
// standalone FTS5 table without UNIQUE constraints — INSERT OR REPLACE has
|
|
94
|
+
// no conflict to trigger on and would accumulate stale index entries.
|
|
95
|
+
db.prepare('DELETE FROM code_fragments_fts WHERE id = ?').run(fragment.id);
|
|
96
|
+
db.prepare('INSERT INTO code_fragments_fts (id, file_path, code_diff) VALUES (?, ?, ?)')
|
|
97
|
+
.run(fragment.id, fragment.filePath, fragment.codeDiff);
|
|
98
|
+
return fragment;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Look up a CodeFragmentNode by primary key.
|
|
102
|
+
* Returns null when not found.
|
|
103
|
+
*/
|
|
104
|
+
function findFragmentById(db, fragmentId) {
|
|
105
|
+
const row = db.prepare('SELECT id, change_type, file_path, start_line, end_line, code_diff FROM code_fragment_nodes WHERE id = ?').get(fragmentId);
|
|
106
|
+
return row ? rowToFragment(row) : null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Find all fragments for a given commit hash, via the join table.
|
|
110
|
+
*/
|
|
111
|
+
function findFragmentsByCommit(db, commitHash) {
|
|
112
|
+
const rows = db.prepare(`
|
|
113
|
+
SELECT f.id, f.change_type, f.file_path, f.start_line, f.end_line, f.code_diff
|
|
114
|
+
FROM code_fragment_nodes f
|
|
115
|
+
JOIN commit_fragment_relations r ON r.fragment_id = f.id
|
|
116
|
+
WHERE r.commit_hash = ?
|
|
117
|
+
ORDER BY f.file_path, f.start_line
|
|
118
|
+
`).all(commitHash);
|
|
119
|
+
return rows.map(rowToFragment);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Count total fragments.
|
|
123
|
+
*/
|
|
124
|
+
function countFragments(db) {
|
|
125
|
+
const row = db.prepare('SELECT COUNT(*) as cnt FROM code_fragment_nodes').get();
|
|
126
|
+
return row?.cnt ?? 0;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=fragment-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-node.js","sourceRoot":"","sources":["../../../src/spec/db/fragment-node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDH,gDA+BC;AAMD,4CASC;AAKD,sDAaC;AAKD,wCAKC;AA9HD,+CAAiC;AAiBjC,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;GAGG;AACH,SAAS,MAAM;IACb,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,aAAa,CAAC,GAAoB;IACzC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,UAAU,EAAE,GAAG,CAAC,WAA6C;QAC7D,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,SAAS,EAAE,GAAG,CAAC,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