@bilalimamoglu/sift 0.1.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/LICENSE +21 -0
- package/README.md +252 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1346 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +990 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bilal Imamoglu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# sift
|
|
2
|
+
|
|
3
|
+
`sift` is a small wrapper for agent workflows.
|
|
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.
|
|
6
|
+
|
|
7
|
+
That answer can be short text or structured JSON.
|
|
8
|
+
|
|
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.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Requires Node.js 20 or later.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g @bilalimamoglu/sift
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## One-time setup
|
|
46
|
+
|
|
47
|
+
Set credentials once in your shell:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
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
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or write them to a config file:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
sift config init
|
|
59
|
+
```
|
|
60
|
+
|
|
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.
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
sift exec "what changed?" -- git diff
|
|
67
|
+
sift exec --preset test-status -- pytest
|
|
68
|
+
sift exec --preset audit-critical -- npm audit
|
|
69
|
+
sift exec --preset infra-risk -- terraform plan
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Main workflow
|
|
73
|
+
|
|
74
|
+
`sift exec` is the main path:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
sift exec "did tests pass?" -- pytest
|
|
78
|
+
sift exec "what changed?" -- git diff
|
|
79
|
+
sift exec --preset infra-risk -- terraform plan
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
What happens:
|
|
83
|
+
|
|
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.
|
|
90
|
+
|
|
91
|
+
## Pipe mode
|
|
92
|
+
|
|
93
|
+
If the output already exists in a pipeline, pipe mode still works:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git diff 2>&1 | sift "what changed?"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Use pipe mode when the command is already being produced elsewhere.
|
|
100
|
+
|
|
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`
|
|
111
|
+
|
|
112
|
+
Inspect them with:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
sift presets list
|
|
116
|
+
sift presets show audit-critical
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Output modes
|
|
120
|
+
|
|
121
|
+
- `brief`: short plain-text answer
|
|
122
|
+
- `bullets`: short bullet list
|
|
123
|
+
- `json`: structured JSON
|
|
124
|
+
- `verdict`: `{ verdict, reason, evidence }`
|
|
125
|
+
|
|
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.
|
|
127
|
+
|
|
128
|
+
## Config
|
|
129
|
+
|
|
130
|
+
Generate an example config:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
sift config init
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`sift config show` masks secret values by default. Use `sift config show --show-secrets` only when you explicitly need the raw values.
|
|
137
|
+
|
|
138
|
+
Resolution order:
|
|
139
|
+
|
|
140
|
+
1. CLI flags
|
|
141
|
+
2. environment variables
|
|
142
|
+
3. `sift.config.yaml` or `sift.config.yml`
|
|
143
|
+
4. `~/.config/sift/config.yaml` or `~/.config/sift/config.yml`
|
|
144
|
+
5. built-in defaults
|
|
145
|
+
|
|
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`
|
|
157
|
+
|
|
158
|
+
Example config:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
provider:
|
|
162
|
+
provider: openai-compatible
|
|
163
|
+
model: gpt-4.1-mini
|
|
164
|
+
baseUrl: https://api.openai.com/v1
|
|
165
|
+
apiKey: YOUR_API_KEY
|
|
166
|
+
timeoutMs: 20000
|
|
167
|
+
temperature: 0.1
|
|
168
|
+
maxOutputTokens: 220
|
|
169
|
+
|
|
170
|
+
input:
|
|
171
|
+
stripAnsi: true
|
|
172
|
+
redact: true
|
|
173
|
+
redactStrict: false
|
|
174
|
+
maxCaptureChars: 250000
|
|
175
|
+
maxInputChars: 20000
|
|
176
|
+
headChars: 6000
|
|
177
|
+
tailChars: 6000
|
|
178
|
+
|
|
179
|
+
runtime:
|
|
180
|
+
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
|
+
```
|
|
200
|
+
|
|
201
|
+
## Using it with Codex
|
|
202
|
+
|
|
203
|
+
`sift` does not install itself into Codex. The normal setup is:
|
|
204
|
+
|
|
205
|
+
1. put credentials in your shell environment or `sift.config.yaml`
|
|
206
|
+
2. add a short rule to `~/.codex/AGENTS.md`
|
|
207
|
+
|
|
208
|
+
That way Codex inherits credentials safely. It should not pass API keys inline on every command.
|
|
209
|
+
|
|
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
|
|
223
|
+
|
|
224
|
+
## Safety and limits
|
|
225
|
+
|
|
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`.
|
|
233
|
+
|
|
234
|
+
## Current scope
|
|
235
|
+
|
|
236
|
+
`sift` is intentionally small.
|
|
237
|
+
|
|
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
|
|
245
|
+
|
|
246
|
+
It does not try to be a full agent platform.
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
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.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|