pinsay-cli 0.7.1 → 0.7.3

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 (2) hide show
  1. package/dist/cli.js +49 -36
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ var init_build_constants = __esm({
15
15
  "src/build-constants.ts"() {
16
16
  "use strict";
17
17
  BUILD_DEFAULT_SERVER = true ? "https://app.pinsay.dev" : "https://app.pinsay.dev";
18
- BUILD_CLI_VERSION = true ? "0.7.1" : "0.0.0-dev";
18
+ BUILD_CLI_VERSION = true ? "0.7.3" : "0.0.0-dev";
19
19
  }
20
20
  });
21
21
 
@@ -5506,6 +5506,16 @@ function headSha(cwd2) {
5506
5506
  }
5507
5507
  return result.stdout.trim();
5508
5508
  }
5509
+ function resolveCommit(ref, cwd2) {
5510
+ const result = spawnSync2("git", ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`], {
5511
+ cwd: cwd2,
5512
+ encoding: "utf8"
5513
+ });
5514
+ if (result.status !== 0) {
5515
+ throw new Error(`Not a commit in this repository: ${ref}`);
5516
+ }
5517
+ return result.stdout.trim();
5518
+ }
5509
5519
  function getRemoteUrl(cwd2, remote = "origin") {
5510
5520
  const result = spawnSync2("git", ["remote", "get-url", remote], {
5511
5521
  cwd: cwd2,
@@ -5666,11 +5676,21 @@ async function markApplied(options, ctx) {
5666
5676
  const warning = delegationWarning(projectCtx.delegation ?? "auto", models);
5667
5677
  if (warning)
5668
5678
  console.error(warning);
5679
+ let existingSha;
5680
+ if (options.noCommit) {
5681
+ try {
5682
+ existingSha = resolveCommit(options.commit ?? "HEAD", ctx.cwd);
5683
+ } catch (err) {
5684
+ console.error(err.message);
5685
+ process.exit(1);
5686
+ }
5687
+ }
5669
5688
  if (options.dryRun) {
5670
5689
  console.log(`[dry-run] Would mark comment ${options.id} as applied`);
5671
5690
  console.log(`[dry-run] Reply: ${options.reply}`);
5672
5691
  console.log(`[dry-run] AppliedBy: ${appliedByLabel}`);
5673
5692
  console.log(`[dry-run] Models: ${describeModels(models)}`);
5693
+ console.log(`[dry-run] Commit: ${existingSha ?? "a new commit of the staged changes"}`);
5674
5694
  return {
5675
5695
  committed: false,
5676
5696
  patchedIds: typeof options.id === "number" ? [options.id] : []
@@ -5698,6 +5718,9 @@ async function markApplied(options, ctx) {
5698
5718
  sha = headSha(ctx.cwd);
5699
5719
  const remote = getRemoteUrl(ctx.cwd);
5700
5720
  commitUrl = commitUrlFor(sha, remote);
5721
+ } else {
5722
+ sha = existingSha;
5723
+ commitUrl = sha ? commitUrlFor(sha, getRemoteUrl(ctx.cwd)) : null;
5701
5724
  }
5702
5725
  for (const item of pending) {
5703
5726
  await api(ctx.server, `/api/comments/${item.id}`, {
@@ -5746,6 +5769,9 @@ async function markApplied(options, ctx) {
5746
5769
  sha = headSha(ctx.cwd);
5747
5770
  const remote = getRemoteUrl(ctx.cwd);
5748
5771
  commitUrl = commitUrlFor(sha, remote);
5772
+ } else {
5773
+ sha = existingSha;
5774
+ commitUrl = sha ? commitUrlFor(sha, getRemoteUrl(ctx.cwd)) : null;
5749
5775
  }
5750
5776
  await api(ctx.server, `/api/comments/${id}`, {
5751
5777
  method: "PATCH",
@@ -5816,6 +5842,18 @@ async function exitIfWorkspaceFrozen(server, token) {
5816
5842
  } catch {
5817
5843
  }
5818
5844
  }
5845
+ async function checkMetaAndNotify(server, config, root, parsed) {
5846
+ try {
5847
+ const meta = await api(server, "/api/meta");
5848
+ const minCli = meta?.minCliVersion || "0.0.0";
5849
+ if (compareSemver(BUILD_CLI_VERSION, minCli) < 0) {
5850
+ console.error(tooOldMessage(BUILD_CLI_VERSION, minCli));
5851
+ process.exit(5);
5852
+ }
5853
+ await checkAndNotifyUpdates({ meta, config, cwd: root, silent: Boolean(parsed["json"]) });
5854
+ } catch {
5855
+ }
5856
+ }
5819
5857
  function parseModelFlags(parsed) {
5820
5858
  try {
5821
5859
  return resolveModels({
@@ -5859,23 +5897,7 @@ async function applyCommand(cwd2, parsed, positionals = []) {
5859
5897
  return;
5860
5898
  }
5861
5899
  const project = resolved.ok ? resolved.project.key : "";
5862
- try {
5863
- const meta = await api(server, "/api/meta");
5864
- const minCli = meta?.minCliVersion || "0.0.0";
5865
- if (compareSemver(BUILD_CLI_VERSION, minCli) < 0) {
5866
- console.error(tooOldMessage(BUILD_CLI_VERSION, minCli));
5867
- process.exit(5);
5868
- }
5869
- await checkAndNotifyUpdates({
5870
- meta,
5871
- config,
5872
- cwd: root,
5873
- silent: Boolean(parsed["json"])
5874
- });
5875
- } catch (err) {
5876
- if (!(err instanceof ApiError && err.code === 404)) {
5877
- }
5878
- }
5900
+ await checkMetaAndNotify(server, config, root, parsed);
5879
5901
  const explicitKey = typeof parsed["key"] === "string" ? parsed["key"] : void 0;
5880
5902
  const token = await resolveToken(server, root, explicitKey);
5881
5903
  const apiKey = explicitKey || await readApiKey(root, server);
@@ -5918,6 +5940,11 @@ async function applyCommand(cwd2, parsed, positionals = []) {
5918
5940
  }
5919
5941
  const noCommit = parsed["no-commit"] === true;
5920
5942
  const dryRun = parsed["dry-run"] === true;
5943
+ const commitRef = typeof parsed["commit"] === "string" ? parsed["commit"] : void 0;
5944
+ if (commitRef && !noCommit) {
5945
+ console.error("--commit <sha> needs --no-commit (plain --mark records the commit it makes).");
5946
+ process.exit(2);
5947
+ }
5921
5948
  const toolExplicit = typeof parsed["tool"] === "string" ? parsed["tool"] : void 0;
5922
5949
  const tool2 = toolExplicit || config.aiTool;
5923
5950
  if (!toolExplicit && config.aiTool) {
@@ -5946,6 +5973,7 @@ async function applyCommand(cwd2, parsed, positionals = []) {
5946
5973
  id: markId,
5947
5974
  reply,
5948
5975
  noCommit,
5976
+ commit: commitRef,
5949
5977
  dryRun,
5950
5978
  tool: tool2,
5951
5979
  models,
@@ -6014,23 +6042,7 @@ async function applyAllProjects(root, cwd2, config, server, parsed) {
6014
6042
  console.error("--tool needs a single project \u2014 pass --project <key> (several are configured).");
6015
6043
  process.exit(2);
6016
6044
  }
6017
- try {
6018
- const meta = await api(server, "/api/meta");
6019
- const minCli = meta?.minCliVersion || "0.0.0";
6020
- if (compareSemver(BUILD_CLI_VERSION, minCli) < 0) {
6021
- console.error(tooOldMessage(BUILD_CLI_VERSION, minCli));
6022
- process.exit(5);
6023
- }
6024
- await checkAndNotifyUpdates({
6025
- meta,
6026
- config,
6027
- cwd: root,
6028
- silent: Boolean(parsed["json"])
6029
- });
6030
- } catch (err) {
6031
- if (!(err instanceof ApiError && err.code === 404)) {
6032
- }
6033
- }
6045
+ await checkMetaAndNotify(server, config, root, parsed);
6034
6046
  const explicitKey = typeof parsed["key"] === "string" ? parsed["key"] : void 0;
6035
6047
  const token = await resolveToken(server, root, explicitKey);
6036
6048
  const apiKey = explicitKey || await readApiKey(root, server);
@@ -12862,7 +12874,8 @@ Options:
12862
12874
  --tool <name> Hand off prompt to claude, opencode, cursor, or clipboard
12863
12875
  --mark <id>|all Commit staged changes and mark comment(s) applied
12864
12876
  --reply <text> Reply text for applied comment (required with --mark)
12865
- --no-commit Skip git commit during --mark (PATCH only)
12877
+ --no-commit Mark without committing: the fix is already committed (records --commit, default HEAD)
12878
+ --commit <sha> With --no-commit: the commit that holds the fix (default HEAD)
12866
12879
  --dry-run Print what --mark would do without making git/API changes
12867
12880
  --models <list> Every model that worked on the item, with its role, for --mark/--fail:
12868
12881
  "<id>=<role>,<id>=<role>" (role: planner|implementer|reviewer, optional;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinsay-cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Click-to-comment feedback for your web app: install the widget, then turn pending comments into AI apply prompts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "directory": "."
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/moamen-ui/pinsay-api/issues"
15
+ "url": "https://github.com/moamen-ui/pinsay-cli/issues"
16
16
  },
17
17
  "keywords": [
18
18
  "feedback",