@psnext/slingcli 2.5.20260617-1 → 2.5.20260617-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 (64) hide show
  1. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  2. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +21 -57
  3. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +116 -155
  4. package/node_modules/@earendil-works/pi-ai/dist/models.js +4 -1
  5. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +52 -34
  6. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +11 -9
  7. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +7 -4
  8. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js +4 -3
  9. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js +15 -5
  10. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js +2 -1
  11. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +18 -17
  12. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +21 -8
  13. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +2 -1
  14. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +8 -7
  15. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +1 -0
  16. package/node_modules/@earendil-works/pi-ai/dist/stream.js +1 -1
  17. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +17 -22
  18. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js +2 -1
  19. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +3 -2
  20. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-env.js +44 -0
  21. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  22. package/node_modules/@earendil-works/pi-coding-agent/dist/bun/restore-sandbox-env.js +4 -0
  23. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +1 -1
  24. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +10 -7
  25. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +8 -1
  26. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js +2 -2
  27. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +10 -10
  28. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/vendor/marked.min.js +75 -3
  29. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.js +17 -1
  30. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +8 -4
  31. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +1 -1
  32. package/node_modules/@earendil-works/pi-coding-agent/dist/core/provider-attribution.js +10 -0
  33. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resolve-config-value.js +19 -19
  34. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +2 -0
  35. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +6 -6
  36. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +4 -0
  37. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +17 -5
  38. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +4 -0
  39. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +0 -1
  40. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.js +0 -5
  41. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +6 -6
  42. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +23 -5
  43. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +17 -17
  44. package/node_modules/@earendil-works/pi-coding-agent/package.json +4 -4
  45. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -1
  46. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  47. package/node_modules/marked/README.md +13 -4
  48. package/node_modules/marked/bin/main.js +16 -14
  49. package/node_modules/marked/bin/marked.js +2 -1
  50. package/node_modules/marked/lib/marked.d.ts +157 -125
  51. package/node_modules/marked/lib/marked.esm.js +67 -2179
  52. package/node_modules/marked/lib/marked.esm.js.map +3 -3
  53. package/node_modules/marked/lib/marked.umd.js +67 -2201
  54. package/node_modules/marked/lib/marked.umd.js.map +3 -3
  55. package/node_modules/marked/man/marked.1 +4 -2
  56. package/node_modules/marked/man/marked.1.md +2 -1
  57. package/node_modules/marked/package.json +27 -35
  58. package/package.json +6 -6
  59. package/slingshot/index.js +253 -253
  60. package/node_modules/marked/lib/marked.cjs +0 -2211
  61. package/node_modules/marked/lib/marked.cjs.map +0 -7
  62. package/node_modules/marked/lib/marked.d.cts +0 -728
  63. package/node_modules/marked/marked.min.js +0 -69
  64. /package/node_modules/marked/{LICENSE.md → LICENSE} +0 -0
@@ -20,7 +20,7 @@ import { createAgentSessionFromServices, createAgentSessionServices, } from "./c
20
20
  import { formatNoModelsAvailableMessage } from "./core/auth-guidance.js";
21
21
  import { AuthStorage } from "./core/auth-storage.js";
22
22
  import { exportFromFile } from "./core/export-html/index.js";
23
- import { configureHttpDispatcher } from "./core/http-dispatcher.js";
23
+ import { applyHttpProxySettings, configureHttpDispatcher } from "./core/http-dispatcher.js";
24
24
  import { resolveCliModel, resolveModelScope } from "./core/model-resolver.js";
25
25
  import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
26
26
  import { resolveProjectTrusted } from "./core/project-trust.js";
@@ -360,8 +360,21 @@ export async function main(args, options) {
360
360
  if (process.platform === "win32") {
361
361
  cleanupWindowsSelfUpdateQuarantine(getPackageDir());
362
362
  }
363
+ const cwd = process.cwd();
364
+ const agentDir = getAgentDir();
365
+ const bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });
366
+ applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy);
367
+ configureHttpDispatcher();
363
368
  if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) {
364
- process.exit(process.exitCode ?? 0);
369
+ const exitCode = process.exitCode ?? 0;
370
+ if (process.platform === "win32" && exitCode === 0 && args[0] === "update") {
371
+ // We normally prefer process.exit(0) for package commands so bad extensions cannot keep
372
+ // one-shot commands alive. On Windows, Node can assert after fetch() if process.exit(0)
373
+ // runs during teardown; let successful `pi update` drain naturally instead.
374
+ // https://github.com/nodejs/node/issues/56645
375
+ return;
376
+ }
377
+ process.exit(exitCode);
365
378
  return;
366
379
  }
367
380
  if (await handleConfigCommand(args, { extensionFactories: options?.extensionFactories })) {
@@ -408,10 +421,8 @@ export async function main(args, options) {
408
421
  validateForkFlags(parsed);
409
422
  validateSessionIdFlags(parsed);
410
423
  // Run migrations (pass cwd for project-local migrations)
411
- const { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(process.cwd());
424
+ const { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(cwd);
412
425
  time("runMigrations");
413
- const cwd = process.cwd();
414
- const agentDir = getAgentDir();
415
426
  const startupSettingsManager = SettingsManager.create(cwd, agentDir);
416
427
  reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup"));
417
428
  // Experimental first-time setup: theme choice and analytics opt-in.
@@ -577,6 +588,7 @@ export async function main(args, options) {
577
588
  time("createAgentSessionRuntime");
578
589
  const { services, session, modelFallbackMessage } = runtime;
579
590
  const { settingsManager, modelRegistry, resourceLoader } = services;
591
+ applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
580
592
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
581
593
  if (parsed.help) {
582
594
  const extensionFlags = resourceLoader
@@ -1,5 +1,6 @@
1
1
  import { isAbsolute, relative, resolve, sep } from "node:path";
2
2
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
3
+ import { areExperimentalFeaturesEnabled } from "../../../core/experimental.js";
3
4
  import { theme } from "../theme/theme.js";
4
5
  /**
5
6
  * Sanitize text for display in a single-line status.
@@ -144,6 +145,9 @@ export class FooterComponent {
144
145
  contextPercentStr = contextPercentDisplay;
145
146
  }
146
147
  statsParts.push(contextPercentStr);
148
+ if (areExperimentalFeaturesEnabled()) {
149
+ statsParts.push(`${theme.fg("dim", "•")} ${theme.bold(theme.fg("warning", "xp"))}`);
150
+ }
147
151
  let statsLeft = statsParts.join(" ");
148
152
  // Add model name on the right side, plus thinking level if model supports it
149
153
  const modelName = state.model?.id || "no-model";
@@ -101,7 +101,6 @@ export class LoginDialogComponent extends Container {
101
101
  this.contentContainer.addChild(new Text(theme.fg("dim", hyperlink), 1, 0));
102
102
  this.contentContainer.addChild(new Spacer(1));
103
103
  this.contentContainer.addChild(new Text(theme.fg("warning", `Enter code: ${info.userCode}`), 1, 0));
104
- openBrowser(info.verificationUri);
105
104
  this.tui.requestRender();
106
105
  }
107
106
  /**
@@ -587,7 +587,6 @@ export class SessionSelectorComponent extends Container {
587
587
  allSessions = null;
588
588
  currentSessionsLoader;
589
589
  allSessionsLoader;
590
- onCancel;
591
590
  requestRender;
592
591
  renameSession;
593
592
  currentLoading = false;
@@ -627,7 +626,6 @@ export class SessionSelectorComponent extends Container {
627
626
  this.keybindings = options?.keybindings ?? KeybindingsManager.create();
628
627
  this.currentSessionsLoader = currentSessionsLoader;
629
628
  this.allSessionsLoader = allSessionsLoader;
630
- this.onCancel = onCancel;
631
629
  this.requestRender = requestRender;
632
630
  this.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.requestRender);
633
631
  const renameSession = options?.renameSession;
@@ -793,9 +791,6 @@ export class SessionSelectorComponent extends Container {
793
791
  this.header.setLoading(false);
794
792
  this.sessionList.setSessions(sessions, showCwd);
795
793
  this.requestRender();
796
- if (scope === "all" && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {
797
- this.onCancel();
798
- }
799
794
  }
800
795
  catch (err) {
801
796
  if (scope === "current") {
@@ -78,7 +78,7 @@ Remove a package and its source from settings.
78
78
  Alias: ${APP_NAME} uninstall <source> [-l]
79
79
 
80
80
  Options:
81
- -l, --local Remove from project settings (.sling/settings.json)
81
+ -l, --local Remove from project settings (.pi/settings.json)
82
82
  -a, --approve Trust project-local files for this command
83
83
  -na, --no-approve Ignore project-local files for this command
84
84
 
@@ -91,20 +91,20 @@ Examples:
91
91
  console.log(`${chalk.bold("Usage:")}
92
92
  ${getPackageCommandUsage("update")}
93
93
 
94
- Update sling and installed packages.
94
+ Update pi and installed packages.
95
95
 
96
96
  Options:
97
- --self Update sling only
97
+ --self Update pi only
98
98
  --extensions Update installed packages only
99
99
  --extension <source> Update one package only
100
100
  -a, --approve Trust project-local files for this command
101
101
  -na, --no-approve Ignore project-local files for this command
102
- --force Reinstall sling even if the current version is latest
102
+ --force Reinstall pi even if the current version is latest
103
103
 
104
104
  Short forms:
105
- ${APP_NAME} update Update sling and all extensions
105
+ ${APP_NAME} update Update pi and all extensions
106
106
  ${APP_NAME} update <source> Update one package
107
- ${APP_NAME} update sling Update sling only (self works as alias to sling)
107
+ ${APP_NAME} update pi Update pi only (self works as alias to pi)
108
108
  `);
109
109
  return;
110
110
  case "list":
@@ -12,10 +12,13 @@ export function spawnProcessSync(command, args, options) {
12
12
  /**
13
13
  * Wait for a child process to terminate without hanging on inherited stdio handles.
14
14
  *
15
- * On Windows, daemonized descendants can inherit the child's stdout/stderr pipe
16
- * handles. In that case the child emits `exit`, but `close` can hang forever even
17
- * though the original process is already gone. We wait briefly for stdio to end,
18
- * then forcibly stop tracking the inherited handles.
15
+ * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr
16
+ * pipe open. We must not resolve and destroy the streams on a fixed deadline measured
17
+ * from `exit`, or output still being written past that deadline is silently lost
18
+ * (earendil-works/pi#5303). Instead, after `exit` we wait for the pipes to fall idle:
19
+ * the grace timer is re-armed on every chunk, so an actively writing descendant keeps
20
+ * us reading, while a quiet inherited handle (e.g. a Windows daemonized descendant
21
+ * that never lets `close` fire) still releases us after the grace elapses.
19
22
  */
20
23
  export function waitForChildProcess(child) {
21
24
  return new Promise((resolve, reject) => {
@@ -35,6 +38,8 @@ export function waitForChildProcess(child) {
35
38
  child.removeListener("close", onClose);
36
39
  child.stdout?.removeListener("end", onStdoutEnd);
37
40
  child.stderr?.removeListener("end", onStderrEnd);
41
+ child.stdout?.removeListener("data", onData);
42
+ child.stderr?.removeListener("data", onData);
38
43
  };
39
44
  const finalize = (code) => {
40
45
  if (settled)
@@ -52,6 +57,17 @@ export function waitForChildProcess(child) {
52
57
  finalize(exitCode);
53
58
  }
54
59
  };
60
+ const armIdleTimer = () => {
61
+ if (postExitTimer)
62
+ clearTimeout(postExitTimer);
63
+ postExitTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_GRACE_MS);
64
+ };
65
+ const onData = () => {
66
+ // Output is still arriving after exit; defer finalizing so we don't
67
+ // destroy the stream mid-write and truncate the tail.
68
+ if (exited && !settled)
69
+ armIdleTimer();
70
+ };
55
71
  const onStdoutEnd = () => {
56
72
  stdoutEnded = true;
57
73
  maybeFinalizeAfterExit();
@@ -72,7 +88,7 @@ export function waitForChildProcess(child) {
72
88
  exitCode = code;
73
89
  maybeFinalizeAfterExit();
74
90
  if (!settled) {
75
- postExitTimer = setTimeout(() => finalize(code), EXIT_STDIO_GRACE_MS);
91
+ armIdleTimer();
76
92
  }
77
93
  };
78
94
  const onClose = (code) => {
@@ -80,6 +96,8 @@ export function waitForChildProcess(child) {
80
96
  };
81
97
  child.stdout?.once("end", onStdoutEnd);
82
98
  child.stderr?.once("end", onStderrEnd);
99
+ child.stdout?.on("data", onData);
100
+ child.stderr?.on("data", onData);
83
101
  child.once("error", onError);
84
102
  child.once("exit", onExit);
85
103
  child.once("close", onClose);
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-coding-agent",
3
- "version": "0.79.3",
3
+ "version": "0.79.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@earendil-works/pi-coding-agent",
9
- "version": "0.79.3",
9
+ "version": "0.79.6",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@earendil-works/pi-agent-core": "^0.79.3",
13
- "@earendil-works/pi-ai": "^0.79.3",
14
- "@earendil-works/pi-tui": "^0.79.3",
12
+ "@earendil-works/pi-agent-core": "^0.79.6",
13
+ "@earendil-works/pi-ai": "^0.79.6",
14
+ "@earendil-works/pi-tui": "^0.79.6",
15
15
  "@silvia-odwyer/photon-node": "0.3.4",
16
16
  "chalk": "5.6.2",
17
17
  "cross-spawn": "7.0.6",
@@ -474,11 +474,11 @@
474
474
  }
475
475
  },
476
476
  "node_modules/@earendil-works/pi-agent-core": {
477
- "version": "0.79.3",
478
- "resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-0.79.3.tgz",
477
+ "version": "0.79.6",
478
+ "resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-0.79.6.tgz",
479
479
  "license": "MIT",
480
480
  "dependencies": {
481
- "@earendil-works/pi-ai": "^0.79.3",
481
+ "@earendil-works/pi-ai": "^0.79.6",
482
482
  "ignore": "7.0.5",
483
483
  "typebox": "1.1.38",
484
484
  "yaml": "2.9.0"
@@ -488,8 +488,8 @@
488
488
  }
489
489
  },
490
490
  "node_modules/@earendil-works/pi-ai": {
491
- "version": "0.79.3",
492
- "resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-0.79.3.tgz",
491
+ "version": "0.79.6",
492
+ "resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-0.79.6.tgz",
493
493
  "license": "MIT",
494
494
  "dependencies": {
495
495
  "@anthropic-ai/sdk": "0.91.1",
@@ -511,12 +511,12 @@
511
511
  }
512
512
  },
513
513
  "node_modules/@earendil-works/pi-tui": {
514
- "version": "0.79.3",
515
- "resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-0.79.3.tgz",
514
+ "version": "0.79.6",
515
+ "resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-0.79.6.tgz",
516
516
  "license": "MIT",
517
517
  "dependencies": {
518
518
  "get-east-asian-width": "1.6.0",
519
- "marked": "15.0.12"
519
+ "marked": "18.0.5"
520
520
  },
521
521
  "engines": {
522
522
  "node": ">=22.19.0"
@@ -1399,15 +1399,15 @@
1399
1399
  }
1400
1400
  },
1401
1401
  "node_modules/marked": {
1402
- "version": "15.0.12",
1403
- "resolved": "https://registry.npmjs.org/marked/-/marked-15.0.12.tgz",
1404
- "integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==",
1402
+ "version": "18.0.5",
1403
+ "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.5.tgz",
1404
+ "integrity": "sha512-S6GcvALHg6K4ohtu4E7x0a1AqhAjp6cV8KhLSyN9qVapnzJkusVBxZRcIU9AeYsbe6P1hKDusSbEOzGyyuce6w==",
1405
1405
  "license": "MIT",
1406
1406
  "bin": {
1407
1407
  "marked": "bin/marked.js"
1408
1408
  },
1409
1409
  "engines": {
1410
- "node": ">= 18"
1410
+ "node": ">= 20"
1411
1411
  }
1412
1412
  },
1413
1413
  "node_modules/minimatch": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-coding-agent",
3
- "version": "0.79.3",
3
+ "version": "0.79.6",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -37,9 +37,9 @@
37
37
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
38
38
  },
39
39
  "dependencies": {
40
- "@earendil-works/pi-agent-core": "^0.79.3",
41
- "@earendil-works/pi-ai": "^0.79.3",
42
- "@earendil-works/pi-tui": "^0.79.3",
40
+ "@earendil-works/pi-agent-core": "^0.79.6",
41
+ "@earendil-works/pi-ai": "^0.79.6",
42
+ "@earendil-works/pi-tui": "^0.79.6",
43
43
  "@silvia-odwyer/photon-node": "0.3.4",
44
44
  "chalk": "5.6.2",
45
45
  "cross-spawn": "7.0.6",
@@ -296,6 +296,9 @@ export class Editor {
296
296
  this.history.pop();
297
297
  }
298
298
  }
299
+ isEditorEmpty() {
300
+ return this.state.lines.length === 1 && this.state.lines[0] === "";
301
+ }
299
302
  isOnFirstVisualLine() {
300
303
  const visualLines = this.buildVisualLineMap(this.lastWidth);
301
304
  const currentVisualLine = this.findCurrentVisualLine(visualLines);
@@ -656,7 +659,8 @@ export class Editor {
656
659
  }
657
660
  // Arrow key navigation (with history support)
658
661
  if (kb.matches(data, "tui.editor.cursorUp")) {
659
- if (this.isOnFirstVisualLine() && this.history.length > 0) {
662
+ if (this.isOnFirstVisualLine() &&
663
+ (this.isEditorEmpty() || this.historyIndex > -1 || this.state.cursorCol === 0)) {
660
664
  this.navigateHistory(-1);
661
665
  }
662
666
  else if (this.isOnFirstVisualLine()) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-tui",
3
- "version": "0.79.3",
3
+ "version": "0.79.6",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "types": "./dist/index.d.ts",
39
39
  "dependencies": {
40
40
  "get-east-asian-width": "1.6.0",
41
- "marked": "15.0.12"
41
+ "marked": "18.0.5"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@xterm/headless": "5.5.0",
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Demo
19
19
 
20
- Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
20
+ Check out the [demo page](https://marked.js.org/demo/) to see Marked in action ⛹️
21
21
 
22
22
  ## Docs
23
23
 
@@ -32,7 +32,7 @@ Also read about:
32
32
 
33
33
  **Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.
34
34
 
35
- **Browser:** Not IE11 :)
35
+ **Browser:** [Baseline Widely Available](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility)
36
36
 
37
37
  ## Installation
38
38
 
@@ -72,6 +72,14 @@ $ cat hello.html
72
72
  $ marked --help
73
73
  ```
74
74
 
75
+ **Node.js**
76
+
77
+ ```js
78
+ import { marked } from 'marked';
79
+ const html = marked.parse('# Marked in Node.js');
80
+ console.log(html);
81
+ ```
82
+
75
83
  **Browser**
76
84
 
77
85
  ```html
@@ -83,7 +91,7 @@ $ marked --help
83
91
  </head>
84
92
  <body>
85
93
  <div id="content"></div>
86
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
94
+ <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
87
95
  <script>
88
96
  document.getElementById('content').innerHTML =
89
97
  marked.parse('# Marked in the browser\n\nRendered by **marked**.');
@@ -103,4 +111,5 @@ or import esm module
103
111
 
104
112
  ## License
105
113
 
106
- Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)
114
+ Copyright (c) 2018+, MarkedJS. (MIT License)
115
+ Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
@@ -2,13 +2,15 @@
2
2
 
3
3
  /**
4
4
  * Marked CLI
5
- * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
5
+ * Copyright (c) 2018+, MarkedJS. (MIT License)
6
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
6
7
  */
7
8
 
8
9
  import { promises } from 'node:fs';
9
10
  import { dirname, resolve } from 'node:path';
10
11
  import { homedir } from 'node:os';
11
12
  import { createRequire } from 'node:module';
13
+ import { pathToFileURL } from 'node:url';
12
14
  import { marked } from '../lib/marked.esm.js';
13
15
 
14
16
  const { access, readFile, writeFile } = promises;
@@ -151,16 +153,16 @@ export async function main(nodeProcess) {
151
153
  }
152
154
 
153
155
  async function getData() {
154
- if (!input) {
155
- if (files.length <= 2) {
156
- if (string) {
157
- return string;
158
- }
159
- return await getStdin();
160
- }
161
- input = files.pop();
156
+ if (string) {
157
+ return string;
158
+ }
159
+ if (input) {
160
+ return await readFile(input, 'utf8');
161
+ }
162
+ if (files.length > 0) {
163
+ return await readFile(files.pop(), 'utf8');
162
164
  }
163
- return await readFile(input, 'utf8');
165
+ return await getStdin();
164
166
  }
165
167
 
166
168
  function resolveFile(file) {
@@ -177,12 +179,12 @@ export async function main(nodeProcess) {
177
179
  try {
178
180
  // try require for json
179
181
  markedConfig = require(configFile);
180
- } catch (err) {
182
+ } catch(err) {
181
183
  if (err.code !== 'ERR_REQUIRE_ESM') {
182
184
  throw err;
183
185
  }
184
186
  // must import esm
185
- markedConfig = await import('file:///' + configFile);
187
+ markedConfig = await import(pathToFileURL(configFile).href);
186
188
  }
187
189
 
188
190
  if (markedConfig.default) {
@@ -269,9 +271,9 @@ export async function main(nodeProcess) {
269
271
  }
270
272
 
271
273
  try {
272
- await start(nodeProcess.argv.slice());
274
+ await start(nodeProcess.argv.slice(2));
273
275
  nodeProcess.exit(0);
274
- } catch (err) {
276
+ } catch(err) {
275
277
  if (err.code === 'ENOENT') {
276
278
  nodeProcess.stderr.write('marked: ' + err.path + ': No such file or directory');
277
279
  } else {
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * Marked CLI
5
- * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
5
+ * Copyright (c) 2018+, MarkedJS. (MIT License)
6
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
6
7
  */
7
8
 
8
9
  import { main } from './main.js';