@nzpr/kb 0.1.9 → 0.1.10
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/lib/cli.js +59 -22
- package/lib/init-repo-interactive.js +1 -1
- package/lib/repo-init.js +4 -9
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -355,14 +355,25 @@ function printRepoConfiguration(configuration) {
|
|
|
355
355
|
|
|
356
356
|
function printInitRepoStatus(result) {
|
|
357
357
|
console.log("");
|
|
358
|
-
console.log("
|
|
359
|
-
|
|
360
|
-
console.log(` files created: ${result.created.length}`);
|
|
361
|
-
console.log(` files kept: ${result.skipped.length}`);
|
|
358
|
+
console.log("what happened:");
|
|
359
|
+
printInitRepoScaffoldStatus(result);
|
|
362
360
|
printInitRepoDatabaseStatus(result.database);
|
|
363
361
|
printInitRepoGitHubStatus(result.github);
|
|
364
362
|
}
|
|
365
363
|
|
|
364
|
+
function printInitRepoScaffoldStatus(result) {
|
|
365
|
+
const reusedOnly = !result.created.length && result.skipped.length > 0;
|
|
366
|
+
if (reusedOnly) {
|
|
367
|
+
console.log(` scaffold: reused the existing knowledge repo files in ${result.root}`);
|
|
368
|
+
} else if (result.created.length) {
|
|
369
|
+
console.log(` scaffold: created or updated the knowledge repo scaffold in ${result.root}`);
|
|
370
|
+
} else {
|
|
371
|
+
console.log(` scaffold: nothing changed in ${result.root}`);
|
|
372
|
+
}
|
|
373
|
+
console.log(` docs: documents live in ${result.docsRootRelative}/`);
|
|
374
|
+
console.log(` files: created=${result.created.length} kept=${result.skipped.length}`);
|
|
375
|
+
}
|
|
376
|
+
|
|
366
377
|
function printInitRepoDatabaseStatus(database) {
|
|
367
378
|
if (database.status === "verified") {
|
|
368
379
|
console.log(
|
|
@@ -371,10 +382,16 @@ function printInitRepoDatabaseStatus(database) {
|
|
|
371
382
|
return;
|
|
372
383
|
}
|
|
373
384
|
if (database.status === "failed") {
|
|
374
|
-
|
|
385
|
+
const target = database.target ? ` ${database.target}` : "";
|
|
386
|
+
console.log(` database: attempted verification${target}`);
|
|
387
|
+
console.log(` database result: failed - ${formatCliError(new Error(database.error))}`);
|
|
388
|
+
console.log(" database effect: no schema changes were confirmed");
|
|
375
389
|
return;
|
|
376
390
|
}
|
|
377
|
-
|
|
391
|
+
if (database.target) {
|
|
392
|
+
console.log(` database: pending verification for ${database.target}`);
|
|
393
|
+
}
|
|
394
|
+
console.log(` database result: pending - ${database.message}`);
|
|
378
395
|
}
|
|
379
396
|
|
|
380
397
|
function printInitRepoGitHubStatus(github) {
|
|
@@ -382,36 +399,52 @@ function printInitRepoGitHubStatus(github) {
|
|
|
382
399
|
console.log(` github: configured ${github.repo}`);
|
|
383
400
|
if (github.actions) {
|
|
384
401
|
console.log(
|
|
385
|
-
` actions: enabled=${github.actions.enabled} workflow_permissions=${github.actions.defaultWorkflowPermissions} pr_creation=${github.actions.canApprovePullRequestReviews}`
|
|
402
|
+
` github actions: enabled=${github.actions.enabled} workflow_permissions=${github.actions.defaultWorkflowPermissions} pr_creation=${github.actions.canApprovePullRequestReviews}`
|
|
386
403
|
);
|
|
387
404
|
}
|
|
388
|
-
console.log(` labels: ${github.labels.join(", ")}`);
|
|
405
|
+
console.log(` github labels: ${github.labels.join(", ")}`);
|
|
389
406
|
if (github.secrets.length) {
|
|
390
|
-
console.log(` secrets: ${github.secrets.join(", ")}`);
|
|
407
|
+
console.log(` github secrets: ${github.secrets.join(", ")}`);
|
|
391
408
|
}
|
|
392
409
|
if (github.variables.length) {
|
|
393
|
-
console.log(` variables: ${github.variables.join(", ")}`);
|
|
410
|
+
console.log(` github variables: ${github.variables.join(", ")}`);
|
|
394
411
|
}
|
|
395
412
|
return;
|
|
396
413
|
}
|
|
397
414
|
if (github.status === "failed") {
|
|
398
|
-
|
|
415
|
+
const repo = github.repo ? ` ${github.repo}` : "";
|
|
416
|
+
console.log(` github: attempted repo bootstrap${repo}`);
|
|
417
|
+
console.log(` github result: failed - ${github.error}`);
|
|
399
418
|
return;
|
|
400
419
|
}
|
|
401
|
-
|
|
420
|
+
if (github.repo) {
|
|
421
|
+
console.log(` github: pending bootstrap for ${github.repo}`);
|
|
422
|
+
}
|
|
423
|
+
console.log(` github result: ${github.status} - ${github.message}`);
|
|
402
424
|
}
|
|
403
425
|
|
|
404
426
|
function printInitRepoNextStep(result) {
|
|
427
|
+
const failures = [];
|
|
428
|
+
if (result.database.status === "failed") {
|
|
429
|
+
failures.push("database verification failed");
|
|
430
|
+
}
|
|
431
|
+
if (result.github.status === "failed") {
|
|
432
|
+
failures.push("GitHub bootstrap failed");
|
|
433
|
+
}
|
|
434
|
+
|
|
405
435
|
if (!result.ok) {
|
|
436
|
+
console.log("");
|
|
406
437
|
console.log(
|
|
407
|
-
|
|
438
|
+
`next: fix ${failures.join(" and ")} and rerun kb init-repo; rerunning is safe because the scaffold is idempotent`
|
|
408
439
|
);
|
|
409
440
|
return;
|
|
410
441
|
}
|
|
411
442
|
if (result.database.status === "verified" && result.github.status === "configured") {
|
|
443
|
+
console.log("");
|
|
412
444
|
console.log("next: commit the scaffold in the knowledge repo, push it, and let that repo own KB publishing");
|
|
413
445
|
return;
|
|
414
446
|
}
|
|
447
|
+
console.log("");
|
|
415
448
|
console.log(
|
|
416
449
|
"next: rerun kb init-repo with the missing repo or database inputs when you are ready, or commit the scaffold now and finish remote setup later"
|
|
417
450
|
);
|
|
@@ -420,25 +453,29 @@ function printInitRepoNextStep(result) {
|
|
|
420
453
|
function printInitRepoChecklist(result) {
|
|
421
454
|
console.log("");
|
|
422
455
|
console.log("next steps:");
|
|
456
|
+
const steps = [];
|
|
423
457
|
if (result.created.length || result.skipped.length) {
|
|
424
|
-
|
|
458
|
+
steps.push(`commit and push the scaffolded knowledge repo files, including ${result.docsRootRelative}/`);
|
|
425
459
|
}
|
|
426
460
|
if (result.github.status !== "configured") {
|
|
427
|
-
|
|
461
|
+
steps.push("make sure the target repo exists and rerun with --repo once GitHub setup is ready");
|
|
428
462
|
}
|
|
429
463
|
if (result.database.status !== "verified") {
|
|
430
|
-
|
|
464
|
+
steps.push("rerun with --database-url once the target database is reachable");
|
|
431
465
|
}
|
|
432
|
-
|
|
433
|
-
|
|
466
|
+
steps.push("use kb create to open a proposal issue for the first knowledge entry");
|
|
467
|
+
steps.push("review the issue, add kb-approved, merge the generated PR, and let publish sync the live KB");
|
|
468
|
+
steps.forEach((step, index) => {
|
|
469
|
+
console.log(` ${index + 1}. ${step}`);
|
|
470
|
+
});
|
|
434
471
|
console.log("");
|
|
435
|
-
console.log("
|
|
472
|
+
console.log("changes in this run:");
|
|
436
473
|
if (result.created.length) {
|
|
437
|
-
console.log(` created: ${result.created.join(", ")}`);
|
|
474
|
+
console.log(` created files: ${result.created.join(", ")}`);
|
|
438
475
|
} else {
|
|
439
|
-
console.log(" created:
|
|
476
|
+
console.log(" created files: none");
|
|
440
477
|
}
|
|
441
478
|
if (result.skipped.length) {
|
|
442
|
-
console.log(` kept: ${result.skipped.join(", ")}`);
|
|
479
|
+
console.log(` kept existing files: ${result.skipped.join(", ")}`);
|
|
443
480
|
}
|
|
444
481
|
}
|
|
@@ -126,7 +126,7 @@ export async function collectInitRepoInteractiveOptions({
|
|
|
126
126
|
` embeddings config: ${embeddingMode === "bge-m3-openai" ? `${embeddingMode}/${embeddingModel}` : "skip for now"}\n`
|
|
127
127
|
);
|
|
128
128
|
|
|
129
|
-
const proceed = await prompt.askConfirm("
|
|
129
|
+
const proceed = await prompt.askConfirm("proceed with initialization", true);
|
|
130
130
|
if (!proceed) {
|
|
131
131
|
throw new Error("interactive init-repo cancelled");
|
|
132
132
|
}
|
package/lib/repo-init.js
CHANGED
|
@@ -79,11 +79,13 @@ export async function bootstrapKnowledgeRepo({
|
|
|
79
79
|
...scaffold,
|
|
80
80
|
ok: true,
|
|
81
81
|
database: {
|
|
82
|
+
target: databaseUrl ? maskConnection(databaseUrl) : null,
|
|
82
83
|
status: "pending",
|
|
83
84
|
message:
|
|
84
85
|
"rerun with --database-url URL or KB_DATABASE_URL to verify the target database and initialize the schema"
|
|
85
86
|
},
|
|
86
87
|
github: {
|
|
88
|
+
repo,
|
|
87
89
|
status: "pending",
|
|
88
90
|
message:
|
|
89
91
|
"rerun with --repo OWNER/REPO and GITHUB_TOKEN to configure labels, repo settings, and GitHub secrets or variables"
|
|
@@ -94,12 +96,14 @@ export async function bootstrapKnowledgeRepo({
|
|
|
94
96
|
try {
|
|
95
97
|
const database = await verifyDatabaseReady({ databaseUrl });
|
|
96
98
|
result.database = {
|
|
99
|
+
target: maskConnection(databaseUrl),
|
|
97
100
|
status: "verified",
|
|
98
101
|
...database
|
|
99
102
|
};
|
|
100
103
|
} catch (error) {
|
|
101
104
|
result.ok = false;
|
|
102
105
|
result.database = {
|
|
106
|
+
target: maskConnection(databaseUrl),
|
|
103
107
|
status: "failed",
|
|
104
108
|
error: String(error?.message ?? error)
|
|
105
109
|
};
|
|
@@ -117,15 +121,6 @@ export async function bootstrapKnowledgeRepo({
|
|
|
117
121
|
};
|
|
118
122
|
return result;
|
|
119
123
|
}
|
|
120
|
-
|
|
121
|
-
if (result.database.status === "failed") {
|
|
122
|
-
result.github = {
|
|
123
|
-
status: "skipped",
|
|
124
|
-
repo,
|
|
125
|
-
message: "database preflight failed, so repo secrets and variables were not changed"
|
|
126
|
-
};
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
124
|
const secrets = new Map();
|
|
130
125
|
const variables = new Map();
|
|
131
126
|
|