@nzpr/kb 0.1.9 → 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.
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,117 +326,81 @@ 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("summary:");
359
- console.log(` docs layout: ${result.docsRootRelative}/`);
360
- console.log(` files created: ${result.created.length}`);
361
- console.log(` files kept: ${result.skipped.length}`);
331
+ printInitRepoScaffoldStatus(result);
362
332
  printInitRepoDatabaseStatus(result.database);
363
333
  printInitRepoGitHubStatus(result.github);
364
334
  }
365
335
 
336
+ function printInitRepoScaffoldStatus(result) {
337
+ const reusedOnly = !result.created.length && result.skipped.length > 0;
338
+ if (reusedOnly) {
339
+ console.log(`scaffold: reused existing files in ${result.root}`);
340
+ } else if (result.created.length) {
341
+ console.log(`scaffold: created or updated files in ${result.root}`);
342
+ } else {
343
+ console.log(`scaffold: nothing changed in ${result.root}`);
344
+ }
345
+ console.log(`docs: ${result.docsRootRelative}/`);
346
+ }
347
+
366
348
  function printInitRepoDatabaseStatus(database) {
367
349
  if (database.status === "verified") {
368
- console.log(
369
- ` database: verified ${database.database} current=${database.currentVersion} applied=${database.appliedCount}`
370
- );
350
+ console.log(`database: ok ${database.database} current=${database.currentVersion} applied=${database.appliedCount}`);
371
351
  return;
372
352
  }
373
353
  if (database.status === "failed") {
374
- console.log(` database: failed - ${formatCliError(new Error(database.error))}`);
354
+ console.log(`database: failed - ${formatCliError(new Error(database.error))}`);
375
355
  return;
376
356
  }
377
- console.log(` database: pending - ${database.message}`);
357
+ console.log("database: skipped");
378
358
  }
379
359
 
380
360
  function printInitRepoGitHubStatus(github) {
381
361
  if (github.status === "configured") {
382
- console.log(` github: configured ${github.repo}`);
362
+ console.log(`github: ok ${github.repo}`);
383
363
  if (github.actions) {
384
364
  console.log(
385
- ` 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}`
386
366
  );
387
367
  }
388
- console.log(` labels: ${github.labels.join(", ")}`);
389
- if (github.secrets.length) {
390
- console.log(` secrets: ${github.secrets.join(", ")}`);
391
- }
392
- if (github.variables.length) {
393
- console.log(` variables: ${github.variables.join(", ")}`);
394
- }
395
368
  return;
396
369
  }
397
370
  if (github.status === "failed") {
398
- console.log(` github: failed - ${github.error}`);
371
+ console.log(`github: failed - ${github.error}`);
399
372
  return;
400
373
  }
401
- console.log(` github: ${github.status} - ${github.message}`);
374
+ console.log("github: skipped");
402
375
  }
403
376
 
404
377
  function printInitRepoNextStep(result) {
405
378
  if (!result.ok) {
406
- console.log(
407
- "next: fix the failed bootstrap step and rerun kb init-repo; rerunning is safe because the scaffold is idempotent"
408
- );
379
+ console.log("");
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
+ }
409
387
  return;
410
388
  }
411
389
  if (result.database.status === "verified" && result.github.status === "configured") {
412
- console.log("next: commit the scaffold in the knowledge repo, push it, and let that repo own KB publishing");
390
+ console.log("");
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");
413
395
  return;
414
396
  }
415
- console.log(
416
- "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
- );
418
- }
419
-
420
- function printInitRepoChecklist(result) {
421
397
  console.log("");
422
- console.log("next steps:");
423
- if (result.created.length || result.skipped.length) {
424
- console.log(` 1. commit and push the scaffolded knowledge repo files, including ${result.docsRootRelative}/`);
425
- }
398
+ console.log("next:");
426
399
  if (result.github.status !== "configured") {
427
- console.log(" 2. 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");
428
401
  }
429
402
  if (result.database.status !== "verified") {
430
- console.log(" 3. rerun with --database-url once the target database is ready");
431
- }
432
- console.log(" 4. use kb create to open a proposal issue for the first knowledge entry");
433
- console.log(" 5. review the issue, add kb-approved, merge the generated PR, and let publish sync the live KB");
434
- console.log("");
435
- console.log("done in this run:");
436
- if (result.created.length) {
437
- console.log(` created: ${result.created.join(", ")}`);
438
- } else {
439
- console.log(" created: no new files");
440
- }
441
- if (result.skipped.length) {
442
- console.log(` kept: ${result.skipped.join(", ")}`);
403
+ console.log(" rerun init-repo with a reachable --database-url");
443
404
  }
405
+ console.log(" after that, create a knowledge proposal with kb create");
444
406
  }
@@ -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("run init-repo with this plan", true);
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nzpr/kb",
3
- "version": "0.1.9",
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",