dsh-context 0.3.0 → 0.4.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 +9 -17
- package/lib/client.js +532 -498
- package/lib/index.js +239 -279
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -57,37 +57,29 @@ Open any session and click **上下文 / Context** (to the right of Chat and Tra
|
|
|
57
57
|
- **Transport**: host ↔ browser over a generic **Connection RPC channel** (`/dsh-context`, `ctx.connection.rpc` — the same channel mechanism the api gateway uses). The host half registers a `snapshot` endpoint; the client half calls it via `ctx.connection.rpc.call`.
|
|
58
58
|
- **Incremental fold**: per-session fold state lives in the Host half, so each poll only processes newly appended events — reopening the tab is instant.
|
|
59
59
|
- **Events decoded**: `request/header` (system prompt + tool schemas), surface events with `surfaceOp` (append/replace — compaction rewrites history in place), `compaction/summary|prune`, `assistant/message.usage` (real provider tokens), and message `source` metadata (`plugin` forms, `skill-invocation`) for injection events.
|
|
60
|
-
- **Architecture**: `src/host.
|
|
60
|
+
- **Architecture**: `src/host.ts` is a plain ESM Cordis plugin (zero runtime dependencies) loaded by the `dsh-context` loader row; `src/client.cts` is the browser half, transpiled and wrapped at build time into the web boot's closure-factory bundle (`window.__ModuleLoader__.load`). The client renders with bare `React.createElement` — theme-native via dsh CSS variables, bilingual via the client `locale` service. Both halves are TypeScript with strict mode and local (drift-free) service contracts.
|
|
61
61
|
|
|
62
62
|
## Development
|
|
63
63
|
|
|
64
64
|
```sh
|
|
65
|
-
|
|
65
|
+
npm install # devDependencies only — the plugin itself stays dependency-free
|
|
66
|
+
npm run typecheck # tsc --noEmit (strict)
|
|
67
|
+
npm run build # esbuild: lib/index.js (host) + lib/client.js (client bundle)
|
|
68
|
+
npm test # typecheck + functional tests for both halves
|
|
66
69
|
```
|
|
67
70
|
|
|
68
71
|
`build.mjs` also smoke-checks the outputs (both halves must parse; the host half must import with the `name`/`inject`/`apply` plugin shape).
|
|
69
72
|
|
|
70
|
-
## Publishing
|
|
71
|
-
|
|
72
|
-
`scripts/publish.sh` builds and publishes to npm as the authenticated user:
|
|
73
|
-
|
|
74
|
-
```sh
|
|
75
|
-
NPM_TOKEN=<your npmjs access token> ./scripts/publish.sh # patch bump if the current version is already published
|
|
76
|
-
NPM_TOKEN=<token> ./scripts/publish.sh minor # explicit bump level
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
The token is read from the environment only and never written to disk. The script auto-bumps the version when the current one is already on the registry, so re-running it after a successful publish is a no-op.
|
|
80
|
-
|
|
81
73
|
## Files
|
|
82
74
|
|
|
83
75
|
| File | Role |
|
|
84
76
|
| --- | --- |
|
|
85
|
-
| `src/host.
|
|
86
|
-
| `src/client.
|
|
77
|
+
| `src/host.ts` | Host half (strict TS): incremental log fold, category accounting, `/dsh-context` snapshot RPC |
|
|
78
|
+
| `src/client.cts` | Client half (strict TS, CJS-flavored for the browser bundle): tab registration, bilingual chart UI |
|
|
79
|
+
| `tsconfig.json` | Strict typecheck config (noEmit; esbuild does the transpiling) |
|
|
87
80
|
| `package.json` | `dsh.bundle` (patch layer) + `dsh.client` (web UI) manifests |
|
|
88
81
|
| `cordis.patch.yml` | The bundle's patch layer: inserts the `dsh-context` row |
|
|
89
|
-
| `scripts/build.mjs` |
|
|
90
|
-
| `scripts/publish.sh` | npm publish with `NPM_TOKEN` |
|
|
82
|
+
| `scripts/build.mjs` | esbuild-based build of `lib/index.js` + `lib/client.js` |
|
|
91
83
|
| `docs/screenshot.png` | The UI in action |
|
|
92
84
|
|
|
93
85
|
## License
|