@psnext/slingcli 2.5.20260607-2 → 2.5.20260615-2

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 (205) hide show
  1. package/node_modules/@aws-sdk/core/dist-cjs/index.js +47 -2297
  2. package/node_modules/@aws-sdk/core/dist-es/index.js +3 -3
  3. package/node_modules/@aws-sdk/core/dist-types/index.d.ts +5 -5
  4. package/node_modules/@aws-sdk/core/dist-types/ts3.4/index.d.ts +5 -5
  5. package/node_modules/@aws-sdk/core/package.json +8 -8
  6. package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
  7. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +7 -7
  8. package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -5
  9. package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
  10. package/node_modules/@aws-sdk/credential-provider-login/package.json +5 -5
  11. package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
  12. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  13. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +4 -1
  14. package/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js +4 -1
  15. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +5 -5
  16. package/node_modules/@aws-sdk/credential-provider-sso/package.json +9 -7
  17. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +5 -5
  18. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +3 -3
  19. package/node_modules/@aws-sdk/middleware-eventstream/package.json +3 -3
  20. package/node_modules/@aws-sdk/middleware-websocket/package.json +5 -5
  21. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  22. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  23. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  24. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  25. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  26. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +7 -7
  27. package/node_modules/@aws-sdk/nested-clients/package.json +6 -6
  28. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +7 -6
  29. package/node_modules/@aws-sdk/types/package.json +2 -2
  30. package/node_modules/@aws-sdk/util-locate-window/package.json +2 -2
  31. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  32. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +8 -0
  33. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +1 -1
  34. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  35. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +6 -6
  36. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +906 -873
  37. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +25 -8
  38. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +19 -12
  39. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -0
  40. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +8 -4
  41. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +2 -1
  42. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +2 -1
  43. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +1 -0
  44. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +1 -1
  45. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +3 -2
  46. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  47. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +3 -5
  48. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/project-trust.js +48 -0
  49. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/startup-ui.js +133 -0
  50. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +14 -3
  51. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +4 -1
  52. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js +2 -2
  53. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +9 -2
  54. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js +1 -1
  55. package/node_modules/@earendil-works/pi-coding-agent/dist/core/experimental.js +4 -0
  56. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +4 -4
  57. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js +34 -0
  58. package/node_modules/@earendil-works/pi-coding-agent/dist/core/index.js +1 -0
  59. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +5 -57
  60. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js +41 -5
  61. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +31 -17
  62. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +58 -0
  63. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js +24 -26
  64. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resolve-config-value.js +0 -4
  65. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +121 -54
  66. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +11 -2
  67. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +26 -0
  68. package/node_modules/@earendil-works/pi-coding-agent/dist/core/trust-manager.js +89 -17
  69. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js +2 -2
  70. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +65 -76
  71. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.js +1 -118
  72. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/first-time-setup.js +103 -0
  73. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/index.js +1 -0
  74. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +7 -1
  75. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +20 -0
  76. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +87 -12
  77. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/trust-selector.js +23 -18
  78. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +104 -30
  79. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +19 -41
  80. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +72 -18
  81. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js +78 -0
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/version-check.js +4 -27
  83. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/LICENSE +15 -0
  84. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/bin/semver.js +195 -0
  85. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/classes/comparator.js +143 -0
  86. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/classes/index.js +7 -0
  87. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/classes/range.js +557 -0
  88. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/classes/semver.js +333 -0
  89. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/clean.js +8 -0
  90. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/cmp.js +54 -0
  91. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/coerce.js +62 -0
  92. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/compare-build.js +9 -0
  93. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/compare-loose.js +5 -0
  94. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/compare.js +7 -0
  95. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/diff.js +60 -0
  96. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/eq.js +5 -0
  97. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/gt.js +5 -0
  98. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/gte.js +5 -0
  99. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/inc.js +21 -0
  100. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/lt.js +5 -0
  101. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/lte.js +5 -0
  102. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/major.js +5 -0
  103. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/minor.js +5 -0
  104. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/neq.js +5 -0
  105. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/parse.js +18 -0
  106. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/patch.js +5 -0
  107. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/prerelease.js +8 -0
  108. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/rcompare.js +5 -0
  109. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/rsort.js +5 -0
  110. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/satisfies.js +12 -0
  111. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/sort.js +5 -0
  112. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/truncate.js +48 -0
  113. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/functions/valid.js +8 -0
  114. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/index.js +93 -0
  115. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/constants.js +37 -0
  116. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/debug.js +11 -0
  117. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/identifiers.js +29 -0
  118. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/lrucache.js +42 -0
  119. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/parse-options.js +17 -0
  120. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/internal/re.js +223 -0
  121. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/package.json +78 -0
  122. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/preload.js +4 -0
  123. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/range.bnf +17 -0
  124. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/gtr.js +6 -0
  125. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/intersects.js +9 -0
  126. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/ltr.js +6 -0
  127. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/max-satisfying.js +27 -0
  128. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/min-satisfying.js +26 -0
  129. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/min-version.js +63 -0
  130. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/outside.js +82 -0
  131. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/simplify.js +49 -0
  132. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/subset.js +249 -0
  133. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/to-comparators.js +10 -0
  134. package/node_modules/@earendil-works/pi-coding-agent/node_modules/semver/ranges/valid.js +13 -0
  135. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +25 -12
  136. package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -8
  137. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +102 -43
  138. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -1
  139. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +2 -2
  140. package/node_modules/@earendil-works/pi-tui/dist/index.js +2 -0
  141. package/node_modules/@earendil-works/pi-tui/dist/terminal-colors.js +51 -0
  142. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +38 -77
  143. package/node_modules/@earendil-works/pi-tui/dist/tui.js +145 -21
  144. package/node_modules/@earendil-works/pi-tui/dist/utils.js +44 -16
  145. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  146. package/node_modules/@nodable/entities/package.json +4 -1
  147. package/node_modules/@nodable/entities/src/EntityDecoder.js +104 -3
  148. package/node_modules/@nodable/entities/src/index.d.ts +77 -0
  149. package/node_modules/@nodable/entities/src/index.js +1 -1
  150. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +3 -3
  151. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +3 -3
  152. package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/retry-pre-sra-deprecated/StandardRetryStrategy.js +2 -2
  153. package/node_modules/@smithy/core/dist-es/submodules/retry/util-retry/DefaultRateLimiter.js +1 -1
  154. package/node_modules/@smithy/core/package.json +17 -17
  155. package/node_modules/@smithy/credential-provider-imds/package.json +6 -6
  156. package/node_modules/@smithy/fetch-http-handler/package.json +9 -9
  157. package/node_modules/@smithy/signature-v4/package.json +6 -6
  158. package/node_modules/@smithy/types/package.json +9 -9
  159. package/node_modules/@types/node/README.md +1 -1
  160. package/node_modules/@types/node/http2.d.ts +1 -0
  161. package/node_modules/@types/node/package.json +2 -2
  162. package/node_modules/anynum/LICENSE +21 -0
  163. package/node_modules/anynum/README.md +142 -0
  164. package/node_modules/anynum/anynum.js +135 -0
  165. package/node_modules/anynum/digitTable.js +116 -0
  166. package/node_modules/anynum/package.json +42 -0
  167. package/node_modules/protobufjs/dist/light/protobuf.js +161 -203
  168. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  169. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  170. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  171. package/node_modules/protobufjs/dist/minimal/protobuf.js +34 -77
  172. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  173. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  174. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  175. package/node_modules/protobufjs/dist/protobuf.js +181 -223
  176. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  177. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  178. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  179. package/node_modules/protobufjs/index.d.ts +0 -8
  180. package/node_modules/protobufjs/package.json +2 -3
  181. package/node_modules/protobufjs/src/converter.js +5 -4
  182. package/node_modules/protobufjs/src/decoder.js +1 -1
  183. package/node_modules/protobufjs/src/service.js +5 -7
  184. package/node_modules/protobufjs/src/type.js +3 -1
  185. package/node_modules/protobufjs/src/util/minimal.js +1 -4
  186. package/node_modules/protobufjs/src/verifier.js +1 -1
  187. package/node_modules/semver/classes/range.js +11 -2
  188. package/node_modules/semver/package.json +2 -2
  189. package/node_modules/strnum/CHANGELOG.md +8 -0
  190. package/node_modules/strnum/README.md +9 -0
  191. package/node_modules/strnum/package.json +4 -1
  192. package/node_modules/strnum/strnum.js +9 -1
  193. package/package.json +6 -6
  194. package/slingshot/index.js +260 -258
  195. package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
  196. package/node_modules/@protobufjs/inquire/LICENSE +0 -26
  197. package/node_modules/@protobufjs/inquire/README.md +0 -13
  198. package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
  199. package/node_modules/@protobufjs/inquire/index.js +0 -38
  200. package/node_modules/@protobufjs/inquire/package.json +0 -21
  201. package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
  202. package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
  203. package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
  204. package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
  205. package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
@@ -1,10 +1,13 @@
1
1
  import { Markdown } from "@earendil-works/pi-tui";
2
2
  import chalk from "chalk";
3
3
  import { selectConfig } from "./cli/config-selector.js";
4
+ import { createProjectTrustContext } from "./cli/project-trust.js";
4
5
  import { APP_NAME, detectInstallMethod, getAgentDir, getPackageDir, getSelfUpdateCommand, getSelfUpdateUnavailableInstruction, PACKAGE_NAME, VERSION, } from "./config.js";
5
6
  import { DefaultPackageManager } from "./core/package-manager.js";
7
+ import { resolveProjectTrusted } from "./core/project-trust.js";
8
+ import { DefaultResourceLoader } from "./core/resource-loader.js";
6
9
  import { SettingsManager } from "./core/settings-manager.js";
7
- import { hasProjectTrustInputs, ProjectTrustStore } from "./core/trust-manager.js";
10
+ import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/trust-manager.js";
8
11
  import { spawnProcess } from "./utils/child-process.js";
9
12
  import { getLatestPiRelease, isNewerPackageVersion } from "./utils/version-check.js";
10
13
  import { cleanupWindowsSelfUpdateQuarantine, quarantineWindowsNativeDependencies, } from "./utils/windows-self-update.js";
@@ -75,7 +78,7 @@ Remove a package and its source from settings.
75
78
  Alias: ${APP_NAME} uninstall <source> [-l]
76
79
 
77
80
  Options:
78
- -l, --local Remove from project settings (.pi/settings.json)
81
+ -l, --local Remove from project settings (.sling/settings.json)
79
82
  -a, --approve Trust project-local files for this command
80
83
  -na, --no-approve Ignore project-local files for this command
81
84
 
@@ -88,20 +91,20 @@ Examples:
88
91
  console.log(`${chalk.bold("Usage:")}
89
92
  ${getPackageCommandUsage("update")}
90
93
 
91
- Update pi and installed packages.
94
+ Update sling and installed packages.
92
95
 
93
96
  Options:
94
- --self Update pi only
97
+ --self Update sling only
95
98
  --extensions Update installed packages only
96
99
  --extension <source> Update one package only
97
100
  -a, --approve Trust project-local files for this command
98
101
  -na, --no-approve Ignore project-local files for this command
99
- --force Reinstall pi even if the current version is latest
102
+ --force Reinstall sling even if the current version is latest
100
103
 
101
104
  Short forms:
102
- ${APP_NAME} update Update pi and all extensions
105
+ ${APP_NAME} update Update sling and all extensions
103
106
  ${APP_NAME} update <source> Update one package
104
- ${APP_NAME} update pi Update pi only (self works as alias to pi)
107
+ ${APP_NAME} update sling Update sling only (self works as alias to sling)
105
108
  `);
106
109
  return;
107
110
  case "list":
@@ -370,20 +373,65 @@ function parseProjectTrustOverride(args) {
370
373
  }
371
374
  return trustOverride;
372
375
  }
373
- function resolveProjectTrusted(cwd, agentDir, trustOverride) {
374
- if (trustOverride !== undefined) {
375
- return trustOverride;
376
+ function getCommandAppMode() {
377
+ return process.stdin.isTTY && process.stdout.isTTY ? "interactive" : "print";
378
+ }
379
+ function reportProjectTrustWarnings(warnings) {
380
+ for (const warning of warnings) {
381
+ console.error(chalk.yellow(`Warning: ${warning}`));
382
+ }
383
+ }
384
+ async function createCommandSettingsManager(options) {
385
+ const settingsManager = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });
386
+ const projectTrustWarnings = [];
387
+ const trustStore = new ProjectTrustStore(options.agentDir);
388
+ if (options.useSavedProjectTrustOnly) {
389
+ const savedProjectTrusted = trustStore.get(options.cwd) === true;
390
+ settingsManager.setProjectTrusted(options.projectTrustOverride ?? savedProjectTrusted);
391
+ return { settingsManager, projectTrustWarnings };
376
392
  }
377
- return !hasProjectTrustInputs(cwd) || new ProjectTrustStore(agentDir).get(cwd) === true;
393
+ const appMode = getCommandAppMode();
394
+ const extensionsResult = options.projectTrustOverride === undefined && hasTrustRequiringProjectResources(options.cwd)
395
+ ? await new DefaultResourceLoader({
396
+ cwd: options.cwd,
397
+ agentDir: options.agentDir,
398
+ settingsManager,
399
+ extensionFactories: options.extensionFactories,
400
+ }).loadProjectTrustExtensions()
401
+ : undefined;
402
+ for (const error of extensionsResult?.errors ?? []) {
403
+ projectTrustWarnings.push(`Failed to load extension "${error.path}": ${error.error}`);
404
+ }
405
+ const projectTrusted = await resolveProjectTrusted({
406
+ cwd: options.cwd,
407
+ trustStore,
408
+ trustOverride: options.projectTrustOverride,
409
+ defaultProjectTrust: settingsManager.getDefaultProjectTrust(),
410
+ extensionsResult,
411
+ projectTrustContext: createProjectTrustContext({
412
+ cwd: options.cwd,
413
+ mode: appMode,
414
+ settingsManager,
415
+ hasUI: appMode === "interactive",
416
+ }),
417
+ onExtensionError: (message) => projectTrustWarnings.push(message),
418
+ });
419
+ settingsManager.setProjectTrusted(projectTrusted);
420
+ return { settingsManager, projectTrustWarnings };
378
421
  }
379
- export async function handleConfigCommand(args) {
422
+ export async function handleConfigCommand(args, runtimeOptions = {}) {
380
423
  if (args[0] !== "config") {
381
424
  return false;
382
425
  }
383
426
  const cwd = process.cwd();
384
427
  const agentDir = getAgentDir();
385
- const projectTrusted = parseProjectTrustOverride(args) ?? true;
386
- const settingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted });
428
+ const { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({
429
+ cwd,
430
+ agentDir,
431
+ projectTrustOverride: parseProjectTrustOverride(args),
432
+ extensionFactories: runtimeOptions.extensionFactories,
433
+ });
434
+ reportProjectTrustWarnings(projectTrustWarnings);
387
435
  reportSettingsErrors(settingsManager, "config command");
388
436
  const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
389
437
  const resolvedPaths = await packageManager.resolve();
@@ -395,7 +443,7 @@ export async function handleConfigCommand(args) {
395
443
  });
396
444
  process.exit(0);
397
445
  }
398
- export async function handlePackageCommand(args) {
446
+ export async function handlePackageCommand(args, runtimeOptions = {}) {
399
447
  const options = parsePackageCommand(args);
400
448
  if (!options) {
401
449
  return false;
@@ -438,13 +486,19 @@ export async function handlePackageCommand(args) {
438
486
  const cwd = process.cwd();
439
487
  const agentDir = getAgentDir();
440
488
  const writesProjectPackageConfig = (options.command === "install" || options.command === "remove") && options.local;
441
- const projectTrusted = resolveProjectTrusted(cwd, agentDir, options.projectTrustOverride);
442
- if (!projectTrusted && writesProjectPackageConfig) {
489
+ const { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({
490
+ cwd,
491
+ agentDir,
492
+ projectTrustOverride: options.projectTrustOverride,
493
+ useSavedProjectTrustOnly: options.command === "update",
494
+ extensionFactories: runtimeOptions.extensionFactories,
495
+ });
496
+ reportProjectTrustWarnings(projectTrustWarnings);
497
+ if (!settingsManager.isProjectTrusted() && writesProjectPackageConfig) {
443
498
  console.error(chalk.red("Project is not trusted. Use --approve to modify local package config."));
444
499
  process.exitCode = 1;
445
500
  return true;
446
501
  }
447
- const settingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted });
448
502
  reportSettingsErrors(settingsManager, "package command");
449
503
  const selfUpdateNpmCommand = settingsManager.getGlobalSettings().npmCommand;
450
504
  const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
@@ -1,4 +1,82 @@
1
+ import path from "node:path";
1
2
  import { existsSync, readFileSync } from "fs";
3
+ const GITHUB_REPO = "earendil-works/pi";
4
+ const CHANGELOG_LINK_BASE_PATH = "packages/coding-agent";
5
+ const LEGACY_REPO_RE = /^https:\/\/github\.com\/(?:badlogic|earendil-works)\/pi-mono(?=\/|$)/;
6
+ const URL_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
7
+ const INLINE_MARKDOWN_LINK_RE = /(!?\[[^\]\n]+\]\()([^\s)]+)((?:\s+[^)]*)?\))/g;
8
+ function entryVersion(entry) {
9
+ return `${entry.major}.${entry.minor}.${entry.patch}`;
10
+ }
11
+ function normalizeTag(version) {
12
+ const versionString = typeof version === "string" ? version : entryVersion(version);
13
+ return versionString.startsWith("v") ? versionString : `v${versionString}`;
14
+ }
15
+ function splitLocalTarget(target) {
16
+ const hashIndex = target.indexOf("#");
17
+ const beforeHash = hashIndex === -1 ? target : target.slice(0, hashIndex);
18
+ const fragment = hashIndex === -1 ? "" : target.slice(hashIndex);
19
+ const queryIndex = beforeHash.indexOf("?");
20
+ if (queryIndex === -1) {
21
+ return { fragment, pathPart: beforeHash, query: "" };
22
+ }
23
+ return {
24
+ fragment,
25
+ pathPart: beforeHash.slice(0, queryIndex),
26
+ query: beforeHash.slice(queryIndex),
27
+ };
28
+ }
29
+ function normalizePathPart(value) {
30
+ return value.replaceAll("\\", "/");
31
+ }
32
+ function resolveRepositoryPath(targetPath) {
33
+ const normalizedTarget = normalizePathPart(targetPath);
34
+ const joined = normalizedTarget.startsWith("/")
35
+ ? path.posix.normalize(normalizedTarget.replace(/^\/+/, ""))
36
+ : path.posix.normalize(path.posix.join(CHANGELOG_LINK_BASE_PATH, normalizedTarget));
37
+ if (joined === "." || joined.startsWith("../") || joined === "..") {
38
+ return undefined;
39
+ }
40
+ return joined;
41
+ }
42
+ function isDirectoryTarget(originalPath, repositoryPath) {
43
+ if (originalPath.endsWith("/")) {
44
+ return true;
45
+ }
46
+ const basename = path.posix.basename(repositoryPath);
47
+ return !basename.includes(".");
48
+ }
49
+ function normalizeChangelogLinkTarget(target, tag) {
50
+ let canonicalTarget = target.replace(LEGACY_REPO_RE, `https://github.com/${GITHUB_REPO}`);
51
+ const repoUrl = `https://github.com/${GITHUB_REPO}`;
52
+ for (const route of ["blob", "tree"]) {
53
+ for (const branch of ["main", "master"]) {
54
+ const floatingRefPrefix = `${repoUrl}/${route}/${branch}/`;
55
+ if (canonicalTarget.startsWith(floatingRefPrefix)) {
56
+ canonicalTarget = `${repoUrl}/${route}/${tag}/${canonicalTarget.slice(floatingRefPrefix.length)}`;
57
+ }
58
+ }
59
+ }
60
+ if (canonicalTarget.startsWith("#") || canonicalTarget.startsWith("//") || URL_SCHEME_RE.test(canonicalTarget)) {
61
+ return canonicalTarget;
62
+ }
63
+ const { fragment, pathPart, query } = splitLocalTarget(canonicalTarget);
64
+ if (!pathPart) {
65
+ return canonicalTarget;
66
+ }
67
+ const repositoryPath = resolveRepositoryPath(pathPart);
68
+ if (!repositoryPath) {
69
+ return canonicalTarget;
70
+ }
71
+ const route = isDirectoryTarget(pathPart, repositoryPath) ? "tree" : "blob";
72
+ return `https://github.com/${GITHUB_REPO}/${route}/${tag}/${encodeURI(repositoryPath)}${query}${fragment}`;
73
+ }
74
+ export function normalizeChangelogLinks(markdown, version) {
75
+ const tag = normalizeTag(version);
76
+ return markdown.replace(INLINE_MARKDOWN_LINK_RE, (_match, prefix, target, suffix) => {
77
+ return `${prefix}${normalizeChangelogLinkTarget(target, tag)}${suffix}`;
78
+ });
79
+ }
2
80
  /**
3
81
  * Parse changelog entries from CHANGELOG.md
4
82
  * Scans for ## lines and collects content until next ## or EOF
@@ -1,37 +1,14 @@
1
+ import { compare, valid } from "semver";
1
2
  import { getPiUserAgent } from "./pi-user-agent.js";
2
3
  const LATEST_VERSION_URL = "https://pi.dev/api/latest-version";
3
4
  const DEFAULT_VERSION_CHECK_TIMEOUT_MS = 10000;
4
- function parsePackageVersion(version) {
5
- const match = version.trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/);
6
- if (!match) {
7
- return undefined;
8
- }
9
- return {
10
- major: Number.parseInt(match[1], 10),
11
- minor: Number.parseInt(match[2], 10),
12
- patch: Number.parseInt(match[3], 10),
13
- prerelease: match[4],
14
- };
15
- }
16
5
  export function comparePackageVersions(leftVersion, rightVersion) {
17
- const left = parsePackageVersion(leftVersion);
18
- const right = parsePackageVersion(rightVersion);
6
+ const left = valid(leftVersion.trim());
7
+ const right = valid(rightVersion.trim());
19
8
  if (!left || !right) {
20
9
  return undefined;
21
10
  }
22
- if (left.major !== right.major)
23
- return left.major - right.major;
24
- if (left.minor !== right.minor)
25
- return left.minor - right.minor;
26
- if (left.patch !== right.patch)
27
- return left.patch - right.patch;
28
- if (left.prerelease === right.prerelease)
29
- return 0;
30
- if (!left.prerelease)
31
- return 1;
32
- if (!right.prerelease)
33
- return -1;
34
- return left.prerelease.localeCompare(right.prerelease);
11
+ return compare(left, right);
35
12
  }
36
13
  export function isNewerPackageVersion(candidateVersion, currentVersion) {
37
14
  const comparison = comparePackageVersions(candidateVersion, currentVersion);
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env node
2
+ // Standalone semver comparison program.
3
+ // Exits successfully and prints matching version(s) if
4
+ // any supplied version is valid and passes all tests.
5
+
6
+ 'use strict'
7
+
8
+ const argv = process.argv.slice(2)
9
+
10
+ let versions = []
11
+
12
+ const range = []
13
+
14
+ let inc = null
15
+
16
+ const version = require('../package.json').version
17
+
18
+ let loose = false
19
+
20
+ let includePrerelease = false
21
+
22
+ let coerce = false
23
+
24
+ let rtl = false
25
+
26
+ let identifier
27
+
28
+ let identifierBase
29
+
30
+ const semver = require('../')
31
+ const parseOptions = require('../internal/parse-options')
32
+
33
+ let reverse = false
34
+
35
+ let options = {}
36
+
37
+ const main = () => {
38
+ if (!argv.length) {
39
+ return help()
40
+ }
41
+ while (argv.length) {
42
+ let a = argv.shift()
43
+ const indexOfEqualSign = a.indexOf('=')
44
+ if (indexOfEqualSign !== -1) {
45
+ const value = a.slice(indexOfEqualSign + 1)
46
+ a = a.slice(0, indexOfEqualSign)
47
+ argv.unshift(value)
48
+ }
49
+
50
+ switch (a) {
51
+ case '-rv': case '-rev': case '--rev': case '--reverse':
52
+ reverse = true
53
+ break
54
+ case '-l': case '--loose':
55
+ loose = true
56
+ break
57
+ case '-p': case '--include-prerelease':
58
+ includePrerelease = true
59
+ break
60
+ case '-v': case '--version':
61
+ versions.push(argv.shift())
62
+ break
63
+ case '-i': case '--inc': case '--increment':
64
+ if (semver.RELEASE_TYPES.includes(argv[0]) || (argv[0] === 'release')) {
65
+ inc = { value: argv.shift(), maybeErrantValue: null, option: a }
66
+ } else {
67
+ inc = { value: 'patch', maybeErrantValue: argv[0], option: a }
68
+ }
69
+ break
70
+ case '--preid':
71
+ identifier = argv.shift()
72
+ break
73
+ case '-r': case '--range':
74
+ range.push(argv.shift())
75
+ break
76
+ case '-n':
77
+ identifierBase = argv.shift()
78
+ if (identifierBase === 'false') {
79
+ identifierBase = false
80
+ }
81
+ break
82
+ case '-c': case '--coerce':
83
+ coerce = true
84
+ break
85
+ case '--rtl':
86
+ rtl = true
87
+ break
88
+ case '--ltr':
89
+ rtl = false
90
+ break
91
+ case '-h': case '--help': case '-?':
92
+ return help()
93
+ default:
94
+ versions.push(a)
95
+ break
96
+ }
97
+ }
98
+
99
+ options = parseOptions({ loose, includePrerelease, rtl })
100
+
101
+ if (
102
+ inc &&
103
+ versions.includes(inc.maybeErrantValue) &&
104
+ !semver.valid(inc.maybeErrantValue, options)
105
+ ) {
106
+ console.warn(`Invalid value for ${inc.option}; defaulting to 'patch'. This may become a failure in future major versions.`)
107
+ }
108
+
109
+ versions = versions.map((v) => {
110
+ return coerce ? (semver.coerce(v, options) || { version: v }).version : v
111
+ }).filter((v) => {
112
+ return semver.valid(v, options)
113
+ })
114
+ if (!versions.length) {
115
+ return fail()
116
+ }
117
+ if (inc && (versions.length !== 1 || range.length)) {
118
+ return failInc()
119
+ }
120
+
121
+ for (let i = 0, l = range.length; i < l; i++) {
122
+ versions = versions.filter((v) => {
123
+ return semver.satisfies(v, range[i], options)
124
+ })
125
+ if (!versions.length) {
126
+ return fail()
127
+ }
128
+ }
129
+ versions
130
+ .sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
131
+ .map(v => semver.clean(v, options))
132
+ .map(v => inc ? semver.inc(v, inc.value, options, identifier, identifierBase) : v)
133
+ .forEach(v => console.log(v))
134
+ }
135
+
136
+ const failInc = () => {
137
+ console.error('--inc can only be used on a single version with no range')
138
+ fail()
139
+ }
140
+
141
+ const fail = () => process.exit(1)
142
+
143
+ const help = () => console.log(
144
+ `SemVer ${version}
145
+
146
+ A JavaScript implementation of the https://semver.org/ specification
147
+ Copyright Isaac Z. Schlueter
148
+
149
+ Usage: semver [options] <version> [<version> [...]]
150
+ Prints valid versions sorted by SemVer precedence
151
+
152
+ Options:
153
+ -r --range <range>
154
+ Print versions that match the specified range.
155
+
156
+ -i --increment [<level>]
157
+ Increment a version by the specified level. Level can
158
+ be one of: major, minor, patch, premajor, preminor,
159
+ prepatch, prerelease, or release. Default level is 'patch'.
160
+ Only one version may be specified.
161
+
162
+ --preid <identifier>
163
+ Identifier to be used to prefix premajor, preminor,
164
+ prepatch or prerelease version increments.
165
+
166
+ -l --loose
167
+ Interpret versions and ranges loosely
168
+
169
+ -p --include-prerelease
170
+ Always include prerelease versions in range matching
171
+
172
+ -c --coerce
173
+ Coerce a string into SemVer if possible
174
+ (does not imply --loose)
175
+
176
+ --rtl
177
+ Coerce version strings right to left
178
+
179
+ --ltr
180
+ Coerce version strings left to right (default)
181
+
182
+ -n <base>
183
+ Base number to be used for the prerelease identifier.
184
+ Can be either 0 or 1, or false to omit the number altogether.
185
+ Defaults to 0.
186
+
187
+ Program exits successfully if any valid version satisfies
188
+ all supplied ranges, and prints all satisfying versions.
189
+
190
+ If no satisfying versions are found, then exits failure.
191
+
192
+ Versions are printed in ascending order, so supplying
193
+ multiple versions to the utility will just sort them.`)
194
+
195
+ main()
@@ -0,0 +1,143 @@
1
+ 'use strict'
2
+
3
+ const ANY = Symbol('SemVer ANY')
4
+ // hoisted class for cyclic dependency
5
+ class Comparator {
6
+ static get ANY () {
7
+ return ANY
8
+ }
9
+
10
+ constructor (comp, options) {
11
+ options = parseOptions(options)
12
+
13
+ if (comp instanceof Comparator) {
14
+ if (comp.loose === !!options.loose) {
15
+ return comp
16
+ } else {
17
+ comp = comp.value
18
+ }
19
+ }
20
+
21
+ comp = comp.trim().split(/\s+/).join(' ')
22
+ debug('comparator', comp, options)
23
+ this.options = options
24
+ this.loose = !!options.loose
25
+ this.parse(comp)
26
+
27
+ if (this.semver === ANY) {
28
+ this.value = ''
29
+ } else {
30
+ this.value = this.operator + this.semver.version
31
+ }
32
+
33
+ debug('comp', this)
34
+ }
35
+
36
+ parse (comp) {
37
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
38
+ const m = comp.match(r)
39
+
40
+ if (!m) {
41
+ throw new TypeError(`Invalid comparator: ${comp}`)
42
+ }
43
+
44
+ this.operator = m[1] !== undefined ? m[1] : ''
45
+ if (this.operator === '=') {
46
+ this.operator = ''
47
+ }
48
+
49
+ // if it literally is just '>' or '' then allow anything.
50
+ if (!m[2]) {
51
+ this.semver = ANY
52
+ } else {
53
+ this.semver = new SemVer(m[2], this.options.loose)
54
+ }
55
+ }
56
+
57
+ toString () {
58
+ return this.value
59
+ }
60
+
61
+ test (version) {
62
+ debug('Comparator.test', version, this.options.loose)
63
+
64
+ if (this.semver === ANY || version === ANY) {
65
+ return true
66
+ }
67
+
68
+ if (typeof version === 'string') {
69
+ try {
70
+ version = new SemVer(version, this.options)
71
+ } catch (er) {
72
+ return false
73
+ }
74
+ }
75
+
76
+ return cmp(version, this.operator, this.semver, this.options)
77
+ }
78
+
79
+ intersects (comp, options) {
80
+ if (!(comp instanceof Comparator)) {
81
+ throw new TypeError('a Comparator is required')
82
+ }
83
+
84
+ if (this.operator === '') {
85
+ if (this.value === '') {
86
+ return true
87
+ }
88
+ return new Range(comp.value, options).test(this.value)
89
+ } else if (comp.operator === '') {
90
+ if (comp.value === '') {
91
+ return true
92
+ }
93
+ return new Range(this.value, options).test(comp.semver)
94
+ }
95
+
96
+ options = parseOptions(options)
97
+
98
+ // Special cases where nothing can possibly be lower
99
+ if (options.includePrerelease &&
100
+ (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
101
+ return false
102
+ }
103
+ if (!options.includePrerelease &&
104
+ (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
105
+ return false
106
+ }
107
+
108
+ // Same direction increasing (> or >=)
109
+ if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
110
+ return true
111
+ }
112
+ // Same direction decreasing (< or <=)
113
+ if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
114
+ return true
115
+ }
116
+ // same SemVer and both sides are inclusive (<= or >=)
117
+ if (
118
+ (this.semver.version === comp.semver.version) &&
119
+ this.operator.includes('=') && comp.operator.includes('=')) {
120
+ return true
121
+ }
122
+ // opposite directions less than
123
+ if (cmp(this.semver, '<', comp.semver, options) &&
124
+ this.operator.startsWith('>') && comp.operator.startsWith('<')) {
125
+ return true
126
+ }
127
+ // opposite directions greater than
128
+ if (cmp(this.semver, '>', comp.semver, options) &&
129
+ this.operator.startsWith('<') && comp.operator.startsWith('>')) {
130
+ return true
131
+ }
132
+ return false
133
+ }
134
+ }
135
+
136
+ module.exports = Comparator
137
+
138
+ const parseOptions = require('../internal/parse-options')
139
+ const { safeRe: re, t } = require('../internal/re')
140
+ const cmp = require('../functions/cmp')
141
+ const debug = require('../internal/debug')
142
+ const SemVer = require('./semver')
143
+ const Range = require('./range')
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ SemVer: require('./semver.js'),
5
+ Range: require('./range.js'),
6
+ Comparator: require('./comparator.js'),
7
+ }