@peekdev/cli 0.1.0-alpha.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.
Files changed (74) hide show
  1. package/NOTICE +8 -0
  2. package/dist/commands/audit.d.ts +3 -0
  3. package/dist/commands/audit.d.ts.map +1 -0
  4. package/dist/commands/audit.js +96 -0
  5. package/dist/commands/audit.js.map +1 -0
  6. package/dist/commands/init.d.ts +3 -0
  7. package/dist/commands/init.d.ts.map +1 -0
  8. package/dist/commands/init.js +180 -0
  9. package/dist/commands/init.js.map +1 -0
  10. package/dist/commands/sessions.d.ts +3 -0
  11. package/dist/commands/sessions.d.ts.map +1 -0
  12. package/dist/commands/sessions.js +214 -0
  13. package/dist/commands/sessions.js.map +1 -0
  14. package/dist/commands/status.d.ts +2 -0
  15. package/dist/commands/status.d.ts.map +1 -0
  16. package/dist/commands/status.js +88 -0
  17. package/dist/commands/status.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +78 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/lib/audit.d.ts +47 -0
  23. package/dist/lib/audit.d.ts.map +1 -0
  24. package/dist/lib/audit.js +68 -0
  25. package/dist/lib/audit.js.map +1 -0
  26. package/dist/lib/db.d.ts +86 -0
  27. package/dist/lib/db.d.ts.map +1 -0
  28. package/dist/lib/db.js +117 -0
  29. package/dist/lib/db.js.map +1 -0
  30. package/dist/lib/duration.d.ts +14 -0
  31. package/dist/lib/duration.d.ts.map +1 -0
  32. package/dist/lib/duration.js +41 -0
  33. package/dist/lib/duration.js.map +1 -0
  34. package/dist/lib/format/index.d.ts +16 -0
  35. package/dist/lib/format/index.d.ts.map +1 -0
  36. package/dist/lib/format/index.js +43 -0
  37. package/dist/lib/format/index.js.map +1 -0
  38. package/dist/lib/format/json.d.ts +35 -0
  39. package/dist/lib/format/json.d.ts.map +1 -0
  40. package/dist/lib/format/json.js +41 -0
  41. package/dist/lib/format/json.js.map +1 -0
  42. package/dist/lib/format/markdown.d.ts +4 -0
  43. package/dist/lib/format/markdown.d.ts.map +1 -0
  44. package/dist/lib/format/markdown.js +76 -0
  45. package/dist/lib/format/markdown.js.map +1 -0
  46. package/dist/lib/fs-atomic.d.ts +10 -0
  47. package/dist/lib/fs-atomic.d.ts.map +1 -0
  48. package/dist/lib/fs-atomic.js +32 -0
  49. package/dist/lib/fs-atomic.js.map +1 -0
  50. package/dist/lib/init-config.d.ts +81 -0
  51. package/dist/lib/init-config.d.ts.map +1 -0
  52. package/dist/lib/init-config.js +152 -0
  53. package/dist/lib/init-config.js.map +1 -0
  54. package/dist/lib/output.d.ts +5 -0
  55. package/dist/lib/output.d.ts.map +1 -0
  56. package/dist/lib/output.js +23 -0
  57. package/dist/lib/output.js.map +1 -0
  58. package/dist/lib/peek-home.d.ts +5 -0
  59. package/dist/lib/peek-home.d.ts.map +1 -0
  60. package/dist/lib/peek-home.js +11 -0
  61. package/dist/lib/peek-home.js.map +1 -0
  62. package/dist/lib/prompt.d.ts +25 -0
  63. package/dist/lib/prompt.d.ts.map +1 -0
  64. package/dist/lib/prompt.js +62 -0
  65. package/dist/lib/prompt.js.map +1 -0
  66. package/dist/lib/status.d.ts +54 -0
  67. package/dist/lib/status.d.ts.map +1 -0
  68. package/dist/lib/status.js +62 -0
  69. package/dist/lib/status.js.map +1 -0
  70. package/dist/version.d.ts +2 -0
  71. package/dist/version.d.ts.map +1 -0
  72. package/dist/version.js +6 -0
  73. package/dist/version.js.map +1 -0
  74. package/package.json +42 -0
@@ -0,0 +1,54 @@
1
+ import { type ExtensionIds, type InstallTarget } from '@peekdev/mcp/native-host';
2
+ import type { Database } from 'better-sqlite3';
3
+ /** Manifest install state for one browser target. */
4
+ export interface ManifestTargetStatus {
5
+ readonly browser: string;
6
+ /** Filesystem path (darwin/linux) or registry key (win32). */
7
+ readonly location: string;
8
+ /** True when the manifest is present at the location. */
9
+ readonly installed: boolean;
10
+ }
11
+ /** Extension connection state — best-effort; "unknown" until a loopback exists (pre-3d). */
12
+ export type ExtensionConnectionState = 'connected' | 'disconnected' | 'unknown';
13
+ /** Everything `peek status` reports. */
14
+ export interface StatusReport {
15
+ readonly dbPath: string;
16
+ /** True if the DB file exists on disk. */
17
+ readonly dbExists: boolean;
18
+ /** On-disk size in bytes (0 if absent). */
19
+ readonly dbBytes: number;
20
+ /** Highest applied migration, or 0 (or null if the DB couldn't be opened). */
21
+ readonly schemaVersion: number | null;
22
+ readonly sessionCount: number | null;
23
+ readonly hostBinaryPath: string;
24
+ readonly manifestTargets: ManifestTargetStatus[];
25
+ /** True if at least one browser has the manifest installed. */
26
+ readonly anyManifestInstalled: boolean;
27
+ readonly extensionConnection: ExtensionConnectionState;
28
+ }
29
+ /** Injected probes so status-gathering stays pure + testable. */
30
+ export interface StatusProbes {
31
+ /** Absolute DB path (defaults via @peekdev/mcp/db `defaultDbPath`). */
32
+ readonly dbPath: string;
33
+ /** stat → byte size, or null if the path doesn't exist. */
34
+ readonly fileSize: (path: string) => number | null;
35
+ /** True if a manifest path / file exists. */
36
+ readonly fileExists: (path: string) => boolean;
37
+ /** Install targets for the current platform (from `resolveInstallTargets`). */
38
+ readonly manifestTargets: readonly InstallTarget[];
39
+ /** Configured extension IDs (drives the manifest preview). */
40
+ readonly extensionIds: ExtensionIds;
41
+ /**
42
+ * Open the DB read-only for schema/session counts, or null if it can't be
43
+ * opened (absent / locked / corrupt). The caller owns closing it.
44
+ */
45
+ readonly openDb: () => Database | null;
46
+ }
47
+ /**
48
+ * Gather the status report from the injected probes. Never throws on a missing
49
+ * DB or unreadable manifest dir — those become `false`/`null`/`0` fields so
50
+ * `peek status` can render a clean partial picture (e.g. fresh install with no
51
+ * DB yet, native host not registered).
52
+ */
53
+ export declare function gatherStatus(probes: StatusProbes): StatusReport;
54
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/lib/status.ts"],"names":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AI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,EAAE,SAAS,aAAa,EAAE,CAAC;IACnD,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,GAAG,IAAI,CAAC;CACxC;AAMD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CA4C/D"}
@@ -0,0 +1,62 @@
1
+ // `peek status` data-gathering (ADR-0007 action item 6 / P2 PRD §C.1): native
2
+ // host manifest install state, SQLite DB path + size + schema version, and
3
+ // extension connection state. The gathering is factored into a pure function
4
+ // over injected probes (filesystem stat/exists, platform, home dir) so it can be
5
+ // tested against a temp PEEK_HOME with a seeded DB without touching the real OS
6
+ // or browser dirs. The command shell wires the real probes + prints.
7
+ import { schemaVersion } from '@peekdev/mcp/db';
8
+ import { buildManifest, hostBinaryPath, } from '@peekdev/mcp/native-host';
9
+ function targetLocation(t) {
10
+ return t.manifestPath ?? t.registryKey ?? '(unknown target)';
11
+ }
12
+ /**
13
+ * Gather the status report from the injected probes. Never throws on a missing
14
+ * DB or unreadable manifest dir — those become `false`/`null`/`0` fields so
15
+ * `peek status` can render a clean partial picture (e.g. fresh install with no
16
+ * DB yet, native host not registered).
17
+ */
18
+ export function gatherStatus(probes) {
19
+ const dbBytes = probes.fileSize(probes.dbPath);
20
+ const dbExists = dbBytes !== null;
21
+ let version = null;
22
+ let sessionCount = null;
23
+ if (dbExists) {
24
+ const db = probes.openDb();
25
+ if (db) {
26
+ try {
27
+ version = schemaVersion(db);
28
+ sessionCount = db.prepare('SELECT COUNT(*) AS c FROM sessions').get().c;
29
+ }
30
+ catch {
31
+ // Leave version/sessionCount null — a present-but-unreadable DB is still
32
+ // worth reporting (the path + size already are).
33
+ }
34
+ finally {
35
+ db.close();
36
+ }
37
+ }
38
+ }
39
+ const manifest = buildManifest(hostBinaryPath(), probes.extensionIds);
40
+ const manifestTargets = probes.manifestTargets.map((t) => {
41
+ const location = targetLocation(t);
42
+ // Only filesystem targets can be probed for existence here; registry
43
+ // targets (win32) report `installed:false` until the Windows path lands
44
+ // (Phase 3d) — consistent with the installer's deferred registry write.
45
+ const installed = t.manifestPath !== undefined ? probes.fileExists(t.manifestPath) : false;
46
+ return { browser: t.browser, location, installed };
47
+ });
48
+ return {
49
+ dbPath: probes.dbPath,
50
+ dbExists,
51
+ dbBytes: dbBytes ?? 0,
52
+ schemaVersion: version,
53
+ sessionCount,
54
+ hostBinaryPath: manifest.path,
55
+ manifestTargets,
56
+ anyManifestInstalled: manifestTargets.some((t) => t.installed),
57
+ // A real loopback/health check needs the extension's native port, which
58
+ // isn't wired until Phase 3d. Report "unknown" cleanly rather than fake it.
59
+ extensionConnection: 'unknown',
60
+ };
61
+ }
62
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/lib/status.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,iFAAiF;AACjF,gFAAgF;AAChF,qEAAqE;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAGL,aAAa,EACb,cAAc,GACf,MAAM,0BAA0B,CAAC;AAmDlC,SAAS,cAAc,CAAC,CAAgB;IACtC,OAAO,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,WAAW,IAAI,kBAAkB,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAC;IAElC,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,IAAI,YAAY,GAAkB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AAC,CAAC,SAAS,CAAC;QAC9D,wEAAwE;QACxE,4EAA4E;QAC5E,mBAAmB,EAAE,SAAS;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const CLI_VERSION = "0.1.0-alpha.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ // CLI version string surfaced by `peek --version` / `peek --help`. Kept as a
2
+ // literal (rather than importing package.json — NodeNext + verbatimModuleSyntax
3
+ // makes a runtime JSON import awkward, and a stray resolveJsonModule asset in
4
+ // dist is avoidable). The release Changeset bumps both this and package.json.
5
+ export const CLI_VERSION = '0.1.0-alpha.0';
6
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@peekdev/cli",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "peek command-line tool. A thin read-mostly client of the native host's ~/.peek/sessions.db (ADR-0007): status, sessions list/show/export/delete, the `peek init` MCP-client wizard, and `peek audit log`.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "peek": "./dist/index.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": ["dist", "NOTICE", "README.md"],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json && node ./scripts/postbuild.mjs",
21
+ "typecheck": "tsc -p tsconfig.json --noEmit",
22
+ "test": "vitest run --passWithNoTests"
23
+ },
24
+ "dependencies": {
25
+ "@peekdev/mcp": "workspace:*",
26
+ "better-sqlite3": "^12.10.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/better-sqlite3": "^7.6.13",
30
+ "@types/node": "^22.10.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/Cubenest/rrweb-stack.git",
39
+ "directory": "packages/peek-cli"
40
+ },
41
+ "homepage": "https://github.com/Cubenest/rrweb-stack/tree/main/packages/peek-cli#readme"
42
+ }