@mcptoolshop/housekeeping 0.0.0 → 1.3.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/CHANGELOG.md +103 -0
- package/LICENSE +21 -0
- package/README.es.md +217 -0
- package/README.fr.md +195 -0
- package/README.hi.md +195 -0
- package/README.it.md +195 -0
- package/README.ja.md +199 -0
- package/README.md +246 -5
- package/README.pt-BR.md +222 -0
- package/README.zh.md +197 -0
- package/housekeeping.config.example.json +4 -0
- package/package.json +55 -5
- package/rules/atlas-map.md +30 -0
- package/rules/github-actions.md +59 -0
- package/rules/repo-first.md +12 -0
- package/rules/shipcheck-product-standards.md +37 -0
- package/src/analyze.mjs +1360 -0
- package/src/cli.mjs +316 -0
- package/src/collect.mjs +1184 -0
- package/src/config.mjs +75 -0
- package/src/cost.mjs +271 -0
- package/src/errors.mjs +102 -0
- package/src/gh.mjs +286 -0
- package/src/load.mjs +907 -0
- package/src/lockfile.mjs +272 -0
- package/src/log.mjs +41 -0
- package/src/mcp.mjs +298 -0
- package/src/paths.mjs +31 -0
- package/src/report.mjs +570 -0
- package/src/schema.sql +385 -0
- package/src/workflow-risks.mjs +455 -0
package/README.md
CHANGED
|
@@ -1,8 +1,249 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.md">English</a> | <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/housekeeping/readme.png" alt="housekeeping" width="400" />
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
housekeeping
|
|
9
|
+
<h1 align="center">housekeeping</h1>
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
-
|
|
11
|
+
<p align="center">
|
|
12
|
+
An operational-health warehouse for a GitHub organization.<br>
|
|
13
|
+
One sweep, one SQLite database, findings you can argue with.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/mcp-tool-shop-org/housekeeping/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/housekeeping/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
18
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" /></a>
|
|
19
|
+
<a href="https://mcp-tool-shop-org.github.io/housekeeping/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page" /></a>
|
|
20
|
+
<a href="https://mcp-tool-shop-org.github.io/housekeeping/handbook/"><img src="https://img.shields.io/badge/Handbook-read-blue" alt="Handbook" /></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
One sweep collects every repository's CI status, open issues and pull requests,
|
|
24
|
+
releases, version tags, workflow files, branch protection, security alerts,
|
|
25
|
+
lockfiles and Actions billing into SQLite, then audits it all against written
|
|
26
|
+
rules.
|
|
27
|
+
|
|
28
|
+
It answers, for the whole organization at once:
|
|
29
|
+
|
|
30
|
+
- Which default branches are red, and is that a broken mainline or stale history?
|
|
31
|
+
- Which pull requests can never merge, because a required check nothing emits is blocking them?
|
|
32
|
+
- Which deploys do the repository's own settings refuse?
|
|
33
|
+
- Where have `package.json`, git tags and the npm registry drifted apart?
|
|
34
|
+
- Which workflows break the Actions cost rules, what did they cost, and which jobs spent it?
|
|
35
|
+
- Which repositories carry advisories that GitHub's own alert count misses?
|
|
36
|
+
|
|
37
|
+
It is an audit instrument, not a fixer. It reads GitHub and changes nothing.
|
|
38
|
+
|
|
39
|
+
## Why it is shaped this way
|
|
40
|
+
|
|
41
|
+
| Layer | Choice | Reason |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| Transport | the `gh` CLI | It already holds your token. The tool never stores or asks for a credential. |
|
|
44
|
+
| Collection | GitHub GraphQL, paged | One query returns metadata, open issues, open pull requests, releases and file trees for a page of repositories. A page that keeps timing out is halved and re-asked from the same cursor. |
|
|
45
|
+
| Actions runs | REST | GraphQL has no Actions surface. |
|
|
46
|
+
| Actions cost | billing API plus per-job durations | The invoice says which repository; only jobs say which workflow. GitHub's `/timing` endpoints return zeros, so the per-job sum is rebuilt and then reconciled against the invoice. |
|
|
47
|
+
| Runner rates | read from the invoice | A billed rate can differ from the list price, and a constant in source would misstate every number. |
|
|
48
|
+
| Storage | SQLite through the built-in `node:sqlite` | No native build step. |
|
|
49
|
+
| Source of truth | `data/snapshots/*.json` | Raw, diffable and append-only. The database is derived: `npm run rebuild` reconstructs it offline. |
|
|
50
|
+
| Sweep log | `data/sweeps.jsonl` | One line per sweep, including sweeps that failed and sweeps that found nothing new. |
|
|
51
|
+
|
|
52
|
+
Snapshots are immutable and additive, so drift between two dates is a `JOIN`.
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Node.js 22.5 or later.
|
|
57
|
+
- The [GitHub CLI](https://cli.github.com/), signed in (`gh auth status`) as an
|
|
58
|
+
account that can read the organization. Reading billing and security alerts
|
|
59
|
+
needs the matching access; a sweep without it records "not measured" and
|
|
60
|
+
carries on. It never records a missing permission as a clean result.
|
|
61
|
+
- Windows or Linux. It is developed on Windows and its tests run on Linux in
|
|
62
|
+
CI. macOS should work and is not tested.
|
|
63
|
+
|
|
64
|
+
## Use
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install -g @mcptoolshop/housekeeping # puts `hk` and `hk-mcp` on your path
|
|
68
|
+
mkdir warehouse && cd warehouse # housekeeping keeps its data here
|
|
69
|
+
hk refresh your-org # collect, load, analyze, write reports/AUDIT-<date>.md
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To keep settings between sweeps, put a `housekeeping.config.json` in that
|
|
73
|
+
directory (see Configuration); then `hk refresh` needs no argument.
|
|
74
|
+
|
|
75
|
+
Or run it from a clone, which keeps its data in the clone:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/mcp-tool-shop-org/housekeeping.git
|
|
79
|
+
cd housekeeping
|
|
80
|
+
npm install
|
|
81
|
+
npm link # puts `hk` on your path
|
|
82
|
+
cp housekeeping.config.example.json housekeeping.config.json # then set "org"
|
|
83
|
+
hk refresh
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Then query it:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
hk summary # portfolio totals
|
|
90
|
+
hk ci # repositories whose default branch is red
|
|
91
|
+
hk findings # findings grouped by severity and code
|
|
92
|
+
hk health # per-repository health score, worst first
|
|
93
|
+
hk repo <name> # one repository in full
|
|
94
|
+
hk prs # every open pull request by age
|
|
95
|
+
hk versions # package.json against git tag against npm
|
|
96
|
+
hk actions # every workflow and its rule flags
|
|
97
|
+
hk cost # Actions cost, gross and net side by side
|
|
98
|
+
hk sql "SELECT ..." # one read-only statement
|
|
99
|
+
hk help # every command and flag
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
In a clone without `npm link`, each `hk <command>` is `node src/cli.mjs <command>`.
|
|
103
|
+
|
|
104
|
+
`npm run rebuild` re-derives the database and the report from snapshots already
|
|
105
|
+
on disk, with no network access.
|
|
106
|
+
|
|
107
|
+
A full sweep makes a few hundred API calls. Do not run `refresh` in a loop.
|
|
108
|
+
|
|
109
|
+
Results go to standard output; progress and errors go to standard error. Every
|
|
110
|
+
error prints a code and a hint. Exit codes: 0 ok, 1 user error, 2 runtime
|
|
111
|
+
error, 3 partial (the sweep finished, with gaps).
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
`housekeeping.config.json`, in the directory housekeeping works in (see below):
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"org": "your-org",
|
|
120
|
+
"metaRepos": [".github"]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- `org` is the organization to sweep. `hk refresh <org>` overrides it. With
|
|
125
|
+
neither, a sweep refuses to start.
|
|
126
|
+
- `metaRepos` are repositories that hold organization defaults, assets or
|
|
127
|
+
tooling, not a shipped product. They are exempt from the findings that only
|
|
128
|
+
make sense for a product: missing README, LICENSE and similar files, having
|
|
129
|
+
no workflows, and having no releases.
|
|
130
|
+
|
|
131
|
+
A malformed file is an error, never a silent default: an unknown key, a wrong
|
|
132
|
+
type or broken JSON stops the run.
|
|
133
|
+
|
|
134
|
+
Run from a clone, housekeeping keeps `data/`, `reports/` and the config file
|
|
135
|
+
in the clone. Run as an installed package, it keeps them in the directory you
|
|
136
|
+
run it from, or in `HK_HOME` when that is set.
|
|
137
|
+
|
|
138
|
+
Environment: `HK_HOME` (where data, reports and the config live),
|
|
139
|
+
`HK_CONFIG` (config path), `HK_DB` (database path), `HK_LOG`
|
|
140
|
+
(`silent`, `normal`, `verbose` or `debug`), `HK_COST_REPOS` and
|
|
141
|
+
`HK_COST_BUDGET` (bounds on the per-job cost pass), `GH_PATH` (path to `gh`).
|
|
142
|
+
|
|
143
|
+
## Keep the data private
|
|
144
|
+
|
|
145
|
+
**What a sweep writes is sensitive. Do not commit `data/` or `reports/` to a
|
|
146
|
+
public repository.**
|
|
147
|
+
|
|
148
|
+
A snapshot records the names and descriptions of private repositories, every
|
|
149
|
+
open security alert with the package it names, workflow files and Actions
|
|
150
|
+
billing. GitHub deliberately hides a public repository's security alerts from
|
|
151
|
+
everyone but its maintainers; a published snapshot would hand that list out.
|
|
152
|
+
|
|
153
|
+
This repository's `.gitignore` excludes `data/`, `reports/` and
|
|
154
|
+
`housekeeping.config.json`. To keep history, which is the point of snapshots,
|
|
155
|
+
run the tool from a **private** repository of your own and commit them there.
|
|
156
|
+
|
|
157
|
+
## MCP server
|
|
158
|
+
|
|
159
|
+
`hk-mcp` (or `npm run mcp` in a clone) serves the warehouse over stdio, so an
|
|
160
|
+
assistant can ask questions without reading a multi-megabyte snapshot:
|
|
161
|
+
|
|
162
|
+
`hk_summary` · `hk_findings` · `hk_ci` · `hk_repo` · `hk_backlog` ·
|
|
163
|
+
`hk_health` · `hk_cost` · `hk_sql` · `hk_schema`
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"mcpServers": {
|
|
168
|
+
"housekeeping": { "command": "hk-mcp", "env": { "HK_HOME": "/path/to/warehouse" } }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`HK_HOME` is the directory you sweep from. From a clone, use
|
|
174
|
+
`"command": "node", "args": ["/path/to/housekeeping/src/mcp.mjs"]` instead.
|
|
175
|
+
|
|
176
|
+
`hk_sql` accepts a single `SELECT` or `WITH` statement and opens the database
|
|
177
|
+
read-only. A failing call returns a structured error, never a stack trace.
|
|
178
|
+
|
|
179
|
+
## Findings
|
|
180
|
+
|
|
181
|
+
Rules live in `src/analyze.mjs`. Each one cites the written rule it enforces,
|
|
182
|
+
so a finding is arguable against a standard and not against taste. The rules
|
|
183
|
+
this repository ships are in [`rules/`](rules/):
|
|
184
|
+
|
|
185
|
+
- [`rules/github-actions.md`](rules/github-actions.md): paths filters, runners, matrix size, the workflow file limit, concurrency.
|
|
186
|
+
- [`rules/shipcheck-product-standards.md`](rules/shipcheck-product-standards.md): CI must pass, the ship gates, versions.
|
|
187
|
+
- [`rules/repo-first.md`](rules/repo-first.md): the default branch.
|
|
188
|
+
- [`rules/atlas-map.md`](rules/atlas-map.md): a committed map of each repository, checked in CI.
|
|
189
|
+
|
|
190
|
+
They are one organization's standards. If yours differ, change the rule file
|
|
191
|
+
and the rule together.
|
|
192
|
+
|
|
193
|
+
The rules take care to keep apart things that look alike, because collapsing
|
|
194
|
+
them produces noise:
|
|
195
|
+
|
|
196
|
+
- **A red default branch is not a red pull-request branch.** A failing
|
|
197
|
+
Dependabot branch is backlog; a failing `push` run on the default branch is
|
|
198
|
+
breakage. The run's event decides which.
|
|
199
|
+
- **History is not breakage.** A workflow moved to release-only triggers keeps
|
|
200
|
+
its last default-branch failure forever. A deleted workflow keeps its runs.
|
|
201
|
+
Neither is a live defect.
|
|
202
|
+
- **A required check nothing can emit is not a check that did not run here.**
|
|
203
|
+
One says drop the requirement; the other says fix the trigger. The repairs
|
|
204
|
+
contradict each other.
|
|
205
|
+
- **A failed run is not a cancelled one.** `cancel-in-progress` exists to kill
|
|
206
|
+
superseded runs, so cancelled minutes are usually the concurrency rule working.
|
|
207
|
+
- **Gross cost is not net cost.** GitHub meters public repositories at full
|
|
208
|
+
price and discounts them to zero. Gross is real compute; net is real money.
|
|
209
|
+
They are never summed.
|
|
210
|
+
- **Not measured is not clean.** A repository GitHub is not scanning reports
|
|
211
|
+
zero alerts. A repository the cost pass did not reach has no cost row. Both
|
|
212
|
+
are reported as unknown.
|
|
213
|
+
|
|
214
|
+
Severity drives a health score: critical 40, high 15, medium 6, low 2, info 0,
|
|
215
|
+
deducted from 100. The score ranks attention, not quality.
|
|
216
|
+
|
|
217
|
+
The [handbook](https://mcp-tool-shop-org.github.io/housekeeping/handbook/)
|
|
218
|
+
lists every finding, command, error code and table.
|
|
219
|
+
|
|
220
|
+
## Security
|
|
221
|
+
|
|
222
|
+
- **Read-only.** The collector issues GraphQL queries and REST `GET`s. It never
|
|
223
|
+
merges, pushes, releases, publishes or edits a setting.
|
|
224
|
+
- **No credentials.** Authentication is whatever `gh` already holds. Nothing is
|
|
225
|
+
written to disk about it.
|
|
226
|
+
- **No telemetry.** The only hosts contacted are the GitHub API, through `gh`,
|
|
227
|
+
and the npm registry, for version and advisory lookups.
|
|
228
|
+
- **What it stores** is the sensitive part: see "Keep the data private".
|
|
229
|
+
|
|
230
|
+
Report a vulnerability as described in [SECURITY.md](SECURITY.md).
|
|
231
|
+
|
|
232
|
+
## Tests
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npm test
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Every rule is tested in both directions: the shape that must fire, and the
|
|
239
|
+
neighbouring shape that must not. A separate verifier re-derives a sample of
|
|
240
|
+
findings from live GitHub through its own transport, and skips, loudly, when
|
|
241
|
+
there is no database or no network.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT. See [LICENSE](LICENSE).
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|
package/README.pt-BR.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.md">English</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/housekeeping/readme.png" alt="housekeeping" width="400" />
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">housekeeping</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
An operational-health warehouse for a GitHub organization.<br>
|
|
13
|
+
One sweep, one SQLite database, findings you can argue with.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/mcp-tool-shop-org/housekeeping/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/housekeeping/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
18
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" /></a>
|
|
19
|
+
<a href="https://mcp-tool-shop-org.github.io/housekeeping/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page" /></a>
|
|
20
|
+
<a href="https://mcp-tool-shop-org.github.io/housekeeping/handbook/"><img src="https://img.shields.io/badge/Handbook-read-blue" alt="Handbook" /></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
Uma execução coleta o status de CI de todos os repositórios, problemas abertos e solicitações de pull,
|
|
24
|
+
lançamentos, tags de versão, arquivos de fluxo de trabalho, proteção de branch, alertas de segurança,
|
|
25
|
+
arquivos de bloqueio e faturamento do Actions em SQLite, e, em seguida, verifica tudo em relação às
|
|
26
|
+
regras definidas.
|
|
27
|
+
|
|
28
|
+
Ele responde, para toda a organização de uma só vez:
|
|
29
|
+
|
|
30
|
+
- Quais branches padrão estão marcadas em vermelho e isso indica uma branch principal com problemas ou um histórico desatualizado?
|
|
31
|
+
- Quais solicitações de pull nunca podem ser mescladas, porque uma verificação obrigatória que não emite nada está bloqueando-as?
|
|
32
|
+
- Quais implantações as configurações do próprio repositório rejeitam?
|
|
33
|
+
- Onde `package.json`, as tags Git e o registro npm divergiram?
|
|
34
|
+
- Quais fluxos de trabalho violam as regras de custo do Actions, quanto custaram e quais tarefas gastaram esse valor?
|
|
35
|
+
- Quais repositórios contêm avisos que o próprio contador de alertas do GitHub não detecta?
|
|
36
|
+
|
|
37
|
+
É um instrumento de auditoria, não um corretor. Ele lê o GitHub e não altera nada.
|
|
38
|
+
|
|
39
|
+
## Por que ele tem essa estrutura:
|
|
40
|
+
|
|
41
|
+
| Camada | Escolha | Razão |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| Transporte | a CLI `gh` | Ele já contém seu token. A ferramenta nunca armazena ou solicita uma credencial. |
|
|
44
|
+
| Coleta | GitHub GraphQL, paginado | Uma consulta retorna metadados, problemas abertos, solicitações de pull abertas, lançamentos e árvores de arquivos para uma página de repositórios. Uma página que continua excedendo o tempo limite é dividida ao meio e a solicitação é repetida a partir do mesmo cursor. |
|
|
45
|
+
| Execuções do Actions | REST | O GraphQL não tem uma interface para o Actions. |
|
|
46
|
+
| Custo do Actions | API de faturamento mais durações por tarefa | A fatura indica qual repositório; apenas as tarefas indicam qual fluxo de trabalho. Os endpoints `/timing` do GitHub retornam zeros, portanto, a soma por tarefa é reconstruída e, em seguida, reconciliada com a fatura. |
|
|
47
|
+
| Taxas do Runner | lidas da fatura | Uma taxa faturada pode diferir do preço de tabela, e uma constante na fonte distorceria todos os números. |
|
|
48
|
+
| Armazenamento | SQLite por meio do `node:sqlite` integrado | Sem etapa de construção nativa. |
|
|
49
|
+
| Fonte da verdade | `data/snapshots/*.json` | Bruta, comparável e apenas para anexar. O banco de dados é derivado: `npm run rebuild` o reconstrói offline. |
|
|
50
|
+
| Registro da execução | `data/sweeps.jsonl` | Uma linha por execução, incluindo execuções que falharam e execuções que não encontraram nada de novo. |
|
|
51
|
+
|
|
52
|
+
Os snapshots são imutáveis e aditivos, portanto, a diferença entre duas datas é um `JOIN`.
|
|
53
|
+
|
|
54
|
+
## Requisitos
|
|
55
|
+
|
|
56
|
+
- Node.js 22.5 ou posterior.
|
|
57
|
+
- O [GitHub CLI](https://cli.github.com/), conectado (`gh auth status`) como uma
|
|
58
|
+
conta que pode ler a organização. A leitura do faturamento e dos alertas de segurança
|
|
59
|
+
requer o acesso correspondente; uma execução sem ele registra "não medido" e
|
|
60
|
+
continua. Ele nunca registra uma permissão ausente como um resultado válido.
|
|
61
|
+
- Windows ou Linux. Ele é desenvolvido no Windows e seus testes são executados no Linux em
|
|
62
|
+
CI. O macOS deve funcionar e não é testado.
|
|
63
|
+
|
|
64
|
+
## Uso
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install -g @mcptoolshop/housekeeping # puts `hk` and `hk-mcp` on your path
|
|
68
|
+
mkdir warehouse && cd warehouse # housekeeping keeps its data here
|
|
69
|
+
hk refresh your-org # collect, load, analyze, write reports/AUDIT-<date>.md
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Para manter as configurações entre as execuções, coloque um `housekeeping.config.json` nesse diretório (veja a seção Configuração); então, `hk refresh` não precisa de nenhum argumento.
|
|
73
|
+
|
|
74
|
+
Ou execute-o a partir de uma cópia, que mantém os seus dados na cópia:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/mcp-tool-shop-org/housekeeping.git
|
|
78
|
+
cd housekeeping
|
|
79
|
+
npm install
|
|
80
|
+
npm link # puts `hk` on your path
|
|
81
|
+
cp housekeeping.config.example.json housekeeping.config.json # then set "org"
|
|
82
|
+
hk refresh
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Em seguida, consulte-o:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
hk summary # portfolio totals
|
|
89
|
+
hk ci # repositories whose default branch is red
|
|
90
|
+
hk findings # findings grouped by severity and code
|
|
91
|
+
hk health # per-repository health score, worst first
|
|
92
|
+
hk repo <name> # one repository in full
|
|
93
|
+
hk prs # every open pull request by age
|
|
94
|
+
hk versions # package.json against git tag against npm
|
|
95
|
+
hk actions # every workflow and its rule flags
|
|
96
|
+
hk cost # Actions cost, gross and net side by side
|
|
97
|
+
hk sql "SELECT ..." # one read-only statement
|
|
98
|
+
hk help # every command and flag
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Em uma cópia sem `npm link`, cada `hk <command>` é `node src/cli.mjs <command>`.
|
|
102
|
+
|
|
103
|
+
`npm run rebuild` rederiva o banco de dados e o relatório a partir de snapshots já
|
|
104
|
+
armazenados no disco, sem acesso à rede.
|
|
105
|
+
|
|
106
|
+
Uma execução completa faz algumas centenas de chamadas de API. Não execute `refresh` em um loop.
|
|
107
|
+
|
|
108
|
+
Os resultados são enviados para a saída padrão; o progresso e os erros são enviados para a saída de erro padrão. Cada
|
|
109
|
+
erro imprime um código e uma dica. Códigos de saída: 0 ok, 1 erro do usuário, 2 erro de tempo de execução, 3 parcial (a execução foi concluída, com lacunas).
|
|
110
|
+
|
|
111
|
+
## Configuração
|
|
112
|
+
|
|
113
|
+
`housekeeping.config.json`, no diretório em que a ferramenta de organização funciona (veja abaixo):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"org": "your-org",
|
|
118
|
+
"metaRepos": [".github"]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- `org` é a organização a ser executada. `hk refresh <org>` o substitui. Sem
|
|
123
|
+
nenhum dos dois, uma execução se recusará a iniciar.
|
|
124
|
+
- `metaRepos` são os repositórios que contêm as configurações, ativos ou
|
|
125
|
+
ferramentas padrão da organização, e não um produto lançado. Eles são isentos das descobertas que só
|
|
126
|
+
fazem sentido para um produto: ausência de arquivos README, LICENSE e semelhantes, ausência de
|
|
127
|
+
fluxos de trabalho e ausência de lançamentos.
|
|
128
|
+
|
|
129
|
+
Um arquivo malformado é um erro, nunca um padrão silencioso: uma chave desconhecida, um tipo incorreto ou um JSON corrompido interrompe a execução.
|
|
130
|
+
|
|
131
|
+
Execute a partir de um clone, a ferramenta de organização mantém `data/`, `reports/` e o arquivo de configuração
|
|
132
|
+
no clone. Execute como um pacote instalado, ele os mantém no diretório de onde
|
|
133
|
+
você o executa ou em `HK_HOME` quando isso estiver definido.
|
|
134
|
+
|
|
135
|
+
Ambiente: `HK_HOME` (onde os dados, relatórios e a configuração estão localizados),
|
|
136
|
+
`HK_CONFIG` (caminho da configuração), `HK_DB` (caminho do banco de dados), `HK_LOG`
|
|
137
|
+
(`silent`, `normal`, `verbose` ou `debug`), `HK_COST_REPOS` e
|
|
138
|
+
`HK_COST_BUDGET` (limites para a passagem do custo por tarefa), `GH_PATH` (caminho para `gh`).
|
|
139
|
+
|
|
140
|
+
## Mantenha os dados privados
|
|
141
|
+
|
|
142
|
+
**O que uma execução grava é confidencial. Não inclua `data/` ou `reports/` em um
|
|
143
|
+
repositório público.**
|
|
144
|
+
|
|
145
|
+
Um snapshot registra os nomes e as descrições dos repositórios privados, todos os
|
|
146
|
+
alertas de segurança abertos com o pacote que ele nomeia, arquivos de fluxo de trabalho e faturamento do Actions. O GitHub oculta deliberadamente os alertas de segurança de um repositório público de
|
|
147
|
+
todos, exceto seus mantenedores; um snapshot publicado entregaria essa lista.
|
|
148
|
+
|
|
149
|
+
O `.gitignore` deste repositório exclui `data/`, `reports/` e
|
|
150
|
+
`housekeeping.config.json`. Para manter o histórico, que é o objetivo dos snapshots,
|
|
151
|
+
execute a ferramenta a partir de um repositório **privado** de sua propriedade e inclua-os lá.
|
|
152
|
+
|
|
153
|
+
## Servidor MCP
|
|
154
|
+
|
|
155
|
+
`hk-mcp` (ou `npm run mcp` em uma cópia) serve os dados ao programa através do stdio, para que um assistente possa fazer perguntas sem precisar ler um arquivo de vários megabytes:
|
|
156
|
+
|
|
157
|
+
`hk_summary` · `hk_findings` · `hk_ci` · `hk_repo` · `hk_backlog` ·
|
|
158
|
+
`hk_health` · `hk_cost` · `hk_sql` · `hk_schema`
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"mcpServers": {
|
|
163
|
+
"housekeeping": { "command": "hk-mcp", "env": { "HK_HOME": "/path/to/warehouse" } }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`HK_HOME` é o diretório a partir do qual você executa o programa. Em uma cópia, use `"command": "node", "args": ["/path/to/housekeeping/src/mcp.mjs"]` em vez disso.
|
|
169
|
+
|
|
170
|
+
`hk_sql` aceita uma única instrução `SELECT` ou `WITH` e abre o banco de dados
|
|
171
|
+
em modo somente leitura. Uma chamada com falha retorna um erro estruturado, nunca um rastreamento de pilha.
|
|
172
|
+
|
|
173
|
+
## Descobertas
|
|
174
|
+
|
|
175
|
+
As regras estão em `src/analyze.mjs`. Cada uma cita a regra escrita que ela aplica,
|
|
176
|
+
para que uma descoberta possa ser contestada em relação a um padrão e não em relação ao gosto pessoal. As regras
|
|
177
|
+
que este repositório envia estão em [`rules/`](rules/):
|
|
178
|
+
|
|
179
|
+
- [`rules/github-actions.md`](rules/github-actions.md): filtros de caminhos, executores, tamanho da matriz, limite do arquivo de fluxo de trabalho, concorrência.
|
|
180
|
+
- [`rules/shipcheck-product-standards.md`](rules/shipcheck-product-standards.md): o CI deve ser aprovado, os critérios de lançamento, versões.
|
|
181
|
+
- [`rules/repo-first.md`](rules/repo-first.md): o ramo padrão.
|
|
182
|
+
- [`rules/atlas-map.md`](rules/atlas-map.md): um mapa registrado de cada repositório, verificado no CI.
|
|
183
|
+
|
|
184
|
+
São os padrões de uma organização. Se os seus forem diferentes, altere o arquivo de regra e a regra em conjunto.
|
|
185
|
+
|
|
186
|
+
As regras têm o cuidado de manter separados os elementos que parecem semelhantes, porque agrupá-los gera ruído:
|
|
187
|
+
|
|
188
|
+
- **Um ramo padrão vermelho não é um ramo de solicitação de pull vermelho.** Um ramo do Dependabot com falha é um acúmulo; uma execução `push` com falha no ramo padrão é uma falha. O evento da execução decide qual é.
|
|
189
|
+
- **O histórico não é uma falha.** Um fluxo de trabalho movido para gatilhos apenas de lançamento mantém sua última falha no ramo padrão para sempre. Um fluxo de trabalho excluído mantém suas execuções. Nenhum dos dois é um defeito ativo.
|
|
190
|
+
- **Uma verificação obrigatória que nada pode emitir não é uma verificação que não foi executada aqui.** Uma diz para remover o requisito; a outra diz para corrigir o gatilho. As correções contradizem-se.
|
|
191
|
+
- **Uma execução com falha não é uma execução cancelada.** `cancel-in-progress` existe para encerrar execuções substituídas, portanto, os minutos cancelados geralmente são a regra de concorrência em funcionamento.
|
|
192
|
+
- **O custo bruto não é o custo líquido.** O GitHub mede os repositórios públicos com o preço total e os reduz a zero. O bruto é o poder de computação real; o líquido é o dinheiro real. Eles nunca são somados.
|
|
193
|
+
- **O que não é medido não é limpo.** Um repositório do GitHub que não está sendo verificado relata zero alertas. Um repositório cujo limite de custo não foi atingido não tem linha de custo. Ambos são relatados como desconhecidos.
|
|
194
|
+
|
|
195
|
+
A gravidade impulsiona uma pontuação de saúde: crítica 40, alta 15, média 6, baixa 2, informativa 0, deduzida de 100. A pontuação classifica a atenção, não a qualidade.
|
|
196
|
+
|
|
197
|
+
O [manual](https://mcp-tool-shop-org.github.io/housekeeping/handbook/) lista cada descoberta, comando, código de erro e tabela.
|
|
198
|
+
|
|
199
|
+
## Segurança
|
|
200
|
+
|
|
201
|
+
- **Somente leitura.** O coletor emite consultas GraphQL e solicitações REST `GET`. Ele nunca mescla, envia, lança, publica ou edita uma configuração.
|
|
202
|
+
- **Sem credenciais.** A autenticação é o que `gh` já possui. Nada é gravado em disco sobre isso.
|
|
203
|
+
- **Sem telemetria.** Os únicos hosts contatados são a API do GitHub, por meio de `gh`, e o registro npm, para pesquisas de versão e avisos.
|
|
204
|
+
- **O que ele armazena** é a parte sensível: veja "Mantenha os dados privados".
|
|
205
|
+
|
|
206
|
+
Relate uma vulnerabilidade conforme descrito em [SECURITY.md](SECURITY.md).
|
|
207
|
+
|
|
208
|
+
## Testes
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm test
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Cada regra é testada em ambas as direções: a forma que deve ser ativada e a forma vizinha que não deve ser. Um verificador separado deriva novamente uma amostra de descobertas do GitHub em tempo real por meio de seu próprio transporte e ignora, em voz alta, quando não há banco de dados ou rede.
|
|
215
|
+
|
|
216
|
+
## Licença
|
|
217
|
+
|
|
218
|
+
MIT. Veja [LICENSE](LICENSE).
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
Criado por <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|