ai-dev-maintenance 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.ja.md +94 -0
- package/README.md +124 -0
- package/SECURITY.md +17 -0
- package/dist/cli.d.ts +40 -0
- package/dist/cli.js +1115 -0
- package/examples/sample-report.json +30 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ai-dev-maintenance contributors
|
|
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.ja.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# ai-dev-maintenance
|
|
2
|
+
|
|
3
|
+
AI開発ツールのローカル状態で増えたディスク使用量を、安全に診断・回収するためのCLIです。
|
|
4
|
+
|
|
5
|
+
v1はmacOS専用です。CodexのSQLiteログDBに対するWAL回収を中心に、セッション履歴を触らないことを最優先にしています。
|
|
6
|
+
|
|
7
|
+
`doctor` は、ローカルに伏せ字済みの診断レポートを書くだけです。`fix --safe --yes` は、Codexログデータを含む可能性がある非公開のローカルバックアップを作成してから、SQLiteのWAL領域を整理します。ログ本文の表示、アップロード、ログ削除、セッション履歴の書き換え、trigger追加、設定変更は行いません。
|
|
8
|
+
|
|
9
|
+
## 使い方
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- doctor --show-paths
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. 最新レポートを確認:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- report --latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
3. 出力で安全と表示された場合だけ実行:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- fix --safe --yes
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`npm exec` はCLI起動前にnpm registryからpackageを取得する場合があります。CLI起動後、このツールはネットワーク通信を行いません。
|
|
28
|
+
|
|
29
|
+
最初は `doctor` だけを実行してください。`doctor` は `<home>/.ai-dev-maintenance/reports` に伏せ字済みレポートを書き込みます。レポート確認後に `fix --safe --yes` を実行します。
|
|
30
|
+
|
|
31
|
+
## コマンド
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ai-dev-maintenance doctor [--json] [--show-paths]
|
|
35
|
+
ai-dev-maintenance fix --safe --yes
|
|
36
|
+
ai-dev-maintenance report --latest [--show-paths]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 安全方針
|
|
40
|
+
|
|
41
|
+
- `doctor` は原本DBをSQLite接続として開きません。
|
|
42
|
+
- `doctor` はツール用データディレクトリに伏せ字済みローカルレポートを書き込みます。
|
|
43
|
+
- v1の `doctor` はprivate log DB bytesを複製しないため、SQLite本文検査をスキップします。
|
|
44
|
+
- `fix --safe --yes` はデフォルトのCodex `logs_2.sqlite` とSQLite補助ファイルだけを対象にします。
|
|
45
|
+
- Codex processが動いている場合、対象DBを開いているprocessがある場合、open-handle確認ができない場合はblockします。
|
|
46
|
+
- SQLite起動には `file:` URI modeを使い、plain database pathを使いません。
|
|
47
|
+
- session、Claude data、Codex config、DB rows、schema、triggerは変更しません。
|
|
48
|
+
- レポートはデフォルトで伏せ字済みです。
|
|
49
|
+
|
|
50
|
+
## `fix --safe` が行うこと
|
|
51
|
+
|
|
52
|
+
できること:
|
|
53
|
+
|
|
54
|
+
- 検証済みbackupを作る
|
|
55
|
+
- Codex log DBのWAL checkpoint/truncateを行う
|
|
56
|
+
- WAL bytesのbefore/afterを表示する
|
|
57
|
+
|
|
58
|
+
やらないこと:
|
|
59
|
+
|
|
60
|
+
- log削除
|
|
61
|
+
- full `VACUUM`
|
|
62
|
+
- DBファイル置換
|
|
63
|
+
- trigger追加
|
|
64
|
+
- session履歴編集
|
|
65
|
+
- backup自動復元
|
|
66
|
+
|
|
67
|
+
伏せ字済みレポートには、対象カテゴリ、存在有無、ファイルサイズ、コマンド状態、回収量などの高レベル情報だけを残します。ローカルマシン固有の識別子、コマンドの生出力、絶対パスは保存・表示しません。`--show-paths` でも伏せ字済みパスだけを表示します。
|
|
68
|
+
|
|
69
|
+
## 緊急時 / 上級者向け
|
|
70
|
+
|
|
71
|
+
バックアップ検証だけを行うコマンドがあります。
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ai-dev-maintenance restore validate --backup <path>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
これは検証だけです。復旧手順を理解し、AI開発ツールをすべて閉じている場合を除き、DBファイルを移動・コピー・置換しないでください。
|
|
78
|
+
|
|
79
|
+
## 開発
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
corepack pnpm install
|
|
83
|
+
corepack pnpm run verify
|
|
84
|
+
corepack pnpm run build
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
runtime dependencyとinstall-time package lifecycle scriptはありません。
|
|
88
|
+
|
|
89
|
+
## ローカルデータ
|
|
90
|
+
|
|
91
|
+
伏せ字済み診断レポートは `<home>/.ai-dev-maintenance/reports` に保存されます。
|
|
92
|
+
このレポートは小さく、Codexのセッション、他AIツールのセッション、バックアップは含みません。
|
|
93
|
+
|
|
94
|
+
v1では手動ワイルドカード削除の手順を公開しません。将来cleanupコマンドを追加する場合は、削除前にapp data directoryの安全性を検証し、ツール所有のレポートファイルだけを対象にします。
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# ai-dev-maintenance
|
|
2
|
+
|
|
3
|
+
Safely diagnose and reclaim local disk usage created by AI coding tool state.
|
|
4
|
+
|
|
5
|
+
The first release is intentionally small. It focuses on macOS, redacted reports, and safe reclaim of a Codex SQLite log database WAL file.
|
|
6
|
+
|
|
7
|
+
`doctor` only writes a local redacted report. `fix --safe --yes` creates a private local backup that may contain Codex log data, then truncates SQLite WAL storage. It does not upload data, print log contents, delete logs, rewrite session history, install database triggers, or change tool configuration.
|
|
8
|
+
|
|
9
|
+
## Install-Free Usage
|
|
10
|
+
|
|
11
|
+
1. Diagnose only:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- doctor --show-paths
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. Review the latest report:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- report --latest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Only if the output says it is safe:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm exec --ignore-scripts ai-dev-maintenance@0.1.0 -- fix --safe --yes
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use the pinned version above when you want repeatable behavior. The npm `latest` tag is convenient after you trust the release channel.
|
|
30
|
+
|
|
31
|
+
`npm exec` may download the package from the npm registry before the CLI starts. After the CLI starts, this tool performs no network calls.
|
|
32
|
+
|
|
33
|
+
Start with `doctor`. It writes a redacted local report under `<home>/.ai-dev-maintenance/reports`. Review that report before running `fix --safe --yes`.
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ai-dev-maintenance doctor [--json] [--show-paths]
|
|
39
|
+
ai-dev-maintenance fix --safe --yes
|
|
40
|
+
ai-dev-maintenance report --latest [--show-paths]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Safety Guarantees
|
|
44
|
+
|
|
45
|
+
- `doctor` does not open the source database as a SQLite connection.
|
|
46
|
+
- `doctor` writes a redacted local report under the tool data directory.
|
|
47
|
+
- `doctor` skips SQLite content inspection in v1 to avoid copying private log database bytes.
|
|
48
|
+
- `fix --safe --yes` targets only the default Codex `logs_2.sqlite` database and its SQLite sidecar files.
|
|
49
|
+
- `fix --safe` blocks when a known Codex process is running, any process has the target database open, or open-handle checks are unavailable.
|
|
50
|
+
- SQLite commands use safe SQLite file URLs instead of passing plain database paths.
|
|
51
|
+
- The tool does not edit sessions, Claude data, Codex config, database rows, schema, or triggers.
|
|
52
|
+
- Reports are redacted by default.
|
|
53
|
+
|
|
54
|
+
## What `fix --safe` Can Change
|
|
55
|
+
|
|
56
|
+
It can:
|
|
57
|
+
|
|
58
|
+
- create a verified private local backup under the tool data directory;
|
|
59
|
+
- run WAL checkpoint/truncate on the Codex log database;
|
|
60
|
+
- report WAL bytes before and after cleanup.
|
|
61
|
+
|
|
62
|
+
It cannot:
|
|
63
|
+
|
|
64
|
+
- delete logs;
|
|
65
|
+
- shrink the main database with full `VACUUM`;
|
|
66
|
+
- replace the database file;
|
|
67
|
+
- install triggers;
|
|
68
|
+
- edit session history;
|
|
69
|
+
- restore a backup automatically.
|
|
70
|
+
|
|
71
|
+
## Expected Output
|
|
72
|
+
|
|
73
|
+
The saved report includes:
|
|
74
|
+
|
|
75
|
+
- `status`
|
|
76
|
+
- `blockedReasons`
|
|
77
|
+
- `beforeWalBytes`
|
|
78
|
+
- `afterWalBytes`
|
|
79
|
+
- `reclaimedBytes`
|
|
80
|
+
- `nextSafeAction`
|
|
81
|
+
|
|
82
|
+
See `examples/sample-report.json` for a redacted example.
|
|
83
|
+
|
|
84
|
+
Redacted reports keep high-level target categories, existence flags, file sizes, command status, and reclaim metrics. They remove raw local-machine identifiers, raw command output, and absolute local paths. `--show-paths` prints only redacted report paths.
|
|
85
|
+
|
|
86
|
+
Human-readable output includes:
|
|
87
|
+
|
|
88
|
+
- whether it is safe to run `fix --safe`;
|
|
89
|
+
- what changed in the current command;
|
|
90
|
+
- where the redacted report was saved;
|
|
91
|
+
- the command to review the latest report.
|
|
92
|
+
|
|
93
|
+
## Emergency / Advanced Only
|
|
94
|
+
|
|
95
|
+
Backup validation is available for recovery planning:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
ai-dev-maintenance restore validate --backup <path>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This only validates a backup. Do not move, copy, or replace database files unless you are following a recovery guide and all AI coding tools are closed.
|
|
102
|
+
|
|
103
|
+
## Platform Support
|
|
104
|
+
|
|
105
|
+
v1 supports macOS only. Other platforms exit before touching macOS-specific paths.
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
corepack pnpm install
|
|
111
|
+
corepack pnpm run verify
|
|
112
|
+
corepack pnpm run build
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The package has no runtime dependencies and no install-time package lifecycle scripts.
|
|
116
|
+
|
|
117
|
+
Before npm publishing, set real `repository`, `bugs`, and `homepage` metadata in `package.json`. Local pre-public CI can use `release:check:prepublic`, but `prepublishOnly` intentionally fails until real public repository metadata exists.
|
|
118
|
+
|
|
119
|
+
## Local Data
|
|
120
|
+
|
|
121
|
+
Redacted maintenance reports are stored under `<home>/.ai-dev-maintenance/reports`.
|
|
122
|
+
They are intentionally small and do not contain Codex sessions, other AI tool sessions, or backups.
|
|
123
|
+
|
|
124
|
+
v1 does not publish a manual wildcard cleanup recipe. A future cleanup command should validate the app data directory before deleting any tool-owned report files.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Security fixes target the latest published minor version.
|
|
6
|
+
|
|
7
|
+
## Reporting a Vulnerability
|
|
8
|
+
|
|
9
|
+
Please open a private security advisory in the public repository once available. If private advisories are not enabled yet, do not open a public issue with sensitive material; use a minimal public issue asking for a private contact path.
|
|
10
|
+
|
|
11
|
+
Do not include private session content, logs, tokens, browser data, or machine-specific absolute paths in reports. Use redacted output whenever possible.
|
|
12
|
+
|
|
13
|
+
We aim to acknowledge actionable vulnerability reports within 7 days.
|
|
14
|
+
|
|
15
|
+
## Data Handling
|
|
16
|
+
|
|
17
|
+
The CLI is designed to operate locally. It does not upload diagnostic data. Reports are redacted by default. v1 has no unredacted report output mode.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type ReportStatus = 'ok' | 'partial' | 'blocked' | 'unsupported' | 'error';
|
|
2
|
+
type MaintenanceReport = {
|
|
3
|
+
schemaVersion: 1;
|
|
4
|
+
toolVersion: string;
|
|
5
|
+
generatedAt: string;
|
|
6
|
+
command: string;
|
|
7
|
+
status: ReportStatus;
|
|
8
|
+
redacted: true;
|
|
9
|
+
target: {
|
|
10
|
+
kind: 'default-codex-log-db' | 'unknown';
|
|
11
|
+
pathCategory: string;
|
|
12
|
+
};
|
|
13
|
+
findings: Record<string, unknown>;
|
|
14
|
+
metrics: Record<string, unknown>;
|
|
15
|
+
blockedReasons: string[];
|
|
16
|
+
nextSafeAction?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
declare function runDoctor(options?: {
|
|
20
|
+
json?: boolean;
|
|
21
|
+
showPaths?: boolean;
|
|
22
|
+
platform?: NodeJS.Platform;
|
|
23
|
+
env?: NodeJS.ProcessEnv;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
report: MaintenanceReport;
|
|
26
|
+
reportPath?: string;
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
type CliResult = {
|
|
30
|
+
exitCode: number;
|
|
31
|
+
output: string;
|
|
32
|
+
};
|
|
33
|
+
declare function runCli(argv?: string[]): Promise<CliResult>;
|
|
34
|
+
declare function renderReport(report: Awaited<ReturnType<typeof runDoctor>>['report'], reportPath?: string, showPaths?: boolean): string;
|
|
35
|
+
|
|
36
|
+
declare function fixSafeConfirmationError(args: string[]): string | undefined;
|
|
37
|
+
declare function isDirectCliInvocation(moduleUrl: string, argv1: string | undefined): boolean;
|
|
38
|
+
declare function formatCliError(error: unknown): string;
|
|
39
|
+
|
|
40
|
+
export { fixSafeConfirmationError, formatCliError, isDirectCliInvocation, renderReport, runCli };
|