@bilalimamoglu/sift 0.1.0 → 0.2.1

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 CHANGED
@@ -1,38 +1,18 @@
1
1
  # sift
2
2
 
3
- `sift` is a small wrapper for agent workflows.
3
+ `sift` is a small command-output reducer for agent workflows.
4
4
 
5
- Instead of giving a model the full output of `pytest`, `git diff`, `npm audit`, or `terraform plan`, you run the command through `sift`. `sift` captures the output, trims the noise, and returns a much smaller answer.
5
+ Instead of feeding a model the full output of `pytest`, `git diff`, `npm audit`, `tsc --noEmit`, `eslint .`, or `terraform plan`, you run the command through `sift`. It captures the output, trims the noise, and returns a much smaller answer.
6
6
 
7
- That answer can be short text or structured JSON.
7
+ Best fit:
8
+ - non-interactive shell commands
9
+ - agents that need short answers instead of full logs
10
+ - CI checks where a command may succeed but still produce a blocking result
8
11
 
9
- ## What it is
10
-
11
- - a command-output reducer for agents
12
- - best used with `sift exec ... -- <command>`
13
- - designed for non-interactive shell commands
14
- - compatible with OpenAI-style APIs
15
-
16
- ## What it is not
17
-
18
- - not a native Codex tool
19
- - not an MCP server
20
- - not a replacement for raw shell output when exact logs matter
21
- - not meant for TUI or interactive password/confirmation flows
22
-
23
- ## Why use it
24
-
25
- Large shell output is expensive and noisy.
26
-
27
- If an agent only needs to know:
28
- - did tests pass
29
- - what changed
30
- - are there critical vulnerabilities
31
- - is this infra plan risky
32
-
33
- then sending the full raw output to a large model is wasteful.
34
-
35
- `sift` keeps the shell command, but shrinks what the model has to read.
12
+ Not a fit:
13
+ - exact raw log inspection
14
+ - TUI tools
15
+ - password/confirmation prompts
36
16
 
37
17
  ## Installation
38
18
 
@@ -44,70 +24,84 @@ npm install -g @bilalimamoglu/sift
44
24
 
45
25
  ## One-time setup
46
26
 
47
- Set credentials once in your shell:
27
+ For OpenAI-hosted models:
48
28
 
49
29
  ```bash
30
+ export SIFT_PROVIDER=openai
50
31
  export SIFT_BASE_URL=https://api.openai.com/v1
51
- export SIFT_API_KEY=your_api_key
52
- export SIFT_MODEL=gpt-4.1-mini
32
+ export SIFT_MODEL=gpt-5-nano
33
+ export OPENAI_API_KEY=your_openai_api_key
53
34
  ```
54
35
 
55
- Or write them to a config file:
36
+ Or generate a config file:
56
37
 
57
38
  ```bash
58
39
  sift config init
59
40
  ```
60
41
 
61
- `sift` is remote-first today. The safe path is to set `SIFT_API_KEY`, `SIFT_BASE_URL`, and `SIFT_MODEL` once, then run `sift` normally.
42
+ If you use a different OpenAI-compatible endpoint, switch to `provider: openai-compatible` and use either the endpoint's native API key env var or the generic fallback:
43
+
44
+ ```bash
45
+ export SIFT_PROVIDER_API_KEY=your_provider_api_key
46
+ ```
47
+
48
+ Common compatible env fallbacks:
49
+ - `OPENROUTER_API_KEY`
50
+ - `TOGETHER_API_KEY`
51
+ - `GROQ_API_KEY`
62
52
 
63
53
  ## Quick start
64
54
 
65
55
  ```bash
66
56
  sift exec "what changed?" -- git diff
67
57
  sift exec --preset test-status -- pytest
58
+ sift exec --preset typecheck-summary -- tsc --noEmit
59
+ sift exec --preset lint-failures -- eslint .
68
60
  sift exec --preset audit-critical -- npm audit
69
61
  sift exec --preset infra-risk -- terraform plan
62
+ sift exec --preset audit-critical --fail-on -- npm audit
63
+ sift exec --preset infra-risk --fail-on -- terraform plan
70
64
  ```
71
65
 
72
66
  ## Main workflow
73
67
 
74
- `sift exec` is the main path:
68
+ `sift exec` is the default path:
75
69
 
76
70
  ```bash
77
71
  sift exec "did tests pass?" -- pytest
78
- sift exec "what changed?" -- git diff
79
- sift exec --preset infra-risk -- terraform plan
72
+ sift exec --dry-run "what changed?" -- git diff
80
73
  ```
81
74
 
82
- What happens:
75
+ What it does:
76
+ 1. runs the command
77
+ 2. captures `stdout` and `stderr`
78
+ 3. sanitizes, optionally redacts, and truncates the output
79
+ 4. sends the reduced input to a smaller model
80
+ 5. prints a short answer or JSON
81
+ 6. preserves the wrapped command's exit code
83
82
 
84
- 1. `sift` runs the command.
85
- 2. It captures `stdout` and `stderr`.
86
- 3. It sanitizes, optionally redacts, and truncates the result.
87
- 4. It sends the reduced input to a smaller model.
88
- 5. It prints a short answer or JSON.
89
- 6. It preserves the wrapped command's exit code.
83
+ Use `--dry-run` to inspect the reduced input and prompt without calling the provider.
90
84
 
91
- ## Pipe mode
85
+ Use `--fail-on` when a built-in semantic preset should turn a technically successful command into a CI failure. Supported presets:
86
+ - `infra-risk`
87
+ - `audit-critical`
92
88
 
93
- If the output already exists in a pipeline, pipe mode still works:
89
+ Pipe mode still works when output already exists:
94
90
 
95
91
  ```bash
96
92
  git diff 2>&1 | sift "what changed?"
97
93
  ```
98
94
 
99
- Use pipe mode when the command is already being produced elsewhere.
95
+ ## Built-in presets
100
96
 
101
- ## Presets
102
-
103
- Built-in presets:
104
-
105
- - `test-status`
106
- - `audit-critical`
107
- - `diff-summary`
108
- - `build-failure`
109
- - `log-errors`
110
- - `infra-risk`
97
+ - `test-status`: summarize test results
98
+ - `typecheck-summary`: group blocking type errors by root cause
99
+ - `lint-failures`: group repeated lint violations and highlight the files or rules that matter
100
+ - `audit-critical`: extract only high and critical vulnerabilities
101
+ - `infra-risk`: return a safety verdict for infra changes
102
+ - `diff-summary`: summarize code changes and risks
103
+ - `build-failure`: explain the most likely build failure
104
+ - `log-errors`: extract the most relevant error signals
111
105
 
112
106
  Inspect them with:
113
107
 
@@ -118,135 +112,89 @@ sift presets show audit-critical
118
112
 
119
113
  ## Output modes
120
114
 
121
- - `brief`: short plain-text answer
122
- - `bullets`: short bullet list
123
- - `json`: structured JSON
124
- - `verdict`: `{ verdict, reason, evidence }`
115
+ - `brief`
116
+ - `bullets`
117
+ - `json`
118
+ - `verdict`
125
119
 
126
- Some built-in presets also use local heuristics before calling a model. For example, `infra-risk` can mark obvious destructive plans as `fail` without sending the whole decision to the model.
120
+ Built-in JSON and verdict flows return strict error objects on provider or model failure.
127
121
 
128
122
  ## Config
129
123
 
130
- Generate an example config:
124
+ Useful commands:
131
125
 
132
126
  ```bash
133
127
  sift config init
128
+ sift config show
129
+ sift config validate
130
+ sift doctor
134
131
  ```
135
132
 
136
- `sift config show` masks secret values by default. Use `sift config show --show-secrets` only when you explicitly need the raw values.
133
+ `sift config show` masks secrets by default. Use `--show-secrets` only when you explicitly need raw values.
137
134
 
138
135
  Resolution order:
139
-
140
136
  1. CLI flags
141
137
  2. environment variables
142
138
  3. `sift.config.yaml` or `sift.config.yml`
143
139
  4. `~/.config/sift/config.yaml` or `~/.config/sift/config.yml`
144
140
  5. built-in defaults
145
141
 
146
- If you pass `--config <path>`, that path is treated strictly. Missing explicit config paths are errors; `sift` does not silently fall back to defaults in that case.
147
-
148
- Supported environment variables:
149
-
150
- - `SIFT_PROVIDER`
151
- - `SIFT_MODEL`
152
- - `SIFT_BASE_URL`
153
- - `SIFT_API_KEY`
154
- - `SIFT_MAX_CAPTURE_CHARS`
155
- - `SIFT_TIMEOUT_MS`
156
- - `SIFT_MAX_INPUT_CHARS`
142
+ If you pass `--config <path>`, that path is strict. Missing explicit config paths are errors.
157
143
 
158
- Example config:
144
+ Minimal example:
159
145
 
160
146
  ```yaml
161
147
  provider:
162
- provider: openai-compatible
163
- model: gpt-4.1-mini
148
+ provider: openai
149
+ model: gpt-5-nano
164
150
  baseUrl: https://api.openai.com/v1
165
151
  apiKey: YOUR_API_KEY
166
- timeoutMs: 20000
167
- temperature: 0.1
168
- maxOutputTokens: 220
169
152
 
170
153
  input:
171
154
  stripAnsi: true
172
- redact: true
173
- redactStrict: false
174
- maxCaptureChars: 250000
175
- maxInputChars: 20000
176
- headChars: 6000
177
- tailChars: 6000
155
+ redact: false
156
+ maxCaptureChars: 400000
157
+ maxInputChars: 60000
178
158
 
179
159
  runtime:
180
160
  rawFallback: true
181
- verbose: false
182
- ```
183
-
184
- ## Commands
185
-
186
- ```bash
187
- sift [question]
188
- sift preset <name>
189
- sift exec [question] -- <program> [args...]
190
- sift exec --preset <name> -- <program> [args...]
191
- sift exec [question] --shell "<command string>"
192
- sift exec --preset <name> --shell "<command string>"
193
- sift config init
194
- sift config show
195
- sift config validate
196
- sift doctor
197
- sift presets list
198
- sift presets show <name>
199
161
  ```
200
162
 
201
- ## Using it with Codex
202
-
203
- `sift` does not install itself into Codex. The normal setup is:
163
+ ## Agent usage
204
164
 
205
- 1. put credentials in your shell environment or `sift.config.yaml`
206
- 2. add a short rule to `~/.codex/AGENTS.md`
165
+ For Claude Code, add a short rule to `CLAUDE.md`.
207
166
 
208
- That way Codex inherits credentials safely. It should not pass API keys inline on every command.
167
+ For Codex, add the same rule to `~/.codex/AGENTS.md`.
209
168
 
210
- Example:
211
-
212
- ```md
213
- Prefer `sift exec` for non-interactive shell commands whose output will be read or summarized.
214
- Use pipe mode only when the output already exists from another pipeline.
215
- Do not use `sift` when exact raw output is required.
216
- Do not use `sift` for interactive or TUI workflows.
217
- ```
218
-
219
- That gives the agent a simple habit:
220
-
221
- - run command through `sift exec` when a summary is enough
222
- - skip `sift` when exact output matters
169
+ The important part is simple:
170
+ - prefer `sift exec` for noisy shell commands
171
+ - skip `sift` when exact raw output matters
172
+ - keep credentials in your shell env or `sift.config.yaml`, never inline in prompts or agent instructions
223
173
 
224
174
  ## Safety and limits
225
175
 
226
- - Redaction is optional and regex-based.
227
- - Redaction is off by default. If command output may contain secrets, enable `--redact` or set it in config before sending output to a provider.
228
- - Built-in JSON and verdict flows return strict error objects on provider/model failure.
229
- - `sift exec` detects simple prompt-like output such as `[y/N]` or `password:` and skips reduction instead of guessing.
230
- - Pipe mode does not preserve upstream shell pipeline failures; use `set -o pipefail` if you need that behavior.
231
- - `sift exec` mirrors the wrapped command's exit code.
232
- - `sift doctor` is a conservative local config check. For the default OpenAI-compatible path it requires `baseUrl`, `model`, and `apiKey`.
176
+ - redaction is optional and regex-based
177
+ - retriable provider failures such as `429`, timeouts, and `5xx` are retried once
178
+ - `sift exec` detects simple prompt-like output such as `[y/N]` or `password:` and skips reduction
179
+ - pipe mode does not preserve upstream shell pipeline failures; use `set -o pipefail` if you need that behavior
233
180
 
234
- ## Current scope
181
+ ## Releasing
235
182
 
236
- `sift` is intentionally small.
183
+ This repo uses a manual GitHub Actions release workflow with npm trusted publishing.
237
184
 
238
- Today it supports:
239
- - OpenAI-compatible providers
240
- - agent-first `exec` mode
241
- - pipe mode
242
- - presets
243
- - local redaction and truncation
244
- - strict JSON/verdict fallbacks
185
+ Release flow:
186
+ 1. bump `package.json`
187
+ 2. merge to `main`
188
+ 3. run the `release` workflow manually
245
189
 
246
- It does not try to be a full agent platform.
190
+ The workflow:
191
+ 1. installs dependencies
192
+ 2. runs typecheck, tests, and build
193
+ 3. packs and smoke-tests the tarball
194
+ 4. publishes to npm
195
+ 5. creates and pushes the `vX.Y.Z` tag
196
+ 6. creates a GitHub Release
247
197
 
248
198
  ## License
249
199
 
250
200
  MIT
251
-
252
- The top-level MIT license is the licensing surface for this repo. Per-file license headers are not required unless code is copied or adapted from another source that needs separate notice or attribution.