@haystackeditor/cli 0.25.0 → 0.26.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.
Files changed (113) hide show
  1. package/README.md +39 -455
  2. package/dist/capture/adapters/django.js +7 -0
  3. package/dist/capture/adapters/index.js +10 -0
  4. package/dist/capture/adapters/next-build.js +113 -0
  5. package/dist/capture/adapters/next.js +272 -105
  6. package/dist/capture/adapters/nuxt.js +7 -0
  7. package/dist/capture/adapters/rails.js +7 -0
  8. package/dist/capture/adapters/react-router.js +7 -0
  9. package/dist/capture/adapters/sveltekit.js +7 -0
  10. package/dist/capture/adapters/vite.js +14 -0
  11. package/dist/capture/app-config.js +27 -2
  12. package/dist/capture/csp.js +7 -6
  13. package/dist/capture/url-rewrites.js +232 -0
  14. package/dist/capture-step.js +3 -0
  15. package/dist/commands/capture-brief.js +41 -32
  16. package/dist/commands/capture-manifest.js +25 -17
  17. package/dist/commands/feedback.js +66 -0
  18. package/dist/commands/init-capture.js +44 -27
  19. package/dist/commands/init-telemetry.js +77 -14
  20. package/dist/commands/init.js +19 -4
  21. package/dist/commands/lockfile-pin.js +307 -0
  22. package/dist/commands/verify-onboarding.js +16 -0
  23. package/dist/commands/verify.js +70 -15
  24. package/dist/index.js +29 -923
  25. package/dist/schema.js +4 -10
  26. package/dist/utils/haystack-api.js +0 -36
  27. package/package.json +1 -5
  28. package/schemas/feedback.v1.json +13 -0
  29. package/schemas/init.v1.json +1 -1
  30. package/schemas/pre-verify.v2.json +240 -0
  31. package/schemas/verify-raw.v1.json +1132 -0
  32. package/schemas/verify.v2.json +655 -0
  33. package/dist/assets/hooks/agent-context/detect.ts +0 -316
  34. package/dist/assets/hooks/agent-context/format.ts +0 -100
  35. package/dist/assets/hooks/agent-context/index.ts +0 -41
  36. package/dist/assets/hooks/agent-context/parsers/claude.ts +0 -262
  37. package/dist/assets/hooks/agent-context/parsers/codex.ts +0 -416
  38. package/dist/assets/hooks/agent-context/parsers/gemini.ts +0 -155
  39. package/dist/assets/hooks/agent-context/parsers/opencode.ts +0 -174
  40. package/dist/assets/hooks/agent-context/tsconfig.json +0 -14
  41. package/dist/assets/hooks/agent-context/types.ts +0 -58
  42. package/dist/assets/hooks/llm-rules-template.md +0 -59
  43. package/dist/assets/hooks/package-lock.json +0 -598
  44. package/dist/assets/hooks/package.json +0 -12
  45. package/dist/assets/hooks/scripts/commit-msg.sh +0 -5
  46. package/dist/assets/hooks/scripts/post-commit.sh +0 -5
  47. package/dist/assets/hooks/scripts/pre-commit.sh +0 -175
  48. package/dist/assets/hooks/scripts/pre-push.sh +0 -25
  49. package/dist/assets/hooks/scripts/prepare-commit-msg.sh +0 -5
  50. package/dist/assets/hooks/truncation-checker/ast-analyzer.ts +0 -528
  51. package/dist/assets/hooks/truncation-checker/index.ts +0 -595
  52. package/dist/assets/hooks/truncation-checker/tsconfig.json +0 -13
  53. package/dist/assets/skills/map-cloud-verifier-universe/SKILL.md +0 -2051
  54. package/dist/assets/skills/map-cloud-verifier-universe/agents/openai.yaml +0 -4
  55. package/dist/assets/skills/map-cloud-verifier-universe/references/output-contract.md +0 -3411
  56. package/dist/assets/skills/map-your-system.md +0 -143
  57. package/dist/assets/skills/submit.md +0 -200
  58. package/dist/commands/ask.js +0 -20
  59. package/dist/commands/cloud-verifier-behaviors.js +0 -218
  60. package/dist/commands/cloud-verifier-data-store-census.js +0 -539
  61. package/dist/commands/cloud-verifier-data-store-drift.js +0 -158
  62. package/dist/commands/cloud-verifier-identity-census.js +0 -4060
  63. package/dist/commands/cloud-verifier-materialization.js +0 -704
  64. package/dist/commands/cloud-verifier-pascal-selector-census.js +0 -1382
  65. package/dist/commands/cloud-verifier-python-manifest-selector-census.js +0 -2015
  66. package/dist/commands/cloud-verifier-specialized-operational-census.js +0 -11432
  67. package/dist/commands/cloud-verifier-universe.js +0 -10178
  68. package/dist/commands/config.js +0 -549
  69. package/dist/commands/design-verify.js +0 -311
  70. package/dist/commands/dismiss.js +0 -159
  71. package/dist/commands/hooks.js +0 -226
  72. package/dist/commands/inbox.js +0 -137
  73. package/dist/commands/mcp.js +0 -201
  74. package/dist/commands/policy.js +0 -371
  75. package/dist/commands/pr-status.js +0 -207
  76. package/dist/commands/pr.js +0 -105
  77. package/dist/commands/prepare-universe-review.js +0 -1092
  78. package/dist/commands/production-source-deny-policy.js +0 -100
  79. package/dist/commands/request-review.js +0 -74
  80. package/dist/commands/review.js +0 -191
  81. package/dist/commands/rules.js +0 -98
  82. package/dist/commands/scaffold-provisional-universe.js +0 -806
  83. package/dist/commands/setup.js +0 -1170
  84. package/dist/commands/skills.js +0 -447
  85. package/dist/commands/submit.js +0 -745
  86. package/dist/commands/system-map.js +0 -228
  87. package/dist/commands/triage.js +0 -598
  88. package/dist/commands/webhooks.js +0 -241
  89. package/dist/states.js +0 -46
  90. package/dist/tools/detect.js +0 -832
  91. package/dist/triage/astra.js +0 -202
  92. package/dist/triage/prompts.js +0 -188
  93. package/dist/triage/runner.js +0 -200
  94. package/dist/triage/types.js +0 -7
  95. package/dist/utils/action-output.js +0 -26
  96. package/dist/utils/analysis-api.js +0 -416
  97. package/dist/utils/design-verifier-api.js +0 -294
  98. package/dist/utils/design-verifier-history.js +0 -79
  99. package/dist/utils/design-verifier-result.js +0 -424
  100. package/dist/utils/github-api.js +0 -324
  101. package/dist/utils/pending-state.js +0 -86
  102. package/dist/utils/pr-ref.js +0 -56
  103. package/dist/utils/prompter.js +0 -328
  104. package/schemas/action.v1.json +0 -22
  105. package/schemas/ask.v1.json +0 -40
  106. package/schemas/inbox.v1.json +0 -27
  107. package/schemas/pr-status.v1.json +0 -61
  108. package/schemas/pr.v1.json +0 -97
  109. package/schemas/pr.v3.json +0 -45
  110. package/schemas/setup.v1.json +0 -75
  111. package/schemas/submit.v1.json +0 -90
  112. package/schemas/triage.v1.json +0 -103
  113. 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
- }