@gitset-dev/cli 2.4.1 → 2.4.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.
- package/README.md +32 -0
- package/package.json +1 -1
- package/src/commands/knowledge.js +44 -5
package/README.md
CHANGED
|
@@ -87,6 +87,38 @@ Local tools (no AI):
|
|
|
87
87
|
Common flags: `--provider` `--model` `--yes` `--print` `--json`. Run
|
|
88
88
|
`gitset help <command>` for everything else.
|
|
89
89
|
|
|
90
|
+
## Knowledge Mapper
|
|
91
|
+
|
|
92
|
+
`gitset knowledge` builds and maintains `docs/gitset-knowledge/` — a
|
|
93
|
+
structured, always-current map of your codebase (architecture, module
|
|
94
|
+
boundaries, commands, dependency graph) that both developers and AI coding
|
|
95
|
+
agents can read before touching your code. It's generated from your source
|
|
96
|
+
code, manifests, and CI configuration — never from your existing prose docs,
|
|
97
|
+
so it can't inherit their drift.
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
gitset knowledge init # scaffold optional .gitset-knowledge.json (include/exclude globs)
|
|
101
|
+
gitset knowledge scan # zero AI calls — discovers files, prints the plan + exact cost estimate
|
|
102
|
+
gitset knowledge generate # shows the estimate again, asks to confirm, then writes the knowledge base
|
|
103
|
+
gitset knowledge update # incremental — only changed modules (and their direct importers) are re-summarized
|
|
104
|
+
gitset knowledge automate # writes a GitHub Actions workflow that runs `update` in CI and opens a review PR
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
It's a six-stage local pipeline (Discover → Map → Summarize → Plan → Write →
|
|
108
|
+
Validate): Discover and Map walk the repository and build an import graph
|
|
109
|
+
with zero AI calls; only Summarize and Write touch your configured provider
|
|
110
|
+
— there's no separate "default model" for this tool, it uses whatever you
|
|
111
|
+
picked with `gitset config`; and a deterministic Validate pass checks every
|
|
112
|
+
generated link, command, and script before anything is written to disk.
|
|
113
|
+
Secrets are redacted locally before any file content is sent, and prose
|
|
114
|
+
docs / test file bodies are listed structurally but never sent at all.
|
|
115
|
+
|
|
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.
|
|
121
|
+
|
|
90
122
|
## Templates
|
|
91
123
|
|
|
92
124
|
Define your commit style, issue structure, PR format, README skeleton, or
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitset-dev/cli",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
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": {
|
|
@@ -492,6 +492,39 @@ async function runUpdate(rootDir, argv) {
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
+
function ghApiJson(args) {
|
|
496
|
+
try {
|
|
497
|
+
const out = execFileSync('gh', ['api', ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
498
|
+
return JSON.parse(out);
|
|
499
|
+
} catch {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async function ensurePrPermission(repo, argv) {
|
|
505
|
+
if (!repo.includes('/')) return 'unknown';
|
|
506
|
+
const current = ghApiJson([`/repos/${repo}/actions/permissions/workflow`]);
|
|
507
|
+
if (!current) return 'unknown';
|
|
508
|
+
if (current.can_approve_pull_request_reviews) return 'already-enabled';
|
|
509
|
+
|
|
510
|
+
log('\n"Allow GitHub Actions to create and approve pull requests" is currently OFF for this repository. The update step will still run and commit safely without it — only opening the review PR will fail.', 'yellow');
|
|
511
|
+
const proceed = await confirmOrAbort('Enable it now via the GitHub API? (only this one setting changes)', argv);
|
|
512
|
+
if (!proceed) return 'declined';
|
|
513
|
+
|
|
514
|
+
try {
|
|
515
|
+
execFileSync('gh', [
|
|
516
|
+
'api', '--method', 'PUT', `/repos/${repo}/actions/permissions/workflow`,
|
|
517
|
+
'-f', `default_workflow_permissions=${current.default_workflow_permissions}`,
|
|
518
|
+
'-F', 'can_approve_pull_request_reviews=true',
|
|
519
|
+
], { stdio: 'pipe' });
|
|
520
|
+
log('Enabled — CI will be able to open the review PR.', 'green');
|
|
521
|
+
return 'enabled';
|
|
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');
|
|
524
|
+
return 'failed';
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
495
528
|
async function runAutomate(rootDir, argv) {
|
|
496
529
|
let cfg;
|
|
497
530
|
try {
|
|
@@ -558,6 +591,8 @@ async function runAutomate(rootDir, argv) {
|
|
|
558
591
|
log(`\nWrote ${km.WORKFLOW_PATH}.`, 'green');
|
|
559
592
|
|
|
560
593
|
const repo = repoLabel(rootDir);
|
|
594
|
+
const prPermission = await ensurePrPermission(repo, argv);
|
|
595
|
+
|
|
561
596
|
log('\nNext steps:', 'cyan');
|
|
562
597
|
log(` 1. Add the repository secret ${envKey} with your ${cfg.provider} API key:`, 'reset');
|
|
563
598
|
if (repo.includes('/')) {
|
|
@@ -565,13 +600,17 @@ async function runAutomate(rootDir, argv) {
|
|
|
565
600
|
} else {
|
|
566
601
|
log(' GitHub repo > Settings > Secrets and variables > Actions', 'dim');
|
|
567
602
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
log(` https://github.com/${repo}/settings/actions`, 'dim');
|
|
603
|
+
if (prPermission === 'enabled' || prPermission === 'already-enabled') {
|
|
604
|
+
log(' 2. "Allow GitHub Actions to create and approve pull requests" is already on — the update PR step is ready.', 'reset');
|
|
571
605
|
} else {
|
|
572
|
-
log('
|
|
606
|
+
log(' 2. Enable "Allow GitHub Actions to create and approve pull requests" (required for the update PR):', 'reset');
|
|
607
|
+
if (repo.includes('/')) {
|
|
608
|
+
log(` https://github.com/${repo}/settings/actions`, 'dim');
|
|
609
|
+
} else {
|
|
610
|
+
log(' GitHub repo > Settings > Actions > General > Workflow permissions', 'dim');
|
|
611
|
+
}
|
|
612
|
+
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');
|
|
573
613
|
}
|
|
574
|
-
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');
|
|
575
614
|
log(' 3. Make sure the knowledge base itself is committed (gitset knowledge generate, then commit docs/gitset-knowledge/ and AGENTS.md).', 'reset');
|
|
576
615
|
log(' 4. Commit and push the workflow file.', 'reset');
|
|
577
616
|
log('\nWhen mapped source changes land, CI opens a PR on branch gitset/knowledge-update — you review it like any docs change. Runs with no mapped changes make zero AI calls.', 'dim');
|