@tomingtoming/kioq 0.9.0 → 0.9.1

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/dist/src/index.js CHANGED
@@ -118,7 +118,10 @@ function appendScopeLabel(lines, scopeLabel) {
118
118
  lines.push(`scope_label: ${scopeLabel}`);
119
119
  }
120
120
  function appendResponsibilityWarning(lines, warnings) {
121
- lines.push(`responsibility_warning: ${responsibilityWarningCode(warnings)}`);
121
+ const code = responsibilityWarningCode(warnings);
122
+ if (code === "none")
123
+ return;
124
+ lines.push(`responsibility_warning: ${code}`);
122
125
  }
123
126
  function appendTemplateHints(lines, hints) {
124
127
  lines.push(`template_hint_primary: ${hints.primary}`);
@@ -263,10 +266,9 @@ function appendAuditResponseSummary(lines, summary) {
263
266
  }
264
267
  }
265
268
  function appendChangeTriggerSummary(lines, summary) {
266
- lines.push(`change_trigger: ${summary.code}`);
267
- if (summary.code === "none") {
269
+ if (summary.code === "none")
268
270
  return;
269
- }
271
+ lines.push(`change_trigger: ${summary.code}`);
270
272
  lines.push(`trigger_confidence: ${summary.confidence}`);
271
273
  lines.push(`cascade_targets: ${summary.cascadeTargets?.join(", ") ?? "(none)"}`);
272
274
  lines.push(`noise_risk: ${summary.noiseRisk}`);
@@ -277,9 +279,7 @@ function appendOperationImpact(lines, impact) {
277
279
  lines.push(`impact_reasons: ${impact.reasons.join(", ")}`);
278
280
  }
279
281
  function appendConflictSummary(lines, summary) {
280
- lines.push(`conflict_type: ${summary.conflictType}`);
281
282
  lines.push(`server_updated: ${summary.serverUpdated}`);
282
- lines.push(`retry_hint: ${summary.retryHint}`);
283
283
  }
284
284
  const responseModeSchema = z.enum(RESPONSE_MODE_VALUES).optional().describe("default: standard");
285
285
  async function main() {
@@ -291,7 +291,11 @@ async function main() {
291
291
  const store = new LocalNoteStore(config, storage);
292
292
  const signalLog = new SignalLog(storage);
293
293
  const engagementIndex = new EngagementIndex();
294
+ let storageContextEmitted = false;
294
295
  const appendStorageContext = (lines) => {
296
+ if (storageContextEmitted)
297
+ return;
298
+ storageContextEmitted = true;
295
299
  lines.push(`storage_backend: ${config.github ? "github" : "filesystem"}`);
296
300
  lines.push(`storage_root: ${config.root}`);
297
301
  if (config.github) {
@@ -299,16 +303,34 @@ async function main() {
299
303
  lines.push(`storage_branch: ${config.github.branch}`);
300
304
  }
301
305
  };
306
+ /** Returns storage context lines only on first call, empty array after. */
307
+ const storageContextLines = () => {
308
+ if (storageContextEmitted)
309
+ return [];
310
+ storageContextEmitted = true;
311
+ return [
312
+ `storage_backend: ${config.github ? "github" : "filesystem"}`,
313
+ `storage_root: ${config.root}`,
314
+ ...(config.github
315
+ ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
316
+ : []),
317
+ ];
318
+ };
302
319
  const appendAutoProjectHealth = async (lines) => {
303
320
  try {
304
321
  const health = await store.lintStructure({
305
322
  limit: 3,
306
323
  });
324
+ const hasAttention = health.unresolvedWikiLinkCount > 0
325
+ || health.duplicateWarningCount > 0
326
+ || health.technicalDebtSignals.dependencyDirectionViolationCount > 0
327
+ || health.orphanNoteCount > 0;
328
+ if (!hasAttention)
329
+ return;
307
330
  appendProjectHealthSummary(lines, health);
308
331
  }
309
- catch (error) {
310
- lines.push("");
311
- lines.push(`project_health: unavailable (${normalizeError(error)})`);
332
+ catch {
333
+ // silently skip if lint fails
312
334
  }
313
335
  };
314
336
  const server = new McpServer({
@@ -423,11 +445,13 @@ async function main() {
423
445
  if (responseModeAtLeast(responseMode, "standard")) {
424
446
  lines.push(` permalink: ${item.permalink}`);
425
447
  lines.push(` file: ${item.filePath}`);
426
- lines.push(` exact_identifier_match: ${item.exactIdentifierMatch ? "yes" : "no"}`);
427
- lines.push(` index_like: ${item.indexLike ? "yes" : "no"}`);
448
+ if (item.exactIdentifierMatch)
449
+ lines.push(` exact_identifier_match: yes`);
450
+ if (item.indexLike)
451
+ lines.push(` index_like: yes`);
428
452
  }
429
- if (responseModeAtLeast(responseMode, "verbose")) {
430
- lines.push(` index_like_reasons: ${item.indexLike && item.indexReasons.length > 0 ? item.indexReasons.join(", ") : "(none)"}`);
453
+ if (responseModeAtLeast(responseMode, "verbose") && item.indexLike && item.indexReasons.length > 0) {
454
+ lines.push(` index_like_reasons: ${item.indexReasons.join(", ")}`);
431
455
  }
432
456
  });
433
457
  }
@@ -466,8 +490,7 @@ async function main() {
466
490
  const lines = [
467
491
  `identifier: ${identifier}`,
468
492
  `project: ${result.project}`,
469
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
470
- `storage_root: ${config.root}`,
493
+ ...storageContextLines(),
471
494
  `scope_label: ${TOOL_SCOPE_LABELS.read_note}`,
472
495
  `response_mode: ${responseMode}`,
473
496
  `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
@@ -476,9 +499,6 @@ async function main() {
476
499
  `file: ${result.note.relativePath}`,
477
500
  `permalink: ${result.note.permalink}`,
478
501
  ];
479
- if (config.github) {
480
- lines.splice(4, 0, `storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`);
481
- }
482
502
  if (summary.nextRecommendedTarget) {
483
503
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
484
504
  }
@@ -488,7 +508,8 @@ async function main() {
488
508
  if (responseModeAtLeast(responseMode, "standard")) {
489
509
  lines.push(`link_health: ${result.linkHealth.resolved}/${result.linkHealth.total} resolved`);
490
510
  lines.push(`backlinks: ${result.backlinkCount}`);
491
- lines.push(`orphan_warning: ${result.orphanWarning ? "yes" : "no"}`);
511
+ if (result.orphanWarning)
512
+ lines.push(`orphan_warning: yes`);
492
513
  appendDocumentClarity(lines, result.documentClarity, responseModeAtLeast(responseMode, "verbose"));
493
514
  appendUnresolvedWikiLinks(lines, result.unresolvedWikiLinks);
494
515
  }
@@ -528,7 +549,8 @@ async function main() {
528
549
  lines.push(` score: ${item.score}`);
529
550
  lines.push(` permalink: ${item.permalink}`);
530
551
  lines.push(` file: ${item.filePath}`);
531
- lines.push(` exact_identifier_match: ${item.exactIdentifierMatch ? "yes" : "no"}`);
552
+ if (item.exactIdentifierMatch)
553
+ lines.push(` exact_identifier_match: yes`);
532
554
  });
533
555
  }
534
556
  return textResult(lines.join("\n"));
@@ -715,9 +737,10 @@ async function main() {
715
737
  `parent_stock_resolved: ${flowResult.parentStockResolved ? "yes" : "no"}`,
716
738
  `link_health: ${flowResult.linkHealth.resolved}/${flowResult.linkHealth.total} resolved`,
717
739
  `backlinks: ${flowResult.backlinkCount}`,
718
- `orphan_warning: ${flowResult.orphanWarning ? "yes" : "no"}`,
719
740
  ];
720
- flowLines.splice(2, 0, ...[`storage_backend: ${config.github ? "github" : "filesystem"}`, `storage_root: ${config.root}`, ...(config.github ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`] : [])]);
741
+ if (flowResult.orphanWarning)
742
+ flowLines.push(`orphan_warning: yes`);
743
+ flowLines.splice(2, 0, ...storageContextLines());
721
744
  if (flowSummary.nextRecommendedTarget) {
722
745
  insertBeforeLine(flowLines, "next_recommended_action:", `next_recommended_target: ${flowSummary.nextRecommendedTarget}`);
723
746
  }
@@ -763,15 +786,8 @@ async function main() {
763
786
  `title: ${result.title}`,
764
787
  `link_health: ${result.linkHealth.resolved}/${result.linkHealth.total} resolved`,
765
788
  `backlinks: ${result.backlinkCount}`,
766
- `orphan_warning: ${result.orphanWarning ? "yes" : "no"}`,
767
789
  ];
768
- lines.splice(2, 0, ...[
769
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
770
- `storage_root: ${config.root}`,
771
- ...(config.github
772
- ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
773
- : []),
774
- ]);
790
+ lines.splice(2, 0, ...storageContextLines());
775
791
  if (summary.nextRecommendedTarget) {
776
792
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
777
793
  }
@@ -780,12 +796,14 @@ async function main() {
780
796
  appendStructureScore(lines, result.structureScore);
781
797
  appendMemoryContract(lines, result.memoryContract);
782
798
  appendBoundaryWarnings(lines, result.boundaryWarnings);
783
- appendTemplateHints(lines, {
784
- primary: "stock",
785
- alternatives: ["index"],
786
- reason: "通常ノートとして知識を残すときは stock template を基準にする",
787
- whenToSwitch: "再訪導線を固定したい入口ノートなら index template に切り替える",
788
- });
799
+ if (result.memoryContract.status === "fail") {
800
+ appendTemplateHints(lines, {
801
+ primary: "stock",
802
+ alternatives: ["index"],
803
+ reason: "通常ノートとして知識を残すときは stock template を基準にする",
804
+ whenToSwitch: "再訪導線を固定したい入口ノートなら index template に切り替える",
805
+ });
806
+ }
789
807
  appendUnresolvedWikiLinks(lines, result.unresolvedWikiLinks);
790
808
  appendUnresolvedLinkHints(lines, result.unresolvedLinkHints);
791
809
  appendDuplicateWarnings(lines, result.duplicateWarnings);
@@ -825,13 +843,7 @@ async function main() {
825
843
  `stock_permalink: ${result.stock.permalink}`,
826
844
  `flow_state: ${result.flowState}`,
827
845
  ];
828
- lines.splice(2, 0, ...[
829
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
830
- `storage_root: ${config.root}`,
831
- ...(config.github
832
- ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
833
- : []),
834
- ]);
846
+ lines.splice(2, 0, ...storageContextLines());
835
847
  if (summary.nextRecommendedTarget) {
836
848
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
837
849
  }
@@ -882,15 +894,8 @@ async function main() {
882
894
  `title: ${result.title}`,
883
895
  `link_health: ${result.linkHealth.resolved}/${result.linkHealth.total} resolved`,
884
896
  `backlinks: ${result.backlinkCount}`,
885
- `orphan_warning: ${result.orphanWarning ? "yes" : "no"}`,
886
897
  ];
887
- lines.splice(2, 0, ...[
888
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
889
- `storage_root: ${config.root}`,
890
- ...(config.github
891
- ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
892
- : []),
893
- ]);
898
+ lines.splice(2, 0, ...storageContextLines());
894
899
  if (summary.nextRecommendedTarget) {
895
900
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
896
901
  }
@@ -899,7 +904,7 @@ async function main() {
899
904
  appendStructureScore(lines, result.structureScore);
900
905
  appendMemoryContract(lines, result.memoryContract);
901
906
  appendBoundaryWarnings(lines, result.boundaryWarnings);
902
- if (result.operation === "created") {
907
+ if (result.operation === "created" && result.memoryContract.status === "fail") {
903
908
  appendTemplateHints(lines, {
904
909
  primary: "stock",
905
910
  alternatives: ["index"],
@@ -945,13 +950,7 @@ async function main() {
945
950
  `project_link_health_after: ${result.projectLinkHealthAfter.resolved}/${result.projectLinkHealthAfter.total}`,
946
951
  `project_unresolved_delta: ${projectUnresolvedDelta}`,
947
952
  ];
948
- lines.splice(2, 0, ...[
949
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
950
- `storage_root: ${config.root}`,
951
- ...(config.github
952
- ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
953
- : []),
954
- ]);
953
+ lines.splice(2, 0, ...storageContextLines());
955
954
  if (summary.nextRecommendedTarget) {
956
955
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
957
956
  }
@@ -1007,18 +1006,11 @@ async function main() {
1007
1006
  `files_updated: ${result.updatedFiles}`,
1008
1007
  `renamed_note_link_health: ${result.renamedNoteLinkHealth.resolved}/${result.renamedNoteLinkHealth.total}`,
1009
1008
  `backlinks: ${result.backlinkCount}`,
1010
- `orphan_warning: ${result.orphanWarning ? "yes" : "no"}`,
1011
1009
  `project_link_health_before: ${result.projectLinkHealthBefore.resolved}/${result.projectLinkHealthBefore.total}`,
1012
1010
  `project_link_health_after: ${result.projectLinkHealthAfter.resolved}/${result.projectLinkHealthAfter.total}`,
1013
1011
  `project_unresolved_delta: ${projectUnresolvedDelta}`,
1014
1012
  ];
1015
- lines.splice(2, 0, ...[
1016
- `storage_backend: ${config.github ? "github" : "filesystem"}`,
1017
- `storage_root: ${config.root}`,
1018
- ...(config.github
1019
- ? [`storage_repo: ${config.github.owner}/${config.github.repo}`, `storage_branch: ${config.github.branch}`]
1020
- : []),
1021
- ]);
1013
+ lines.splice(2, 0, ...storageContextLines());
1022
1014
  if (summary.nextRecommendedTarget) {
1023
1015
  insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
1024
1016
  }
@@ -354,7 +354,7 @@ export class GitHubStorage {
354
354
  }
355
355
  async pullLocal(context) {
356
356
  try {
357
- await this.execFileAsyncFn("git", ["pull", "--ff-only"], {
357
+ await this.execFileAsyncFn("git", ["pull", "--ff-only", "origin", this.branch], {
358
358
  cwd: this.rootPath,
359
359
  timeout: 30_000,
360
360
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomingtoming/kioq",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Japanese-first local markdown MCP server",
5
5
  "type": "module",
6
6
  "bin": {