@haystackeditor/cli 0.15.26 → 0.15.27

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.
Files changed (49) hide show
  1. package/README.md +39 -3
  2. package/dist/assets/hooks/package-lock.json +598 -0
  3. package/dist/assets/skills/map-cloud-verifier-universe/SKILL.md +2051 -0
  4. package/dist/assets/skills/map-cloud-verifier-universe/agents/openai.yaml +4 -0
  5. package/dist/assets/skills/map-cloud-verifier-universe/references/output-contract.md +3411 -0
  6. package/dist/assets/telemetry/browser-runtime.js +861 -0
  7. package/dist/assets/telemetry/runtime.cjs +1509 -0
  8. package/dist/commands/cloud-verifier-behaviors.d.ts +27 -0
  9. package/dist/commands/cloud-verifier-behaviors.js +218 -0
  10. package/dist/commands/cloud-verifier-data-store-census.d.ts +47 -0
  11. package/dist/commands/cloud-verifier-data-store-census.js +539 -0
  12. package/dist/commands/cloud-verifier-data-store-drift.d.ts +42 -0
  13. package/dist/commands/cloud-verifier-data-store-drift.js +158 -0
  14. package/dist/commands/cloud-verifier-identity-census.d.ts +88 -0
  15. package/dist/commands/cloud-verifier-identity-census.js +4057 -0
  16. package/dist/commands/cloud-verifier-materialization.d.ts +16 -0
  17. package/dist/commands/cloud-verifier-materialization.js +704 -0
  18. package/dist/commands/cloud-verifier-pascal-selector-census.d.ts +29 -0
  19. package/dist/commands/cloud-verifier-pascal-selector-census.js +1382 -0
  20. package/dist/commands/cloud-verifier-python-manifest-selector-census.d.ts +27 -0
  21. package/dist/commands/cloud-verifier-python-manifest-selector-census.js +2015 -0
  22. package/dist/commands/cloud-verifier-specialized-operational-census.d.ts +51 -0
  23. package/dist/commands/cloud-verifier-specialized-operational-census.js +11432 -0
  24. package/dist/commands/cloud-verifier-universe.d.ts +31 -0
  25. package/dist/commands/cloud-verifier-universe.js +10178 -0
  26. package/dist/commands/design-verify.d.ts +23 -0
  27. package/dist/commands/design-verify.js +142 -0
  28. package/dist/commands/hooks.js +2 -2
  29. package/dist/commands/prepare-universe-review.d.ts +115 -0
  30. package/dist/commands/prepare-universe-review.js +1092 -0
  31. package/dist/commands/production-source-deny-policy.d.ts +15 -0
  32. package/dist/commands/production-source-deny-policy.js +100 -0
  33. package/dist/commands/scaffold-provisional-universe.d.ts +468 -0
  34. package/dist/commands/scaffold-provisional-universe.js +808 -0
  35. package/dist/commands/schema-cmd.js +32 -0
  36. package/dist/commands/skills.d.ts +2 -2
  37. package/dist/commands/skills.js +415 -47
  38. package/dist/commands/telemetry.d.ts +53 -0
  39. package/dist/commands/telemetry.js +832 -0
  40. package/dist/index.js +134 -12
  41. package/dist/triage/runner.js +7 -6
  42. package/dist/utils/design-verifier-api.d.ts +129 -0
  43. package/dist/utils/design-verifier-api.js +175 -0
  44. package/dist/utils/design-verifier-result.d.ts +52 -0
  45. package/dist/utils/design-verifier-result.js +299 -0
  46. package/dist/utils/haystack-api.d.ts +2 -0
  47. package/dist/utils/haystack-api.js +10 -3
  48. package/dist/utils/hooks.js +2 -1
  49. package/package.json +7 -2
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Data-store drift check.
3
+ *
4
+ * A checked-in universe map lists the stores the Cloud Verifier clones. As the
5
+ * app changes, that map silently goes stale — a new Redis nobody added to the
6
+ * map, or a Mongo the code dropped — and a stale map makes the verifier clone
7
+ * the wrong things. The static detector is a pure function of the repo, so the
8
+ * only moment repo-derived drift can enter is a change to a file the detector
9
+ * reads. This command catches that at the source: re-detect the stores, diff
10
+ * against the checked-in baseline, and flag the delta.
11
+ *
12
+ * It is built to run per-PR and cost almost nothing: given a base ref, it first
13
+ * checks whether the diff touches any file the detector reads (the exact gate —
14
+ * nothing else can change the result) and exits immediately if not.
15
+ */
16
+ import { execFileSync } from 'node:child_process';
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
18
+ import { basename, dirname, resolve } from 'node:path';
19
+ import { findGitRoot } from '../utils/hooks.js';
20
+ import { collectDataStores, isDataStoreInputName } from './cloud-verifier-identity-census.js';
21
+ export const DATA_STORE_BASELINE_PATH = '.haystack/cloud-verifier/data-stores.json';
22
+ export const DATA_STORE_BASELINE_SCHEMA = 'cloud-verifier-data-stores-v1';
23
+ function snapshot(store) {
24
+ return {
25
+ engine: store.engine,
26
+ category: store.category,
27
+ confidence: store.confidence,
28
+ clone_strategy: store.clone_strategy,
29
+ };
30
+ }
31
+ /** Diff two store lists by engine. Pure and order-independent. */
32
+ export function diffDataStores(baseline, current) {
33
+ const baseByEngine = new Map(baseline.map((store) => [store.engine, store]));
34
+ const currentByEngine = new Map(current.map((store) => [store.engine, store]));
35
+ const added = current.filter((store) => !baseByEngine.has(store.engine));
36
+ const removed = baseline.filter((store) => !currentByEngine.has(store.engine));
37
+ const changed = [];
38
+ for (const store of current) {
39
+ const before = baseByEngine.get(store.engine);
40
+ if (before && (before.confidence !== store.confidence || before.category !== store.category)) {
41
+ changed.push({
42
+ engine: store.engine,
43
+ from: `${before.category}/${before.confidence}`,
44
+ to: `${store.category}/${store.confidence}`,
45
+ });
46
+ }
47
+ }
48
+ return { added, removed, changed };
49
+ }
50
+ export function hasDrift(drift) {
51
+ return drift.added.length > 0 || drift.removed.length > 0 || drift.changed.length > 0;
52
+ }
53
+ function gitTrackedFiles(root) {
54
+ return execFileSync('git', ['-C', root, 'ls-files', '-z'], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 })
55
+ .split('\0')
56
+ .filter(Boolean);
57
+ }
58
+ // Files changed between a base ref and HEAD. Returns null if git cannot resolve
59
+ // the ref (e.g. a shallow clone missing the base) so the caller can fall back to
60
+ // a full check rather than a false "no store changes" skip.
61
+ function changedFiles(root, baseRef) {
62
+ try {
63
+ const range = `${baseRef}...HEAD`;
64
+ // --no-renames so a rename shows both the removed and added path. Otherwise
65
+ // renaming an input file to a non-input name (docker-compose.yml -> .bak)
66
+ // would report only the irrelevant destination and the gate would wrongly
67
+ // skip a change that actually dropped a store.
68
+ return execFileSync('git', ['-C', root, 'diff', '--name-only', '--no-renames', range], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })
69
+ .split('\n')
70
+ .filter(Boolean);
71
+ }
72
+ catch {
73
+ return null;
74
+ }
75
+ }
76
+ function currentStores(root) {
77
+ return collectDataStores(root, gitTrackedFiles(root)).map(snapshot);
78
+ }
79
+ function readBaseline(path) {
80
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
81
+ if (parsed.schema !== DATA_STORE_BASELINE_SCHEMA || !Array.isArray(parsed.stores)) {
82
+ throw new Error(`Not a data-store baseline (${DATA_STORE_BASELINE_SCHEMA}): ${path}`);
83
+ }
84
+ return parsed.stores;
85
+ }
86
+ function writeBaseline(path, stores) {
87
+ mkdirSync(dirname(path), { recursive: true });
88
+ writeFileSync(path, `${JSON.stringify({ schema: DATA_STORE_BASELINE_SCHEMA, stores }, null, 2)}\n`);
89
+ }
90
+ function emit(payload, json) {
91
+ if (json) {
92
+ process.stdout.write(`${JSON.stringify({ schema: 'cloud-verifier-data-store-drift-v1', ...payload }, null, 2)}\n`);
93
+ }
94
+ }
95
+ export function cloudVerifierDataStoreDriftCommand(options) {
96
+ const root = options.root ? resolve(options.root) : (findGitRoot() ?? process.cwd());
97
+ // resolve (not join) so an absolute --baseline is honored as-is and a relative
98
+ // one resolves against the repo root.
99
+ const baselinePath = resolve(root, options.baseline ?? DATA_STORE_BASELINE_PATH);
100
+ // Path gate: with a base ref, skip unless the diff touches a file the detector
101
+ // reads. This is exact — a file outside that set cannot change the stores.
102
+ if (options.baseRef && !options.update) {
103
+ const changed = changedFiles(root, options.baseRef);
104
+ if (changed !== null) {
105
+ const relevant = changed.filter((path) => isDataStoreInputName(basename(path).toLowerCase()));
106
+ if (relevant.length === 0) {
107
+ emit({ status: 'skipped', reason: 'no-store-relevant-changes', changed_files: changed.length }, options.json ?? false);
108
+ if (!options.json) {
109
+ process.stdout.write('Data-store drift: no store-relevant files changed — skipped.\n');
110
+ }
111
+ return;
112
+ }
113
+ }
114
+ }
115
+ const current = currentStores(root);
116
+ if (options.update) {
117
+ writeBaseline(baselinePath, current);
118
+ emit({ status: 'updated', baseline: options.baseline ?? DATA_STORE_BASELINE_PATH, stores: current }, options.json ?? false);
119
+ if (!options.json) {
120
+ process.stdout.write(`Data-store baseline written: ${current.length} stores → ${options.baseline ?? DATA_STORE_BASELINE_PATH}\n`);
121
+ }
122
+ return;
123
+ }
124
+ if (!existsSync(baselinePath)) {
125
+ // Not opted in yet: a safe no-op so the check can be added to CI broadly
126
+ // without breaking repos that have not created a baseline.
127
+ emit({ status: 'no-baseline', baseline: options.baseline ?? DATA_STORE_BASELINE_PATH }, options.json ?? false);
128
+ if (!options.json) {
129
+ process.stdout.write(`Data-store drift: no baseline at ${options.baseline ?? DATA_STORE_BASELINE_PATH}. `
130
+ + 'Create one with `--update`.\n');
131
+ }
132
+ return;
133
+ }
134
+ const drift = diffDataStores(readBaseline(baselinePath), current);
135
+ if (!hasDrift(drift)) {
136
+ emit({ status: 'ok', stores: current.length }, options.json ?? false);
137
+ if (!options.json) {
138
+ process.stdout.write(`Data-store drift: none — map matches ${current.length} detected stores.\n`);
139
+ }
140
+ return;
141
+ }
142
+ emit({ status: 'drift', drift }, options.json ?? false);
143
+ if (!options.json) {
144
+ process.stdout.write('Data-store drift detected — the universe map is out of date:\n');
145
+ for (const store of drift.added) {
146
+ process.stdout.write(` + ${store.engine} (${store.category}, ${store.confidence}) — detected, not in the map\n`);
147
+ }
148
+ for (const store of drift.removed) {
149
+ process.stdout.write(` - ${store.engine} (${store.category}) — in the map, no longer detected\n`);
150
+ }
151
+ for (const change of drift.changed) {
152
+ process.stdout.write(` ~ ${change.engine}: ${change.from} → ${change.to}\n`);
153
+ }
154
+ process.stdout.write('Sync the map with `--update`, or update the universe map to match.\n');
155
+ }
156
+ // Non-zero exit so a CI gate fails until the map is reconciled.
157
+ process.exitCode = 1;
158
+ }
@@ -0,0 +1,88 @@
1
+ import { type DataStore } from './cloud-verifier-data-store-census.js';
2
+ export declare const IDENTITY_CENSUS_SCHEMA_VERSION = "cloud-verifier-identity-census-v1";
3
+ export declare const IDENTITY_CENSUS_CONTRACT_REVISION = 39;
4
+ export type IdentityCensusProjection = 'runtime_roles' | 'stateful_resources' | 'external_dependencies' | 'registry_families' | 'registry_entries' | 'registry_edges';
5
+ export type IdentityCensusProofStatus = 'proof-complete' | 'discovery-lead' | 'non-inventory';
6
+ export interface IdentityCensusSource {
7
+ path: string;
8
+ start_line: number;
9
+ end_line: number;
10
+ anchor: string;
11
+ }
12
+ export interface IdentityCensusMatrixAxis {
13
+ symbol_identity_key: string;
14
+ item_identity_key: string;
15
+ item_value: string;
16
+ source: IdentityCensusSource;
17
+ }
18
+ export interface IdentityCensusRecord {
19
+ id: string;
20
+ kind: string;
21
+ projections: IdentityCensusProjection[];
22
+ presumptive_inventory: boolean;
23
+ proof_status: IdentityCensusProofStatus;
24
+ semantic_identity_id?: string;
25
+ execution_identity_id?: string;
26
+ identity_components?: Record<string, string | string[]>;
27
+ missing_proof_components?: string[];
28
+ owner_identity_key: string;
29
+ identity_key: string;
30
+ selector_key?: string;
31
+ implementation_key?: string;
32
+ operation_token?: string;
33
+ address_token?: string;
34
+ package_name?: string;
35
+ package_version?: string;
36
+ package_artifact_kind?: string;
37
+ package_artifact_filename?: string;
38
+ package_artifact_url?: string;
39
+ package_artifact_hash?: string;
40
+ operation_identity_key?: string;
41
+ materialization_root_identity_key?: string;
42
+ reproduction_operation_token?: string;
43
+ matrix_axes?: IdentityCensusMatrixAxis[];
44
+ selector_family_record_id?: string;
45
+ parent_selector_entry_record_id?: string;
46
+ child_selector_family_record_id?: string;
47
+ relation_kind?: 'implementation-owns-selector' | 'implementation-invokes-selector' | 'parent-key-partitions-selector';
48
+ source: IdentityCensusSource;
49
+ supporting_tokens: string[];
50
+ }
51
+ export interface IdentityCensusResult {
52
+ schema_version: typeof IDENTITY_CENSUS_SCHEMA_VERSION;
53
+ contract_revision: typeof IDENTITY_CENSUS_CONTRACT_REVISION;
54
+ repository_root: string;
55
+ source_commit: string | null;
56
+ source_tree: string | null;
57
+ source_manifest: {
58
+ digest: string;
59
+ tracked_files_total: number;
60
+ production_files_scanned: number;
61
+ files_omitted: number;
62
+ };
63
+ record_digest: string;
64
+ counts: {
65
+ records: number;
66
+ by_kind: Record<string, number>;
67
+ by_projection: Record<string, number>;
68
+ by_proof_status: Record<IdentityCensusProofStatus, number>;
69
+ presumptive_inventory: number;
70
+ };
71
+ projection_record_ids: Record<IdentityCensusProjection, string[]>;
72
+ records: IdentityCensusRecord[];
73
+ omissions: Array<{
74
+ path: string;
75
+ reason: string;
76
+ }>;
77
+ data_stores: DataStore[];
78
+ }
79
+ export declare function isDataStoreInputName(lowerName: string): boolean;
80
+ export declare function collectDataStores(root: string, tracked: string[], omissions?: Array<{
81
+ path: string;
82
+ reason: string;
83
+ }>): DataStore[];
84
+ export declare function scanUniverseIdentities(repositoryRoot: string): IdentityCensusResult;
85
+ export declare function cloudVerifierIdentityCensusCommand(options: {
86
+ json?: boolean;
87
+ root?: string;
88
+ }): void;