@arcbridge/core 0.1.1 → 0.1.3
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/dist/index.d.ts +138 -18
- package/dist/index.js +509 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
3
3
|
|
|
4
4
|
declare const ServiceSchema: z.ZodObject<{
|
|
5
5
|
name: z.ZodString;
|
|
@@ -78,6 +78,13 @@ declare const ArcBridgeConfigSchema: z.ZodObject<{
|
|
|
78
78
|
}, {
|
|
79
79
|
ignore_paths?: string[] | undefined;
|
|
80
80
|
}>>;
|
|
81
|
+
metrics: z.ZodDefault<z.ZodObject<{
|
|
82
|
+
auto_record: z.ZodDefault<z.ZodBoolean>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
auto_record: boolean;
|
|
85
|
+
}, {
|
|
86
|
+
auto_record?: boolean | undefined;
|
|
87
|
+
}>>;
|
|
81
88
|
sync: z.ZodDefault<z.ZodObject<{
|
|
82
89
|
auto_detect_drift: z.ZodDefault<z.ZodBoolean>;
|
|
83
90
|
drift_severity_threshold: z.ZodDefault<z.ZodEnum<["info", "warning", "error"]>>;
|
|
@@ -117,6 +124,9 @@ declare const ArcBridgeConfigSchema: z.ZodObject<{
|
|
|
117
124
|
drift: {
|
|
118
125
|
ignore_paths: string[];
|
|
119
126
|
};
|
|
127
|
+
metrics: {
|
|
128
|
+
auto_record: boolean;
|
|
129
|
+
};
|
|
120
130
|
sync: {
|
|
121
131
|
auto_detect_drift: boolean;
|
|
122
132
|
drift_severity_threshold: "info" | "warning" | "error";
|
|
@@ -148,6 +158,9 @@ declare const ArcBridgeConfigSchema: z.ZodObject<{
|
|
|
148
158
|
drift?: {
|
|
149
159
|
ignore_paths?: string[] | undefined;
|
|
150
160
|
} | undefined;
|
|
161
|
+
metrics?: {
|
|
162
|
+
auto_record?: boolean | undefined;
|
|
163
|
+
} | undefined;
|
|
151
164
|
sync?: {
|
|
152
165
|
auto_detect_drift?: boolean | undefined;
|
|
153
166
|
drift_severity_threshold?: "info" | "warning" | "error" | undefined;
|
|
@@ -707,13 +720,24 @@ declare const AgentRoleSchema: z.ZodObject<{
|
|
|
707
720
|
}>;
|
|
708
721
|
type AgentRole = z.infer<typeof AgentRoleSchema>;
|
|
709
722
|
|
|
710
|
-
|
|
711
|
-
|
|
723
|
+
/** Re-export DatabaseSync as Database for use across the codebase. */
|
|
724
|
+
type Database = DatabaseSync;
|
|
725
|
+
declare function suppressSqliteWarning(): void;
|
|
726
|
+
declare function openDatabase(dbPath: string): Database;
|
|
727
|
+
declare function openMemoryDatabase(): Database;
|
|
728
|
+
/**
|
|
729
|
+
* Wrap a synchronous function in a SQLite transaction (BEGIN/COMMIT/ROLLBACK).
|
|
730
|
+
* Supports nesting via SAVEPOINTs — inner calls create savepoints
|
|
731
|
+
* instead of starting a new transaction.
|
|
732
|
+
*
|
|
733
|
+
* fn must be synchronous — passing an async function will throw.
|
|
734
|
+
*/
|
|
735
|
+
declare function transaction<T>(db: Database, fn: () => T): T;
|
|
712
736
|
|
|
713
|
-
declare const CURRENT_SCHEMA_VERSION =
|
|
714
|
-
declare function initializeSchema(db: Database
|
|
737
|
+
declare const CURRENT_SCHEMA_VERSION = 2;
|
|
738
|
+
declare function initializeSchema(db: Database): void;
|
|
715
739
|
|
|
716
|
-
declare function migrate(db: Database
|
|
740
|
+
declare function migrate(db: Database): void;
|
|
717
741
|
|
|
718
742
|
interface InitProjectInput {
|
|
719
743
|
name: string;
|
|
@@ -738,14 +762,14 @@ declare function generatePlan(targetDir: string, input: InitProjectInput): void;
|
|
|
738
762
|
declare function generateAgentRoles(targetDir: string, template?: string): AgentRole[];
|
|
739
763
|
|
|
740
764
|
interface GenerateDatabaseResult {
|
|
741
|
-
db: Database
|
|
765
|
+
db: Database;
|
|
742
766
|
warnings: string[];
|
|
743
767
|
}
|
|
744
768
|
/**
|
|
745
769
|
* Re-read arc42 files from disk and update the database.
|
|
746
770
|
* Uses INSERT OR REPLACE to pick up changes made since initial generation.
|
|
747
771
|
*/
|
|
748
|
-
declare function refreshFromDocs(db: Database
|
|
772
|
+
declare function refreshFromDocs(db: Database, targetDir: string): string[];
|
|
749
773
|
declare function generateDatabase(targetDir: string, input: InitProjectInput): GenerateDatabaseResult;
|
|
750
774
|
|
|
751
775
|
interface IndexerOptions {
|
|
@@ -805,7 +829,7 @@ declare function discoverDotnetServices(projectRoot: string): DotnetProjectInfo[
|
|
|
805
829
|
* Scan the project root for package dependency manifests (package.json, .csproj)
|
|
806
830
|
* and write discovered dependencies to the package_dependencies table.
|
|
807
831
|
*/
|
|
808
|
-
declare function indexPackageDependencies(db: Database
|
|
832
|
+
declare function indexPackageDependencies(db: Database, projectRoot: string, service?: string): number;
|
|
809
833
|
|
|
810
834
|
type ProjectLanguage = "typescript" | "csharp" | "auto";
|
|
811
835
|
/**
|
|
@@ -818,7 +842,7 @@ declare function detectProjectLanguage(projectRoot: string): "typescript" | "csh
|
|
|
818
842
|
* Index a project, auto-detecting the language unless explicitly specified.
|
|
819
843
|
* Dispatches to the TypeScript or .NET indexer accordingly.
|
|
820
844
|
*/
|
|
821
|
-
declare function indexProject(db: Database
|
|
845
|
+
declare function indexProject(db: Database, options: IndexerOptions): Promise<IndexResult>;
|
|
822
846
|
|
|
823
847
|
type DriftKind = "undocumented_module" | "missing_module" | "dependency_violation" | "unlinked_test" | "stale_adr" | "new_dependency";
|
|
824
848
|
type DriftSeverity = "info" | "warning" | "error";
|
|
@@ -840,12 +864,12 @@ interface DriftOptions {
|
|
|
840
864
|
* Compares building block code_paths against actual indexed files,
|
|
841
865
|
* checks cross-block dependencies, and validates ADR references.
|
|
842
866
|
*/
|
|
843
|
-
declare function detectDrift(db: Database
|
|
867
|
+
declare function detectDrift(db: Database, options?: DriftOptions): DriftEntry[];
|
|
844
868
|
/**
|
|
845
869
|
* Write drift entries to the drift_log table.
|
|
846
870
|
* Clears existing unresolved entries and inserts fresh ones.
|
|
847
871
|
*/
|
|
848
|
-
declare function writeDriftLog(db: Database
|
|
872
|
+
declare function writeDriftLog(db: Database, entries: DriftEntry[]): void;
|
|
849
873
|
|
|
850
874
|
interface TaskInferenceResult {
|
|
851
875
|
taskId: string;
|
|
@@ -857,11 +881,11 @@ interface TaskInferenceResult {
|
|
|
857
881
|
* Infer task status from code state.
|
|
858
882
|
* Checks if building block code exists, acceptance criteria symbols are present, etc.
|
|
859
883
|
*/
|
|
860
|
-
declare function inferTaskStatuses(db: Database
|
|
884
|
+
declare function inferTaskStatuses(db: Database, phaseId: string): TaskInferenceResult[];
|
|
861
885
|
/**
|
|
862
886
|
* Apply inferred statuses to the database and optionally write back to YAML.
|
|
863
887
|
*/
|
|
864
|
-
declare function applyInferences(db: Database
|
|
888
|
+
declare function applyInferences(db: Database, inferences: TaskInferenceResult[], projectRoot: string): void;
|
|
865
889
|
|
|
866
890
|
/**
|
|
867
891
|
* Update a task's status in the YAML task file.
|
|
@@ -894,6 +918,102 @@ declare function syncScenarioToYaml(projectRoot: string, scenarioId: string, sta
|
|
|
894
918
|
*/
|
|
895
919
|
declare function generateSyncFiles(targetDir: string, config: ArcBridgeConfig): string[];
|
|
896
920
|
|
|
921
|
+
interface InsertActivityParams {
|
|
922
|
+
toolName: string;
|
|
923
|
+
action?: string;
|
|
924
|
+
model?: string;
|
|
925
|
+
agentRole?: string;
|
|
926
|
+
taskId?: string;
|
|
927
|
+
phaseId?: string;
|
|
928
|
+
inputTokens?: number;
|
|
929
|
+
outputTokens?: number;
|
|
930
|
+
totalTokens?: number;
|
|
931
|
+
costUsd?: number;
|
|
932
|
+
durationMs?: number;
|
|
933
|
+
driftCount?: number;
|
|
934
|
+
driftErrors?: number;
|
|
935
|
+
testPassCount?: number;
|
|
936
|
+
testFailCount?: number;
|
|
937
|
+
lintClean?: boolean;
|
|
938
|
+
typecheckClean?: boolean;
|
|
939
|
+
notes?: string;
|
|
940
|
+
metadata?: Record<string, unknown>;
|
|
941
|
+
}
|
|
942
|
+
interface QueryMetricsParams {
|
|
943
|
+
taskId?: string;
|
|
944
|
+
phaseId?: string;
|
|
945
|
+
model?: string;
|
|
946
|
+
agentRole?: string;
|
|
947
|
+
toolName?: string;
|
|
948
|
+
since?: string;
|
|
949
|
+
until?: string;
|
|
950
|
+
groupBy: "model" | "task" | "phase" | "tool" | "day" | "none";
|
|
951
|
+
limit: number;
|
|
952
|
+
}
|
|
953
|
+
interface ActivityRow {
|
|
954
|
+
id: number;
|
|
955
|
+
tool_name: string;
|
|
956
|
+
action: string | null;
|
|
957
|
+
model: string | null;
|
|
958
|
+
agent_role: string | null;
|
|
959
|
+
task_id: string | null;
|
|
960
|
+
phase_id: string | null;
|
|
961
|
+
input_tokens: number | null;
|
|
962
|
+
output_tokens: number | null;
|
|
963
|
+
total_tokens: number | null;
|
|
964
|
+
cost_usd: number | null;
|
|
965
|
+
duration_ms: number | null;
|
|
966
|
+
drift_count: number | null;
|
|
967
|
+
drift_errors: number | null;
|
|
968
|
+
test_pass_count: number | null;
|
|
969
|
+
test_fail_count: number | null;
|
|
970
|
+
lint_clean: number | null;
|
|
971
|
+
typecheck_clean: number | null;
|
|
972
|
+
notes: string | null;
|
|
973
|
+
metadata: string;
|
|
974
|
+
recorded_at: string;
|
|
975
|
+
}
|
|
976
|
+
interface AggregatedRow {
|
|
977
|
+
groupKey: string;
|
|
978
|
+
activityCount: number;
|
|
979
|
+
sumTokens: number | null;
|
|
980
|
+
avgTokens: number | null;
|
|
981
|
+
sumCost: number | null;
|
|
982
|
+
avgDuration: number | null;
|
|
983
|
+
firstActivity: string;
|
|
984
|
+
lastActivity: string;
|
|
985
|
+
}
|
|
986
|
+
interface LatestQualitySnapshot {
|
|
987
|
+
driftCount: number | null;
|
|
988
|
+
driftErrors: number | null;
|
|
989
|
+
testPassCount: number | null;
|
|
990
|
+
testFailCount: number | null;
|
|
991
|
+
lintClean: boolean | null;
|
|
992
|
+
typecheckClean: boolean | null;
|
|
993
|
+
capturedAt: string | null;
|
|
994
|
+
}
|
|
995
|
+
interface SessionTotals {
|
|
996
|
+
totalCost: number;
|
|
997
|
+
totalTokens: number;
|
|
998
|
+
activityCount: number;
|
|
999
|
+
}
|
|
1000
|
+
interface MetricsResult {
|
|
1001
|
+
rows: ActivityRow[] | AggregatedRow[];
|
|
1002
|
+
grouped: boolean;
|
|
1003
|
+
qualitySnapshot: LatestQualitySnapshot;
|
|
1004
|
+
totals: SessionTotals;
|
|
1005
|
+
timeSpan: {
|
|
1006
|
+
first: string;
|
|
1007
|
+
last: string;
|
|
1008
|
+
} | null;
|
|
1009
|
+
}
|
|
1010
|
+
type ExportFormat = "json" | "csv" | "markdown";
|
|
1011
|
+
|
|
1012
|
+
declare function insertActivity(db: Database, params: InsertActivityParams): number;
|
|
1013
|
+
declare function getSessionTotals(db: Database, since?: string, model?: string): SessionTotals;
|
|
1014
|
+
declare function queryMetrics(db: Database, params: QueryMetricsParams): MetricsResult;
|
|
1015
|
+
declare function exportMetrics(db: Database, projectRoot: string, format: ExportFormat, params: Omit<QueryMetricsParams, "groupBy" | "limit">, maxRows?: number): string;
|
|
1016
|
+
|
|
897
1017
|
interface ChangedFile {
|
|
898
1018
|
status: "added" | "modified" | "deleted" | "renamed";
|
|
899
1019
|
path: string;
|
|
@@ -911,7 +1031,7 @@ interface GitRef {
|
|
|
911
1031
|
* - "last-phase" → commit stored in arcbridge_meta under "phase_sync_commit", or HEAD~5 fallback
|
|
912
1032
|
* - anything else → treated as a literal git ref (branch, tag, SHA)
|
|
913
1033
|
*/
|
|
914
|
-
declare function resolveRef(projectRoot: string, since: string, db?: Database
|
|
1034
|
+
declare function resolveRef(projectRoot: string, since: string, db?: Database): GitRef;
|
|
915
1035
|
/**
|
|
916
1036
|
* Get list of changed files between a ref and HEAD.
|
|
917
1037
|
*/
|
|
@@ -927,7 +1047,7 @@ declare function getHeadSha(projectRoot: string): string | null;
|
|
|
927
1047
|
/**
|
|
928
1048
|
* Store the current sync point in arcbridge_meta.
|
|
929
1049
|
*/
|
|
930
|
-
declare function setSyncCommit(db: Database
|
|
1050
|
+
declare function setSyncCommit(db: Database, key: "last_sync_commit" | "phase_sync_commit", sha: string): void;
|
|
931
1051
|
|
|
932
1052
|
type TestOutcome = "passed" | "failed" | "missing" | "error";
|
|
933
1053
|
interface ScenarioTestResult {
|
|
@@ -953,7 +1073,7 @@ interface VerifyResult {
|
|
|
953
1073
|
*
|
|
954
1074
|
* Optionally filter by specific scenario IDs.
|
|
955
1075
|
*/
|
|
956
|
-
declare function verifyScenarios(db: Database
|
|
1076
|
+
declare function verifyScenarios(db: Database, projectRoot: string, options: {
|
|
957
1077
|
testCommand: string;
|
|
958
1078
|
timeoutMs: number;
|
|
959
1079
|
scenarioIds?: string[];
|
|
@@ -988,4 +1108,4 @@ declare function loadConfig(projectRoot: string): {
|
|
|
988
1108
|
error: string | null;
|
|
989
1109
|
};
|
|
990
1110
|
|
|
991
|
-
export { type AdrFrontmatter, AdrFrontmatterSchema, type AgentRole, AgentRoleSchema, type ArcBridgeConfig, ArcBridgeConfigSchema, type BuildingBlock, BuildingBlockSchema, type BuildingBlocksFrontmatter, BuildingBlocksFrontmatterSchema, CURRENT_SCHEMA_VERSION, type ChangedFile, type DotnetProjectInfo, type DriftEntry, type DriftKind, type DriftOptions, type DriftSeverity, type ExtractedSymbol, type GenerateDatabaseResult, type GitRef, type IndexResult, type IndexerOptions, type InitProjectInput, type LoadRolesResult, type Phase, PhaseSchema, type PhasesFile, PhasesFileSchema, type ProjectLanguage, QualityCategorySchema, QualityPrioritySchema, type QualityScenario, QualityScenarioSchema, QualityScenarioStatusSchema, type QualityScenariosFile, QualityScenariosFileSchema, type ScenarioTestResult, type Service, type SymbolKind, type Task, type TaskFile, TaskFileSchema, type TaskInferenceResult, TaskSchema, type TestOutcome, type VerifyResult, addTaskToYaml, applyInferences, detectDrift, detectProjectLanguage, discoverDotnetServices, generateAgentRoles, generateArc42, generateConfig, generateDatabase, generatePlan, generateSyncFiles, getChangedFiles, getHeadSha, getUncommittedChanges, indexPackageDependencies, indexProject, inferTaskStatuses, initializeSchema, loadConfig, loadRole, loadRoles, migrate, openDatabase, openMemoryDatabase, refreshFromDocs, resolveRef, setSyncCommit, syncPhaseToYaml, syncScenarioToYaml, syncTaskToYaml, verifyScenarios, writeDriftLog };
|
|
1111
|
+
export { type ActivityRow, type AdrFrontmatter, AdrFrontmatterSchema, type AgentRole, AgentRoleSchema, type AggregatedRow, type ArcBridgeConfig, ArcBridgeConfigSchema, type BuildingBlock, BuildingBlockSchema, type BuildingBlocksFrontmatter, BuildingBlocksFrontmatterSchema, CURRENT_SCHEMA_VERSION, type ChangedFile, type Database, type DotnetProjectInfo, type DriftEntry, type DriftKind, type DriftOptions, type DriftSeverity, type ExportFormat, type ExtractedSymbol, type GenerateDatabaseResult, type GitRef, type IndexResult, type IndexerOptions, type InitProjectInput, type InsertActivityParams, type LatestQualitySnapshot, type LoadRolesResult, type MetricsResult, type Phase, PhaseSchema, type PhasesFile, PhasesFileSchema, type ProjectLanguage, QualityCategorySchema, QualityPrioritySchema, type QualityScenario, QualityScenarioSchema, QualityScenarioStatusSchema, type QualityScenariosFile, QualityScenariosFileSchema, type QueryMetricsParams, type ScenarioTestResult, type Service, type SessionTotals, type SymbolKind, type Task, type TaskFile, TaskFileSchema, type TaskInferenceResult, TaskSchema, type TestOutcome, type VerifyResult, addTaskToYaml, applyInferences, detectDrift, detectProjectLanguage, discoverDotnetServices, exportMetrics, generateAgentRoles, generateArc42, generateConfig, generateDatabase, generatePlan, generateSyncFiles, getChangedFiles, getHeadSha, getSessionTotals, getUncommittedChanges, indexPackageDependencies, indexProject, inferTaskStatuses, initializeSchema, insertActivity, loadConfig, loadRole, loadRoles, migrate, openDatabase, openMemoryDatabase, queryMetrics, refreshFromDocs, resolveRef, setSyncCommit, suppressSqliteWarning, syncPhaseToYaml, syncScenarioToYaml, syncTaskToYaml, transaction, verifyScenarios, writeDriftLog };
|