@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,174 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import type {
|
|
3
|
-
AgentContext,
|
|
4
|
-
AgentParser,
|
|
5
|
-
DetectionResult,
|
|
6
|
-
InteractionTurn,
|
|
7
|
-
ModifiedFile,
|
|
8
|
-
TokenUsage,
|
|
9
|
-
ToolUseInfo,
|
|
10
|
-
} from '../types.js';
|
|
11
|
-
import { detectAgent } from '../detect.js';
|
|
12
|
-
|
|
13
|
-
const FILE_MOD_TOOLS = new Set(['edit', 'write', 'patch']);
|
|
14
|
-
|
|
15
|
-
interface OpenCodeTokens {
|
|
16
|
-
input?: number;
|
|
17
|
-
output?: number;
|
|
18
|
-
cache?: {
|
|
19
|
-
read?: number;
|
|
20
|
-
write?: number;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface OpenCodePart {
|
|
25
|
-
type: 'text' | 'tool';
|
|
26
|
-
text?: string;
|
|
27
|
-
tool?: string;
|
|
28
|
-
state?: {
|
|
29
|
-
input?: Record<string, unknown>;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface OpenCodeMessage {
|
|
34
|
-
info: {
|
|
35
|
-
id?: string;
|
|
36
|
-
role: 'user' | 'assistant';
|
|
37
|
-
createdAt?: string;
|
|
38
|
-
tokens?: OpenCodeTokens;
|
|
39
|
-
};
|
|
40
|
-
parts: OpenCodePart[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface OpenCodeSession {
|
|
44
|
-
info: {
|
|
45
|
-
id: string;
|
|
46
|
-
title?: string;
|
|
47
|
-
createdAt?: string;
|
|
48
|
-
updatedAt?: string;
|
|
49
|
-
};
|
|
50
|
-
messages: OpenCodeMessage[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function extractTextContent(parts: OpenCodePart[]): string {
|
|
54
|
-
return parts
|
|
55
|
-
.filter((p) => p.type === 'text' && p.text)
|
|
56
|
-
.map((p) => p.text!)
|
|
57
|
-
.join('\n');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function extractModifiedFiles(parts: OpenCodePart[]): ModifiedFile[] {
|
|
61
|
-
const files: ModifiedFile[] = [];
|
|
62
|
-
for (const part of parts) {
|
|
63
|
-
if (part.type !== 'tool' || !part.tool) continue;
|
|
64
|
-
if (!FILE_MOD_TOOLS.has(part.tool)) continue;
|
|
65
|
-
|
|
66
|
-
const input = part.state?.input;
|
|
67
|
-
if (!input) continue;
|
|
68
|
-
|
|
69
|
-
const filePath = (input.filePath as string) || (input.path as string);
|
|
70
|
-
if (filePath) {
|
|
71
|
-
files.push({
|
|
72
|
-
filePath,
|
|
73
|
-
toolName: part.tool,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return files;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function extractToolUses(parts: OpenCodePart[]): ToolUseInfo[] {
|
|
81
|
-
const tools: ToolUseInfo[] = [];
|
|
82
|
-
for (const part of parts) {
|
|
83
|
-
if (part.type !== 'tool' || !part.tool) continue;
|
|
84
|
-
tools.push({
|
|
85
|
-
toolName: part.tool,
|
|
86
|
-
toolUseId: '',
|
|
87
|
-
input: (part.state?.input as Record<string, unknown>) || {},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return tools;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export class OpenCodeParser implements AgentParser {
|
|
94
|
-
async detect(repoPath: string): Promise<DetectionResult> {
|
|
95
|
-
return detectAgent(repoPath);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async parse(
|
|
99
|
-
sessionFilePath: string,
|
|
100
|
-
_repoPath: string,
|
|
101
|
-
): Promise<AgentContext> {
|
|
102
|
-
const raw = fs.readFileSync(sessionFilePath, 'utf-8');
|
|
103
|
-
const session: OpenCodeSession = JSON.parse(raw);
|
|
104
|
-
const messages = session.messages || [];
|
|
105
|
-
|
|
106
|
-
const transcript: InteractionTurn[] = [];
|
|
107
|
-
const totalUsage: TokenUsage = {
|
|
108
|
-
inputTokens: 0,
|
|
109
|
-
outputTokens: 0,
|
|
110
|
-
cacheCreationTokens: 0,
|
|
111
|
-
cacheReadTokens: 0,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
let taskPrompt = '';
|
|
115
|
-
|
|
116
|
-
for (let i = 0; i < messages.length; i++) {
|
|
117
|
-
const msg = messages[i];
|
|
118
|
-
const role = msg.info.role;
|
|
119
|
-
const content = extractTextContent(msg.parts);
|
|
120
|
-
|
|
121
|
-
if (role === 'user' && !taskPrompt && content) {
|
|
122
|
-
taskPrompt = content;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const tokens = msg.info.tokens;
|
|
126
|
-
if (tokens) {
|
|
127
|
-
totalUsage.inputTokens += tokens.input || 0;
|
|
128
|
-
totalUsage.outputTokens += tokens.output || 0;
|
|
129
|
-
totalUsage.cacheReadTokens! += tokens.cache?.read || 0;
|
|
130
|
-
totalUsage.cacheCreationTokens! += tokens.cache?.write || 0;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
transcript.push({
|
|
134
|
-
turnIndex: i,
|
|
135
|
-
role,
|
|
136
|
-
content,
|
|
137
|
-
modifiedFiles:
|
|
138
|
-
role === 'assistant' ? extractModifiedFiles(msg.parts) : [],
|
|
139
|
-
tokenUsage: tokens
|
|
140
|
-
? {
|
|
141
|
-
inputTokens: tokens.input || 0,
|
|
142
|
-
outputTokens: tokens.output || 0,
|
|
143
|
-
cacheReadTokens: tokens.cache?.read,
|
|
144
|
-
cacheCreationTokens: tokens.cache?.write,
|
|
145
|
-
}
|
|
146
|
-
: undefined,
|
|
147
|
-
toolUses: role === 'assistant' ? extractToolUses(msg.parts) : [],
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const allModifiedFiles = new Set<string>();
|
|
152
|
-
for (const turn of transcript) {
|
|
153
|
-
for (const f of turn.modifiedFiles) {
|
|
154
|
-
allModifiedFiles.add(f.filePath);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const stat = fs.statSync(sessionFilePath);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
agent: 'opencode',
|
|
162
|
-
sessionId: session.info.id,
|
|
163
|
-
sessionFilePath,
|
|
164
|
-
taskPrompt,
|
|
165
|
-
modifiedFiles: Array.from(allModifiedFiles),
|
|
166
|
-
tokenUsage: totalUsage,
|
|
167
|
-
transcript,
|
|
168
|
-
metadata: {
|
|
169
|
-
startedAt: session.info.createdAt,
|
|
170
|
-
sessionFileModifiedAt: stat.mtime.toISOString(),
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "Node16",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"types": ["node"],
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["./**/*.ts"]
|
|
14
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export type AgentType = 'claude-code' | 'gemini-cli' | 'opencode' | 'codex';
|
|
2
|
-
|
|
3
|
-
export interface ModifiedFile {
|
|
4
|
-
filePath: string;
|
|
5
|
-
toolName: string;
|
|
6
|
-
toolUseId?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface TokenUsage {
|
|
10
|
-
inputTokens: number;
|
|
11
|
-
outputTokens: number;
|
|
12
|
-
cacheCreationTokens?: number;
|
|
13
|
-
cacheReadTokens?: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ToolUseInfo {
|
|
17
|
-
toolName: string;
|
|
18
|
-
toolUseId: string;
|
|
19
|
-
input: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface InteractionTurn {
|
|
23
|
-
turnIndex: number;
|
|
24
|
-
role: 'user' | 'assistant';
|
|
25
|
-
content: string;
|
|
26
|
-
modifiedFiles: ModifiedFile[];
|
|
27
|
-
tokenUsage?: TokenUsage;
|
|
28
|
-
toolUses: ToolUseInfo[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface AgentContext {
|
|
32
|
-
agent: AgentType;
|
|
33
|
-
sessionId: string;
|
|
34
|
-
sessionFilePath: string;
|
|
35
|
-
taskPrompt: string;
|
|
36
|
-
modifiedFiles: string[];
|
|
37
|
-
tokenUsage: TokenUsage;
|
|
38
|
-
transcript: InteractionTurn[];
|
|
39
|
-
metadata: {
|
|
40
|
-
model?: string;
|
|
41
|
-
version?: string;
|
|
42
|
-
gitBranch?: string;
|
|
43
|
-
startedAt?: string;
|
|
44
|
-
sessionFileModifiedAt: string;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface DetectionResult {
|
|
49
|
-
detected: boolean;
|
|
50
|
-
agent?: AgentType;
|
|
51
|
-
sessionFilePath?: string;
|
|
52
|
-
sessionId?: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface AgentParser {
|
|
56
|
-
detect(repoPath: string): Promise<DetectionResult>;
|
|
57
|
-
parse(sessionFilePath: string, repoPath: string): Promise<AgentContext>;
|
|
58
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# LLM Rules
|
|
2
|
-
|
|
3
|
-
These rules govern how LLM agents should interact with this codebase. They are enforced by a pre-commit hook.
|
|
4
|
-
|
|
5
|
-
## Creating Pull Requests
|
|
6
|
-
|
|
7
|
-
**Always use `haystack submit` instead of `gh pr create` or GitHub API.**
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Default submit - creates the PR from the current branch
|
|
11
|
-
haystack submit
|
|
12
|
-
|
|
13
|
-
# Request Haystack review - for complex/uncertain changes
|
|
14
|
-
haystack submit --review
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
This routes your PR through Haystack's submit workflow:
|
|
18
|
-
1. Haystack runs pre-PR triage on your changes
|
|
19
|
-
2. Pushes the current branch and creates the PR
|
|
20
|
-
3. Waits for analysis results by default
|
|
21
|
-
4. Auto-merges only if the repo has auto-merge enabled and the PR is approved
|
|
22
|
-
|
|
23
|
-
Do NOT use `gh pr create` - it bypasses Haystack's submit workflow.
|
|
24
|
-
|
|
25
|
-
After submitting, use `haystack triage <pr-number>` to check analysis results (rating, findings, agent fix prompts). Use `--json` for machine-readable output.
|
|
26
|
-
|
|
27
|
-
- When you write or edit LLM prompts in response to a failure running against some test data, be certain that your edit is not specific to the test data, and is actually addressing the more generic problem that caused the failure.
|
|
28
|
-
- If the user specifies a model, follow it. Your understanding of current LLM models is outdated.
|
|
29
|
-
- Do not add silent fallbacks.
|
|
30
|
-
- Do not add backwards compatibility, unless you confirmed with the user first that it's desired.
|
|
31
|
-
- Do not add TODOs and incomplete code unless they have been explicitly flagged to the user.
|
|
32
|
-
- When the user asks for a general or systematic fix, do not satisfy it with a check that only catches the known example. Implement the requested class of protection, or explicitly say what remains unfinished.
|
|
33
|
-
- Finish both sides of cross-boundary implementations. When adding a new keyed capability, mode, event, route, config value, feature flag, enum variant, or serialized field, verify and update every required consumer, producer, registry, allow-list, schema, persistence path, and delivery surface. If the existing system requires "also register it in X", do that wiring or explicitly report that it is intentionally out of scope.
|
|
34
|
-
|
|
35
|
-
## No Truncation Without Permission
|
|
36
|
-
|
|
37
|
-
When writing or modifying agent code (tool calls, prompts, LLM pipelines):
|
|
38
|
-
|
|
39
|
-
- **Never truncate, slice, or omit content** from tool call inputs, tool call outputs, prompt context, search results, file contents, or any data passed to/from LLMs without explicit user permission.
|
|
40
|
-
- **Never summarize in place of full content** (e.g., "... [content omitted]", "showing first 50 lines", "[truncated for brevity]").
|
|
41
|
-
- **No silent length limits** - do not add code that silently cuts off text at N characters/lines/tokens.
|
|
42
|
-
|
|
43
|
-
If truncation is technically necessary (e.g., context limits):
|
|
44
|
-
1. **Disclose explicitly** that truncation will occur
|
|
45
|
-
2. **State what and how much** will be omitted
|
|
46
|
-
3. **Ask for user permission** before proceeding
|
|
47
|
-
4. **Offer alternatives** (e.g., chunking, pagination with user control)
|
|
48
|
-
|
|
49
|
-
This applies to: grep/search results, file reads, API responses, prompt templates, tool definitions, agent memory, conversation history, and any other text flowing through agent pipelines.
|
|
50
|
-
|
|
51
|
-
## No Hardcoded Repo Knowledge in Prompts
|
|
52
|
-
|
|
53
|
-
When writing LLM prompts for generic tools:
|
|
54
|
-
|
|
55
|
-
- **Never hardcode repo-specific examples** like component names, file paths, or internal terminology.
|
|
56
|
-
- **Use generic examples** that would work for any codebase (e.g., "Sidebar", "Card", "Modal").
|
|
57
|
-
- **Let the LLM infer from context** rather than baking in assumptions about your specific codebase.
|
|
58
|
-
|
|
59
|
-
This keeps tools portable and prevents prompts from becoming stale when the codebase changes.
|