@hop-top/kit 0.5.0-alpha.12 → 0.5.0-alpha.13
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/CHANGELOG.md +29 -0
- package/README.md +5 -5
- package/dist/bus-D2bAOPYz.d.ts +55 -0
- package/dist/bus.d.ts +1 -0
- package/dist/bus.js +13 -0
- package/dist/chunk-74E6RNOI.js +82 -0
- package/dist/chunk-B7XTFDBB.js +17 -0
- package/dist/chunk-CAONBSPO.js +497 -0
- package/dist/chunk-F7RSL4N4.js +88 -0
- package/dist/chunk-I6XDPSXQ.js +75 -0
- package/dist/chunk-IDM6YZXN.js +204 -0
- package/dist/chunk-VKQCOVKI.js +880 -0
- package/dist/cli.js +3 -3
- package/dist/index-BqZ7WGQf.d.ts +731 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +27 -13
- package/dist/upgrade/drivers/configfile.d.ts +45 -0
- package/dist/upgrade/drivers/configfile.js +78 -0
- package/dist/upgrade/drivers/fsdir.d.ts +61 -0
- package/dist/upgrade/drivers/fsdir.js +170 -0
- package/dist/upgrade/drivers/postgres.d.ts +121 -0
- package/dist/upgrade/drivers/postgres.js +195 -0
- package/dist/upgrade/drivers/sqlite.d.ts +101 -0
- package/dist/upgrade/drivers/sqlite.js +241 -0
- package/dist/upgrade/index.d.ts +2 -0
- package/dist/upgrade/index.js +73 -0
- package/dist/uri-IJ_AoY3d.d.ts +144 -0
- package/dist/uri.d.ts +1 -0
- package/dist/uri.js +37 -0
- package/dist/version-DEJ3pbiO.d.ts +10 -0
- package/dist/wizard-Bf_qHc31.d.ts +159 -0
- package/dist/wizard.d.ts +1 -0
- package/dist/wizard.js +39 -0
- package/package.json +74 -15
- package/skills/hop-top-kit-ts/.claude-plugin/plugin.json +19 -0
- package/skills/hop-top-kit-ts/SKILL.md +117 -0
- package/skills/hop-top-kit-ts/assets/snippets/mcp/mcp.expected +2 -0
- package/skills/hop-top-kit-ts/assets/snippets/mcp/mcp.ts +20 -0
- package/skills/hop-top-kit-ts/assets/snippets/quickstart/quickstart.expected +13 -0
- package/skills/hop-top-kit-ts/assets/snippets/quickstart/quickstart.ts +26 -0
- package/skills/hop-top-kit-ts/gym.json +5 -0
- package/skills/hop-top-kit-ts/references/ai-and-agents.md +45 -0
- package/skills/hop-top-kit-ts/references/cli-and-console.md +63 -0
- package/skills/hop-top-kit-ts/references/coverage.md +56 -0
- package/skills/hop-top-kit-ts/references/guardrails-and-trust.md +60 -0
- package/skills/hop-top-kit-ts/references/other-ports.md +31 -0
- package/skills/hop-top-kit-ts/references/serving-and-transports.md +49 -0
- package/skills/hop-top-kit-ts/scripts/detect-port.sh +168 -0
- package/src/index.test.ts +48 -2
- package/src/index.ts +6 -1
- package/src/published-types.test.ts +8 -0
- package/src/serve.stopped-order.test.ts +156 -0
- package/src/upgrade/README.md +42 -0
- package/src/upgrade/backup.ts +174 -0
- package/src/upgrade/conformance.test.ts +310 -0
- package/src/upgrade/document.ts +229 -0
- package/src/upgrade/driver.ts +66 -0
- package/src/upgrade/drivers/README.md +47 -0
- package/src/upgrade/drivers/configfile.test.ts +112 -0
- package/src/upgrade/drivers/configfile.ts +107 -0
- package/src/upgrade/drivers/fsdir.test.ts +188 -0
- package/src/upgrade/drivers/fsdir.ts +216 -0
- package/src/upgrade/drivers/isolation.test.ts +18 -0
- package/src/upgrade/drivers/postgres.integration.test.ts +395 -0
- package/src/upgrade/drivers/postgres.test.ts +272 -0
- package/src/upgrade/drivers/postgres.ts +284 -0
- package/src/upgrade/drivers/sqlite.integration.test.ts +492 -0
- package/src/upgrade/drivers/sqlite.ts +300 -0
- package/src/upgrade/drivers/version.ts +21 -0
- package/src/upgrade/errors.ts +117 -0
- package/src/upgrade/events.ts +117 -0
- package/src/{upgrade.test.ts → upgrade/index.test.ts} +1 -1
- package/src/{upgrade.ts → upgrade/index.ts} +20 -0
- package/src/upgrade/migration.ts +89 -0
- package/src/upgrade/migrator.test.ts +391 -0
- package/src/upgrade/migrator.ts +527 -0
- package/src/upgrade/options.ts +59 -0
- package/src/upgrade/semver.ts +90 -0
- package/test/skill-snippets.test.ts +60 -0
- package/test/upgrade/conformance-migrator.ts +439 -0
- package/test/upgrade/conformance-support.ts +44 -0
- package/test/upgrade/driver-support.ts +44 -0
- package/test/upgrade/pg-container.ts +64 -0
- package/test/upgrade/pg-race-worker.ts +48 -0
- package/test/upgrade/race-helper.ts +36 -0
- package/test/upgrade/sqlite-support.ts +41 -0
- package/test/upgrade/testdata/go-fsdir-mydata.tar.gz +0 -0
- package/vitest.config.ts +26 -0
- package/dist/chunk-X4E5QGEB.js +0 -171
- package/dist/upgrade-BJ2z6Oqf.d.ts +0 -156
- package/dist/upgrade.d.ts +0 -1
- package/dist/upgrade.js +0 -9
- package/dist/{chunk-MFVUENZR.js → chunk-KV7FYEAF.js} +2 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hop-top-kit-ts
|
|
3
|
+
description: Build CLIs and services in TypeScript or JavaScript with the kit SDK `@hop-top/kit`, covering createCLI, output formats, layered config, MCP serving, safety guards, LLM adapters. Use when code imports `@hop-top/kit`, when adding kit to a Node project, or when a task needs a kit capability in TypeScript and you must check this port covers it. Not for choosing a language; the router skill does that.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
version: "0.5.0-alpha.13" # x-release-please-version
|
|
7
|
+
min_version: "0.5.0-alpha.12"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# hop-top-kit-ts
|
|
11
|
+
|
|
12
|
+
kit's TypeScript port: package `@hop-top/kit`, CommonJS, Node 22.12 or newer (`engines` in its
|
|
13
|
+
package.json). Commander-based. Public API is subpath imports only (see Imports).
|
|
14
|
+
|
|
15
|
+
## Use another port when
|
|
16
|
+
|
|
17
|
+
- The task needs the `kit` binary, or a capability listed below as lacking: switch to Go or run the
|
|
18
|
+
binary as a sidecar. Choose with the
|
|
19
|
+
[router](https://github.com/hop-top/kit/blob/main/skills/hop-top-kit/SKILL.md) and
|
|
20
|
+
[other ports](references/other-ports.md).
|
|
21
|
+
- The project or the user is in another language (Python only, say): stay in that language when its
|
|
22
|
+
port covers the task. Counts across ports are in [other ports](references/other-ports.md); do not
|
|
23
|
+
pick TypeScript for coverage alone.
|
|
24
|
+
|
|
25
|
+
<!-- skills-sync:begin coverage -->
|
|
26
|
+
Tier: supported.
|
|
27
|
+
|
|
28
|
+
- CLI and console. Lacks: Markdown rendering, Config path commands, Fuzzy matching, Process status.
|
|
29
|
+
- Config, storage and secrets. Has only: Layered config, XDG paths, SQLite JSON store.
|
|
30
|
+
- Serving and transports. Lacks: Service command group, Transport service seam, Unix socket, Served authentication, Served observability, Bridge payloads.
|
|
31
|
+
- Events, jobs and runtime. Has only: Event bus, Telemetry.
|
|
32
|
+
- Guardrails and trust. Lacks: Breaker, Event policy engine, Operating mode, Audit log, Identity, Utilities, Avatars.
|
|
33
|
+
- AI and agents. Lacks: Command reflection, Agent CLI invocation, Extensions.
|
|
34
|
+
- Conformance and integrations. Has only: nothing.
|
|
35
|
+
<!-- skills-sync:end coverage -->
|
|
36
|
+
|
|
37
|
+
Per-capability status and evidence: [coverage](references/coverage.md). Find the capability there
|
|
38
|
+
before promising it. Matrix cell `partial`: the Evidence names the gap; stay only if the task avoids
|
|
39
|
+
it. `unverified`: the module exists and nothing pins it to Go; tell the user and test the behaviour
|
|
40
|
+
(check Telemetry here before relying on it). `none`: use Go or the sidecar.
|
|
41
|
+
|
|
42
|
+
`kit init` scaffolds a TypeScript project from the Go binary (`kit init <name> --runtime ts`, see
|
|
43
|
+
[kit init](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/guides/kit-init.md)); this
|
|
44
|
+
port cannot scaffold, and the binary needs no Go toolchain when taken from a release or Homebrew
|
|
45
|
+
(see its [README](https://github.com/hop-top/poly-kit/blob/next/cmd/kit/README.md)).
|
|
46
|
+
|
|
47
|
+
## Install and first program
|
|
48
|
+
|
|
49
|
+
`pnpm add @hop-top/kit`. `assets/snippets/quickstart/` is the smallest program: `createCLI` from
|
|
50
|
+
`@hop-top/kit/cli`, one command, rows through `dispatch` from `@hop-top/kit/output`, so `--format`,
|
|
51
|
+
`--cols`, `-o` and `--template` work with no more code. Its expected output is checked in.
|
|
52
|
+
|
|
53
|
+
- `createCLI` returns `{ program, theme }`, not the Commander command.
|
|
54
|
+
- Async actions: end with `await program.parseAsync()`, not `parse()`.
|
|
55
|
+
- `ColumnSpec` needs `header` equal to `key`; `--cols` selects and reorders.
|
|
56
|
+
- Layered config: `load` from `@hop-top/kit/config`; see the CLI reference.
|
|
57
|
+
- Tests: `make test-ts-sdk` runs the snippets in the kit repo; in your project use your own runner.
|
|
58
|
+
|
|
59
|
+
## Imports
|
|
60
|
+
|
|
61
|
+
- Only keys of the `exports` map in kit's package.json (inside `node_modules`) resolve, as
|
|
62
|
+
`@hop-top/kit/<sub>`; a file under `src/` with no key does not. The package README names subpaths
|
|
63
|
+
the map lacks: trust package.json.
|
|
64
|
+
- The root `@hop-top/kit` is a barrel of namespaces (`import { output } from '@hop-top/kit'`;
|
|
65
|
+
`completion-values` becomes `completionValues`). Prefer subpaths: they load one module.
|
|
66
|
+
- Off the barrel on purpose, import by full subpath: `sqlstore` and the upgrade drivers
|
|
67
|
+
`configfile`, `fsdir`, `sqlite`, `postgres`. `sqlstore` and `sqlite` load native `better-sqlite3`,
|
|
68
|
+
`fsdir` loads `tar`; `postgres` keeps the root and `upgrade` free of any database client.
|
|
69
|
+
- Upgrade migrations: `Migrator` from `@hop-top/kit/upgrade`, a driver per backend. Postgres:
|
|
70
|
+
`@hop-top/kit/upgrade/drivers/postgres`, you pass the `pg` Pool; kit depends on no Postgres
|
|
71
|
+
client.
|
|
72
|
+
- Install with scripts disabled (`--ignore-scripts`) leaves `better-sqlite3` unbuilt: `sqlstore` and
|
|
73
|
+
the sqlite driver fail at load.
|
|
74
|
+
- Subpath names by area: cli, output, completion, completion-values, alias, tui, errcorrect, log,
|
|
75
|
+
progress, stream; config, xdg, sqlstore; serve, mcp, api, rpc, netpolicy, auth; safety, scope,
|
|
76
|
+
provenance, telemetry, id, upgrade; llm, anthropic, openai, routellm, toolspec, aim, compliance.
|
|
77
|
+
|
|
78
|
+
## Gotchas
|
|
79
|
+
|
|
80
|
+
- Delegation gates (`--confirm`, `--max-ops`, `--policy`, `--dry-run`) are reserved root flags; a
|
|
81
|
+
leaf named `delete`, `remove`, `rm`, `destroy`, `purge` or `drop` is gated as destructive and
|
|
82
|
+
blocked on MCP unless annotated.
|
|
83
|
+
- MCP exposure is default-closed, and `commanderBridge` needs your `run`.
|
|
84
|
+
- Telemetry records nothing without granted consent and a mode other than off.
|
|
85
|
+
- `--offline` guards `globalThis.fetch`; own clients wrap `guardFetch`.
|
|
86
|
+
- Importing `anthropic`, `openai` or `routellm` registers their URI schemes.
|
|
87
|
+
|
|
88
|
+
<!-- skills-sync:begin version -->
|
|
89
|
+
## Versions
|
|
90
|
+
|
|
91
|
+
Written for 0.5.0-alpha.13 # x-release-please-version
|
|
92
|
+
Expects 0.5.0-alpha.12 or newer.
|
|
93
|
+
|
|
94
|
+
Installed: `npm ls @hop-top/kit` or `pnpm ls @hop-top/kit`; `scripts/detect-port.sh` shows what the
|
|
95
|
+
manifest pins. Older than expected: tell the user, upgrade (`pnpm add @hop-top/kit@latest`). Newer
|
|
96
|
+
than written for: this copy may be stale; update it, then re-read it. Update by install channel,
|
|
97
|
+
then restart the harness: Claude Code plugin `claude plugin marketplace update hop-top`, then
|
|
98
|
+
`claude plugin update hop-top-kit-ts@hop-top` (marketplace repository `hop-top/skillset`);
|
|
99
|
+
`npx skills` from a GitHub source `npx skills update -g -y` (project scope
|
|
100
|
+
`npx skills update -p -y`), from any other source run the same `npx skills add` again; gym
|
|
101
|
+
`gym update`, then `gym train`; by hand: take `skills/hop-top-kit-ts` again from `hop-top/kit-ts` at
|
|
102
|
+
`main`.
|
|
103
|
+
<!-- skills-sync:end version -->
|
|
104
|
+
|
|
105
|
+
## Open when
|
|
106
|
+
|
|
107
|
+
| File | Open when |
|
|
108
|
+
|------|-----------|
|
|
109
|
+
| `references/coverage.md` | a capability's status or Evidence is needed (is it pinned to Go?) before promising it |
|
|
110
|
+
| `references/other-ports.md` | switching port, or the router and ports table are needed |
|
|
111
|
+
| `references/cli-and-console.md` | wiring commands, output flags, completion, aliases, logging, layered config or XDG paths |
|
|
112
|
+
| `references/serving-and-transports.md` | serving a service lifecycle, MCP, REST or ConnectRPC |
|
|
113
|
+
| `references/guardrails-and-trust.md` | adding safety, scope, netpolicy, telemetry, TypeID or upgrade migrations |
|
|
114
|
+
| `references/ai-and-agents.md` | calling an LLM, routing models, emitting a toolspec or running compliance |
|
|
115
|
+
| `assets/snippets/quickstart/` | starting a CLI that renders rows in several formats |
|
|
116
|
+
| `assets/snippets/mcp/` | exposing a command tree as MCP tools |
|
|
117
|
+
| `scripts/detect-port.sh` | the kit version a project pins is unknown |
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createMcpHandler, commanderBridge } from '@hop-top/kit/mcp';
|
|
3
|
+
|
|
4
|
+
const root = new Command('app');
|
|
5
|
+
root.command('ping').description('Ping the server');
|
|
6
|
+
|
|
7
|
+
const bridge = commanderBridge(root, {
|
|
8
|
+
run: async () => ({ stdout: 'pong\n', exitCode: 0 }),
|
|
9
|
+
});
|
|
10
|
+
const handler = createMcpHandler(bridge, {
|
|
11
|
+
serverInfo: { name: 'app', version: '0.1' },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const res = await handler({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: { 'content-type': 'application/json' },
|
|
17
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' }),
|
|
18
|
+
});
|
|
19
|
+
console.log(res.status);
|
|
20
|
+
console.log(JSON.parse(String(res.body)).result.tools.map((t: { name: string }) => t.name));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createCLI } from '@hop-top/kit/cli';
|
|
2
|
+
import { dispatch } from '@hop-top/kit/output';
|
|
3
|
+
|
|
4
|
+
const { program } = createCLI({
|
|
5
|
+
name: 'mytool',
|
|
6
|
+
version: '1.0',
|
|
7
|
+
description: 'does things',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const rows = [
|
|
11
|
+
{ id: '1', name: 'Alice' },
|
|
12
|
+
{ id: '2', name: 'Bob' },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
program.command('list').action(async () => {
|
|
16
|
+
await dispatch(program, rows, {
|
|
17
|
+
columns: [
|
|
18
|
+
{ header: 'id', key: 'id' },
|
|
19
|
+
{ header: 'name', key: 'name' },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// A real tool ends with `program.parse()`; the snippet passes its argv.
|
|
25
|
+
await program.parseAsync(['list', '--format', 'json'], { from: 'user' });
|
|
26
|
+
await program.parseAsync(['list'], { from: 'user' });
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# AI and agents
|
|
2
|
+
|
|
3
|
+
Open when calling an LLM, routing between models, emitting a capability manifest or running the
|
|
4
|
+
12-factor check. Status per capability: [coverage](coverage.md). Depth:
|
|
5
|
+
[TypeScript API reference](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/ts-api-reference.md)
|
|
6
|
+
(sections LLM adapters, LLM tool calling, Capability manifest).
|
|
7
|
+
|
|
8
|
+
## Modules
|
|
9
|
+
|
|
10
|
+
| Import | Use for | Cue |
|
|
11
|
+
|--------|---------|-----|
|
|
12
|
+
| `@hop-top/kit/llm` | client, registry, fallback, tool calling | `createLLM(uri, { fallback })`, `parseURI`, `loadConfig` |
|
|
13
|
+
| `@hop-top/kit/anthropic` | `anthropic://` scheme | import for its side effect, then `createLLM` |
|
|
14
|
+
| `@hop-top/kit/openai` | `openai://` and OpenAI-compatible schemes | same; `lmstudio://` needs no key |
|
|
15
|
+
| `@hop-top/kit/routellm` | `routellm://` strong/weak routing server | adapter over the openai one |
|
|
16
|
+
| `@hop-top/kit/toolspec` | `<tool> spec` capability manifest | `registerSpecCommand(program, '1.0')` after all commands |
|
|
17
|
+
| `@hop-top/kit/compliance` | 12-factor CLI check | `Factor` enum; static and runtime checks |
|
|
18
|
+
| `@hop-top/kit/aim` | model registry (models.dev source, cache) | `Registry`, `ModelsDevSource`, `Cache` |
|
|
19
|
+
|
|
20
|
+
Matrix cell `unverified`: LLM routing (`@hop-top/kit/routellm`). The LLM client and providers
|
|
21
|
+
are `partial`: Evidence names the gap (no Google or Ollama adapter here). Read it in coverage.
|
|
22
|
+
|
|
23
|
+
## LLM
|
|
24
|
+
|
|
25
|
+
- An adapter registers its URI schemes when imported: forget the import and `createLLM` has no
|
|
26
|
+
provider for the scheme.
|
|
27
|
+
- Key order: the URI's `api_key`, then `llm.yaml` (under the `hop` config dir), then the scheme's
|
|
28
|
+
env var (`ANTHROPIC_API_KEY`, `<SCHEME>_API_KEY`), then `LLM_API_KEY`. A key found nowhere
|
|
29
|
+
throws `MissingKeyError`, listing the variables consulted.
|
|
30
|
+
- `stream` and `streamWithTools` return a `ToolStream`: iterate tokens, then `outcome()` holds
|
|
31
|
+
content, tool calls and usage; it is undefined before the stream ends.
|
|
32
|
+
- `{ hermetic: true }` on `createLLM` reads nothing ambient (no env keys, no `llm.yaml`): the
|
|
33
|
+
URI alone configures the provider.
|
|
34
|
+
- The client corpus is shared with Go, Rust and Python; behaviour beyond it is this port's.
|
|
35
|
+
- The in-process RouteLLM controller and the Triton client have source under `src/` but no
|
|
36
|
+
entry in the package `exports` map when this was written: import `routellm` for the server
|
|
37
|
+
adapter; the controller and Triton are not importable.
|
|
38
|
+
|
|
39
|
+
## Toolspec
|
|
40
|
+
|
|
41
|
+
- Commands describe themselves with `kit/*` annotations (`kit/side-effect`, `kit/args`,
|
|
42
|
+
`kit/exit-codes`, `kit/output-schema`). Register once, after every command exists.
|
|
43
|
+
- `spec --format kit-manifest` emits Go's manifest byte for byte; `spec coverage --min N`
|
|
44
|
+
exits 4 below `N`. The `mcp` format and Go's curation options are not ported.
|
|
45
|
+
- Reflecting a command tree at runtime and invoking other agent CLIs are Go-only (coverage).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CLI and console
|
|
2
|
+
|
|
3
|
+
Open when wiring a command tree, output flags, completion, aliases, styled terminal output,
|
|
4
|
+
logging, layered config or XDG paths. Status per capability: [coverage](coverage.md). Depth:
|
|
5
|
+
[TypeScript API reference](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/ts-api-reference.md).
|
|
6
|
+
|
|
7
|
+
## Modules
|
|
8
|
+
|
|
9
|
+
| Import | Use for | Cue |
|
|
10
|
+
|--------|---------|-----|
|
|
11
|
+
| `@hop-top/kit/cli` | `createCLI`, command groups, delegation gates | `setCommandGroup`, `verboseCount`, `isQuiet`, `isDryRun`, `renderPlan`, `buildTheme` |
|
|
12
|
+
| `@hop-top/kit/output` | five formatters behind `--format` | `registerOutputFlags`, `dispatch`, `newRegistry`; `render` is the legacy shim |
|
|
13
|
+
| `@hop-top/kit/completion` | `completion bash\|zsh\|fish\|powershell` | `completionCommand(program)`; `bindFlag`, `bindArgs` attach completers |
|
|
14
|
+
| `@hop-top/kit/completion-values` | completer building blocks | used with `bindFlag` and `bindArgs` |
|
|
15
|
+
| `@hop-top/kit/alias` | user aliases for subcommands | `AliasStore`, `Expander`, `bridgeAliases` |
|
|
16
|
+
| `@hop-top/kit/tui` | status, badge, spinner, progress, prompts | `status(theme, text, level)`; theme from `buildTheme()` |
|
|
17
|
+
|
|
18
|
+
Matrix cell `unverified` (module exists, no Go pin): `@hop-top/kit/log` (`createLogger`),
|
|
19
|
+
`@hop-top/kit/progress` (`ProgressReporter`), `@hop-top/kit/errcorrect`
|
|
20
|
+
(`createCorrectedError`), `@hop-top/kit/config`, `@hop-top/kit/xdg`, `@hop-top/kit/sqlstore`.
|
|
21
|
+
Check each in coverage, tell the user, and test the behaviour you rely on.
|
|
22
|
+
|
|
23
|
+
URI scheme handlers, the wizard and flag helpers also sit under `unverified`, but their source
|
|
24
|
+
files have no key in the package `exports` map when this was written: you cannot import them.
|
|
25
|
+
Check the map.
|
|
26
|
+
|
|
27
|
+
## Output flags
|
|
28
|
+
|
|
29
|
+
- `createCLI` registers the suite; `--format` default is `table`. `-o report.csv` infers the
|
|
30
|
+
formatter from the extension; `--format json -o report.csv` is a hard error.
|
|
31
|
+
- `--template` takes eta syntax (`<%= %>`), not Go's `{{ }}`; it excludes `--cols`.
|
|
32
|
+
- Pass `columns` to `dispatch` for a fixed order; without it, rows print in key order.
|
|
33
|
+
- A formatter option goes `--format-opt key=value`; `--format-help` lists them.
|
|
34
|
+
|
|
35
|
+
## Layered config and paths
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { load } from '@hop-top/kit/config';
|
|
39
|
+
import { configDir } from '@hop-top/kit/xdg';
|
|
40
|
+
import { join } from 'node:path';
|
|
41
|
+
|
|
42
|
+
const cfg = load<{ host?: string }>({ host: 'localhost' }, {
|
|
43
|
+
userConfigPath: join(configDir('mytool'), 'config.yaml'),
|
|
44
|
+
projectConfigPath: '.mytool.yaml',
|
|
45
|
+
envOverride: (c) => { if (process.env.MYTOOL_HOST) c.host = process.env.MYTOOL_HOST; },
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- Order, lowest first: system, user, project, `envOverride`. A missing file is skipped.
|
|
50
|
+
- `load` fills and returns `dst`. Objects merge deeply; arrays and scalars replace. Go differs
|
|
51
|
+
on map entries and kind mismatches: do not share one config file contract with Go unchecked.
|
|
52
|
+
- `configDir` is `XDG_CONFIG_HOME` when set; otherwise macOS `~/Library/Preferences/<tool>`,
|
|
53
|
+
not `~/.config`. Pin `XDG_CONFIG_HOME` in tests.
|
|
54
|
+
- Merge options (`nullPolicy`, `arrayPolicy`, `maxDepth`) and `mergeLayers` for parsed objects:
|
|
55
|
+
see the API reference, "Layer merge rules".
|
|
56
|
+
|
|
57
|
+
## Traps
|
|
58
|
+
|
|
59
|
+
- `program.command('x').action(async ...)` needs `await program.parseAsync()`.
|
|
60
|
+
- Do not name your own leaf flag `--policy`, `--confirm`, `--max-ops` or `--dry-run` for another
|
|
61
|
+
meaning: the root owns them (a leaf's own flag of that name is the leaf's).
|
|
62
|
+
- Not in this port (coverage lists them): markdown rendering, config path commands, fuzzy
|
|
63
|
+
matching, process status. Use Go or the sidecar.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# TypeScript coverage
|
|
2
|
+
|
|
3
|
+
Generated by `make skills-sync` from the capability parity page. Do not edit by hand.
|
|
4
|
+
|
|
5
|
+
Tier: supported. Needs Node 22.12+. Source of truth: [capability parity](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/capability-parity.md).
|
|
6
|
+
|
|
7
|
+
## done (11)
|
|
8
|
+
|
|
9
|
+
A parity contract, shared corpus or cross-language test pins the SDK's behavior to Go.
|
|
10
|
+
|
|
11
|
+
- CLI and console: CLI factory, Output and errors, Shell completion, Aliases, Help rendering
|
|
12
|
+
- Serving and transports: Serve lifecycle, MCP server
|
|
13
|
+
- Guardrails and trust: Path scope, TypeID
|
|
14
|
+
- AI and agents: Toolspec, 12-factor compliance check
|
|
15
|
+
|
|
16
|
+
## partial (9)
|
|
17
|
+
|
|
18
|
+
The SDK ships a subset: a documented gap, one leg of the capability, or a stub.
|
|
19
|
+
|
|
20
|
+
- TUI components (CLI and console): parity.json blocks (status, spinner, anim, help, verbosity, streams); ts:tui/ py:tui/ rs:tui/ (progress, bar, spinner, status, confirm, app shell; no list or dialog); php Tui.php is an empty placeholder
|
|
21
|
+
- Command surface bridge (Serving and transports): MCP leg only: ts:mcp/bridge.ts py:mcp/bridge.py rs:mcp/bridge.rs php:Mcp/Bridge.php
|
|
22
|
+
- Redaction (Guardrails and trust): make test-parity-redact (Go/Rs); ts:telemetry/redact.ts py:telemetry/redact.py php:Telemetry/Redactor.php cover telemetry only
|
|
23
|
+
- Consent grants (Guardrails and trust): make test-parity-consent (Go/Rs, contracts/consent-v1); ts:telemetry/consent.ts py:telemetry/consent.py php:Telemetry/Consent.php are telemetry consent only
|
|
24
|
+
- Side-effect seams (Guardrails and trust): ts:sideeffect.ts py:sideeffect.py rs:sideeffect/ (--dry-run flag and per-command tiers not wired) php:Cli/SideEffect.php; shared annotation tiers, no corpus
|
|
25
|
+
- Upgrade and migrations (Guardrails and trust): make test-parity-upgrade (Go/Rs/Py/TS/PHP), every runner on all three corpus files; rs:upgrade/ is migrations plus the offline-aware release check (download and replace not ported); py:upgrade/ and ts:upgrade/ have the release check, lenient semver, Migration, Registry, the document migrator and the Migrator; php:Upgrade/ has the same without the release check; drivers: py configfile, fsdir, sqlite, postgres; ts configfile, fsdir, sqlite, postgres; php configfile, fsdir, sqlite, postgres; rs configfile, fsdir, sqlite, postgres; no port has the migrate command tree or a tidb driver
|
|
26
|
+
- LLM client (AI and agents): make test-parity-llm (Go/Rs/Py/TS, contracts/llm-v1); ts:llm.ts py:llm.py rs:llm/
|
|
27
|
+
- LLM providers (AI and agents): ts:llm-anthropic.ts llm-openai.ts (a Triton client exists in `src/triton/` but is not exported); py:llm_anthropic.py llm_openai.py rs:llm/ (anthropic, openai, google, ollama, triton); ts and py have no Google or Ollama adapter
|
|
28
|
+
- LLM routing (AI and agents): ts:routellm.ts (the RouteLLM adapter; the native router in `src/router/` exists but is not exported) py:routellm_adapter.py routellm_grpc.py rs:llm/router/ rs:llm/routellm/
|
|
29
|
+
|
|
30
|
+
## unverified (17)
|
|
31
|
+
|
|
32
|
+
A module exists but nothing in the repo pins it to Go; depth not checked.
|
|
33
|
+
|
|
34
|
+
- CLI and console: Logging, Flag helpers, Autocorrect, URI scheme handlers, Wizard, Progress events
|
|
35
|
+
- Config, storage and secrets: Layered config, XDG paths, SQLite JSON store
|
|
36
|
+
- Serving and transports: REST API toolkit, ConnectRPC, Served middleware
|
|
37
|
+
- Events, jobs and runtime: Event bus, Telemetry
|
|
38
|
+
- Guardrails and trust: Network policy, Delegation safety, Provenance
|
|
39
|
+
|
|
40
|
+
## none (36)
|
|
41
|
+
|
|
42
|
+
No module for the capability in the SDK tree.
|
|
43
|
+
|
|
44
|
+
- CLI and console: Markdown rendering, Config path commands, Fuzzy matching, Process status
|
|
45
|
+
- Config, storage and secrets: Project registry, Key-value store, Blob store, SQLite connections, HTTP cache, Secrets
|
|
46
|
+
- Serving and transports: Service command group, Transport service seam, Unix socket, Served authentication, Served observability, Bridge payloads
|
|
47
|
+
- Events, jobs and runtime: Job queue, Notifications, Domain building blocks, Entity sync, Peer mesh
|
|
48
|
+
- Guardrails and trust: Breaker, Event policy engine, Operating mode, Audit log, Identity, Utilities, Avatars
|
|
49
|
+
- AI and agents: Command reflection, Agent CLI invocation, Extensions
|
|
50
|
+
- Conformance and integrations: Conformance assertions, Conformance harness, Scenario and story DSL, Cassettes and grading client, Repo host drivers
|
|
51
|
+
|
|
52
|
+
## n/a (1)
|
|
53
|
+
|
|
54
|
+
The capability is a language seam that has no counterpart in that SDK.
|
|
55
|
+
|
|
56
|
+
- CLI and console: Command annotations
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Guardrails and trust
|
|
2
|
+
|
|
3
|
+
Open when adding delegation safety, path scope, offline enforcement, provenance, telemetry,
|
|
4
|
+
TypeIDs or upgrade migrations. Status per capability: [coverage](coverage.md). Depth:
|
|
5
|
+
[TypeScript API reference](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/ts-api-reference.md).
|
|
6
|
+
|
|
7
|
+
## Modules
|
|
8
|
+
|
|
9
|
+
| Import | Use for | Cue |
|
|
10
|
+
|--------|---------|-----|
|
|
11
|
+
| `@hop-top/kit/safety` | `--force` guard for destructive work | `safetyGuard(level, { force })`; levels `read`, `caution`, `dangerous` |
|
|
12
|
+
| `@hop-top/kit/scope` | filesystem path policy | `Default().check(path, Op.Read)`; deny list shared with Go |
|
|
13
|
+
| `@hop-top/kit/netpolicy` | `--offline` enforcement | `guardFetch`, `isOffline`, `isOfflineError` |
|
|
14
|
+
| `@hop-top/kit/provenance` | origin metadata on payloads | `withProvenance(data, { source, timestamp, method })` gives `{ data, _meta }` |
|
|
15
|
+
| `@hop-top/kit/telemetry` | consent-gated usage events | `Client`, `resolveMode`, `redact` |
|
|
16
|
+
| `@hop-top/kit/id` | TypeID primitive | mint and parse prefixed ids |
|
|
17
|
+
| `@hop-top/kit/upgrade` | release check, migrations | `createChecker`, `Migrator`, `migrateDocument` |
|
|
18
|
+
|
|
19
|
+
Matrix cell `unverified`: `@hop-top/kit/safety`, `@hop-top/kit/netpolicy`,
|
|
20
|
+
`@hop-top/kit/provenance`, `@hop-top/kit/telemetry`, and the event bus (no `exports` key for it
|
|
21
|
+
when this was written: not importable). Redaction, consent and side-effect seams
|
|
22
|
+
are `partial`; read their Evidence in coverage. Tell the user what is unpinned and test it.
|
|
23
|
+
|
|
24
|
+
## Delegation gates (in `cli`)
|
|
25
|
+
|
|
26
|
+
- Root `--confirm`, `--confirm-token`, `--max-ops`, `--policy`, `--dry-run` enforce a leaf's
|
|
27
|
+
`kit/side-effect` annotation, set on `annotations` of the command.
|
|
28
|
+
- An unannotated leaf named `delete`, `remove`, `rm`, `destroy`, `purge` or `drop` is gated as
|
|
29
|
+
destructive. A value outside the tier set is refused before the handler runs.
|
|
30
|
+
- Handlers under `--dry-run` call `isDryRun(cmd)` and `renderPlan`.
|
|
31
|
+
- Permission rules and per-caller budgets are loaded but never evaluated here.
|
|
32
|
+
- Guide: [guard destructive commands](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/guides/guard-destructive-commands.md).
|
|
33
|
+
|
|
34
|
+
## Telemetry
|
|
35
|
+
|
|
36
|
+
- Default-denied: `record` does nothing without a granted consent decision and a mode other
|
|
37
|
+
than `off` (`KIT_TELEMETRY_MODE`). This port reads consent; granting it is the `kit` binary.
|
|
38
|
+
- `record` never throws and returns at once; end with `await client.shutdown(ms)`.
|
|
39
|
+
- Redaction and consent here cover telemetry only, and the Go parity targets named for them are
|
|
40
|
+
Go and Rust. The envelope names events freely (`event` plus `attrs`), unlike Go's command
|
|
41
|
+
path. Read the Telemetry cell in coverage before saying it matches Go.
|
|
42
|
+
|
|
43
|
+
## Offline
|
|
44
|
+
|
|
45
|
+
`createCLI` installs `guardFetch` on `globalThis.fetch` for `--offline`; loopback stays open.
|
|
46
|
+
It does not cover `node:net`, `http.request`, database drivers or a client built with its own
|
|
47
|
+
`fetch`: those call `isOffline()` themselves or wrap their transport with `guardFetch`.
|
|
48
|
+
|
|
49
|
+
## Upgrade migrations
|
|
50
|
+
|
|
51
|
+
- `Migrator` from `@hop-top/kit/upgrade`; one driver per backend, each its own import:
|
|
52
|
+
`@hop-top/kit/upgrade/drivers/configfile`, `.../fsdir`, `.../sqlite`, `.../postgres`.
|
|
53
|
+
- Postgres: `await openPostgresDriver({ db: pool, connect: () => pool.connect(), table })`;
|
|
54
|
+
you own the `pg` Pool (at least two connections); no backup or restore.
|
|
55
|
+
- Same Postgres table and lock key as Go, so Go and TypeScript Migrators exclude each other.
|
|
56
|
+
`SqliteDriver` locks with `BEGIN EXCLUSIVE` on `.lock.db`, which does not exclude other ports.
|
|
57
|
+
- Drivers take your `dataDir`; the Migrator keeps versions under it.
|
|
58
|
+
- In the kit repo, `make test-ts-upgrade-integration` runs driver tests that need native
|
|
59
|
+
`better-sqlite3` or Docker; `make test-ts-sdk` does not.
|
|
60
|
+
- Not here: self-update (download and replace) and a migrate command tree: Go or the sidecar.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Other ports
|
|
2
|
+
|
|
3
|
+
Generated by `make skills-sync` from the capability parity page. Do not edit by hand.
|
|
4
|
+
|
|
5
|
+
This file is a snapshot taken at the `metadata.version` recorded in this skill's SKILL.md. The current matrix is [capability-matrix](https://github.com/hop-top/kit/blob/main/skills/hop-top-kit/references/capability-matrix.md); its source is [capability parity](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/capability-parity.md).
|
|
6
|
+
|
|
7
|
+
## Ports
|
|
8
|
+
|
|
9
|
+
| Port | Skill | Package | Install | Tier | Needs | Status counts |
|
|
10
|
+
|---|---|---|---|---|---|---|
|
|
11
|
+
| Go | [`hop-top-kit-go`](https://github.com/hop-top/kit/blob/main/skills/hop-top-kit-go/SKILL.md) | `hop.top/kit` | `go get hop.top/kit` | reference | Go 1.27 | 74 done |
|
|
12
|
+
| TypeScript | [`hop-top-kit-ts`](https://github.com/hop-top/kit-ts/blob/main/skills/hop-top-kit-ts/SKILL.md) | `@hop-top/kit` | `pnpm add @hop-top/kit` | supported | Node 22.12+ | 11 done, 9 partial, 17 unverified, 36 none, 1 n/a |
|
|
13
|
+
| Python | [`hop-top-kit-py`](https://github.com/hop-top/kit-py/blob/main/skills/hop-top-kit-py/SKILL.md) | `hop-top-kit` | `pip install hop-top-kit` | supported | Python 3.11+ | 9 done, 8 partial, 18 unverified, 38 none, 1 n/a |
|
|
14
|
+
| Rust | [`hop-top-kit-rs`](https://github.com/hop-top/kit-rs/blob/main/skills/hop-top-kit-rs/SKILL.md) | `hop-top-kit` | `cargo add hop-top-kit` | experimental | Rust 1.89+ | 13 done, 19 partial, 12 unverified, 29 none, 1 n/a |
|
|
15
|
+
| PHP | [`hop-top-kit-php`](https://github.com/hop-top/kit-php/blob/main/skills/hop-top-kit-php/SKILL.md) | `hop-top/kit` | `composer require hop-top/kit` | experimental | PHP 8.4+ | 4 done, 7 partial, 5 unverified, 57 none, 1 n/a |
|
|
16
|
+
|
|
17
|
+
## Router
|
|
18
|
+
|
|
19
|
+
To choose between ports, use [`hop-top-kit`](https://github.com/hop-top/kit/blob/main/skills/hop-top-kit/SKILL.md).
|
|
20
|
+
|
|
21
|
+
## Go only
|
|
22
|
+
|
|
23
|
+
No other port has these (status `none` or `n/a`); use Go or run the `kit` binary as a sidecar.
|
|
24
|
+
|
|
25
|
+
- CLI and console: Markdown rendering, Command annotations, Config path commands, Fuzzy matching, Process status
|
|
26
|
+
- Config, storage and secrets: Project registry, Secrets
|
|
27
|
+
- Serving and transports: Service command group, Transport service seam, Served observability, Bridge payloads
|
|
28
|
+
- Events, jobs and runtime: Job queue, Peer mesh
|
|
29
|
+
- Guardrails and trust: Operating mode, Audit log, Avatars
|
|
30
|
+
- AI and agents: Command reflection, Agent CLI invocation, Extensions
|
|
31
|
+
- Conformance and integrations: Conformance assertions, Conformance harness, Scenario and story DSL, Cassettes and grading client, Repo host drivers
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Serving and transports
|
|
2
|
+
|
|
3
|
+
Open when running a service lifecycle, serving a command tree over MCP, or calling REST or
|
|
4
|
+
ConnectRPC from TypeScript. Status per capability: [coverage](coverage.md). Depth:
|
|
5
|
+
[TypeScript API reference](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/reference/ts-api-reference.md)
|
|
6
|
+
(sections Serve and MCP surface).
|
|
7
|
+
|
|
8
|
+
## This port ships no server
|
|
9
|
+
|
|
10
|
+
kit-ts supervises services and mounts MCP as a plain handler; it opens no HTTP or socket
|
|
11
|
+
listener. Your service's `start` binds the port. The REST projection of a command tree, the Unix
|
|
12
|
+
socket service and served authentication are Go-only (coverage lists them as lacking).
|
|
13
|
+
|
|
14
|
+
## Modules
|
|
15
|
+
|
|
16
|
+
| Import | Use for | Cue |
|
|
17
|
+
|--------|---------|-----|
|
|
18
|
+
| `@hop-top/kit/serve` | `<tool> serve [service]` lifecycle | `ServiceRegistry`, `registerServe(program, { registry, configs })` |
|
|
19
|
+
| `@hop-top/kit/mcp` | command tree as MCP tools | `commanderBridge`, `createMcpHandler`, `serveStdio`, `defaultPolicy` |
|
|
20
|
+
| `@hop-top/kit/api` | REST client for kit entity APIs | `APIClient`, `WSClient`; a client, not a server |
|
|
21
|
+
| `@hop-top/kit/rpc` | ConnectRPC client | `RPCClient` |
|
|
22
|
+
|
|
23
|
+
Matrix cell `unverified`: `@hop-top/kit/api`, `@hop-top/kit/rpc`, and served middleware (the MCP
|
|
24
|
+
audit and safety slice only). Check coverage, tell the user, test the calls you depend on.
|
|
25
|
+
|
|
26
|
+
## Serve
|
|
27
|
+
|
|
28
|
+
- `serve <service>` starts that service even when its `enabled` is false; a supervisor run that
|
|
29
|
+
resolves to zero services exits 2. Exit codes: 0 clean, 1 failure, 2 usage, 3 unknown service,
|
|
30
|
+
5 policy denied.
|
|
31
|
+
- This port does not resolve dotted config keys: pass the resolved blocks as `configs`.
|
|
32
|
+
- Contract and parity: serve lifecycle corpus is shared with Go; see the
|
|
33
|
+
[serve lifecycle contract](https://github.com/hop-top/poly-kit/blob/next/docs/contracts/serve-lifecycle.md).
|
|
34
|
+
|
|
35
|
+
## MCP
|
|
36
|
+
|
|
37
|
+
- `assets/snippets/mcp/` lists tools from a one-leaf tree; its expected output is checked in.
|
|
38
|
+
- `commanderBridge` requires `run` (kit does not capture command output for you). Tools are named
|
|
39
|
+
by the leaf path joined with `toolNameSeparator` (default `.`; use `_` for hosts that refuse dots).
|
|
40
|
+
- Default policy blocks every destructive leaf on remote surfaces, including an unannotated leaf
|
|
41
|
+
named `delete`, `remove`, `rm`, `destroy`, `purge` or `drop`.
|
|
42
|
+
- One mount answers the `2024-11-05` and `2026-07-28` protocol eras per request. The protocol
|
|
43
|
+
layer is `@modelcontextprotocol/server` and `@modelcontextprotocol/core` (v2). The legacy
|
|
44
|
+
`@modelcontextprotocol/sdk` package cannot serve the newer era: do not add it.
|
|
45
|
+
- Host it on any stack: the handler is `(McpHttpRequest) => Promise<McpHttpResponse>`; stdio via
|
|
46
|
+
`serveStdio` for a host that spawns the tool.
|
|
47
|
+
- Confirmation on the modern era: `headerConfirmationGate` or `ElicitationConfirmGate`; the
|
|
48
|
+
`audit` option records every refusal.
|
|
49
|
+
- Guide: [serve MCP from any SDK](https://github.com/hop-top/poly-kit/blob/next/docs/adopters/guides/serve-mcp-from-any-sdk.md).
|