@gitgov/core 2.1.2 → 2.3.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/dist/src/fs.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { R as RecordStore, C as ConfigStore, G as GitGovConfig, S as SessionStore, a as GitGovSession, I as IGitModule, b as GitModuleDependencies, E as ExecOptions, c as ExecResult, d as ChangedFile, e as GetCommitHistoryOptions, f as CommitInfo, g as CommitAuthor } from './index--ahcnsG3.js';
2
- export { F as FsFileListerOptions } from './index--ahcnsG3.js';
3
- import { C as ConfigManager, S as SessionManager, I as ILintModule, L as LintOptions, a as LintReport, F as FixRecordOptions, b as FixReport, R as RecordStores, c as IIndexerAdapter, G as GitGovRecord, d as LintRecordContext, e as LintResult, f as IProjectInitializer, E as EnvironmentValidation, g as ISyncStateModule, h as SyncStateModuleDependencies, i as StateDeltaFile, j as ConflictDiff, k as IntegrityViolation, A as AuditStateOptions, l as AuditStateReport, m as SyncStatePushOptions, n as SyncStatePushResult, o as SyncStatePullOptions, p as SyncStatePullResult, q as SyncStateResolveOptions, r as SyncStateResolveResult, s as IEventStream, t as IAgentRunner, P as ProtocolHandlerRegistry, u as AgentRunnerDependencies, v as RunOptions, w as AgentResponse } from './agent_runner-ByOUWOt6.js';
4
- export { z as FsFileLister, x as FsKeyProvider, y as FsKeyProviderOptions } from './agent_runner-ByOUWOt6.js';
1
+ import { R as RecordStore, I as IdEncoder } from './record_store-BXKWqon5.js';
2
+ export { D as DEFAULT_ID_ENCODER } from './record_store-BXKWqon5.js';
3
+ import { C as ConfigStore, G as GitGovConfig, I as IGitModule, a as GitModuleDependencies, E as ExecOptions, b as ExecResult, c as ChangedFile, d as GetCommitHistoryOptions, e as CommitInfo, f as CommitAuthor } from './index-Bhc341pf.js';
4
+ export { F as FsFileListerOptions } from './index-Bhc341pf.js';
5
+ import { C as ConfigManager, S as SessionManager, I as ILintModule, L as LintOptions, a as LintReport, F as FixRecordOptions, b as FixReport, R as RecordStores, c as LintRecordContext, d as LintResult, e as IProjectInitializer, E as EnvironmentValidation, f as ISyncStateModule, g as SyncStateModuleDependencies, h as StateDeltaFile, i as ConflictDiff, j as IntegrityViolation, A as AuditStateOptions, k as AuditStateReport, l as SyncStatePushOptions, m as SyncStatePushResult, n as SyncStatePullOptions, o as SyncStatePullResult, p as SyncStateResolveOptions, q as SyncStateResolveResult, r as IEventStream, s as IAgentRunner, P as ProtocolHandlerRegistry, t as AgentRunnerDependencies, u as RunOptions, v as AgentResponse } from './agent_runner-D7JahEKk.js';
6
+ export { y as FsFileLister, w as FsKeyProvider, x as FsKeyProviderOptions } from './agent_runner-D7JahEKk.js';
7
+ import { S as SessionStore, G as GitGovSession } from './key_provider-CRpHFGjN.js';
8
+ import { I as IRecordProjector, G as GitGovRecord, a as IRecordProjection, b as IndexData, P as ProjectionContext } from './record_projection.types-B8AM7u8U.js';
5
9
 
6
10
  /**
7
11
  * Serializer for FsRecordStore - allows custom serialization
@@ -10,21 +14,6 @@ interface Serializer {
10
14
  stringify: (value: unknown) => string;
11
15
  parse: <T>(text: string) => T;
12
16
  }
13
- /**
14
- * IdEncoder for transforming IDs to filesystem-safe filenames
15
- * Useful for characters not allowed in filesystem (e.g., `:` on Windows)
16
- */
17
- interface IdEncoder {
18
- /** Transform ID to filename-safe string */
19
- encode: (id: string) => string;
20
- /** Recover original ID from filename */
21
- decode: (encoded: string) => string;
22
- }
23
- /**
24
- * Default encoder: `:` → `_` (for IDs like "human:camilo")
25
- * Reversible because IDs cannot contain `_` (see id_generator.ts)
26
- */
27
- declare const DEFAULT_ID_ENCODER: IdEncoder;
28
17
  /**
29
18
  * Options for FsRecordStore
30
19
  */
@@ -63,6 +52,10 @@ declare class FsRecordStore<T> implements RecordStore<T> {
63
52
  private getFilePath;
64
53
  get(id: string): Promise<T | null>;
65
54
  put(id: string, value: T): Promise<void>;
55
+ putMany(entries: Array<{
56
+ id: string;
57
+ value: T;
58
+ }>): Promise<void>;
66
59
  delete(id: string): Promise<void>;
67
60
  list(): Promise<string[]>;
68
61
  exists(id: string): Promise<boolean>;
@@ -247,8 +240,8 @@ interface FsLintModuleDependencies {
247
240
  lintModule: ILintModule;
248
241
  /** Record stores for reference lookups (OPTIONAL) */
249
242
  stores?: RecordStores;
250
- /** Indexer adapter for reference resolution (OPTIONAL) */
251
- indexerAdapter?: IIndexerAdapter;
243
+ /** Record projector for reference resolution (OPTIONAL) */
244
+ projector?: IRecordProjector;
252
245
  /** FileSystem abstraction for I/O (OPTIONAL, default: Node.js fs) */
253
246
  fileSystem?: FileSystem;
254
247
  }
@@ -920,6 +913,7 @@ declare class LocalGitModule implements IGitModule {
920
913
  */
921
914
  add(filePaths: string[], options?: {
922
915
  force?: boolean;
916
+ contentMap?: Record<string, string>;
923
917
  }): Promise<void>;
924
918
  /**
925
919
  * Removes files from both working directory and staging area
@@ -1366,4 +1360,22 @@ declare class FsAgentRunner implements IAgentRunner {
1366
1360
  */
1367
1361
  declare function createAgentRunner(deps: AgentRunnerDependencies): IAgentRunner;
1368
1362
 
1369
- export { DEFAULT_ID_ENCODER, type FileSystem, FsAgentRunner, AgentRunnerDependencies as FsAgentRunnerDependencies, FsConfigStore, type FsFixOptions, FsLintModule, type FsLintModuleDependencies, type FsLintOptions, FsProjectInitializer, FsRecordStore, FsSessionStore, FsSyncStateModule, FsWatcherStateModule, LocalGitModule as GitModule, GitModuleDependencies, type IFsLintModule, IGitModule, LocalGitModule, createAgentRunner, createConfigManager, createSessionManager, findGitgovRoot, findProjectRoot, getGitgovPath, isGitgovProject, resetDiscoveryCache };
1363
+ type FsRecordProjectionOptions = {
1364
+ basePath: string;
1365
+ };
1366
+ /**
1367
+ * FsRecordProjection - Filesystem IRecordProjection for CLI.
1368
+ *
1369
+ * Writes IndexData as JSON to .gitgov/index.json using atomic write
1370
+ * (write to temp file + rename) to prevent corruption on crash.
1371
+ */
1372
+ declare class FsRecordProjection implements IRecordProjection {
1373
+ private readonly indexPath;
1374
+ constructor(options: FsRecordProjectionOptions);
1375
+ persist(data: IndexData, _context: ProjectionContext): Promise<void>;
1376
+ read(_context: ProjectionContext): Promise<IndexData | null>;
1377
+ exists(_context: ProjectionContext): Promise<boolean>;
1378
+ clear(_context: ProjectionContext): Promise<void>;
1379
+ }
1380
+
1381
+ export { type FileSystem, FsAgentRunner, AgentRunnerDependencies as FsAgentRunnerDependencies, FsConfigStore, type FsFixOptions, FsLintModule, type FsLintModuleDependencies, type FsLintOptions, FsProjectInitializer, FsRecordProjection, type FsRecordProjectionOptions, FsRecordStore, FsSessionStore, FsSyncStateModule, FsWatcherStateModule, LocalGitModule as GitModule, GitModuleDependencies, type IFsLintModule, IGitModule, LocalGitModule, createAgentRunner, createConfigManager, createSessionManager, findGitgovRoot, findProjectRoot, getGitgovPath, isGitgovProject, resetDiscoveryCache };
package/dist/src/fs.js CHANGED
@@ -16,10 +16,14 @@ import os from 'os';
16
16
  import chokidar from 'chokidar';
17
17
 
18
18
  // src/record_store/fs/fs_record_store.ts
19
+
20
+ // src/record_store/record_store.ts
19
21
  var DEFAULT_ID_ENCODER = {
20
22
  encode: (id) => id.replace(/:/g, "_"),
21
23
  decode: (encoded) => encoded.replace(/_/g, ":")
22
24
  };
25
+
26
+ // src/record_store/fs/fs_record_store.ts
23
27
  var DEFAULT_SERIALIZER = {
24
28
  stringify: (value) => JSON.stringify(value, null, 2),
25
29
  parse: (text) => JSON.parse(text)
@@ -70,6 +74,11 @@ var FsRecordStore = class {
70
74
  const content = this.serializer.stringify(value);
71
75
  await fs.writeFile(filePath, content, "utf-8");
72
76
  }
77
+ async putMany(entries) {
78
+ for (const { id, value } of entries) {
79
+ await this.put(id, value);
80
+ }
81
+ }
73
82
  async delete(id) {
74
83
  const filePath = this.getFilePath(id);
75
84
  try {
@@ -3510,25 +3519,25 @@ var FsLintModule = class {
3510
3519
  this.projectRoot = dependencies.projectRoot;
3511
3520
  this.lintModule = dependencies.lintModule;
3512
3521
  this.fileSystem = dependencies.fileSystem ?? {
3513
- readFile: async (path12, encoding) => {
3514
- return promises.readFile(path12, encoding);
3522
+ readFile: async (path13, encoding) => {
3523
+ return promises.readFile(path13, encoding);
3515
3524
  },
3516
- writeFile: async (path12, content) => {
3517
- await promises.writeFile(path12, content, "utf-8");
3525
+ writeFile: async (path13, content) => {
3526
+ await promises.writeFile(path13, content, "utf-8");
3518
3527
  },
3519
- exists: async (path12) => {
3528
+ exists: async (path13) => {
3520
3529
  try {
3521
- await promises.access(path12);
3530
+ await promises.access(path13);
3522
3531
  return true;
3523
3532
  } catch {
3524
3533
  return false;
3525
3534
  }
3526
3535
  },
3527
- unlink: async (path12) => {
3528
- await promises.unlink(path12);
3536
+ unlink: async (path13) => {
3537
+ await promises.unlink(path13);
3529
3538
  },
3530
- readdir: async (path12) => {
3531
- return readdir(path12);
3539
+ readdir: async (path13) => {
3540
+ return readdir(path13);
3532
3541
  }
3533
3542
  };
3534
3543
  }
@@ -5809,7 +5818,7 @@ var FsSyncStateModule = class {
5809
5818
  throw new Error("LintModule is required for SyncStateModule");
5810
5819
  }
5811
5820
  if (!dependencies.indexer) {
5812
- throw new Error("IndexerAdapter is required for SyncStateModule");
5821
+ throw new Error("RecordProjector is required for SyncStateModule");
5813
5822
  }
5814
5823
  this.git = dependencies.git;
5815
5824
  this.config = dependencies.config;
@@ -7298,7 +7307,7 @@ To avoid losing your changes, push first or use --force to overwrite.`,
7298
7307
  }
7299
7308
  }
7300
7309
  if (shouldReindex) {
7301
- logger6.info("Invoking IndexerAdapter.generateIndex() after pull...");
7310
+ logger6.info("Invoking RecordProjector.generateIndex() after pull...");
7302
7311
  try {
7303
7312
  await this.indexer.generateIndex();
7304
7313
  logger6.info("Index regenerated successfully");
@@ -7543,7 +7552,7 @@ Signed-off-by: ${actorId}`;
7543
7552
  log("Temp directory cleaned up");
7544
7553
  } catch {
7545
7554
  }
7546
- logger6.info("Invoking IndexerAdapter.generateIndex() after conflict resolution...");
7555
+ logger6.info("Invoking RecordProjector.generateIndex() after conflict resolution...");
7547
7556
  try {
7548
7557
  await this.indexer.generateIndex();
7549
7558
  logger6.info("Index regenerated successfully after conflict resolution");
@@ -8444,7 +8453,50 @@ var FsAgentRunner = class {
8444
8453
  function createAgentRunner(deps) {
8445
8454
  return new FsAgentRunner(deps);
8446
8455
  }
8456
+ var FsRecordProjection = class {
8457
+ indexPath;
8458
+ constructor(options) {
8459
+ this.indexPath = path9.join(options.basePath, "index.json");
8460
+ }
8461
+ async persist(data, _context) {
8462
+ const dir = path9.dirname(this.indexPath);
8463
+ await fs.mkdir(dir, { recursive: true });
8464
+ const tmpPath = `${this.indexPath}.tmp`;
8465
+ const content = JSON.stringify(data, null, 2);
8466
+ await fs.writeFile(tmpPath, content, "utf-8");
8467
+ await fs.rename(tmpPath, this.indexPath);
8468
+ }
8469
+ async read(_context) {
8470
+ try {
8471
+ const content = await fs.readFile(this.indexPath, "utf-8");
8472
+ return JSON.parse(content);
8473
+ } catch (error) {
8474
+ if (error.code === "ENOENT") {
8475
+ return null;
8476
+ }
8477
+ throw error;
8478
+ }
8479
+ }
8480
+ async exists(_context) {
8481
+ try {
8482
+ await fs.access(this.indexPath);
8483
+ return true;
8484
+ } catch {
8485
+ return false;
8486
+ }
8487
+ }
8488
+ async clear(_context) {
8489
+ try {
8490
+ await fs.unlink(this.indexPath);
8491
+ } catch (error) {
8492
+ if (error.code === "ENOENT") {
8493
+ return;
8494
+ }
8495
+ throw error;
8496
+ }
8497
+ }
8498
+ };
8447
8499
 
8448
- export { DEFAULT_ID_ENCODER, FsAgentRunner, FsConfigStore, FsFileLister, FsKeyProvider, FsLintModule, FsProjectInitializer, FsRecordStore, FsSessionStore, FsSyncStateModule, FsWatcherStateModule, LocalGitModule as GitModule, LocalGitModule, createAgentRunner, createConfigManager, createSessionManager, findGitgovRoot, findProjectRoot, getGitgovPath, isGitgovProject, resetDiscoveryCache };
8500
+ export { DEFAULT_ID_ENCODER, FsAgentRunner, FsConfigStore, FsFileLister, FsKeyProvider, FsLintModule, FsProjectInitializer, FsRecordProjection, FsRecordStore, FsSessionStore, FsSyncStateModule, FsWatcherStateModule, LocalGitModule as GitModule, LocalGitModule, createAgentRunner, createConfigManager, createSessionManager, findGitgovRoot, findProjectRoot, getGitgovPath, isGitgovProject, resetDiscoveryCache };
8449
8501
  //# sourceMappingURL=fs.js.map
8450
8502
  //# sourceMappingURL=fs.js.map