@gitset-dev/cli 2.4.2 → 2.4.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.
package/README.md CHANGED
@@ -114,10 +114,13 @@ Secrets are redacted locally before any file content is sent, and prose
114
114
  docs / test file bodies are listed structurally but never sent at all.
115
115
 
116
116
  `gitset knowledge automate` needs "Allow GitHub Actions to create and
117
- approve pull requests" enabled under the repo's **Settings > Actions >
118
- General > Workflow permissions** without it, the scheduled update still
119
- runs and commits safely, but the review-PR step fails, and the workflow run
120
- will show that failure clearly rather than hide it.
117
+ approve pull requests" enabled (**Settings > Actions > General > Workflow
118
+ permissions**) for the update PR to open. It detects this automatically and
119
+ offers to enable it via the GitHub API — asked first, like everything else
120
+ in this command. If you decline, or the API call fails (no admin access, an
121
+ org policy locking the setting), the scheduled update still runs and
122
+ commits safely; only the review-PR step fails, and the workflow run shows
123
+ that failure clearly rather than hide it.
121
124
 
122
125
  ## Templates
123
126
 
@@ -59,6 +59,16 @@ function buildKnowledgeWorkflow({ mode, provider, envKey, model, defaultBranch =
59
59
  '# permissions. Without it, the update still commits and pushes',
60
60
  '# safely, but opening the review PR fails and this job reports it',
61
61
  '# as a failure so it is never silently missed.',
62
+ '#',
63
+ '# If your organization enforces that setting off and it cannot be',
64
+ '# changed (the checkbox is greyed out even at the org level), add an',
65
+ '# optional repository secret GITSET_PR_TOKEN — a personal access',
66
+ '# token (classic: repo scope; fine-grained: Pull requests write) —',
67
+ '# and this workflow uses it instead of the default token, which is',
68
+ "# the standard workaround: an organization's PR-creation restriction",
69
+ '# applies to the auto-generated Actions token, not to a real PAT.',
70
+ '# No workflow changes needed after adding it — the next run picks it',
71
+ '# up automatically.',
62
72
  ...buildTrigger(mode, defaultBranch),
63
73
  'permissions:',
64
74
  ' contents: write',
@@ -81,7 +91,7 @@ function buildKnowledgeWorkflow({ mode, provider, envKey, model, defaultBranch =
81
91
  ` run: ${updateCmd}`,
82
92
  ' - name: Open a PR when the knowledge base changed',
83
93
  ' env:',
84
- ' GH_TOKEN: ${{ github.token }}',
94
+ ' GH_TOKEN: ${{ secrets.GITSET_PR_TOKEN || github.token }}',
85
95
  ' run: |',
86
96
  ' if git diff --quiet -- docs/gitset-knowledge AGENTS.md; then',
87
97
  ' echo "Knowledge base already up to date."',
@@ -101,7 +111,7 @@ function buildKnowledgeWorkflow({ mode, provider, envKey, model, defaultBranch =
101
111
  ' echo "$PR_OUTPUT"',
102
112
  ' else',
103
113
  ' echo "$PR_OUTPUT"',
104
- ' echo "::error::Could not open the pull request automatically (the branch and commit ARE safely pushed — no work was lost). This is usually because \'Allow GitHub Actions to create and approve pull requests\' is disabled for this repository: enable it under Settings > Actions > General > Workflow permissions, then either re-run this workflow or open the PR yourself: https://github.com/${{ github.repository }}/pull/new/gitset/knowledge-update"',
114
+ ' echo "::error::Could not open the pull request automatically (the branch and commit ARE safely pushed — no work was lost). Try, in order: (1) enable \'Allow GitHub Actions to create and approve pull requests\' under Settings > Actions > General > Workflow permissions; (2) if that checkbox is greyed out, your organization enforces it off — add a repository secret named GITSET_PR_TOKEN with a personal access token (repo scope) and re-run, no workflow change needed; (3) open the PR yourself: https://github.com/${{ github.repository }}/pull/new/gitset/knowledge-update"',
105
115
  ' exit 1',
106
116
  ' fi',
107
117
  '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitset-dev/cli",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Gitset CLI — drafts commits, PRs, issues, READMEs and release notes with your own AI key. Fully local: your code and keys never touch a Gitset server. Draft. Refine. Ship.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -520,7 +520,8 @@ async function ensurePrPermission(repo, argv) {
520
520
  log('Enabled — CI will be able to open the review PR.', 'green');
521
521
  return 'enabled';
522
522
  } catch {
523
- log('Could not change it automatically (you may not have admin access on this repo, or an organization policy may lock this setting).', 'yellow');
523
+ log('Could not change it automatically you may not have admin access on this repo, or an organization policy locks this setting (if it appears greyed out in the GitHub UI at both the repo and org level, that\'s a hard enforcement you cannot toggle either way).', 'yellow');
524
+ log('Workaround: add a repository secret named GITSET_PR_TOKEN with a personal access token (repo scope). It is not subject to the organization\'s Actions PR-creation restriction, and the workflow picks it up automatically — no need to re-run automate.', 'dim');
524
525
  return 'failed';
525
526
  }
526
527
  }
@@ -610,6 +611,9 @@ async function runAutomate(rootDir, argv) {
610
611
  log(' GitHub repo > Settings > Actions > General > Workflow permissions', 'dim');
611
612
  }
612
613
  log(' Without this, the update still runs and commits safely — only opening the review PR fails, and the workflow run will show that failure clearly rather than hide it.', 'dim');
614
+ if (prPermission === 'failed') {
615
+ log(' If that checkbox is greyed out even at the organization level, it is enforced off and cannot be toggled: add a repository secret named GITSET_PR_TOKEN with a personal access token (repo scope) instead — the workflow uses it automatically, no changes needed.', 'dim');
616
+ }
613
617
  }
614
618
  log(' 3. Make sure the knowledge base itself is committed (gitset knowledge generate, then commit docs/gitset-knowledge/ and AGENTS.md).', 'reset');
615
619
  log(' 4. Commit and push the workflow file.', 'reset');