@hkgdevx/logcoz 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 ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ # LogCoz CLI
2
+
3
+ LogCoz CLI is a TypeScript command-line tool for diagnosing application and infrastructure failures from logs.
4
+
5
+ The primary binary is `logcozcli`. The legacy `logcoz` command is still supported as a compatibility alias.
6
+
7
+ ## What It Does
8
+
9
+ LogCoz CLI reads logs from files or stdin, redacts common secrets, extracts the most relevant failure block, detects known issue patterns, optionally enriches the explanation through an opt-in LLM provider, and returns actionable debugging guidance.
10
+
11
+ It also correlates related events across multiple log files using request and trace identifiers.
12
+
13
+ ## Current Capabilities
14
+
15
+ - `logcozcli explain <file>` for file-based analysis
16
+ - `logcozcli paste` for stdin-based analysis
17
+ - `logcozcli correlate <files...>` for multi-file incident grouping
18
+ - human-readable terminal output with versioned header
19
+ - stable JSON envelope output for `explain`, `paste`, and `correlate`
20
+ - Linux and Windows-oriented debug command suggestions
21
+ - opt-in LLM explanation enhancement via `mock`, `http`, or first-class OpenAI provider modes
22
+ - structured context hints from `.env`, Docker Compose, Kubernetes manifests, and JSON config files
23
+
24
+ ## Supported Detectors
25
+
26
+ - Redis connection refused and auth errors
27
+ - PostgreSQL connection/auth errors
28
+ - MySQL connection/auth errors
29
+ - MongoDB connection/auth errors
30
+ - DNS resolution failures
31
+ - network timeout failures
32
+ - TLS and certificate errors
33
+ - port conflicts
34
+ - Nginx upstream failures
35
+ - Docker health-check, restart-loop, and generic container failures
36
+ - Kubernetes workload failures
37
+ - missing file/path failures
38
+ - out-of-memory failures
39
+ - Kafka broker/connectivity failures
40
+ - RabbitMQ/AMQP connection failures
41
+
42
+ See [docs/detectors.md](docs/detectors.md) for details.
43
+
44
+ ## Installation
45
+
46
+ LogCoz CLI is published publicly on npm as `@hkgdevx/logcoz`.
47
+
48
+ Install globally with pnpm:
49
+
50
+ ```bash
51
+ pnpm add -g @hkgdevx/logcoz
52
+ ```
53
+
54
+ Or with npm:
55
+
56
+ ```bash
57
+ npm install -g @hkgdevx/logcoz
58
+ ```
59
+
60
+ After installation, use either:
61
+
62
+ - `logcozcli`
63
+ - `logcoz`
64
+
65
+ ## Quick Start
66
+
67
+ Analyze a log file:
68
+
69
+ ```bash
70
+ logcozcli explain ./app.log
71
+ ```
72
+
73
+ Use the compatibility alias:
74
+
75
+ ```bash
76
+ logcoz explain ./app.log
77
+ ```
78
+
79
+ Analyze with context and confidence reasoning:
80
+
81
+ ```bash
82
+ logcozcli explain ./app.log --context .env,docker-compose.yml,k8s.yaml --include-reasoning
83
+ ```
84
+
85
+ Enable mock LLM enhancement:
86
+
87
+ ```bash
88
+ logcozcli explain ./app.log --llm --llm-provider mock
89
+ ```
90
+
91
+ Enable the OpenAI provider:
92
+
93
+ ```bash
94
+ OPENAI_API_KEY=YOUR_API_KEY logcozcli explain ./app.log --llm --llm-provider openai --llm-model gpt-5-mini
95
+ ```
96
+
97
+ Emit structured JSON:
98
+
99
+ ```bash
100
+ logcozcli explain ./app.log --json
101
+ ```
102
+
103
+ Correlate multiple logs:
104
+
105
+ ```bash
106
+ logcozcli correlate ./api.log ./worker.log ./nginx.log
107
+ ```
108
+
109
+ Correlate as JSON:
110
+
111
+ ```bash
112
+ logcozcli correlate ./api.log ./worker.log ./nginx.log --json
113
+ ```
114
+
115
+ ## CLI Overview
116
+
117
+ ### `logcozcli explain <file>`
118
+
119
+ Options:
120
+
121
+ - `--json`
122
+ - `--context <files>`
123
+ - `--llm`
124
+ - `--llm-provider <provider>`
125
+ - `--llm-endpoint <url>`
126
+ - `--llm-model <model>`
127
+ - `--include-reasoning`
128
+
129
+ ### `logcozcli paste`
130
+
131
+ Options:
132
+
133
+ - `--json`
134
+ - `--context <files>`
135
+ - `--llm`
136
+ - `--llm-provider <provider>`
137
+ - `--llm-endpoint <url>`
138
+ - `--llm-model <model>`
139
+ - `--include-reasoning`
140
+
141
+ ### `logcozcli correlate <files...>`
142
+
143
+ Options:
144
+
145
+ - `--json`
146
+
147
+ Correlates log events using `traceId`, `correlationId`, `requestId`, and `jobId`.
148
+
149
+ ### Version
150
+
151
+ ```bash
152
+ logcozcli --version
153
+ ```
154
+
155
+ The normal terminal header also shows the current CLI version.
156
+
157
+ ## JSON Output Contract
158
+
159
+ `explain --json`, `paste --json`, and `correlate --json` emit a stable envelope with:
160
+
161
+ - `schemaVersion`
162
+ - `cliName`
163
+ - `cliVersion`
164
+ - `exitCode`
165
+ - `status`
166
+ - `result`
167
+
168
+ For `explain` and `paste`, `result` contains the explanation payload, including optional `confidenceReasons` when `--include-reasoning` is enabled.
169
+
170
+ For `correlate`, `result` contains:
171
+
172
+ - `incidents`
173
+ - `count`
174
+ - optional command metadata
175
+
176
+ If correlation finds nothing, the CLI still returns a success envelope with an empty incident list.
177
+
178
+ ## LLM Provider Configuration
179
+
180
+ Supported provider values:
181
+
182
+ - `mock`
183
+ - `http`
184
+ - `openai`
185
+
186
+ OpenAI configuration:
187
+
188
+ - `OPENAI_API_KEY` or `LOGCOZ_LLM_API_KEY`
189
+ - optional `LOGCOZ_OPENAI_BASE_URL` or `OPENAI_BASE_URL`
190
+ - `--llm-model` or `LOGCOZ_LLM_MODEL`
191
+
192
+ If the OpenAI provider is misconfigured or returns unusable output, LogCoz CLI falls back to the deterministic explanation and appends a warning instead of failing the command.
193
+
194
+ ## Publishing
195
+
196
+ The package is intended for public npm publishing.
197
+
198
+ Release notes and versioning are managed with Changesets, and the primary release workflow publishes from GitHub Actions using an npm token secret.
199
+
200
+ Before the first public release, verify the target version is still free on npm:
201
+
202
+ ```bash
203
+ npm view @hkgdevx/logcoz version --registry https://registry.npmjs.org
204
+ ```
205
+
206
+ At the time of this repo update, the public registry returned `404` for `@hkgdevx/logcoz`, so `0.1.0` is available unless something is published later.
207
+
208
+ ## Cross-Platform Notes
209
+
210
+ LogCoz CLI targets Node.js 20+ and supports Linux and Windows.
211
+
212
+ - file and stdin flows are platform-independent
213
+ - suggested debug commands adapt where platform differences matter
214
+ - examples in docs use both POSIX and PowerShell-friendly patterns where helpful
215
+
216
+ ## Documentation
217
+
218
+ - [docs/architecture.md](docs/architecture.md)
219
+ - [docs/cli-reference.md](docs/cli-reference.md)
220
+ - [docs/detectors.md](docs/detectors.md)
221
+ - [docs/context-hints.md](docs/context-hints.md)
222
+ - [docs/correlation.md](docs/correlation.md)
223
+ - [docs/privacy-and-redaction.md](docs/privacy-and-redaction.md)
224
+ - [docs/examples.md](docs/examples.md)
225
+ - [docs/development.md](docs/development.md)
226
+ - [docs/context.md](docs/context.md)
227
+ - [docs/roadmap.md](docs/roadmap.md)
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ pnpm install
233
+ pnpm typecheck
234
+ pnpm test
235
+ pnpm lint
236
+ pnpm build
237
+ ```
238
+
239
+ ## License
240
+
241
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }