@hiveai/core 0.3.3 → 0.4.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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const MemoryScopeSchema: z.ZodEnum<["personal", "team", "module"]>;
3
+ declare const MemoryScopeSchema: z.ZodEnum<["personal", "team", "module", "shared"]>;
4
4
  declare const MemoryStatusSchema: z.ZodEnum<["draft", "proposed", "validated", "deprecated", "stale", "rejected"]>;
5
5
  declare const MemoryTypeSchema: z.ZodEnum<["convention", "decision", "gotcha", "architecture", "glossary", "attempt", "session_recap"]>;
6
6
  declare const AnchorSchema: z.ZodObject<{
@@ -18,7 +18,7 @@ declare const AnchorSchema: z.ZodObject<{
18
18
  }>;
19
19
  declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
20
20
  id: z.ZodString;
21
- scope: z.ZodDefault<z.ZodEnum<["personal", "team", "module"]>>;
21
+ scope: z.ZodDefault<z.ZodEnum<["personal", "team", "module", "shared"]>>;
22
22
  module: z.ZodOptional<z.ZodString>;
23
23
  type: z.ZodEnum<["convention", "decision", "gotcha", "architecture", "glossary", "attempt", "session_recap"]>;
24
24
  status: z.ZodDefault<z.ZodEnum<["draft", "proposed", "validated", "deprecated", "stale", "rejected"]>>;
@@ -50,7 +50,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
50
50
  type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "attempt" | "session_recap";
51
51
  status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
52
52
  id: string;
53
- scope: "personal" | "team" | "module";
53
+ scope: "personal" | "team" | "module" | "shared";
54
54
  anchor: {
55
55
  paths: string[];
56
56
  symbols: string[];
@@ -74,7 +74,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
74
74
  created_at: string | Date;
75
75
  module?: string | undefined;
76
76
  status?: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected" | undefined;
77
- scope?: "personal" | "team" | "module" | undefined;
77
+ scope?: "personal" | "team" | "module" | "shared" | undefined;
78
78
  anchor?: {
79
79
  commit?: string | undefined;
80
80
  paths?: string[] | undefined;
@@ -94,7 +94,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
94
94
  type: "convention" | "decision" | "gotcha" | "architecture" | "glossary" | "attempt" | "session_recap";
95
95
  status: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected";
96
96
  id: string;
97
- scope: "personal" | "team" | "module";
97
+ scope: "personal" | "team" | "module" | "shared";
98
98
  anchor: {
99
99
  paths: string[];
100
100
  symbols: string[];
@@ -118,7 +118,7 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
118
118
  created_at: string | Date;
119
119
  module?: string | undefined;
120
120
  status?: "draft" | "proposed" | "validated" | "deprecated" | "stale" | "rejected" | undefined;
121
- scope?: "personal" | "team" | "module" | undefined;
121
+ scope?: "personal" | "team" | "module" | "shared" | undefined;
122
122
  anchor?: {
123
123
  commit?: string | undefined;
124
124
  paths?: string[] | undefined;
@@ -135,6 +135,22 @@ declare const MemoryFrontmatterSchema: z.ZodEffects<z.ZodObject<{
135
135
  topic?: string | undefined;
136
136
  revision_count?: number | undefined;
137
137
  }>;
138
+ declare const CrossRepoProvenanceSchema: z.ZodOptional<z.ZodObject<{
139
+ source_name: z.ZodString;
140
+ source_path: z.ZodString;
141
+ source_id: z.ZodString;
142
+ imported_at: z.ZodString;
143
+ }, "strip", z.ZodTypeAny, {
144
+ source_name: string;
145
+ source_path: string;
146
+ source_id: string;
147
+ imported_at: string;
148
+ }, {
149
+ source_name: string;
150
+ source_path: string;
151
+ source_id: string;
152
+ imported_at: string;
153
+ }>>;
138
154
 
139
155
  type MemoryScope = z.infer<typeof MemoryScopeSchema>;
140
156
  type MemoryStatus = z.infer<typeof MemoryStatusSchema>;
@@ -163,6 +179,7 @@ declare function buildFrontmatter(input: {
163
179
  commit?: string;
164
180
  topic?: string;
165
181
  status?: MemoryFrontmatter["status"];
182
+ relatedIds?: string[];
166
183
  }): MemoryFrontmatter;
167
184
 
168
185
  declare const HAIVE_DIR = ".ai";
@@ -359,6 +376,31 @@ declare function queryCodeMap(map: CodeMap, options: CodeMapQueryOptions): {
359
376
  };
360
377
 
361
378
  declare const CONFIG_FILE = "haive.config.json";
379
+ /** A remote or local repo to pull shared memories from. */
380
+ interface CrossRepoSource {
381
+ /** Human-readable name for this source (used in imported memory tags). */
382
+ name: string;
383
+ /** Local filesystem path to the other project's root (relative or absolute). */
384
+ path?: string;
385
+ /** Git URL — clone/fetch performed automatically. */
386
+ git?: string;
387
+ /** Only import memories matching all of these filters. */
388
+ filter?: {
389
+ /** Only import memories with these tags. */
390
+ tags?: string[];
391
+ /** Only import memories of these types. */
392
+ types?: string[];
393
+ };
394
+ }
395
+ /** An API contract file to snapshot and monitor for breaking changes. */
396
+ interface ContractFile {
397
+ /** Human-readable name for this contract. */
398
+ name: string;
399
+ /** Path to the contract file, relative to the project root. */
400
+ path: string;
401
+ /** Format of the contract file. */
402
+ format: "openapi" | "graphql" | "proto" | "typescript" | "json-schema";
403
+ }
362
404
  interface HaiveConfig {
363
405
  /** Autopilot mode: maximum autonomy, minimum human intervention. Default: false. */
364
406
  autopilot?: boolean;
@@ -384,6 +426,35 @@ interface HaiveConfig {
384
426
  * the template. Default: true in autopilot, false otherwise.
385
427
  */
386
428
  autoContext?: boolean;
429
+ /**
430
+ * Other repos to pull `shared`-scoped memories from during `haive sync`.
431
+ * Each source must have either `path` (local) or `git` (remote URL).
432
+ *
433
+ * Example:
434
+ * { "name": "backend", "path": "../repo-backend", "filter": { "tags": ["api-contract"] } }
435
+ */
436
+ crossRepoSources?: CrossRepoSource[];
437
+ /**
438
+ * API contract files to snapshot and watch for breaking changes.
439
+ * `haive sync` compares the current file against `.ai/contracts/<name>.lock`
440
+ * and creates a `gotcha` memory if a breaking change is detected.
441
+ *
442
+ * Example:
443
+ * { "name": "payment-api", "path": "docs/openapi.yaml", "format": "openapi" }
444
+ */
445
+ contractFiles?: ContractFile[];
446
+ /**
447
+ * Local path to a shared team-knowledge hub repo.
448
+ * Used by `haive hub pull` and `haive hub push`.
449
+ * Can be relative (resolved from project root) or absolute.
450
+ */
451
+ hubPath?: string;
452
+ /**
453
+ * Lock file paths to watch for dependency version changes.
454
+ * Auto-detected if not specified (package.json, pom.xml, go.mod, etc.).
455
+ * Set to [] to disable dependency tracking entirely.
456
+ */
457
+ dependencyFiles?: string[];
387
458
  }
388
459
  declare const DEFAULT_CONFIG: HaiveConfig;
389
460
  declare const AUTOPILOT_DEFAULTS: HaiveConfig;
@@ -391,4 +462,83 @@ declare function configPath(paths: HaivePaths): string;
391
462
  declare function loadConfig(paths: HaivePaths): Promise<HaiveConfig>;
392
463
  declare function saveConfig(paths: HaivePaths, config: HaiveConfig): Promise<void>;
393
464
 
394
- export { AUTOPILOT_DEFAULTS, type Anchor, AnchorSchema, type AutoPromoteRule, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_FILE, CONFIG_FILE, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type ConfidenceLevel, type ConfidenceThresholds, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, HAIVE_DIR, type HaiveConfig, type HaivePaths, type LoadedMemory, MEMORIES_DIR, type Memory, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, PROJECT_CONTEXT_FILE, type TruncateOptions, type TruncateResult, USAGE_FILE, type UsageIndex, type VerifyOptions, type VerifyResult, allocateBudget, buildCodeMap, buildFrontmatter, bumpRead, codeMapPath, configPath, deriveConfidence, emptyUsage, emptyUsageIndex, estimateTokens, extractSnippet, findProjectRoot, getUsage, inferModulesFromPaths, isAutoPromoteEligible, isDecaying, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadMemoriesFromDir, loadMemory, loadUsageIndex, memoryFilePath, memoryMatchesAnchorPaths, newMemoryId, parseMemory, pathsOverlap, pickSnippetNeedle, queryCodeMap, recordRejection, relPathFrom, resolveHaivePaths, saveCodeMap, saveConfig, saveUsageIndex, serializeMemory, stripPrivate, tokenizeQuery, trackReads, truncateToTokens, usagePath, verifyAnchor };
465
+ interface CrossRepoReport {
466
+ source: string;
467
+ imported: string[];
468
+ updated: string[];
469
+ skipped: string[];
470
+ errors: string[];
471
+ }
472
+ /**
473
+ * Pull shared memories from all configured cross-repo sources.
474
+ * Returns one report per source.
475
+ */
476
+ declare function pullCrossRepoSources(paths: HaivePaths, config: HaiveConfig, projectRoot: string): Promise<CrossRepoReport[]>;
477
+
478
+ interface DependencySnapshot {
479
+ file: string;
480
+ format: string;
481
+ captured_at: string;
482
+ deps: Record<string, string>;
483
+ }
484
+ interface DepChange {
485
+ name: string;
486
+ from: string;
487
+ to: string;
488
+ /** true if the major version number changed */
489
+ isMajorBump: boolean;
490
+ }
491
+ interface DepTrackResult {
492
+ file: string;
493
+ changes: DepChange[];
494
+ }
495
+ /**
496
+ * Resolve which manifest files to track.
497
+ * Uses config.dependencyFiles if set, otherwise auto-detects from KNOWN_MANIFESTS.
498
+ */
499
+ declare function resolveManifestFiles(projectRoot: string, configuredFiles?: string[]): string[];
500
+ /**
501
+ * Check all manifest files for version changes since last snapshot.
502
+ * Returns one result per file that has changes.
503
+ */
504
+ declare function trackDependencies(projectRoot: string, haiveDir: string, manifestFiles: string[]): Promise<DepTrackResult[]>;
505
+
506
+ interface ContractSnapshot {
507
+ name: string;
508
+ path: string;
509
+ format: string;
510
+ captured_at: string;
511
+ hash: string;
512
+ endpoints?: string[];
513
+ types?: string[];
514
+ fields?: Record<string, string[]>;
515
+ raw_lines?: string[];
516
+ }
517
+ interface BreakingChange {
518
+ kind: "endpoint_removed" | "endpoint_added" | "type_removed" | "type_added" | "field_removed" | "field_added" | "content_changed";
519
+ description: string;
520
+ severity: "breaking" | "additive" | "unknown";
521
+ }
522
+ interface ContractDiffResult {
523
+ contract: string;
524
+ file: string;
525
+ changes: BreakingChange[];
526
+ unchanged: boolean;
527
+ }
528
+ declare function contractLockPath(haiveDir: string, name: string): string;
529
+ /**
530
+ * Take a snapshot of a contract file and save it to .ai/contracts/<name>.lock.
531
+ * Returns the snapshot.
532
+ */
533
+ declare function snapshotContract(projectRoot: string, haiveDir: string, contract: ContractFile): Promise<ContractSnapshot>;
534
+ /**
535
+ * Compare a contract file against its stored snapshot.
536
+ * Returns the diff result. If no snapshot exists, creates one and returns unchanged.
537
+ */
538
+ declare function diffContract(projectRoot: string, haiveDir: string, contract: ContractFile): Promise<ContractDiffResult>;
539
+ /**
540
+ * Check all configured contract files for changes.
541
+ */
542
+ declare function watchContracts(projectRoot: string, haiveDir: string, contractFiles: ContractFile[]): Promise<ContractDiffResult[]>;
543
+
544
+ export { AUTOPILOT_DEFAULTS, type Anchor, AnchorSchema, type AutoPromoteRule, type BreakingChange, type BudgetPart, type BudgetSlice, type BuildCodeMapOptions, CHARS_PER_TOKEN, CODE_MAP_FILE, CONFIG_FILE, type CodeExport, type CodeExportKind, type CodeFileEntry, type CodeMap, type CodeMapQueryOptions, type ConfidenceLevel, type ConfidenceThresholds, type ContractDiffResult, type ContractFile, type ContractSnapshot, CrossRepoProvenanceSchema, type CrossRepoReport, type CrossRepoSource, DECAY_DAYS, DEFAULT_AUTO_PROMOTE_RULE, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CONFIG, type DepChange, type DepTrackResult, type DependencySnapshot, HAIVE_DIR, type HaiveConfig, type HaivePaths, type LoadedMemory, MEMORIES_DIR, type Memory, type MemoryFrontmatter, MemoryFrontmatterSchema, type MemoryScope, MemoryScopeSchema, type MemoryStatus, MemoryStatusSchema, type MemoryType, MemoryTypeSchema, type MemoryUsage, PROJECT_CONTEXT_FILE, type TruncateOptions, type TruncateResult, USAGE_FILE, type UsageIndex, type VerifyOptions, type VerifyResult, allocateBudget, buildCodeMap, buildFrontmatter, bumpRead, codeMapPath, configPath, contractLockPath, deriveConfidence, diffContract, emptyUsage, emptyUsageIndex, estimateTokens, extractSnippet, findProjectRoot, getUsage, inferModulesFromPaths, isAutoPromoteEligible, isDecaying, listMarkdownFilesRecursive, literalMatchesAllTokens, literalMatchesAnyToken, loadCodeMap, loadConfig, loadMemoriesFromDir, loadMemory, loadUsageIndex, memoryFilePath, memoryMatchesAnchorPaths, newMemoryId, parseMemory, pathsOverlap, pickSnippetNeedle, pullCrossRepoSources, queryCodeMap, recordRejection, relPathFrom, resolveHaivePaths, resolveManifestFiles, saveCodeMap, saveConfig, saveUsageIndex, serializeMemory, snapshotContract, stripPrivate, tokenizeQuery, trackDependencies, trackReads, truncateToTokens, usagePath, verifyAnchor, watchContracts };