@hop-top/kit 0.5.0-alpha.10 → 0.5.0-alpha.11

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 (58) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +4 -4
  3. package/dist/alias.js +3 -3
  4. package/dist/{chunk-T46YPHKN.js → chunk-4FMALWYB.js} +45 -45
  5. package/dist/{chunk-WWUKGJB5.js → chunk-4GPCWBBA.js} +60 -7
  6. package/dist/{chunk-JZ22ZUFA.js → chunk-65VPWMPV.js} +4 -1
  7. package/dist/{chunk-YGYQUFGY.js → chunk-BXJ2J27B.js} +10 -10
  8. package/dist/chunk-CXBZTONY.js +65 -0
  9. package/dist/{chunk-K7VCKJ27.js → chunk-EE4M2UOF.js} +8 -4
  10. package/dist/{chunk-72XZWQX7.js → chunk-GFRAYYRD.js} +475 -162
  11. package/dist/{chunk-2JV3A7OP.js → chunk-IVQHLI56.js} +6 -10
  12. package/dist/{chunk-NLMS7HGP.js → chunk-IZ6Q4SE3.js} +3 -3
  13. package/dist/chunk-MFVUENZR.js +1549 -0
  14. package/dist/{chunk-BLS2OBIQ.js → chunk-ML7D5DWY.js} +2 -2
  15. package/dist/{chunk-GGWJRWWA.js → chunk-RYKLVOVK.js} +7 -7
  16. package/dist/{chunk-QPUCXQXT.js → chunk-T6OZMPPV.js} +2 -1
  17. package/dist/{chunk-MUIQVU6E.js → chunk-VGOA5Y7S.js} +11 -11
  18. package/dist/{chunk-ABQSE7AI.js → chunk-VWGP4NVJ.js} +38 -38
  19. package/dist/cli-RSRk1M36.d.ts +707 -0
  20. package/dist/cli.d.ts +1 -1
  21. package/dist/cli.js +60 -5
  22. package/dist/completion.js +2 -2
  23. package/dist/{index-DCe1boBz.d.ts → index-CGE5yLBj.d.ts} +1 -1
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +22 -22
  26. package/dist/llm-anthropic.js +5 -5
  27. package/dist/llm-openai.js +5 -5
  28. package/dist/llm.js +3 -3
  29. package/dist/log.js +3 -3
  30. package/dist/mcp/index.js +3 -2
  31. package/dist/output.js +2 -4
  32. package/dist/routellm.js +6 -6
  33. package/dist/toolspec.js +4 -4
  34. package/dist/tui/index.d.ts +2 -2
  35. package/dist/tui/index.js +3 -3
  36. package/dist/{upgrade-p_zh3pvV.d.ts → upgrade-C3RWGwRi.d.ts} +23 -0
  37. package/dist/upgrade.d.ts +1 -1
  38. package/dist/upgrade.js +2 -2
  39. package/package.json +1 -1
  40. package/src/cli.root.conformance.test.ts +166 -0
  41. package/src/cli.ts +39 -0
  42. package/src/completion.conformance.test.ts +3 -2
  43. package/src/completion.test.ts +12 -0
  44. package/src/completion.ts +8 -3
  45. package/src/delegation.test.ts +299 -0
  46. package/src/delegation.ts +807 -0
  47. package/src/mcp/bridge.test.ts +28 -0
  48. package/src/mcp/bridge.ts +5 -10
  49. package/src/plan.ts +89 -0
  50. package/src/policy.ts +472 -0
  51. package/src/sideeffect.ts +105 -0
  52. package/src/toolspec-manifest.ts +7 -2
  53. package/src/upgrade.test.ts +291 -0
  54. package/src/upgrade.ts +116 -7
  55. package/dist/chunk-GHPJJV5L.js +0 -613
  56. package/dist/chunk-IXVQ62NZ.js +0 -334
  57. package/dist/cli-C5B5tnpA.d.ts +0 -400
  58. package/dist/{chunk-PSFYJGDG.js → chunk-K7E34Q3A.js} +2 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,30 @@ All notable changes to `@hop-top/kit` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
5
5
  versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.0-alpha.11](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11) (2026-11-04)
8
+
9
+ The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.11. This release includes new features and bug fixes.
10
+
11
+
12
+ ### ⚠ BREAKING CHANGES
13
+
14
+ * **ts/cli:** unannotated leaf named delete|remove|rm|destroy|purge|drop now needs confirmation on CLI and is blocked on MCP default policy; --dry-run/--confirm/--max-ops/--policy reserved on root
15
+
16
+ ### Features
17
+
18
+ * **ts/cli:** delegation gate, side-effect inference ([692582a](https://github.com/hop-top/poly-kit/commit/692582ad6bd12757b5fa9199266a5e0584c108eb))
19
+ * **ts/upgrade:** tagPrefix and includePrereleases options ([bfec2d7](https://github.com/hop-top/poly-kit/commit/bfec2d7512410205cb9bb9aeb2e5faa52256dff9))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **toolspec:** dry_run_supported counts inferred destructive leaves ([8cb1f6c](https://github.com/hop-top/poly-kit/commit/8cb1f6c60bca7033fd9a137113eb3851bc94b2bb))
25
+ * **ts,py/cli:** inferred dry-run plan matches Go, drop stale skip ([b96cba3](https://github.com/hop-top/poly-kit/commit/b96cba3816a8f21fb2f7b1c900a8240439a8b7c0))
26
+ * **ts/cli:** refuse malformed side-effect tiers before running ([582dc3a](https://github.com/hop-top/poly-kit/commit/582dc3a86e292a1d9ff6ce1bc2576a4559545c80))
27
+ * **ts/completion:** deep alias shim offers inherited root flags ([f79acac](https://github.com/hop-top/poly-kit/commit/f79acac4b1a5fe9004292e3e81a25cc139da1d94))
28
+
29
+ Full diff: [kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.10...kit-ts/v0.5.0-alpha.11)
30
+
7
31
  ## [0.5.0-alpha.10](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.9...kit-ts/v0.5.0-alpha.10) (2026-10-30)
8
32
 
9
33
  The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.10. This release includes new features.
package/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # @hop-top/kit (TypeScript)
2
2
 
3
- Shared CLI utilities for hop-top tools, CommonJS edition. Mirrors the Go
4
- `kit` package surface: a Commander-based CLI factory, output formatting
5
- with a registry/Formatter contract, theming, hint plumbing, XDG paths,
6
- config files, an embedded SQLite store, upgrade checks, LLM helpers,
3
+ Shared CLI utilities for hop-top tools, CommonJS edition. Mirrors the Go `kit` package surface:
4
+ a Commander-based CLI factory, output formatting with a registry/Formatter contract, theming,
5
+ hint plumbing, XDG paths, config files, an embedded SQLite store, upgrade checks, LLM helpers,
7
6
  alias resolution, and a TUI toolkit.
8
7
 
9
8
  ## Install
@@ -64,6 +63,7 @@ upgrade detection), `llm`, `anthropic`, `openai`, `routellm`, `alias`, `uri`
64
63
  - Five built-in formatters (`json`, `yaml`, `table`, `csv`, `text`), the same set every kit SDK ships.
65
64
  - Column order comes from an explicit `ColumnSpec[]`; `--cols` reorders as well as selects; `header` must equal `key`.
66
65
  - `serve <service>` starts a named service even when `services.<name>.enabled` is false; a supervisor run resolving to zero services exits 2.
66
+ - Delegation gates: root `--confirm`, `--confirm-token`, `--max-ops`, `--policy`, `--dry-run` enforce a leaf's `kit/side-effect`; an unannotated leaf named `delete`/`remove`/`rm`/`destroy`/`purge`/`drop` is gated as destructive (and blocked on MCP by default). See the API reference.
67
67
  - MCP exposure is default-closed: `defaultPolicy()` blocks every destructive leaf on every remote surface.
68
68
  - Telemetry is default-denied: `Client.record()` is a no-op without both a granted consent decision and a non-`off` mode.
69
69
 
package/dist/alias.js CHANGED
@@ -9,8 +9,8 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkBLS2OBIQjs = require('./chunk-BLS2OBIQ.js');
13
- require('./chunk-JZ22ZUFA.js');
12
+ var _chunkML7D5DWYjs = require('./chunk-ML7D5DWY.js');
13
+ require('./chunk-65VPWMPV.js');
14
14
  require('./chunk-JKMQSAJP.js');
15
15
  require('./chunk-R5U7XKVJ.js');
16
16
 
@@ -24,4 +24,4 @@ require('./chunk-R5U7XKVJ.js');
24
24
 
25
25
 
26
26
 
27
- exports.AliasNameError = _chunkBLS2OBIQjs.AliasNameError; exports.AliasStore = _chunkBLS2OBIQjs.AliasStore; exports.Expander = _chunkBLS2OBIQjs.Expander; exports.bridgeAliases = _chunkBLS2OBIQjs.bridgeAliases; exports.detectCycles = _chunkBLS2OBIQjs.detectCycles; exports.findCommand = _chunkBLS2OBIQjs.findCommand; exports.findFirstNonFlag = _chunkBLS2OBIQjs.findFirstNonFlag; exports.loadFrom = _chunkBLS2OBIQjs.loadFrom; exports.saveTo = _chunkBLS2OBIQjs.saveTo; exports.validateAliasName = _chunkBLS2OBIQjs.validateAliasName;
27
+ exports.AliasNameError = _chunkML7D5DWYjs.AliasNameError; exports.AliasStore = _chunkML7D5DWYjs.AliasStore; exports.Expander = _chunkML7D5DWYjs.Expander; exports.bridgeAliases = _chunkML7D5DWYjs.bridgeAliases; exports.detectCycles = _chunkML7D5DWYjs.detectCycles; exports.findCommand = _chunkML7D5DWYjs.findCommand; exports.findFirstNonFlag = _chunkML7D5DWYjs.findFirstNonFlag; exports.loadFrom = _chunkML7D5DWYjs.loadFrom; exports.saveTo = _chunkML7D5DWYjs.saveTo; exports.validateAliasName = _chunkML7D5DWYjs.validateAliasName;
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkYGYQUFGYjs = require('./chunk-YGYQUFGY.js');
8
+ var _chunkBXJ2J27Bjs = require('./chunk-BXJ2J27B.js');
9
9
 
10
10
 
11
11
 
@@ -23,7 +23,7 @@ var _chunkYGYQUFGYjs = require('./chunk-YGYQUFGY.js');
23
23
 
24
24
 
25
25
 
26
- var _chunkPSFYJGDGjs = require('./chunk-PSFYJGDG.js');
26
+ var _chunkK7E34Q3Ajs = require('./chunk-K7E34Q3A.js');
27
27
 
28
28
 
29
29
  var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
@@ -55,12 +55,12 @@ var EVENT_STATUS = {
55
55
  var AnthropicAdapter = class {
56
56
  constructor(cfg) {
57
57
  const key = _nullishCoalesce(cfg.provider.apiKey, () => ( ""));
58
- if (key.trim() === "") throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: API key required");
59
- this.limits = _chunkYGYQUFGYjs.limitsFrom.call(void 0, SCHEME, cfg.provider.params);
58
+ if (key.trim() === "") throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: API key required");
59
+ this.limits = _chunkBXJ2J27Bjs.limitsFrom.call(void 0, SCHEME, cfg.provider.params);
60
60
  try {
61
- this.toolNames = _chunkPSFYJGDGjs.toolNameModeOf.call(void 0, cfg.provider.params);
61
+ this.toolNames = _chunkK7E34Q3Ajs.toolNameModeOf.call(void 0, cfg.provider.params);
62
62
  } catch (err) {
63
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`anthropic: ${err.message}`);
63
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: ${err.message}`);
64
64
  }
65
65
  const env = envReader(cfg);
66
66
  const envBase = env("ANTHROPIC_BASE_URL");
@@ -69,7 +69,7 @@ var AnthropicAdapter = class {
69
69
  const base = cfg.provider.baseURL || envBase || ANTHROPIC_DEFAULT_BASE_URL;
70
70
  this.baseURL = base;
71
71
  this.model = cfg.provider.model || _optionalChain([cfg, 'access', _ => _.uri, 'optionalAccess', _2 => _2.model]) || "";
72
- _chunkPSFYJGDGjs.checkKeyEndpoint.call(void 0, SCHEME, key, base);
72
+ _chunkK7E34Q3Ajs.checkKeyEndpoint.call(void 0, SCHEME, key, base);
73
73
  this.headers = {
74
74
  "content-type": "application/json",
75
75
  accept: "application/json",
@@ -79,14 +79,14 @@ var AnthropicAdapter = class {
79
79
  const token = _nullishCoalesce(env("ANTHROPIC_AUTH_TOKEN"), () => ( ""));
80
80
  const extra = {};
81
81
  if (token.trim() !== "") {
82
- _chunkPSFYJGDGjs.checkKeyEndpoint.call(void 0, SCHEME, token, base);
82
+ _chunkK7E34Q3Ajs.checkKeyEndpoint.call(void 0, SCHEME, token, base);
83
83
  extra["authorization"] = `Bearer ${token}`;
84
84
  }
85
85
  const ws = _nullishCoalesce(env("ANTHROPIC_WORKSPACE_ID"), () => ( ""));
86
86
  if (ws !== "") extra["anthropic-workspace-id"] = ws;
87
87
  const trusted = [ANTHROPIC_DEFAULT_BASE_URL];
88
88
  if (envBase) trusted.push(envBase);
89
- if (Object.keys(extra).length > 0 && _chunkPSFYJGDGjs.credentialsTrusted.call(void 0, SCHEME, base, ...trusted)) {
89
+ if (Object.keys(extra).length > 0 && _chunkK7E34Q3Ajs.credentialsTrusted.call(void 0, SCHEME, base, ...trusted)) {
90
90
  Object.assign(this.headers, extra);
91
91
  }
92
92
  this.secrets = [key, token].filter((s) => s.trim() !== "");
@@ -122,7 +122,7 @@ var AnthropicAdapter = class {
122
122
  }
123
123
  // ── private ────────────────────────────────────────────────────
124
124
  toolNameMap(tools) {
125
- return _chunkPSFYJGDGjs.ToolNames.build(_chunkPSFYJGDGjs.ANTHROPIC_TOOL_NAMES, this.toolNames, tools);
125
+ return _chunkK7E34Q3Ajs.ToolNames.build(_chunkK7E34Q3Ajs.ANTHROPIC_TOOL_NAMES, this.toolNames, tools);
126
126
  }
127
127
  transport(req) {
128
128
  const model = req.model || this.model;
@@ -135,18 +135,18 @@ var AnthropicAdapter = class {
135
135
  }
136
136
  async send(body, req) {
137
137
  const opts = this.transport(req);
138
- const resp = await _chunkYGYQUFGYjs.post.call(void 0, opts, this.url(), this.headers, body);
139
- const text = await _chunkYGYQUFGYjs.readBody.call(void 0, resp, this.limits.body, SCHEME).catch((e) => {
140
- throw _chunkYGYQUFGYjs.scrubError.call(void 0, e, this.secrets);
138
+ const resp = await _chunkBXJ2J27Bjs.post.call(void 0, opts, this.url(), this.headers, body);
139
+ const text = await _chunkBXJ2J27Bjs.readBody.call(void 0, resp, this.limits.body, SCHEME).catch((e) => {
140
+ throw _chunkBXJ2J27Bjs.scrubError.call(void 0, e, this.secrets);
141
141
  });
142
142
  try {
143
143
  return JSON.parse(text);
144
144
  } catch (e2) {
145
- throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: response is not valid JSON");
145
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: response is not valid JSON");
146
146
  }
147
147
  }
148
148
  url() {
149
- return _chunkYGYQUFGYjs.joinURL.call(void 0, this.baseURL, "v1/messages");
149
+ return _chunkBXJ2J27Bjs.joinURL.call(void 0, this.baseURL, "v1/messages");
150
150
  }
151
151
  openStream(req, tools) {
152
152
  let outcome;
@@ -165,19 +165,19 @@ var AnthropicAdapter = class {
165
165
  setToolChoice(body, req.toolChoice, _nullishCoalesce(tools, () => ( [])), names);
166
166
  body["stream"] = true;
167
167
  const opts = this.transport(req);
168
- const resp = await _chunkYGYQUFGYjs.post.call(void 0, opts, this.url(), {
168
+ const resp = await _chunkBXJ2J27Bjs.post.call(void 0, opts, this.url(), {
169
169
  ...this.headers,
170
170
  accept: "text/event-stream"
171
171
  }, body);
172
172
  const acc = new Accumulator();
173
173
  const events = req.streamEvents ? new EventMapper(acc, names) : void 0;
174
174
  try {
175
- for await (const ev of _chunkYGYQUFGYjs.sseEvents.call(void 0, resp, this.limits.event, SCHEME)) {
175
+ for await (const ev of _chunkBXJ2J27Bjs.sseEvents.call(void 0, resp, this.limits.event, SCHEME)) {
176
176
  let evt;
177
177
  try {
178
178
  evt = JSON.parse(ev.data);
179
179
  } catch (e3) {
180
- throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: stream event is not valid JSON");
180
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: stream event is not valid JSON");
181
181
  }
182
182
  if (evt.type === "error") {
183
183
  throw streamError(evt.error, req.model || this.model);
@@ -198,9 +198,9 @@ var AnthropicAdapter = class {
198
198
  }
199
199
  }
200
200
  } catch (err) {
201
- throw _chunkYGYQUFGYjs.scrubError.call(void 0, err, this.secrets);
201
+ throw _chunkBXJ2J27Bjs.scrubError.call(void 0, err, this.secrets);
202
202
  }
203
- throw new (0, _chunkPSFYJGDGjs.StreamTruncatedError)(SCHEME);
203
+ throw new (0, _chunkK7E34Q3Ajs.StreamTruncatedError)(SCHEME);
204
204
  }
205
205
  async buildBody(req, names) {
206
206
  const maxTokens = req.maxTokens !== void 0 && req.maxTokens > 0 ? req.maxTokens : DEFAULT_MAX_TOKENS;
@@ -214,12 +214,12 @@ var AnthropicAdapter = class {
214
214
  if (req.thinking) {
215
215
  const b = req.thinking.budgetTokens;
216
216
  if (b < MIN_THINKING_BUDGET) {
217
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
217
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
218
218
  `anthropic: thinking budget_tokens must be at least ${MIN_THINKING_BUDGET}, got ${b}`
219
219
  );
220
220
  }
221
221
  if (b >= maxTokens) {
222
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
222
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
223
223
  `anthropic: thinking budget_tokens (${b}) must be less than max_tokens (${maxTokens})`
224
224
  );
225
225
  }
@@ -237,7 +237,7 @@ function checkBaseURL(what, base) {
237
237
  try {
238
238
  new URL(base);
239
239
  } catch (e4) {
240
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`anthropic: invalid ${what}: ${JSON.stringify(_chunkPSFYJGDGjs.redactURI.call(void 0, base))}`);
240
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: invalid ${what}: ${JSON.stringify(_chunkK7E34Q3Ajs.redactURI.call(void 0, base))}`);
241
241
  }
242
242
  }
243
243
  async function extractSystem(msgs, names) {
@@ -288,27 +288,27 @@ function systemBlocks(msgs) {
288
288
  }
289
289
  function checkLinkageRole(m) {
290
290
  if ((_nullishCoalesce(_optionalChain([m, 'access', _9 => _9.toolCalls, 'optionalAccess', _10 => _10.length]), () => ( 0))) > 0 && m.role !== "assistant") {
291
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
291
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
292
292
  `anthropic: ToolCalls are valid only on role assistant, got ${JSON.stringify(m.role)}`
293
293
  );
294
294
  }
295
295
  if ((_nullishCoalesce(_optionalChain([m, 'access', _11 => _11.thinking, 'optionalAccess', _12 => _12.length]), () => ( 0))) > 0 && m.role !== "assistant") {
296
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
296
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
297
297
  `anthropic: Thinking is valid only on role assistant, got ${JSON.stringify(m.role)}`
298
298
  );
299
299
  }
300
300
  if (m.toolCallId && m.role !== "tool") {
301
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
301
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
302
302
  `anthropic: ToolCallID is valid only on role tool, got ${JSON.stringify(m.role)}`
303
303
  );
304
304
  }
305
305
  }
306
306
  function toolResultBlock(m) {
307
307
  if (!m.toolCallId) {
308
- throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: tool result needs ToolCallID");
308
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: tool result needs ToolCallID");
309
309
  }
310
310
  if (_optionalChain([m, 'access', _13 => _13.parts, 'optionalAccess', _14 => _14.length])) {
311
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
311
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
312
312
  `anthropic: tool result ${JSON.stringify(m.toolCallId)} carries only Content`
313
313
  );
314
314
  }
@@ -319,7 +319,7 @@ function toolResultBlock(m) {
319
319
  function toolUseBlocks(calls, names) {
320
320
  return calls.map((tc) => {
321
321
  if (!tc.id) {
322
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`anthropic: tool call ${JSON.stringify(tc.name)} needs an ID`);
322
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: tool call ${JSON.stringify(tc.name)} needs an ID`);
323
323
  }
324
324
  return {
325
325
  type: "tool_use",
@@ -336,7 +336,7 @@ function inputOf(tc) {
336
336
  try {
337
337
  return JSON.parse(args);
338
338
  } catch (e5) {
339
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
339
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
340
340
  `anthropic: tool call ${JSON.stringify(tc.id)} arguments are not valid JSON`
341
341
  );
342
342
  }
@@ -351,7 +351,7 @@ function cacheParam(cc) {
351
351
  const ttl = _nullishCoalesce(cc.ttl, () => ( ""));
352
352
  if (ttl === "") return { type: "ephemeral" };
353
353
  if (ttl === "5m" || ttl === "1h") return { type: "ephemeral", ttl };
354
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
354
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
355
355
  `anthropic: cache_control ttl must be "5m" or "1h", got ${JSON.stringify(ttl)}`
356
356
  );
357
357
  }
@@ -368,8 +368,8 @@ async function mapParts(parts) {
368
368
  break;
369
369
  case "image": {
370
370
  const mime = p.mimeType || _optionalChain([p, 'access', _15 => _15.source, 'optionalAccess', _16 => _16.mimeType, 'call', _17 => _17()]) || "";
371
- if (!mime) throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: image part needs a MIME type");
372
- if (!p.source) throw new (0, _chunkPSFYJGDGjs.LLMError)("anthropic: nil media source");
371
+ if (!mime) throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: image part needs a MIME type");
372
+ if (!p.source) throw new (0, _chunkK7E34Q3Ajs.LLMError)("anthropic: nil media source");
373
373
  const url = p.source.url();
374
374
  if (url) {
375
375
  out.push({ type: mime === "application/pdf" ? "document" : "image", source: { type: "url", url } });
@@ -382,16 +382,16 @@ async function mapParts(parts) {
382
382
  break;
383
383
  }
384
384
  default:
385
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`anthropic: unsupported modality ${JSON.stringify(p.type)}`);
385
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: unsupported modality ${JSON.stringify(p.type)}`);
386
386
  }
387
387
  }
388
388
  return out;
389
389
  }
390
390
  function setToolChoice(body, c, tools, names) {
391
391
  try {
392
- _chunkPSFYJGDGjs.checkToolChoice.call(void 0, c, tools);
392
+ _chunkK7E34Q3Ajs.checkToolChoice.call(void 0, c, tools);
393
393
  } catch (err) {
394
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`anthropic: ${err.message}`);
394
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`anthropic: ${err.message}`);
395
395
  }
396
396
  if (!c) return;
397
397
  body["tool_choice"] = c.mode === "tool" ? { type: "tool", name: names.wire(_nullishCoalesce(c.name, () => ( ""))) } : { type: c.mode };
@@ -493,7 +493,7 @@ var Accumulator = class {
493
493
  }
494
494
  case "content_block_start": {
495
495
  if (evt.index !== this.content.length) {
496
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
496
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
497
497
  `anthropic: received event of type content_block_start for content block at index ${evt.index}, expected index ${this.content.length}`
498
498
  );
499
499
  }
@@ -505,7 +505,7 @@ var Accumulator = class {
505
505
  case "content_block_delta": {
506
506
  const i = _nullishCoalesce(evt.index, () => ( -1));
507
507
  if (i < 0 || i >= this.content.length) {
508
- throw new (0, _chunkPSFYJGDGjs.LLMError)(
508
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(
509
509
  `anthropic: received event of type content_block_delta for content block at index ${i}, only ${this.content.length} blocks exist`
510
510
  );
511
511
  }
@@ -636,18 +636,18 @@ function streamError(e, model) {
636
636
  return classify(status, type, `anthropic: stream error: ${type}: ${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _26 => _26.message]), () => ( ""))}`, model);
637
637
  }
638
638
  function classify(status, type, message, model) {
639
- const api = new (0, _chunkPSFYJGDGjs.APIError)(SCHEME, status, type, message);
639
+ const api = new (0, _chunkK7E34Q3Ajs.APIError)(SCHEME, status, type, message);
640
640
  switch (status) {
641
641
  case 401:
642
- return new (0, _chunkPSFYJGDGjs.AuthError)(SCHEME, api);
642
+ return new (0, _chunkK7E34Q3Ajs.AuthError)(SCHEME, api);
643
643
  case 403:
644
- return new (0, _chunkPSFYJGDGjs.PermissionDeniedError)(SCHEME, api);
644
+ return new (0, _chunkK7E34Q3Ajs.PermissionDeniedError)(SCHEME, api);
645
645
  case 429:
646
- return new (0, _chunkPSFYJGDGjs.RateLimitError)(SCHEME);
646
+ return new (0, _chunkK7E34Q3Ajs.RateLimitError)(SCHEME);
647
647
  case 404:
648
- return new (0, _chunkPSFYJGDGjs.ModelError)(model, SCHEME);
648
+ return new (0, _chunkK7E34Q3Ajs.ModelError)(model, SCHEME);
649
649
  }
650
- if (status >= 500) return new (0, _chunkPSFYJGDGjs.HTTPStatusError)(status, message);
650
+ if (status >= 500) return new (0, _chunkK7E34Q3Ajs.HTTPStatusError)(status, message);
651
651
  return api;
652
652
  }
653
653
  function anthropicFactory(cfg) {
@@ -660,7 +660,7 @@ function anthropicFactory(cfg) {
660
660
  close: () => a.close()
661
661
  };
662
662
  }
663
- _chunkPSFYJGDGjs.register.call(void 0, SCHEME, anthropicFactory, { endpoints: [ANTHROPIC_DEFAULT_BASE_URL] });
663
+ _chunkK7E34Q3Ajs.register.call(void 0, SCHEME, anthropicFactory, { endpoints: [ANTHROPIC_DEFAULT_BASE_URL] });
664
664
 
665
665
 
666
666
 
@@ -11,6 +11,8 @@ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
11
11
  var _os = require('os'); var os = _interopRequireWildcard(_os);
12
12
  var _path = require('path'); var path = _interopRequireWildcard(_path);
13
13
  var _semver = require('semver'); var _semver2 = _interopRequireDefault(_semver);
14
+ var PAGE_SIZE = 100;
15
+ var MAX_PAGES = 3;
14
16
  function createChecker(opts) {
15
17
  const {
16
18
  name,
@@ -19,25 +21,42 @@ function createChecker(opts) {
19
21
  repo,
20
22
  cacheTTL = 24 * 60 * 60 * 1e3,
21
23
  stateDir = os.tmpdir(),
22
- timeout = 1e4
24
+ timeout = 1e4,
25
+ tagPrefix = "",
26
+ includePrereleases = false
23
27
  } = opts;
28
+ const listMode = tagPrefix !== "" || includePrereleases;
24
29
  const cacheFile = path.join(stateDir, `.upgrade-${name}-cache.json`);
25
30
  const releaseURL = `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
31
+ const listURL = `https://api.github.com/repos/${owner}/${repo}/releases`;
26
32
  const releasesPageURL = `https://github.com/${owner}/${repo}/releases/latest`;
33
+ function noticeURL(tag) {
34
+ if (!listMode) return releasesPageURL;
35
+ const base = `https://github.com/${owner}/${repo}/releases`;
36
+ if (tag === void 0) return base;
37
+ return `${base}/tag/${tag.split("/").map(encodeURIComponent).join("/")}`;
38
+ }
39
+ function tagNamesVersion(tag, version) {
40
+ return typeof tag === "string" && tag.startsWith(tagPrefix) && _semver2.default.valid(tag.slice(tagPrefix.length).replace(/^v/, "")) === version;
41
+ }
27
42
  function readCache() {
28
43
  try {
29
44
  const raw = fs.readFileSync(cacheFile, "utf8");
30
45
  const parsed = JSON.parse(raw);
31
46
  if (typeof parsed.version === "string" && typeof parsed.checkedAt === "number") {
47
+ if (listMode && !tagNamesVersion(parsed.tag, parsed.version)) {
48
+ return null;
49
+ }
32
50
  return parsed;
33
51
  }
34
52
  } catch (e) {
35
53
  }
36
54
  return null;
37
55
  }
38
- function writeCache(version) {
56
+ function writeCache(version, tag) {
39
57
  try {
40
58
  const entry = { version, checkedAt: Date.now() };
59
+ if (tag !== void 0) entry.tag = tag;
41
60
  fs.writeFileSync(cacheFile, JSON.stringify(entry), "utf8");
42
61
  } catch (e2) {
43
62
  }
@@ -46,6 +65,7 @@ function createChecker(opts) {
46
65
  const controller = new AbortController();
47
66
  const timer = setTimeout(() => controller.abort(), timeout);
48
67
  try {
68
+ if (listMode) return await fetchHighestRelease(controller.signal);
49
69
  const res = await fetch(releaseURL, {
50
70
  signal: controller.signal,
51
71
  headers: { Accept: "application/vnd.github+json" }
@@ -54,28 +74,61 @@ function createChecker(opts) {
54
74
  const body = await res.json();
55
75
  const tag = body.tag_name;
56
76
  if (typeof tag !== "string") return null;
57
- return tag.replace(/^v/, "");
77
+ return { version: tag.replace(/^v/, "") };
58
78
  } finally {
59
79
  clearTimeout(timer);
60
80
  }
61
81
  }
82
+ async function fetchHighestRelease(signal) {
83
+ let best = null;
84
+ for (let page = 1; page <= MAX_PAGES; page++) {
85
+ const res = await fetch(`${listURL}?per_page=${PAGE_SIZE}&page=${page}`, {
86
+ signal,
87
+ headers: { Accept: "application/vnd.github+json" }
88
+ });
89
+ if (!res.ok) {
90
+ if (page === 1) return null;
91
+ break;
92
+ }
93
+ const body = await res.json();
94
+ if (!Array.isArray(body)) return page === 1 ? null : best;
95
+ for (const rel of body) {
96
+ if (rel === null || typeof rel !== "object") continue;
97
+ if (rel.draft === true || typeof rel.tag_name !== "string") continue;
98
+ const tag = rel.tag_name;
99
+ if (!tag.startsWith(tagPrefix)) continue;
100
+ const version = _semver2.default.valid(tag.slice(tagPrefix.length).replace(/^v/, ""));
101
+ if (version === null) continue;
102
+ if (!includePrereleases && (rel.prerelease === true || _semver2.default.prerelease(version) !== null)) {
103
+ continue;
104
+ }
105
+ if (best === null || _semver2.default.gt(version, best.version)) best = { version, tag };
106
+ }
107
+ if (body.length < PAGE_SIZE) break;
108
+ }
109
+ return best;
110
+ }
62
111
  async function notifyIfAvailable(out) {
63
112
  try {
64
113
  let latestVersion = null;
114
+ let latestTag;
65
115
  const cached = readCache();
66
116
  if (cached !== null && Date.now() - cached.checkedAt < cacheTTL) {
67
117
  latestVersion = cached.version;
118
+ latestTag = cached.tag;
68
119
  } else {
69
- latestVersion = await fetchLatestVersion();
70
- if (latestVersion !== null) {
71
- writeCache(latestVersion);
120
+ const latest = await fetchLatestVersion();
121
+ if (latest !== null) {
122
+ latestVersion = latest.version;
123
+ latestTag = latest.tag;
124
+ writeCache(latest.version, latest.tag);
72
125
  }
73
126
  }
74
127
  if (latestVersion === null) return;
75
128
  if (!_semver2.default.gt(latestVersion, currentVersion)) return;
76
129
  const notice = `
77
130
  A new release of ${name} is available: v${currentVersion} \u2192 v${latestVersion}
78
- ${releasesPageURL}
131
+ ${noticeURL(latestTag)}
79
132
  `;
80
133
  out.write(notice);
81
134
  } catch (e3) {
@@ -832,7 +832,10 @@ function flagsOf(root, chain) {
832
832
  for (let i = chain.length - 2; i >= 0; i--) {
833
833
  const anc = chain[i];
834
834
  if (internals(anc)._enablePositionalOptions) break;
835
- for (const o of anc.options) out.push(toFlag(o, anc, root, true));
835
+ for (const o of anc.options) {
836
+ if (internals(anc)._versionOptionName === o.attributeName()) continue;
837
+ out.push(toFlag(o, anc, root, true));
838
+ }
836
839
  }
837
840
  if (isShim(root, cmd)) {
838
841
  out.push({
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkPSFYJGDGjs = require('./chunk-PSFYJGDG.js');
6
+ var _chunkK7E34Q3Ajs = require('./chunk-K7E34Q3A.js');
7
7
 
8
8
  // src/llm-http.ts
9
9
  var DEFAULT_MAX_BODY_BYTES = 32 << 20;
@@ -21,7 +21,7 @@ function limitsFrom(provider, params) {
21
21
  const t = v.trim();
22
22
  const n = Number(t);
23
23
  if (!/^\d+$/.test(t) || !Number.isSafeInteger(n) || n <= 0) {
24
- throw new (0, _chunkPSFYJGDGjs.LLMError)(`${provider}: ${name} must be a positive byte count`);
24
+ throw new (0, _chunkK7E34Q3Ajs.LLMError)(`${provider}: ${name} must be a positive byte count`);
25
25
  }
26
26
  l[key] = n;
27
27
  }
@@ -48,7 +48,7 @@ async function post(opts, url, headers, body) {
48
48
  }
49
49
  if (resp.status >= 300 && resp.status < 400) {
50
50
  await _optionalChain([resp, 'access', _2 => _2.body, 'optionalAccess', _3 => _3.cancel, 'call', _4 => _4(), 'access', _5 => _5.catch, 'call', _6 => _6(() => void 0)]);
51
- throw new (0, _chunkPSFYJGDGjs.HTTPStatusError)(resp.status, `${opts.provider}: redirect not followed`);
51
+ throw new (0, _chunkK7E34Q3Ajs.HTTPStatusError)(resp.status, `${opts.provider}: redirect not followed`);
52
52
  }
53
53
  if (resp.ok) return resp;
54
54
  const text = await readBody(resp, opts.limits.body, opts.provider).catch(
@@ -65,7 +65,7 @@ async function post(opts, url, headers, body) {
65
65
  status: resp.status,
66
66
  statusText: resp.statusText,
67
67
  headers: resp.headers,
68
- body: _chunkPSFYJGDGjs.scrubSecrets.call(void 0, text, opts.secrets)
68
+ body: _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, text, opts.secrets)
69
69
  }),
70
70
  opts.secrets
71
71
  );
@@ -114,14 +114,14 @@ function sleep(ms) {
114
114
  function networkError(provider, err) {
115
115
  const cause = err.cause;
116
116
  const detail = _nullishCoalesce(_nullishCoalesce(_optionalChain([cause, 'optionalAccess', _7 => _7.message]), () => ( _optionalChain([err, 'optionalAccess', _8 => _8.message]))), () => ( String(err)));
117
- const e = new (0, _chunkPSFYJGDGjs.LLMError)(`${provider}: request failed: ${detail}`);
117
+ const e = new (0, _chunkK7E34Q3Ajs.LLMError)(`${provider}: request failed: ${detail}`);
118
118
  if (_optionalChain([cause, 'optionalAccess', _9 => _9.code])) e.code = cause.code;
119
119
  return e;
120
120
  }
121
121
  function scrubError(err, secrets) {
122
122
  if (!(err instanceof Error) || secrets.length === 0) return err;
123
- err.message = _chunkPSFYJGDGjs.scrubSecrets.call(void 0, err.message, secrets);
124
- if (err.stack) err.stack = _chunkPSFYJGDGjs.scrubSecrets.call(void 0, err.stack, secrets);
123
+ err.message = _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, err.message, secrets);
124
+ if (err.stack) err.stack = _chunkK7E34Q3Ajs.scrubSecrets.call(void 0, err.stack, secrets);
125
125
  const cause = err.cause;
126
126
  if (cause instanceof Error && cause !== err) scrubError(cause, secrets);
127
127
  return err;
@@ -138,7 +138,7 @@ async function readBody(resp, max, provider) {
138
138
  read += value.byteLength;
139
139
  if (read > max) {
140
140
  await reader.cancel().catch(() => void 0);
141
- throw new (0, _chunkPSFYJGDGjs.ResponseTooLargeError)(provider, "body", max);
141
+ throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "body", max);
142
142
  }
143
143
  chunks.push(value);
144
144
  }
@@ -177,7 +177,7 @@ async function* sseEvents(resp, max, provider) {
177
177
  continue;
178
178
  }
179
179
  eventBytes += nonCR(line) + 1;
180
- if (eventBytes > max) throw new (0, _chunkPSFYJGDGjs.ResponseTooLargeError)(provider, "event", max);
180
+ if (eventBytes > max) throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "event", max);
181
181
  const text = decoder.decode(line);
182
182
  if (text.startsWith(":")) continue;
183
183
  const colon = text.indexOf(":");
@@ -188,7 +188,7 @@ async function* sseEvents(resp, max, provider) {
188
188
  else if (field === "data") data.push(v);
189
189
  }
190
190
  if (eventBytes + nonCR(buf) > max) {
191
- throw new (0, _chunkPSFYJGDGjs.ResponseTooLargeError)(provider, "event", max);
191
+ throw new (0, _chunkK7E34Q3Ajs.ResponseTooLargeError)(provider, "event", max);
192
192
  }
193
193
  if (done) {
194
194
  finished = true;
@@ -0,0 +1,65 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/sideeffect.ts
2
+ var SIDE_EFFECT_ANNOTATION = "kit/side-effect";
3
+ var SIDE_EFFECT_TIERS = [
4
+ "read",
5
+ "write",
6
+ "write-local",
7
+ "write-shared",
8
+ "destructive",
9
+ "destructive-local",
10
+ "destructive-shared",
11
+ "interactive"
12
+ ];
13
+ var INFERRED_TIER = "destructive-shared";
14
+ var WRITE_LIKE = /* @__PURE__ */ new Set(["write", "write-local", "write-shared"]);
15
+ var DESTRUCTIVE_LIKE = /* @__PURE__ */ new Set([
16
+ "destructive",
17
+ "destructive-local",
18
+ "destructive-shared"
19
+ ]);
20
+ function isWriteLike(tier) {
21
+ return WRITE_LIKE.has(tier);
22
+ }
23
+ function isDestructiveLike(tier) {
24
+ return DESTRUCTIVE_LIKE.has(tier);
25
+ }
26
+ function isValidSideEffect(tier) {
27
+ return SIDE_EFFECT_TIERS.includes(tier);
28
+ }
29
+ var DESTRUCTIVE_NAMES = /* @__PURE__ */ new Set([
30
+ "delete",
31
+ "remove",
32
+ "rm",
33
+ "destroy",
34
+ "purge",
35
+ "drop"
36
+ ]);
37
+ function isDestructiveName(name) {
38
+ return DESTRUCTIVE_NAMES.has(name);
39
+ }
40
+ function destructiveNames() {
41
+ return [...DESTRUCTIVE_NAMES].sort();
42
+ }
43
+ function inferredDestructive(name, annotations) {
44
+ const declared = _optionalChain([annotations, 'optionalAccess', _ => _[SIDE_EFFECT_ANNOTATION]]);
45
+ if (declared !== void 0 && declared !== "") return false;
46
+ return isDestructiveName(name);
47
+ }
48
+ function gateSideEffect(name, annotations) {
49
+ if (inferredDestructive(name, annotations)) return INFERRED_TIER;
50
+ const declared = _optionalChain([annotations, 'optionalAccess', _2 => _2[SIDE_EFFECT_ANNOTATION]]);
51
+ return declared === void 0 ? void 0 : declared;
52
+ }
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+ exports.SIDE_EFFECT_ANNOTATION = SIDE_EFFECT_ANNOTATION; exports.SIDE_EFFECT_TIERS = SIDE_EFFECT_TIERS; exports.INFERRED_TIER = INFERRED_TIER; exports.isWriteLike = isWriteLike; exports.isDestructiveLike = isDestructiveLike; exports.isValidSideEffect = isValidSideEffect; exports.isDestructiveName = isDestructiveName; exports.destructiveNames = destructiveNames; exports.inferredDestructive = inferredDestructive; exports.gateSideEffect = gateSideEffect;