project-mgr 0.1.0 → 0.1.2

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/.env_sample CHANGED
@@ -1,5 +1,7 @@
1
- # SQLite database path. Relative paths are resolved from the current directory.
2
- PMGR_DB_PATH=./data/project-mgr.sqlite
1
+ # Optional SQLite database override. When unset, the database is stored at
2
+ # ~/.local/share/project-mgr/project-mgr.sqlite.
3
+ # Use a literal absolute path here; .env files do not expand ~ or $HOME.
4
+ # PMGR_DB_PATH=/absolute/path/to/project-mgr.sqlite
3
5
 
4
6
  # For isolated manual testing, use a separate database instead:
5
- # PMGR_DB_PATH=./data/manual-test.sqlite
7
+ # PMGR_DB_PATH=/tmp/project-mgr-manual-test.sqlite
package/CHANGELOG.md CHANGED
@@ -2,14 +2,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.2 - 2026-08-03
6
+
7
+ ### Changed
8
+
9
+ - Moved the default database from the command's working directory to the stable per-user path `~/.local/share/project-mgr/project-mgr.sqlite`.
10
+
11
+ ## 0.1.1 - 2026-08-03
12
+
13
+ ### Changed
14
+
15
+ - Documented npm execution with `npx` and optional global installation.
16
+
17
+ ## 0.1.0 - 2026-08-03
18
+
5
19
  ### Fixed
6
20
 
7
21
  - Approved the required `better-sqlite3` and `esbuild` build scripts for reproducible frozen pnpm installs.
8
22
  - Made empty human-readable list queries explicit while preserving `[]` JSON output.
9
23
  - Added top-level CLI action shorthand while keeping `status <action>` compatibility.
10
24
 
11
- ## 0.1.0 - 2026-08-03
12
-
13
25
  ### Added
14
26
 
15
27
  - A local TypeScript CLI and SQLite append-only project status ledger.
package/README.md CHANGED
@@ -6,7 +6,32 @@
6
6
 
7
7
  The first release provides only a local CLI and SQLite. It has no HTTP API, long-running service, or agent skills. Data stays on the local machine and requires no account or cloud service.
8
8
 
9
- ## Install and run
9
+ ## Run from npm
10
+
11
+ Requires Node.js 22+.
12
+
13
+ Run without installing:
14
+
15
+ ```bash
16
+ npx --yes project-mgr current
17
+ ```
18
+
19
+ Or install the CLI globally:
20
+
21
+ ```bash
22
+ npm install --global project-mgr
23
+ pmgr current
24
+ ```
25
+
26
+ The database defaults to `~/.local/share/project-mgr/project-mgr.sqlite`, regardless of the directory where `pmgr` is executed. The CLI resolves this to an absolute path using the current user's home directory and creates the parent directory automatically.
27
+
28
+ Set `PMGR_DB_PATH` to use another location:
29
+
30
+ ```bash
31
+ PMGR_DB_PATH=/absolute/path/projects.sqlite npx --yes project-mgr current
32
+ ```
33
+
34
+ ## Build from source
10
35
 
11
36
  Requires Node.js 22+ and pnpm 10.30.2.
12
37
 
@@ -30,26 +55,26 @@ During development, run the TypeScript CLI directly:
30
55
  pnpm pmgr current
31
56
  ```
32
57
 
33
- The default configuration in `.env_sample` is:
58
+ The default database path is:
34
59
 
35
- ```dotenv
36
- PMGR_DB_PATH=./data/project-mgr.sqlite
60
+ ```text
61
+ ~/.local/share/project-mgr/project-mgr.sqlite
37
62
  ```
38
63
 
39
- Set `PMGR_DB_PATH` in `.env` to use another location, or override it for one command:
64
+ `PMGR_DB_PATH` is optional in `.env_sample`. Set it in `.env` to use another location, or override it for one command:
40
65
 
41
66
  ```bash
42
67
  PMGR_DB_PATH=/absolute/path/projects.sqlite pnpm start current
43
68
  ```
44
69
 
45
- Relative paths are resolved from the working directory of the command. When `pnpm start ...` runs from this project's root, the default database is `./data/project-mgr.sqlite`. It is created automatically when the first valid command runs.
70
+ Use a literal absolute path in `.env`; `.env` files do not expand `~` or `$HOME`. The database is created automatically when the first valid command runs.
46
71
 
47
72
  ### Use an isolated test database
48
73
 
49
74
  For manual testing, set a persistent path in `.env` that is separate from production data:
50
75
 
51
76
  ```dotenv
52
- PMGR_DB_PATH=./data/manual-test.sqlite
77
+ PMGR_DB_PATH=/tmp/project-mgr-manual-test.sqlite
53
78
  ```
54
79
 
55
80
  Then run commands normally:
@@ -65,7 +90,7 @@ pnpm start history --project test-project
65
90
 
66
91
  Project keys must match exactly: a record added to `test-project` is not part of `project-mgr` history. Empty human-readable list queries print `No entries found.`; with `--json`, they print `[]`.
67
92
 
68
- `data/` is ignored by Git, so test data is not committed. Delete `data/manual-test.sqlite` when it is no longer needed.
93
+ Delete `/tmp/project-mgr-manual-test.sqlite` when it is no longer needed.
69
94
 
70
95
  Automated tests use an in-memory database or SQLite files in the system temporary directory; they do not read or write the default database. `PMGR_DB_PATH=:memory:` also works for one command, but each CLI command runs in a separate process and its data disappears when the command exits, so it is not suitable for consecutive manual tests.
71
96
 
@@ -166,7 +191,7 @@ Exports omit the database-internal `id` and `recordedAt` fields and can be impor
166
191
  ```bash
167
192
  pnpm start export --format jsonl > project-statuses.jsonl
168
193
 
169
- PMGR_DB_PATH=./data/restored.sqlite \
194
+ PMGR_DB_PATH=/tmp/project-mgr-restored.sqlite \
170
195
  pnpm start import project-statuses.jsonl
171
196
  ```
172
197
 
package/README_CN.md CHANGED
@@ -6,7 +6,32 @@
6
6
 
7
7
  首版只提供本地 CLI 和 SQLite,不包含 HTTP API、常驻服务或 Agent Skills。数据默认保存在本机,无需账号或云服务。
8
8
 
9
- ## 安装与运行
9
+ ## 从 npm 运行
10
+
11
+ 需要 Node.js 22+。
12
+
13
+ 无需安装即可运行:
14
+
15
+ ```bash
16
+ npx --yes project-mgr current
17
+ ```
18
+
19
+ 也可以全局安装 CLI:
20
+
21
+ ```bash
22
+ npm install --global project-mgr
23
+ pmgr current
24
+ ```
25
+
26
+ 无论在哪个目录执行 `pmgr`,数据库都默认位于 `~/.local/share/project-mgr/project-mgr.sqlite`。CLI 会根据当前用户的主目录将其解析为绝对路径,并自动创建父目录。
27
+
28
+ 通过 `PMGR_DB_PATH` 指定其他位置:
29
+
30
+ ```bash
31
+ PMGR_DB_PATH=/absolute/path/projects.sqlite npx --yes project-mgr current
32
+ ```
33
+
34
+ ## 从源码构建
10
35
 
11
36
  需要 Node.js 22+ 和 pnpm 10.30.2。
12
37
 
@@ -30,26 +55,26 @@ pnpm start current
30
55
  pnpm pmgr current
31
56
  ```
32
57
 
33
- 默认配置位于 `.env_sample`:
58
+ 默认数据库路径是:
34
59
 
35
- ```dotenv
36
- PMGR_DB_PATH=./data/project-mgr.sqlite
60
+ ```text
61
+ ~/.local/share/project-mgr/project-mgr.sqlite
37
62
  ```
38
63
 
39
- 通过 `.env` 中的 `PMGR_DB_PATH` 指定其他位置,也可以为单条命令临时覆盖:
64
+ `.env_sample` 中的 `PMGR_DB_PATH` 是可选配置。可以在 `.env` 中指定其他位置,也可以为单条命令临时覆盖:
40
65
 
41
66
  ```bash
42
67
  PMGR_DB_PATH=/absolute/path/projects.sqlite pnpm start current
43
68
  ```
44
69
 
45
- 路径基于启动命令的当前工作目录计算。从本项目根目录执行 `pnpm start ...` 时,默认位置就是 `./data/project-mgr.sqlite`。数据库会在第一次执行有效命令时自动创建。
70
+ 在 `.env` 中应填写字面量绝对路径;`.env` 文件不会展开 `~` 或 `$HOME`。数据库会在第一次执行有效命令时自动创建。
46
71
 
47
72
  ### 使用独立测试数据库
48
73
 
49
74
  手工测试时,建议在 `.env` 中固定设置一个与正式数据分离的路径:
50
75
 
51
76
  ```dotenv
52
- PMGR_DB_PATH=./data/manual-test.sqlite
77
+ PMGR_DB_PATH=/tmp/project-mgr-manual-test.sqlite
53
78
  ```
54
79
 
55
80
  随后正常执行命令:
@@ -65,7 +90,7 @@ pnpm start history --project test-project
65
90
 
66
91
  项目键必须完全一致:写入 `test-project` 的记录不会出现在 `project-mgr` 的历史中。人类可读的空列表查询会输出 `No entries found.`;使用 `--json` 时则输出 `[]`。
67
92
 
68
- `data/` 已加入 Git ignore,测试数据不会进入版本库。不需要保留时,可以删除 `data/manual-test.sqlite`。
93
+ 不需要保留时,可以删除 `/tmp/project-mgr-manual-test.sqlite`。
69
94
 
70
95
  自动化测试会使用内存数据库或系统临时目录中的 SQLite 文件,不会读写默认数据库。`PMGR_DB_PATH=:memory:` 也可用于单条命令,但每个 CLI 命令都是独立进程,命令结束后数据就会消失,不适合连续手工测试。
71
96
 
@@ -166,7 +191,7 @@ pnpm start import --file statuses.jsonl --json
166
191
  ```bash
167
192
  pnpm start export --format jsonl > project-statuses.jsonl
168
193
 
169
- PMGR_DB_PATH=./data/restored.sqlite \
194
+ PMGR_DB_PATH=/tmp/project-mgr-restored.sqlite \
170
195
  pnpm start import project-statuses.jsonl
171
196
  ```
172
197
 
package/dist/db.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import Database from "better-sqlite3";
2
2
  import { mkdirSync } from "node:fs";
3
+ import { homedir } from "node:os";
3
4
  import { dirname, resolve } from "node:path";
4
5
  import { validateStatusEntry, ValidationError, } from "./domain.js";
5
6
  const migration = `
@@ -28,7 +29,7 @@ CREATE INDEX IF NOT EXISTS idx_status_entries_project_occurred ON status_entries
28
29
  `;
29
30
  export function databasePath() {
30
31
  return (process.env.PMGR_DB_PATH ||
31
- resolve(process.cwd(), "data", "project-mgr.sqlite"));
32
+ resolve(homedir(), ".local", "share", "project-mgr", "project-mgr.sqlite"));
32
33
  }
33
34
  export function openLedger(path = databasePath()) {
34
35
  if (path !== ":memory:")
@@ -57,7 +57,7 @@ The `project_id, occurred_at DESC, id DESC` index supports current-status and hi
57
57
 
58
58
  After opening the database, `openLedger()` enables foreign keys, creates the migration table, and checks for and applies migration 1 within a `BEGIN IMMEDIATE` transaction. The immediate transaction prevents migration checks and writes from interleaving when several local processes open the database for the first time at once.
59
59
 
60
- The database path is read from `PMGR_DB_PATH` first; otherwise, it uses `data/project-mgr.sqlite` in the process working directory. Non-memory databases create their parent directory automatically.
60
+ The database path is read from `PMGR_DB_PATH` first; otherwise, it uses the absolute path `~/.local/share/project-mgr/project-mgr.sqlite`, resolved from the current user's home directory. Non-memory databases create their parent directory automatically.
61
61
 
62
62
  ## Write flow
63
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-mgr",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Local-first append-only project status ledger",
5
5
  "type": "module",
6
6
  "bin": {
package/src/db.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Database from "better-sqlite3";
2
2
  import { mkdirSync } from "node:fs";
3
+ import { homedir } from "node:os";
3
4
  import { dirname, resolve } from "node:path";
4
5
  import {
5
6
  type Source,
@@ -46,7 +47,7 @@ CREATE INDEX IF NOT EXISTS idx_status_entries_project_occurred ON status_entries
46
47
  export function databasePath(): string {
47
48
  return (
48
49
  process.env.PMGR_DB_PATH ||
49
- resolve(process.cwd(), "data", "project-mgr.sqlite")
50
+ resolve(homedir(), ".local", "share", "project-mgr", "project-mgr.sqlite")
50
51
  );
51
52
  }
52
53
 
package/test/core.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
- import { tmpdir } from "node:os";
3
+ import { homedir, tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import test from "node:test";
6
6
  import { run } from "../src/cli.js";
@@ -171,7 +171,7 @@ test("import validates before transaction and default source is import", () => {
171
171
  db.close();
172
172
  });
173
173
 
174
- test("database path uses environment override and file migration creates parent directory", () => {
174
+ test("database path has a stable default and environment override creates its parent directory", () => {
175
175
  const directory = mkdtempSync(join(tmpdir(), "pmgr-"));
176
176
  const previous = process.env.PMGR_DB_PATH;
177
177
  process.env.PMGR_DB_PATH = join(directory, "nested", "ledger.sqlite");
@@ -180,7 +180,10 @@ test("database path uses environment override and file migration creates parent
180
180
  db.close();
181
181
  if (previous === undefined) delete process.env.PMGR_DB_PATH;
182
182
  else process.env.PMGR_DB_PATH = previous;
183
- assert.match(databasePath(), /data\/project-mgr\.sqlite$/);
183
+ assert.equal(
184
+ databasePath(),
185
+ join(homedir(), ".local", "share", "project-mgr", "project-mgr.sqlite"),
186
+ );
184
187
  rmSync(directory, { recursive: true, force: true });
185
188
  });
186
189