@nzpr/kb 0.1.10 → 0.1.11

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/lib/cli.js +26 -101
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -102,9 +102,7 @@ export async function main(argv) {
102
102
  console.log("no files created");
103
103
  }
104
104
  printInitRepoStatus(result);
105
- printRepoConfiguration(result.configuration);
106
105
  printInitRepoNextStep(result);
107
- printInitRepoChecklist(result);
108
106
  return result.ok ? 0 : 1;
109
107
  }
110
108
  case "search": {
@@ -328,34 +326,8 @@ async function requirePublishAccess({ repo, token, apiBaseUrl }) {
328
326
  throw new Error(`GITHUB_TOKEN does not have repository access to ${repo}`);
329
327
  }
330
328
 
331
- function printRepoConfiguration(configuration) {
332
- console.log("");
333
- console.log("configuration reference:");
334
- console.log("");
335
- console.log("required secrets:");
336
- for (const entry of configuration.requiredSecrets) {
337
- console.log(` ${entry.name} - ${entry.purpose}`);
338
- }
339
- console.log("");
340
- console.log("optional secrets:");
341
- for (const entry of configuration.optionalSecrets) {
342
- console.log(` ${entry.name} - ${entry.purpose}`);
343
- }
344
- console.log("");
345
- console.log("optional variables:");
346
- for (const entry of configuration.optionalVariables) {
347
- console.log(` ${entry.name}=${entry.value} - ${entry.purpose}`);
348
- }
349
- console.log("");
350
- console.log("publish workflow auth:");
351
- console.log(" KB_GITHUB_REPO is set automatically to github.repository in the scaffolded workflow");
352
- console.log(" GITHUB_TOKEN is provided automatically by GitHub Actions and only needs repository read access for publish");
353
- console.log(" the token used for kb init-repo itself must have admin access if you want the CLI to configure repo Actions settings")
354
- }
355
-
356
329
  function printInitRepoStatus(result) {
357
330
  console.log("");
358
- console.log("what happened:");
359
331
  printInitRepoScaffoldStatus(result);
360
332
  printInitRepoDatabaseStatus(result.database);
361
333
  printInitRepoGitHubStatus(result.github);
@@ -364,118 +336,71 @@ function printInitRepoStatus(result) {
364
336
  function printInitRepoScaffoldStatus(result) {
365
337
  const reusedOnly = !result.created.length && result.skipped.length > 0;
366
338
  if (reusedOnly) {
367
- console.log(` scaffold: reused the existing knowledge repo files in ${result.root}`);
339
+ console.log(`scaffold: reused existing files in ${result.root}`);
368
340
  } else if (result.created.length) {
369
- console.log(` scaffold: created or updated the knowledge repo scaffold in ${result.root}`);
341
+ console.log(`scaffold: created or updated files in ${result.root}`);
370
342
  } else {
371
- console.log(` scaffold: nothing changed in ${result.root}`);
343
+ console.log(`scaffold: nothing changed in ${result.root}`);
372
344
  }
373
- console.log(` docs: documents live in ${result.docsRootRelative}/`);
374
- console.log(` files: created=${result.created.length} kept=${result.skipped.length}`);
345
+ console.log(`docs: ${result.docsRootRelative}/`);
375
346
  }
376
347
 
377
348
  function printInitRepoDatabaseStatus(database) {
378
349
  if (database.status === "verified") {
379
- console.log(
380
- ` database: verified ${database.database} current=${database.currentVersion} applied=${database.appliedCount}`
381
- );
350
+ console.log(`database: ok ${database.database} current=${database.currentVersion} applied=${database.appliedCount}`);
382
351
  return;
383
352
  }
384
353
  if (database.status === "failed") {
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");
354
+ console.log(`database: failed - ${formatCliError(new Error(database.error))}`);
389
355
  return;
390
356
  }
391
- if (database.target) {
392
- console.log(` database: pending verification for ${database.target}`);
393
- }
394
- console.log(` database result: pending - ${database.message}`);
357
+ console.log("database: skipped");
395
358
  }
396
359
 
397
360
  function printInitRepoGitHubStatus(github) {
398
361
  if (github.status === "configured") {
399
- console.log(` github: configured ${github.repo}`);
362
+ console.log(`github: ok ${github.repo}`);
400
363
  if (github.actions) {
401
364
  console.log(
402
- ` github actions: enabled=${github.actions.enabled} workflow_permissions=${github.actions.defaultWorkflowPermissions} pr_creation=${github.actions.canApprovePullRequestReviews}`
365
+ `github actions: enabled=${github.actions.enabled} workflow_permissions=${github.actions.defaultWorkflowPermissions} pr_creation=${github.actions.canApprovePullRequestReviews}`
403
366
  );
404
367
  }
405
- console.log(` github labels: ${github.labels.join(", ")}`);
406
- if (github.secrets.length) {
407
- console.log(` github secrets: ${github.secrets.join(", ")}`);
408
- }
409
- if (github.variables.length) {
410
- console.log(` github variables: ${github.variables.join(", ")}`);
411
- }
412
368
  return;
413
369
  }
414
370
  if (github.status === "failed") {
415
- const repo = github.repo ? ` ${github.repo}` : "";
416
- console.log(` github: attempted repo bootstrap${repo}`);
417
- console.log(` github result: failed - ${github.error}`);
371
+ console.log(`github: failed - ${github.error}`);
418
372
  return;
419
373
  }
420
- if (github.repo) {
421
- console.log(` github: pending bootstrap for ${github.repo}`);
422
- }
423
- console.log(` github result: ${github.status} - ${github.message}`);
374
+ console.log("github: skipped");
424
375
  }
425
376
 
426
377
  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
-
435
378
  if (!result.ok) {
436
379
  console.log("");
437
- console.log(
438
- `next: fix ${failures.join(" and ")} and rerun kb init-repo; rerunning is safe because the scaffold is idempotent`
439
- );
380
+ console.log("next:");
381
+ if (result.database.status === "failed") {
382
+ console.log(" fix the database connection and rerun kb init-repo");
383
+ }
384
+ if (result.github.status === "failed") {
385
+ console.log(" fix GitHub access or repo settings and rerun kb init-repo");
386
+ }
440
387
  return;
441
388
  }
442
389
  if (result.database.status === "verified" && result.github.status === "configured") {
443
390
  console.log("");
444
- console.log("next: commit the scaffold in the knowledge repo, push it, and let that repo own KB publishing");
391
+ console.log("next:");
392
+ console.log(" create a knowledge proposal with kb create");
393
+ console.log(" add kb-approved to open the PR");
394
+ console.log(" merge the PR and let publish sync the database");
445
395
  return;
446
396
  }
447
397
  console.log("");
448
- console.log(
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"
450
- );
451
- }
452
-
453
- function printInitRepoChecklist(result) {
454
- console.log("");
455
- console.log("next steps:");
456
- const steps = [];
457
- if (result.created.length || result.skipped.length) {
458
- steps.push(`commit and push the scaffolded knowledge repo files, including ${result.docsRootRelative}/`);
459
- }
398
+ console.log("next:");
460
399
  if (result.github.status !== "configured") {
461
- steps.push("make sure the target repo exists and rerun with --repo once GitHub setup is ready");
400
+ console.log(" rerun init-repo with --repo and admin GitHub access");
462
401
  }
463
402
  if (result.database.status !== "verified") {
464
- steps.push("rerun with --database-url once the target database is reachable");
465
- }
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
- });
471
- console.log("");
472
- console.log("changes in this run:");
473
- if (result.created.length) {
474
- console.log(` created files: ${result.created.join(", ")}`);
475
- } else {
476
- console.log(" created files: none");
477
- }
478
- if (result.skipped.length) {
479
- console.log(` kept existing files: ${result.skipped.join(", ")}`);
403
+ console.log(" rerun init-repo with a reachable --database-url");
480
404
  }
405
+ console.log(" after that, create a knowledge proposal with kb create");
481
406
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nzpr/kb",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Knowledge base CLI for proposing, publishing, and querying curated agent knowledge.",
5
5
  "repository": {
6
6
  "type": "git",