opencode-session-port 0.0.0-stage → 0.1.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -2
  3. package/dist/tui.js +10276 -0
  4. package/package.json +48 -4
  5. package/src/core/contracts/crypto.ts +66 -0
  6. package/src/core/contracts/index.ts +13 -0
  7. package/src/core/contracts/json.ts +142 -0
  8. package/src/core/contracts/session.ts +12 -0
  9. package/src/core/crypto/container.ts +686 -0
  10. package/src/core/crypto/envelope.ts +232 -0
  11. package/src/core/crypto/errors.ts +52 -0
  12. package/src/core/crypto/gzip-stream.ts +388 -0
  13. package/src/core/crypto/index.ts +13 -0
  14. package/src/core/crypto/kdf.ts +101 -0
  15. package/src/core/crypto/policy.ts +202 -0
  16. package/src/core/crypto/zero.ts +33 -0
  17. package/src/core/restore/identity.ts +202 -0
  18. package/src/core/restore/index.ts +24 -0
  19. package/src/core/restore/planner.ts +1122 -0
  20. package/src/core/sessions/collector.ts +323 -0
  21. package/src/core/sessions/errors.ts +37 -0
  22. package/src/core/sessions/guards.ts +11 -0
  23. package/src/core/sessions/index.ts +29 -0
  24. package/src/core/sessions/policy.ts +80 -0
  25. package/src/core/sessions/port.ts +88 -0
  26. package/src/core/sessions/serialize.ts +15 -0
  27. package/src/core/sessions/unsettled.ts +35 -0
  28. package/src/integrations/omo/index.ts +28 -0
  29. package/src/tui/adapters/host-client.ts +254 -0
  30. package/src/tui/adapters/index.ts +72 -0
  31. package/src/tui/adapters/location-resolver.ts +281 -0
  32. package/src/tui/adapters/project-destinations.ts +271 -0
  33. package/src/tui/adapters/session-id-inventory.ts +378 -0
  34. package/src/tui/adapters/session-import.ts +189 -0
  35. package/src/tui/adapters/session-read.ts +115 -0
  36. package/src/tui/artifacts/files.ts +285 -0
  37. package/src/tui/orchestration/checkpoint.ts +160 -0
  38. package/src/tui/orchestration/index.ts +55 -0
  39. package/src/tui/orchestration/restore-auth.ts +94 -0
  40. package/src/tui/orchestration/restore-execution.ts +381 -0
  41. package/src/tui/orchestration/restore-preflight.ts +223 -0
  42. package/src/tui/orchestration/shared.ts +75 -0
  43. package/src/tui/ui/password-dialog.tsx +251 -0
  44. package/src/tui/ui/password-flow.ts +288 -0
  45. package/src/tui/ui/restore-project-selector.ts +62 -0
  46. package/src/tui/ui/restore-report-dialog.tsx +251 -0
  47. package/src/tui/ui/restore-report-flow.ts +94 -0
  48. package/src/tui/ui/sessionport-commands.tsx +65 -0
  49. package/src/tui/wiring/composition.ts +354 -0
  50. package/src/tui/wiring/experimental-profile.ts +86 -0
  51. package/src/tui/wiring/index.ts +51 -0
  52. package/src/tui/wiring/install.ts +108 -0
  53. package/src/tui/wiring/reports.ts +340 -0
  54. package/src/tui.ts +34 -0
  55. package/tsconfig.json +18 -0
  56. package/tui.ts +17 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Maivand Rahmani
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.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # SessionPort
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Encrypted session checkpoints for OpenCode.**
4
+
5
+ SessionPort is a local plugin for the OpenCode TUI. It captures the sessions of your current project into a single password-encrypted artifact and restores them in another checkout, worktree, or machine. Artifacts travel with Git or any other channel you choose — SessionPort never runs Git commands itself.
6
+
7
+ > **Status: experimental pre-release (0.1.1).** SessionPort completed one bounded synthetic checkpoint/restore round trip on Windows with OpenCode v2.0.22. That test used test-only password and project-selector seams and staged source, not the npm tarball. Real modal interactions and loading the packed package in OpenCode have not been verified. The checkpoint format may change; no compatibility, security, or platform-support guarantee is made.
8
+
9
+ ## Commands
10
+
11
+ - **`/checkpoint [artifact-path]`** — collects the current project's sessions as returned by the host (child/subagent and archived sessions included when the host returns them) and writes one encrypted artifact. It fails cleanly, with no artifact, when the set is empty, a session cannot be captured completely, or the output file already exists.
12
+ - **`/restore <artifact-path>`** — decrypts and validates the artifact before session imports, then restores it into an existing project you select. Restore does not overwrite existing sessions: exact destination matches are skipped, conflicting IDs are remapped deterministically, and parents are imported before children.
13
+
14
+ Both commands are registered by the plugin as `sessionport.checkpoint` and `sessionport.restore`, and appear in the slash-command list and the command palette.
15
+
16
+ ## Requirements
17
+
18
+ - OpenCode with the v2 TUI plugin API (exercised with OpenCode v2.0.22).
19
+ - Windows. The current build enables the commands on Windows only; macOS and Linux are intended targets but are not yet enabled or validated.
20
+
21
+ ## Install
22
+
23
+ Install the package plugin with the OpenCode CLI:
24
+
25
+ ```sh
26
+ opencode plugin add opencode-session-port@0.1.1
27
+ ```
28
+
29
+ Or add it to the `plugins` array in your `opencode.jsonc` (or `opencode.json`):
30
+
31
+ ```jsonc
32
+ {
33
+ "$schema": "https://opencode.ai/config.json",
34
+ "plugins": ["opencode-session-port@0.1.1"]
35
+ }
36
+ ```
37
+
38
+ These are the documented OpenCode v2 setup paths; the published tarball has not yet been loaded by OpenCode. The final tarball passed npm consumer checks, but a direct Bun package-manager install timed out in the verification environment, so that install path remains unverified.
39
+
40
+ ## Usage
41
+
42
+ ### Checkpoint
43
+
44
+ ```text
45
+ /checkpoint [artifact-path]
46
+ ```
47
+
48
+ Without an argument, the artifact is written to `.sessionport/checkpoint-<UTC timestamp>.sessionport` inside the current project. An argument overrides the location (absolute, or relative to the project). An existing file is never overwritten — a collision fails the checkpoint.
49
+
50
+ Checkpoint prompts for a password twice in a masked input (paste is allowed); both entries must match. Strength guidance is advisory — weak passwords are not rejected.
51
+
52
+ ### Restore
53
+
54
+ ```text
55
+ /restore <artifact-path>
56
+ ```
57
+
58
+ Restore first asks which existing project to import into, then prompts for the password (up to three attempts). The artifact is fully checked before the first session import. Project resolution may still update bounded host project metadata through OpenCode's public `location.get` API. Imports run parents-first, one session at a time: independent branches continue after a failure, descendants of a failed parent are blocked, and outcomes are reported per session. There is no atomic rollback. A later manual rerun may skip exact matching records, but exact retry behavior on a real host has not been established. Imported sessions are not opened or navigated to automatically.
59
+
60
+ ### Moving artifacts
61
+
62
+ Move the artifact with Git (commit it, stash it, or sync it your own way) or any other channel. SessionPort never runs Git commands, and the password is never stored with the artifact or in the repository — if you lose it, the artifact cannot be recovered.
63
+
64
+ ## Security notes
65
+
66
+ - Encryption is mandatory: no plaintext fallback, no plaintext temporary file.
67
+ - Payloads are compressed, then encrypted with an Argon2id-derived key and XChaCha20-Poly1305 secretstream; truncated or tampered artifacts are rejected.
68
+ - Password input is masked and capped at 4 KiB of UTF-8. SessionPort does not intentionally log it, write it to disk, or copy it to the clipboard. JavaScript strings cannot be reliably zeroed; no secure-erasure claim is made.
69
+ - Protection applies to the artifact at rest only. Git history and metadata, a compromised machine, and secrets copied into session content are outside SessionPort's protection; no secure-deletion promise is made.
70
+ - SessionPort makes no model/LLM calls and never replays historical tool calls.
71
+
72
+ ## Development
73
+
74
+ ```sh
75
+ bun install --frozen-lockfile
76
+ bun run typecheck
77
+ bun test
78
+ bun run verify:package # host-free package verification
79
+ ```
80
+
81
+ Design and validation records live under `docs/` in this repository; they are not part of the published package.
82
+
83
+ ## License
84
+
85
+ MIT © 2026 Maivand Rahmani