pi-codex-marketplace 0.1.9 → 0.2.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/README.md +31 -34
- package/extensions/pi/bridge-ledger.ts +118 -374
- package/extensions/pi/effective-state-view.ts +70 -0
- package/extensions/pi/git-registration.ts +10 -22
- package/extensions/pi/index.ts +39 -99
- package/extensions/pi/installation.ts +27 -47
- package/extensions/pi/journal.ts +48 -215
- package/extensions/pi/lifecycle.ts +27 -58
- package/extensions/pi/registration.ts +13 -27
- package/extensions/pi/transaction-sheet.ts +5 -5
- package/extensions/pi/ui-strings.ts +35 -129
- package/package.json +2 -2
- package/src/bridge-state/migrate.ts +40 -7
- package/src/bridge-state/paths.ts +6 -27
- package/src/bridge-state/repair.ts +28 -44
- package/src/bridge-state/schema.ts +1 -2
- package/src/bridge-state/store.ts +17 -42
- package/src/bridge-state/types.ts +17 -18
- package/src/cache/source-cache.ts +7 -11
- package/src/compatibility/profile.ts +15 -6
- package/src/installation/flow.ts +81 -165
- package/src/installation/inspection.ts +19 -19
- package/src/journal/active-chains.ts +2 -3
- package/src/journal/journal.ts +18 -34
- package/src/journal/types.ts +0 -2
- package/src/lifecycle/rebind.ts +30 -38
- package/src/lifecycle/refresh.ts +34 -51
- package/src/lifecycle/removal.ts +51 -138
- package/src/lifecycle/update-plan.ts +8 -16
- package/src/lifecycle/update.ts +12 -37
- package/src/projection/collision.ts +13 -38
- package/src/projection/effective-state.ts +14 -168
- package/src/projection/exposure.ts +257 -0
- package/src/projection/index.ts +2 -2
- package/src/projection/{project.ts → runtime.ts} +22 -55
- package/src/reconciliation/startup.ts +20 -100
- package/src/registration/catalog.ts +1 -7
- package/src/registration/fence.ts +10 -30
- package/src/registration/findings.ts +16 -12
- package/src/registration/flow.ts +35 -90
- package/src/registration/git-acquisition.ts +16 -26
- package/src/registration/git-flow.ts +34 -86
- package/src/registration/git-locator.ts +21 -29
- package/src/registration/git-selector.ts +24 -28
- package/src/registration/receipt.ts +1 -10
- package/src/registration/registration.ts +6 -11
- package/src/registration/snapshot.ts +5 -17
- package/src/registration/source-key.ts +1 -1
- package/extensions/pi/scope-overrides.ts +0 -357
- package/src/barrier/global-barrier.ts +0 -105
- package/src/projection/overrides.ts +0 -363
package/README.md
CHANGED
|
@@ -2,25 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Bridge Package for Codex Marketplace compatibility in Pi (`Pi 0.84.2`).
|
|
4
4
|
|
|
5
|
-
> **One-line:** `pi install npm:pi-codex-marketplace` → `/codex-marketplace` opens a responsive Bridge Ledger with
|
|
5
|
+
> **One-line:** `pi install npm:pi-codex-marketplace` → `/codex-marketplace` opens a responsive Bridge Ledger with Global authority, guarded lifecycle transactions, and three-orthogonal Receipt reporting.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pi install npm:pi-codex-marketplace # Global
|
|
11
|
-
pi install npm:pi-codex-marketplace -l # Project
|
|
10
|
+
pi install npm:pi-codex-marketplace # Global package (writes to ~/.pi/agent/settings.json)
|
|
11
|
+
pi install npm:pi-codex-marketplace -l # Project package location (.pi/settings.json; Pi host package setting only)
|
|
12
12
|
pi install ./path/to/pi-codex-marketplace # Local path (try without publishing)
|
|
13
|
-
pi install ./path/to/pi-codex-marketplace -l # Local path, Project
|
|
13
|
+
pi install ./path/to/pi-codex-marketplace -l # Local path, Project package location
|
|
14
14
|
pi -e npm:pi-codex-marketplace # Ephemeral try without installing (temporary)
|
|
15
15
|
pi update npm:pi-codex-marketplace # Update one package
|
|
16
16
|
pi update --all # Update pi + all packages
|
|
17
17
|
pi remove npm:pi-codex-marketplace # Remove package
|
|
18
18
|
pi list # List installed packages
|
|
19
|
-
pi config # Enable/disable resources
|
|
19
|
+
pi config # Enable/disable resources
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Source types follow `docs/packages.md`: `npm:` for registry, `git:`/`https://` for git, and absolute/relative paths for local. Ephemeral runs use `pi -e <source>` (not `pi install -e`). This package declares a single `pi` extension entry (`extensions/pi/index.ts`) loaded via `jiti` and requires no build step.
|
|
23
23
|
|
|
24
|
+
> [!NOTE]
|
|
25
|
+
> `pi install -l` controls where Pi loads this Bridge Package extension from (`.pi/settings.json` vs `~/.pi/agent/settings.json` on the Pi host). Regardless of how Pi installs the package, the Bridge State managed by `pi-codex-marketplace` is always recorded in the single Global Scope (`~/.pi/agent/codex-marketplace/state.json`).
|
|
26
|
+
|
|
24
27
|
Requirements: **Pi 0.84.2**, **Node >=22.19.0**, **macOS / Linux** (Windows not supported).
|
|
25
28
|
|
|
26
29
|
## Usage — `/codex-marketplace` (聚合指令)
|
|
@@ -31,39 +34,37 @@ Single aggregated command in Pi TUI, faithful to `prototype/tui-management-flow@
|
|
|
31
34
|
/codex-marketplace
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
TUI mode opens a persistent **Bridge Ledger** instead of a flat action list.
|
|
37
|
+
TUI mode opens a persistent **Bridge Ledger** instead of a flat action list. The workspace presents the Global authority with its State Revision, counts, and health. Navigation is grouped into **Observe**, **Sources**, **Plugins**, and **Recovery & receipts**; every action is attached to a canonical object identity rather than dispatched from its translated label.
|
|
35
38
|
|
|
36
|
-
At 120/80 columns the Ledger uses navigation and detail panes; below 64 columns it switches to a single-column drill-down. Use arrows or `j/k` to move, `Enter` to open/activate, `Esc` to go back or cancel, `q`/Ctrl-C to exit, `?` for help
|
|
39
|
+
At 120/80 columns the Ledger uses navigation and detail panes; below 64 columns it switches to a single-column drill-down. Use arrows or `j/k` to move, `Enter` to open/activate, `Esc` to go back or cancel, `q`/Ctrl-C to exit, and `?` for help. On Validation sheets, `d` expands or collapses the full ordered disclosure after the initial verdict and finding counts.
|
|
37
40
|
|
|
38
|
-
Every mutation uses the shared transaction sequence **`Intent → Validation → Consent → Plan → Commit → Receipt`**. The target authority, State Revision, Validation Snapshot, separate Default-No confirmations, atomic commit boundary, and final Durable / Findings / Runtime outcomes remain visible across the flow. After every completed, declined, blocked, stale, or cancelled action, the workspace re-reads
|
|
41
|
+
Every mutation uses the shared transaction sequence **`Intent → Validation → Consent → Plan → Commit → Receipt`**. The target authority, State Revision, Validation Snapshot, separate Default-No confirmations, atomic commit boundary, and final Durable / Findings / Runtime outcomes remain visible across the flow. After every completed, declined, blocked, stale, or cancelled action, the workspace re-reads the authoritative state document and receipts before rendering again. Existing `list` / `inspect` and non-TUI summary paths remain non-interactive.
|
|
39
42
|
|
|
40
43
|
The Ledger exposes these existing capabilities without changing their lifecycle semantics:
|
|
41
44
|
|
|
42
|
-
- **檢視 Global
|
|
43
|
-
- **註冊本地 / Git Marketplace…** — local or Git Marketplace Source Registration. Local uses canonical real path; Git uses Canonical Git Locator (credential-free) + Normalized Git Selector (`default` / `branch refs/heads/*` / `tag refs/tags/*` / `commit` lower 40/64 hex) → Resolved Revision. Validation Disclosure shows source,
|
|
44
|
-
- **安裝 Compatible Plugin…** — the Plugins ledger is keyed directly by stable **Marketplace Entry ID** (`/plugins/<序號>`), classification, skills, Invocation Policies, and resources; each compatible row exposes `Install Disabled` and `Install and Enable` without reopening a display-label Entry selector. Unavailable rows remain visible with their exact reason (unsupported source kind / parse failure / Invalid / Incompatible / Plugin ID collision). Compatibility Profile v1 classifies every Plugin atomically as Compatible / Incompatible / Invalid; collision never changes classification. `Install Disabled` persists provenance without Activation Confirmation; `Install and Enable` discloses exact Plugin, skill list, Skill Resources, Invocation Policies, `Pi →
|
|
45
|
+
- **檢視 Global 分區** — single `Global Scope` (`{getAgentDir()}/codex-marketplace/state.json`) workspace. Shows `schemaVersion` (v2), `stateRevision`, registrations/installations, empty-state guidance, and provenance notes.
|
|
46
|
+
- **註冊本地 / Git Marketplace…** — local or Git Marketplace Source Registration. Local uses canonical real path; Git uses Canonical Git Locator (credential-free) + Normalized Git Selector (`default` / `branch refs/heads/*` / `tag refs/tags/*` / `commit` lower 40/64 hex) → Resolved Revision. Validation Disclosure shows source, Marketplace name, State Revision, Validation Snapshot fingerprint, entry outcomes, findings summary. **Registration Confirmation** is snapshot+revision bound, Default No. Blocking Findings (Contained Path / Contained Symlink / Budget / duplicate Source Key / locator/selector trust) block the attempt; concurrent attempt is blocked by Attempt Fence (`FENCE-01`); changed State Revision or snapshot yields `Rejected as Stale` (`STALE-01/02`).
|
|
47
|
+
- **安裝 Compatible Plugin…** — the Plugins ledger is keyed directly by stable **Marketplace Entry ID** (`/plugins/<序號>`), classification, skills, Invocation Policies, and resources; each compatible row exposes `Install Disabled` and `Install and Enable` without reopening a display-label Entry selector. Unavailable rows remain visible with their exact reason (unsupported source kind / parse failure / Invalid / Incompatible / Plugin ID collision). Compatibility Profile v1 classifies every Plugin atomically as Compatible / Incompatible / Invalid; collision never changes classification. `Install Disabled` persists provenance without Activation Confirmation; `Install and Enable` discloses exact Plugin, skill list, Skill Resources, Invocation Policies, `Pi → Global` precedence and findings, then requires a separate **Default No** Activation Confirmation (bound to same snapshot+revision). Re-enabling a disabled Installation repeats validation and confirmation; disabling preserves its Installation ID.
|
|
45
48
|
- **管理已安裝 Plugin(Enable / Disable)…** — toggle Installation State; disabling preserves provenance, enabling re-validates under current profile/ruleset/budget.
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
- **
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
- **執行 State Repair…** — explicit, fence-guarded verification for an unreadable state or an exact Persistence Indeterminate recovery chain; it stays visibly disabled for Pending Application, Persistence Failed, and healthy scopes because those require a different Recovery Action. It is never auto-retried.
|
|
49
|
+
- **檢視 Effective State 與 Projected Skills…** — read-time derived Effective State (Global Scope enabled installations) and Projected Skills with Runtime Skill Collision resolution (`Pi → Global Scope` exact name layering: pre-existing Pi skills reserve their names; non-colliding Bridge skills are projected; colliding Bridge skills within the same layer are unavailable). Whole-Plugin Blocking Findings block the Plugin; collision affects only that skill; `Available` is established only by independent host evidence (`AVAIL-01`).
|
|
50
|
+
- **Refresh / 更新 Registration… (Marketplace Refresh → Update Candidate → Update Plan Checklist → Apply Update)** — Refresh is non-mutating and produces an Update Candidate when the validated source state differs (Plugin version alone does not; full-commit Git selector ref movement alone does not). Update Plan Checklist requires fresh **Registration Confirmation** + one explicit outcome per Installation (`update` / `disable` / `remove`, with `update` only when a Compatible candidate exists) + **Activation Confirmation** per enabled installation that remains enabled. Commit is a single atomic Lifecycle Operation replacing the Registration's Validation Snapshot and applying every disclosed consequence without mixing revisions.
|
|
51
|
+
- **Rebind Registration…** — explicitly replace a Registration's locator/selector with fresh validation, Registration Confirmation, and a complete Update Plan for every existing Installation; prior activation consent never carries over.
|
|
52
|
+
- **移除 Registration / Installation…** — Registration Removal discloses that all associated Installations will be atomically removed; Installation Removal removes the selected Installation.
|
|
53
|
+
- **檢視 Receipt Journal…** — bounded immutable Receipt Journal (redacted, non-authoritative, with active recovery chain preservation across restarts); degraded journal surfaces `JOURNAL-01/02` without changing Persistence Failed outcome, and Repair State can atomically reconstruct validated lines while preserving parsed active chains. An exact active Pending Application chain exposes an Attempt Fence-held Retry Application transaction bound to State Revision and Validation Snapshot; missing snapshots remain visible but Retry is disabled in favor of a fresh validated intent, interaction-time drift fails closed without reload, reload failure remains Pending Application, and the chain resolves only after exact post-reload verification.
|
|
54
|
+
- **執行 State Repair…** — explicit, fence-guarded verification for an unreadable state or an exact Persistence Indeterminate recovery chain; it stays visibly disabled for Pending Application, Persistence Failed, and healthy states because those require a different Recovery Action. It is never auto-retried.
|
|
53
55
|
|
|
54
|
-
Diagnostics throughout are shown with **synchronized ordering** `class → phase → target → pointer → rule` and **closed rule codes** (`CONT-01`, `COMP-02`, `
|
|
56
|
+
Diagnostics throughout are shown with **synchronized ordering** `class → phase → target → pointer → rule` and **closed rule codes** (`CONT-01`, `COMP-02`, `FENCE-01`, `MIGRATE-01`, etc.), grouped by severity (`Blocking` / `Validation Warning` / `Operational Notice`). Closed **Recovery Actions** (`Retry` / `Revalidate` / `Refresh` / `Rebind` / `Retry Application` / `Disable` / `Remove` / `Repair State` / `Inspect`) list only the currently safe next step under the exact current State Revision. Every committed operation reports a **three-orthogonal Attempt Summary** (`Completed` / `Completed with diagnostics` / `Declined` / `Blocked` / `Rejected as Stale` / `Persistence Failed` / `Persistence Indeterminate` / `Pending Application`) with separate persistence, findings, and runtime (`Applied` / `Pending Application` / `none`) diagnostics. A post-commit `reload` is attempted immediately; if not host-verifiable at the expected revision it is reported as `Pending Application` and no inspection or Refresh supersedes it. Pending state is carried by active recovery chains (Retry Application and other Recovery Actions) and is reconciled at startup by producing a new reconciling receipt without implicit retry or rollback.
|
|
55
57
|
|
|
56
58
|
## Bridge State storage & migration
|
|
57
59
|
|
|
58
|
-
Bridge State is the sole authority, stored
|
|
60
|
+
Bridge State is the sole authority, stored in a **single Global Scope document** at `{getAgentDir()}/codex-marketplace/state.json` (`~/.pi/agent/codex-marketplace/state.json`):
|
|
59
61
|
|
|
60
62
|
```jsonc
|
|
61
63
|
{
|
|
62
|
-
"schemaVersion":
|
|
63
|
-
"stateRevision": "1", // opaque monotonic
|
|
64
|
+
"schemaVersion": 2,
|
|
65
|
+
"stateRevision": "1", // opaque monotonic (string "0" -> "1" -> "2" ...)
|
|
64
66
|
"registrations": [], // immutable Registration ID = UUIDv4 allocated before preflight
|
|
65
|
-
"installations": []
|
|
66
|
-
"scopeOverrides": [] // Project-only: sparse suppression of Global records
|
|
67
|
+
"installations": [] // Installed Plugins (enabled/disabled), each bound to a Validation Snapshot
|
|
67
68
|
}
|
|
68
69
|
```
|
|
69
70
|
|
|
@@ -72,15 +73,11 @@ Only authoritative fields are persisted. `Effective State`, catalogs, compatibil
|
|
|
72
73
|
- `State Revision` increments monotonically under file lock; commit is CAS-guarded by `expectedStateRevision` when supplied.
|
|
73
74
|
- Writes are **atomic**: `write-to-temp → fsync → rename` + `fsync` parent dir + **file lock** (`.lock` sibling) + **WAL** (`state.json.wal`) + **read-after-verify**.
|
|
74
75
|
- Cross-process concurrency is safe: lock serializes RMW; rename prevents torn reads; per-fingerprint `flock` guards Source Cache fetches with `p50 <200ms` on cache hit.
|
|
75
|
-
- **WAL migration** (`src/bridge-state/migrate.ts`): supported forward migrations are applied atomically via WAL (`state.json.wal` fsynced before commit, replayed on the next read after a crash, cleaned after commit success). Migrations are **non-waivable, opt-in per version**, require no implicit activation, and preserve the active recovery chain. Unknown/older-without-path and newer (`schemaVersion > CURRENT_SCHEMA_VERSION`) versions are treated as **incompatible** — fail-closed, no auto-migration, no rollback. **Downgrade never writes back** (`isDowngradeAttempt` guard): a newer durable file is never overwritten by an older Bridge Package; the operator must update the package first.
|
|
76
|
+
- **WAL migration** (`src/bridge-state/migrate.ts`): supported forward migrations are applied atomically via WAL (`state.json.wal` fsynced before commit, replayed on the next read after a crash, cleaned after commit success). Migrations are **non-waivable, opt-in per version**, require no implicit activation, and preserve the active recovery chain. Schema v1 → v2 migration strips legacy `scopeOverrides` (non-empty overrides generate a non-blocking `MIGRATE-01` diagnostic finding without fail-closed) and normalizes Installation IDs (stripping legacy `global/` prefix). Unknown/older-without-path and newer (`schemaVersion > CURRENT_SCHEMA_VERSION`) versions are treated as **incompatible** — fail-closed, no auto-migration, no rollback. **Downgrade never writes back** (`isDowngradeAttempt` guard): a newer durable file is never overwritten by an older Bridge Package; the operator must update the package first.
|
|
76
77
|
- Corrupted / unknown `schemaVersion` → classified as **corrupted / incompatible (Persistence Indeterminate)**, **never auto-rollback** — fail-closed. `validateSchema` and `migrateForward` enforce the closed set `CORRUPTED_JSON` / `INVALID_SCHEMA` / `INCOMPATIBLE_SCHEMA_VERSION` / `UNKNOWN_OLD_VERSION` / `MIGRATION_FAILED`.
|
|
77
78
|
|
|
78
79
|
See `src/bridge-state/` for `store.ts`, `atomic.ts`, `schema.ts`, `migrate.ts`, `paths.ts`.
|
|
79
80
|
|
|
80
|
-
## Project Trust
|
|
81
|
-
|
|
82
|
-
Project Scope mutations and Effective-State participation require Pi's `Project Trust` (host-owned, never granted/persisted by this package). Without trust, project records remain stored but excluded from Effective State and no Project Scope Lifecycle Operation may mutate them.
|
|
83
|
-
|
|
84
81
|
## Support matrix
|
|
85
82
|
|
|
86
83
|
| Dimension | Supported | Notes |
|
|
@@ -109,12 +106,12 @@ Every row is a **release blocker**: `v*` may not publish unless the full matrix
|
|
|
109
106
|
| unit | **synthetic** | macOS + Linux | 22.19.0 | — | selector/locator normalization, Contained Path/Symlink, budget, compatibility atomic classification, precedence, collision, fence/sync ordering |
|
|
110
107
|
| unit | **pinned** `SamWang32191/codex-plugins@98e78ca` | macOS + Linux | 22.19.0 | — | catalog parsing + validation against a real pinned marketplace snapshot (fingerprint-stable) |
|
|
111
108
|
| unit | **adversarial** | macOS + Linux | 22.19.0 | — | malformed manifests, path-escapes, symlink loops, budget overflows, ID collisions, parser depth |
|
|
112
|
-
| integration | synthetic | macOS + Linux | 22.19.0 | 0.84.2 | Bridge State atomic WAL + file lock + read-after-verify, Cache pinning/LRU/flock, Receipt Journal rebuild & prune (active chain)
|
|
109
|
+
| integration | synthetic | macOS + Linux | 22.19.0 | 0.84.2 | Bridge State atomic WAL + file lock + read-after-verify, Cache pinning/LRU/flock, Receipt Journal rebuild & prune (active chain) |
|
|
113
110
|
| integration | pinned | macOS + Linux | 22.19.0 | 0.84.2 | Git acquisition (non-executing), Snapshot fingerprinting, Installation dual-path, Effective State, projection/collision, Refresh/Rebind/Removal WAL commit |
|
|
114
|
-
| integration | adversarial | macOS + Linux | 22.19.0 | 0.84.2 | Source Drift (Blocking), Stale Snapshot rejection, Persistence Indeterminate fail-closed, Fence
|
|
115
|
-
| E2E (highest seam — **TUI**) | synthetic | macOS + Linux | 22.19.0 | **0.84.2** | `/codex-marketplace` → Bridge Ledger custom component → structured
|
|
116
|
-
| E2E (highest seam — **TUI**) | pinned | macOS + Linux | 22.19.0 | **0.84.2** | full lifecycle (Register → Install Disabled / Install and Enable → Disable/Enable → Refresh → Update Plan Checklist → Apply Update / Rebind → Removal
|
|
117
|
-
| E2E (highest seam — **TUI**) | adversarial | macOS + Linux | 22.19.0 | **0.84.2** | collision (`Pi →
|
|
111
|
+
| integration | adversarial | macOS + Linux | 22.19.0 | 0.84.2 | Source Drift (Blocking), Stale Snapshot rejection, Persistence Indeterminate fail-closed, Fence admission, Cache stale-snapshot never promotes |
|
|
112
|
+
| E2E (highest seam — **TUI**) | synthetic | macOS + Linux | 22.19.0 | **0.84.2** | `/codex-marketplace` → Bridge Ledger custom component → structured object intent → transaction sheet → commit → authoritative reload → three-orthogonal Receipt |
|
|
113
|
+
| E2E (highest seam — **TUI**) | pinned | macOS + Linux | 22.19.0 | **0.84.2** | full lifecycle (Register → Install Disabled / Install and Enable → Disable/Enable → Refresh → Update Plan Checklist → Apply Update / Rebind → Removal) with fence/cache/external observability |
|
|
114
|
+
| E2E (highest seam — **TUI**) | adversarial | macOS + Linux | 22.19.0 | **0.84.2** | collision (`Pi → Global`), cache (`offline exact fingerprint hit` vs `stale never success`) |
|
|
118
115
|
|
|
119
116
|
Fixtures: `tests/fixtures/synthetic/`, `tests/fixtures/pinned/` (captured `SamWang32191/codex-plugins@98e78ca` snapshot + fingerprint manifest), `tests/fixtures/adversarial/` (path-escape / symlink-loop / budget-overflow / malformed frontmatter corpora). See `tests/acceptance/` for the matrix runner that enforces per-row gating (any row failure blocks publish).
|
|
120
117
|
|