@haystackeditor/cli 0.25.1 → 0.27.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/README.md +39 -463
- package/dist/capture/app-config.js +30 -6
- package/dist/commands/capture-brief.js +45 -35
- package/dist/commands/capture-contract.js +4 -4
- package/dist/commands/crawl-report.js +196 -0
- package/dist/commands/db-profile-upload.js +3 -3
- package/dist/commands/feedback.js +66 -0
- package/dist/commands/init-telemetry.js +55 -9
- package/dist/commands/init.js +8 -3
- package/dist/commands/lockfile-pin.js +307 -0
- package/dist/commands/telemetry-token.js +3 -3
- package/dist/commands/tokens.js +4 -4
- package/dist/commands/verify-explore.js +3 -3
- package/dist/commands/verify-history.js +2 -2
- package/dist/commands/verify-onboarding.js +13 -16
- package/dist/commands/verify-precompute.js +3 -4
- package/dist/commands/verify.js +31 -118
- package/dist/index.js +55 -968
- package/dist/schema.js +4 -10
- package/dist/utils/haystack-api.js +8 -36
- package/package.json +1 -5
- package/schemas/feedback.v1.json +13 -0
- package/schemas/pre-verify.v2.json +240 -0
- package/schemas/verify-raw.v1.json +1132 -0
- package/schemas/verify.v2.json +655 -0
- package/dist/assets/hooks/agent-context/detect.ts +0 -316
- package/dist/assets/hooks/agent-context/format.ts +0 -100
- package/dist/assets/hooks/agent-context/index.ts +0 -41
- package/dist/assets/hooks/agent-context/parsers/claude.ts +0 -262
- package/dist/assets/hooks/agent-context/parsers/codex.ts +0 -416
- package/dist/assets/hooks/agent-context/parsers/gemini.ts +0 -155
- package/dist/assets/hooks/agent-context/parsers/opencode.ts +0 -174
- package/dist/assets/hooks/agent-context/tsconfig.json +0 -14
- package/dist/assets/hooks/agent-context/types.ts +0 -58
- package/dist/assets/hooks/llm-rules-template.md +0 -59
- package/dist/assets/hooks/package-lock.json +0 -598
- package/dist/assets/hooks/package.json +0 -12
- package/dist/assets/hooks/scripts/commit-msg.sh +0 -5
- package/dist/assets/hooks/scripts/post-commit.sh +0 -5
- package/dist/assets/hooks/scripts/pre-commit.sh +0 -175
- package/dist/assets/hooks/scripts/pre-push.sh +0 -25
- package/dist/assets/hooks/scripts/prepare-commit-msg.sh +0 -5
- package/dist/assets/hooks/truncation-checker/ast-analyzer.ts +0 -528
- package/dist/assets/hooks/truncation-checker/index.ts +0 -595
- package/dist/assets/hooks/truncation-checker/tsconfig.json +0 -13
- package/dist/assets/skills/map-cloud-verifier-universe/SKILL.md +0 -2051
- package/dist/assets/skills/map-cloud-verifier-universe/agents/openai.yaml +0 -4
- package/dist/assets/skills/map-cloud-verifier-universe/references/output-contract.md +0 -3411
- package/dist/assets/skills/map-your-system.md +0 -143
- package/dist/assets/skills/submit.md +0 -200
- package/dist/commands/ask.js +0 -20
- package/dist/commands/cloud-verifier-behaviors.js +0 -218
- package/dist/commands/cloud-verifier-data-store-census.js +0 -539
- package/dist/commands/cloud-verifier-data-store-drift.js +0 -158
- package/dist/commands/cloud-verifier-identity-census.js +0 -4060
- package/dist/commands/cloud-verifier-materialization.js +0 -704
- package/dist/commands/cloud-verifier-pascal-selector-census.js +0 -1382
- package/dist/commands/cloud-verifier-python-manifest-selector-census.js +0 -2015
- package/dist/commands/cloud-verifier-specialized-operational-census.js +0 -11432
- package/dist/commands/cloud-verifier-universe.js +0 -10178
- package/dist/commands/config.js +0 -549
- package/dist/commands/design-verify.js +0 -311
- package/dist/commands/dismiss.js +0 -159
- package/dist/commands/hooks.js +0 -226
- package/dist/commands/inbox.js +0 -137
- package/dist/commands/mcp.js +0 -201
- package/dist/commands/policy.js +0 -371
- package/dist/commands/pr-status.js +0 -207
- package/dist/commands/pr.js +0 -105
- package/dist/commands/prepare-universe-review.js +0 -1092
- package/dist/commands/production-source-deny-policy.js +0 -100
- package/dist/commands/request-review.js +0 -74
- package/dist/commands/review.js +0 -191
- package/dist/commands/rules.js +0 -98
- package/dist/commands/scaffold-provisional-universe.js +0 -806
- package/dist/commands/setup.js +0 -1170
- package/dist/commands/skills.js +0 -447
- package/dist/commands/status.js +0 -35
- package/dist/commands/submit.js +0 -745
- package/dist/commands/system-map.js +0 -228
- package/dist/commands/triage.js +0 -598
- package/dist/commands/webhooks.js +0 -241
- package/dist/states.js +0 -46
- package/dist/tools/detect.js +0 -832
- package/dist/triage/astra.js +0 -202
- package/dist/triage/prompts.js +0 -188
- package/dist/triage/runner.js +0 -200
- package/dist/triage/types.js +0 -7
- package/dist/types.js +0 -326
- package/dist/utils/action-output.js +0 -26
- package/dist/utils/analysis-api.js +0 -416
- package/dist/utils/config.js +0 -54
- package/dist/utils/design-verifier-api.js +0 -294
- package/dist/utils/design-verifier-history.js +0 -79
- package/dist/utils/design-verifier-result.js +0 -424
- package/dist/utils/github-api.js +0 -324
- package/dist/utils/pending-state.js +0 -86
- package/dist/utils/pr-ref.js +0 -56
- package/dist/utils/prompter.js +0 -328
- package/schemas/action.v1.json +0 -22
- package/schemas/ask.v1.json +0 -40
- package/schemas/inbox.v1.json +0 -27
- package/schemas/pr-status.v1.json +0 -61
- package/schemas/pr.v1.json +0 -97
- package/schemas/pr.v3.json +0 -45
- package/schemas/setup.v1.json +0 -75
- package/schemas/submit.v1.json +0 -90
- package/schemas/triage.v1.json +0 -103
- package/schemas/triage.v2.json +0 -64
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `haystack system-map validate` — instant feedback on `.haystack/system.yml`.
|
|
3
|
-
*
|
|
4
|
-
* The system map holds customer-declared facts about how their system WORKS
|
|
5
|
-
* (build, boot, seed, log in, observe) so Haystack QA can run it. It never
|
|
6
|
-
* selects tests — Haystack decides what to test from each PR's diff. The
|
|
7
|
-
* `/map-your-system` skill authors the file; this command lets a user (or
|
|
8
|
-
* their coding agent) check it before committing, instead of waiting for the
|
|
9
|
-
* next QA run to reject it.
|
|
10
|
-
*
|
|
11
|
-
* Source-of-truth note: the QA pipeline's own loader for this file
|
|
12
|
-
* (`analysis/src/agents/systemMap.ts`) lives on the incoming QA-replay
|
|
13
|
-
* subsystem branch and is NOT on main yet — until it lands, this command is
|
|
14
|
-
* the only validator of the format, and its rules were copied verbatim from
|
|
15
|
-
* that loader. Once the subsystem merges, the analysis-side loader becomes
|
|
16
|
-
* the source of truth (it is a separate deployable the CLI cannot import),
|
|
17
|
-
* and rule changes must update both in the same PR.
|
|
18
|
-
*/
|
|
19
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
20
|
-
import { join } from 'node:path';
|
|
21
|
-
import chalk from 'chalk';
|
|
22
|
-
import { parse as parseYaml } from 'yaml';
|
|
23
|
-
import { findGitRoot } from '../utils/hooks.js';
|
|
24
|
-
const SYSTEM_MAP_RELATIVE_PATHS = ['.haystack/system.yml', '.haystack/system.yaml'];
|
|
25
|
-
/**
|
|
26
|
-
* Keys whose presence means the file is steering test selection rather than
|
|
27
|
-
* describing the system. Rejected structurally so the "facts in, never test
|
|
28
|
-
* selection in" rule cannot erode.
|
|
29
|
-
*/
|
|
30
|
-
const TEST_SELECTION_KEYS = new Set([
|
|
31
|
-
'scenarios', 'tests', 'tests_to_run', 'run_tests', 'skip', 'skip_tests',
|
|
32
|
-
'focus', 'only', 'exclude', 'test_plan', 'experiments',
|
|
33
|
-
]);
|
|
34
|
-
/** Values that look like credentials rather than references to them. */
|
|
35
|
-
const SECRET_VALUE_RES = [
|
|
36
|
-
{ name: 'AWS access key', re: /AKIA[0-9A-Z]{16}/ },
|
|
37
|
-
{ name: 'GitHub token', re: /gh[pousr]_[A-Za-z0-9]{36,}/ },
|
|
38
|
-
{ name: 'API key', re: /sk-[A-Za-z0-9_-]{24,}/ },
|
|
39
|
-
{ name: 'private key block', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ },
|
|
40
|
-
{ name: 'password-like assignment', re: /(password|passwd|secret)\s*[:=]\s*\S{8,}/i },
|
|
41
|
-
];
|
|
42
|
-
export function validateSystemMapText(rawYaml) {
|
|
43
|
-
const issues = [];
|
|
44
|
-
let doc;
|
|
45
|
-
try {
|
|
46
|
-
doc = parseYaml(rawYaml);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return {
|
|
50
|
-
issues: [{ severity: 'error', path: '(root)', message: `YAML parse error: ${error.message}` }],
|
|
51
|
-
summary: null,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (!doc || typeof doc !== 'object' || Array.isArray(doc)) {
|
|
55
|
-
return {
|
|
56
|
-
issues: [{ severity: 'error', path: '(root)', message: 'System map must be a mapping' }],
|
|
57
|
-
summary: null,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const root = doc;
|
|
61
|
-
if (root.version !== 1 && root.version !== '1') {
|
|
62
|
-
issues.push({ severity: 'error', path: 'version', message: 'version must be 1' });
|
|
63
|
-
}
|
|
64
|
-
for (const key of Object.keys(root)) {
|
|
65
|
-
if (TEST_SELECTION_KEYS.has(key)) {
|
|
66
|
-
issues.push({
|
|
67
|
-
severity: 'error',
|
|
68
|
-
path: key,
|
|
69
|
-
message: `"${key}" steers test selection — the system map may only describe how the system works. Haystack decides what to test from the diff.`,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
scanForSecrets(root, '(root)', issues);
|
|
74
|
-
validateCommands(root, issues);
|
|
75
|
-
if (issues.some((issue) => issue.severity === 'error')) {
|
|
76
|
-
return { issues, summary: null };
|
|
77
|
-
}
|
|
78
|
-
return { issues, summary: summarize(root) };
|
|
79
|
-
}
|
|
80
|
-
function scanForSecrets(value, atPath, issues) {
|
|
81
|
-
if (typeof value === 'string') {
|
|
82
|
-
for (const { name, re } of SECRET_VALUE_RES) {
|
|
83
|
-
if (re.test(value)) {
|
|
84
|
-
issues.push({
|
|
85
|
-
severity: 'error',
|
|
86
|
-
path: atPath,
|
|
87
|
-
message: `Value looks like a ${name}. Facts must reference env var NAMES; secret values are injected out-of-band.`,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (Array.isArray(value)) {
|
|
94
|
-
value.forEach((entry, index) => scanForSecrets(entry, `${atPath}[${index}]`, issues));
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (value && typeof value === 'object') {
|
|
98
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
99
|
-
scanForSecrets(entry, atPath === '(root)' ? key : `${atPath}.${key}`, issues);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function validateCommands(root, issues) {
|
|
104
|
-
const requireString = (value, atPath) => {
|
|
105
|
-
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
106
|
-
issues.push({ severity: 'error', path: atPath, message: 'must be a non-empty string command' });
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const env = root.environment;
|
|
110
|
-
if (env?.setup !== undefined) {
|
|
111
|
-
if (!Array.isArray(env.setup)) {
|
|
112
|
-
issues.push({ severity: 'error', path: 'environment.setup', message: 'must be a list of { run } steps' });
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
env.setup.forEach((step, index) => requireString(step?.run, `environment.setup[${index}].run`));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Not in the QA loader's checks (yet): a scalar here would silently compile
|
|
119
|
-
// into per-character garbage via Object.entries — reject it as malformed.
|
|
120
|
-
if (env?.toolchain !== undefined && !isPlainObject(env.toolchain)) {
|
|
121
|
-
issues.push({
|
|
122
|
-
severity: 'error',
|
|
123
|
-
path: 'environment.toolchain',
|
|
124
|
-
message: 'must be a mapping of tool name → version (e.g. { node: "22" })',
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const services = root.services;
|
|
128
|
-
for (const [name, service] of Object.entries(services ?? {})) {
|
|
129
|
-
requireString(service?.boot, `services.${name}.boot`);
|
|
130
|
-
}
|
|
131
|
-
const personas = root.data?.personas;
|
|
132
|
-
for (const [name, persona] of Object.entries(personas ?? {})) {
|
|
133
|
-
requireString(persona?.login, `data.personas.${name}.login`);
|
|
134
|
-
}
|
|
135
|
-
const artifacts = root.artifacts;
|
|
136
|
-
for (const [name, artifact] of Object.entries(artifacts ?? {})) {
|
|
137
|
-
const decl = artifact;
|
|
138
|
-
if (decl?.kind !== 'container-image') {
|
|
139
|
-
issues.push({
|
|
140
|
-
severity: 'error',
|
|
141
|
-
path: `artifacts.${name}.kind`,
|
|
142
|
-
message: 'must be "container-image" (the only artifact kind supported today)',
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
requireString(decl?.reference, `artifacts.${name}.reference`);
|
|
146
|
-
if (decl?.boot !== undefined) {
|
|
147
|
-
if (!Array.isArray(decl.boot)) {
|
|
148
|
-
issues.push({ severity: 'error', path: `artifacts.${name}.boot`, message: 'must be a list of { name } boot modes' });
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
decl.boot.forEach((mode, index) => requireString(mode?.name, `artifacts.${name}.boot[${index}].name`));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function isPlainObject(value) {
|
|
157
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
158
|
-
}
|
|
159
|
-
function summarize(root) {
|
|
160
|
-
const env = (root.environment ?? {});
|
|
161
|
-
const data = (root.data ?? {});
|
|
162
|
-
const observability = (root.observability ?? {});
|
|
163
|
-
const testing = (root.testing ?? {});
|
|
164
|
-
return {
|
|
165
|
-
setup_steps: Array.isArray(env.setup) ? env.setup.length : 0,
|
|
166
|
-
toolchain_entries: isPlainObject(env.toolchain) ? Object.keys(env.toolchain).length : 0,
|
|
167
|
-
services: Object.keys((root.services ?? {})),
|
|
168
|
-
personas: Object.keys(data.personas ?? {}),
|
|
169
|
-
data_commands: (data.seed ? 1 : 0) + (data.reset ? 1 : 0),
|
|
170
|
-
observability_entries: (Array.isArray(observability.logs) ? observability.logs.length : 0) + (observability.inspect_db ? 1 : 0),
|
|
171
|
-
external_services: Object.keys((root.external_services ?? {})),
|
|
172
|
-
testing_entries: Object.keys(testing).length,
|
|
173
|
-
constraints: Array.isArray(root.constraints) ? root.constraints.length : 0,
|
|
174
|
-
artifacts: Object.keys((root.artifacts ?? {})),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
export async function systemMapValidateCommand(options) {
|
|
178
|
-
const root = findGitRoot() ?? process.cwd();
|
|
179
|
-
const relativePath = SYSTEM_MAP_RELATIVE_PATHS.find((candidate) => existsSync(join(root, candidate)));
|
|
180
|
-
if (!relativePath) {
|
|
181
|
-
if (options.json) {
|
|
182
|
-
console.log(JSON.stringify({ status: 'missing', path: SYSTEM_MAP_RELATIVE_PATHS[0], issues: [] }, null, 2));
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.error(chalk.red(`No system map found at ${SYSTEM_MAP_RELATIVE_PATHS[0]}.`) +
|
|
186
|
-
' Run the /map-your-system skill in your coding agent (installed via `haystack skills install`) to create one.');
|
|
187
|
-
}
|
|
188
|
-
process.exit(1);
|
|
189
|
-
}
|
|
190
|
-
const { issues, summary } = validateSystemMapText(readFileSync(join(root, relativePath), 'utf-8'));
|
|
191
|
-
const ok = summary !== null;
|
|
192
|
-
if (options.json) {
|
|
193
|
-
console.log(JSON.stringify({ status: ok ? 'valid' : 'invalid', path: relativePath, issues, summary }, null, 2));
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
for (const issue of issues) {
|
|
197
|
-
const bullet = issue.severity === 'error' ? chalk.red('✗') : chalk.yellow('•');
|
|
198
|
-
console.log(`${bullet} ${chalk.white(issue.path)}: ${issue.message}`);
|
|
199
|
-
}
|
|
200
|
-
if (!ok) {
|
|
201
|
-
console.log();
|
|
202
|
-
console.log(chalk.red(`${relativePath} is invalid — fix the errors above.`));
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
const declared = [];
|
|
206
|
-
if (summary.setup_steps)
|
|
207
|
-
declared.push(`${summary.setup_steps} setup step(s)`);
|
|
208
|
-
if (summary.services.length)
|
|
209
|
-
declared.push(`services: ${summary.services.join(', ')}`);
|
|
210
|
-
if (summary.personas.length)
|
|
211
|
-
declared.push(`personas: ${summary.personas.join(', ')}`);
|
|
212
|
-
if (summary.data_commands)
|
|
213
|
-
declared.push(`${summary.data_commands} data command(s)`);
|
|
214
|
-
if (summary.external_services.length)
|
|
215
|
-
declared.push(`external: ${summary.external_services.join(', ')}`);
|
|
216
|
-
if (summary.artifacts.length)
|
|
217
|
-
declared.push(`artifacts: ${summary.artifacts.join(', ')}`);
|
|
218
|
-
if (summary.testing_entries)
|
|
219
|
-
declared.push('testing');
|
|
220
|
-
if (summary.constraints)
|
|
221
|
-
declared.push(`${summary.constraints} constraint(s)`);
|
|
222
|
-
console.log(chalk.green(`✓ ${relativePath} is valid`) + (declared.length ? chalk.dim(` — ${declared.join('; ')}`) : ''));
|
|
223
|
-
console.log(chalk.dim('When Haystack QA runs on this repo, each entry is treated as a declared fact and checked against run receipts.'));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (!ok)
|
|
227
|
-
process.exit(1);
|
|
228
|
-
}
|