@tomingtoming/kioq 0.9.1 → 0.9.3

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
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
4
  import { z } from "zod";
@@ -114,8 +115,8 @@ function appendBoundaryWarnings(lines, warnings) {
114
115
  lines.push(` suggestion: ${warning.suggestion}`);
115
116
  });
116
117
  }
117
- function appendScopeLabel(lines, scopeLabel) {
118
- lines.push(`scope_label: ${scopeLabel}`);
118
+ function appendScopeLabel(_lines, _scopeLabel) {
119
+ // Removed: scope_label duplicates tool name, adds no value for AI
119
120
  }
120
121
  function appendResponsibilityWarning(lines, warnings) {
121
122
  const code = responsibilityWarningCode(warnings);
@@ -292,10 +293,12 @@ async function main() {
292
293
  const signalLog = new SignalLog(storage);
293
294
  const engagementIndex = new EngagementIndex();
294
295
  let storageContextEmitted = false;
296
+ const projectName = path.basename(config.root);
295
297
  const appendStorageContext = (lines) => {
296
298
  if (storageContextEmitted)
297
299
  return;
298
300
  storageContextEmitted = true;
301
+ lines.push(`project: ${projectName}`);
299
302
  lines.push(`storage_backend: ${config.github ? "github" : "filesystem"}`);
300
303
  lines.push(`storage_root: ${config.root}`);
301
304
  if (config.github) {
@@ -309,6 +312,7 @@ async function main() {
309
312
  return [];
310
313
  storageContextEmitted = true;
311
314
  return [
315
+ `project: ${projectName}`,
312
316
  `storage_backend: ${config.github ? "github" : "filesystem"}`,
313
317
  `storage_root: ${config.root}`,
314
318
  ...(config.github
@@ -340,26 +344,24 @@ async function main() {
340
344
  server.tool("orient", "kioqを通じて思考を構造化するツール。チェインバー型パイロット支援システムとして、応答を組み立てる前に現在の思考を渡すことで、3つのスロットを返します: (1) relevant — 思考に直接関連するノート(engagement重み付け)、(2) active_context — 進行中のflowと最近のアクティブなノート、(3) discovery — 未接触だが接点がありそうなノート(セレンディピティ)。各ノートのengagement(接触回数、人間の反応、AI被参照数、origin)が付与されます。observationで人間の反応を記録でき、それがengagementに蓄積されます。対話の各ターンで呼び出すことを推奨します。", {
341
345
  thought: z.string().min(1).describe("今何を考えているか、何について応答しようとしているか"),
342
346
  references: z.array(z.string()).optional().describe("明示的に関連するノートの identifier(あれば)"),
343
- observation: z.object({
347
+ observations: z.array(z.object({
344
348
  note: z.string().min(1).describe("観察対象のノート identifier"),
345
349
  signal: z.enum(["cited", "discussed", "applied", "questioned", "dismissed"]).describe("人間の反応の種類"),
346
- }).optional().describe("直前の対話で人間がノートの概念に反応した場合に記録"),
347
- }, async ({ thought, references, observation }) => {
350
+ })).optional().describe("直前の対話で人間がノートの概念に反応した場合に記録(複数可)"),
351
+ }, async ({ thought, references, observations }) => {
348
352
  const signals = await signalLog.load();
349
353
  const notes = await store.loadAllNotes();
350
354
  engagementIndex.build(signals, notes);
351
355
  const result = await store.orient({
352
356
  thought,
353
357
  references,
354
- observation,
358
+ observations,
355
359
  engagementIndex,
356
360
  signalLog,
357
361
  });
358
362
  await signalLog.flush();
359
363
  const lines = [];
360
- lines.push(`project: ${result.project}`);
361
364
  appendStorageContext(lines);
362
- lines.push(`scope_label: orient`);
363
365
  lines.push(`thought: ${thought.slice(0, 200)}`);
364
366
  lines.push("");
365
367
  if (result.relevant.length > 0) {
@@ -426,13 +428,10 @@ async function main() {
426
428
  });
427
429
  const lines = [];
428
430
  lines.push(`検索クエリ: ${query}`);
429
- lines.push(`対象プロジェクト: ${result.project}`);
430
431
  appendStorageContext(lines);
431
- appendScopeLabel(lines, TOOL_SCOPE_LABELS.search_notes);
432
- lines.push(`response_mode: ${responseMode}`);
433
- appendReadResponseSummary(lines, summary);
434
432
  lines.push(`ヒット件数: ${result.results.length}`);
435
- lines.push(`exact_identifier_matches: ${result.exactIdentifierMatchCount}`);
433
+ if (result.exactIdentifierMatchCount > 0)
434
+ lines.push(`exact_identifier_matches: ${result.exactIdentifierMatchCount}`);
436
435
  lines.push("");
437
436
  if (result.results.length === 0) {
438
437
  lines.push("候補が見つかりませんでした。");
@@ -489,19 +488,10 @@ async function main() {
489
488
  });
490
489
  const lines = [
491
490
  `identifier: ${identifier}`,
492
- `project: ${result.project}`,
493
491
  ...storageContextLines(),
494
- `scope_label: ${TOOL_SCOPE_LABELS.read_note}`,
495
- `response_mode: ${responseMode}`,
496
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
497
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
498
- `next_recommended_action: ${summary.nextRecommendedAction}`,
499
492
  `file: ${result.note.relativePath}`,
500
493
  `permalink: ${result.note.permalink}`,
501
494
  ];
502
- if (summary.nextRecommendedTarget) {
503
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
504
- }
505
495
  appendChangeTriggerSummary(lines, changeTrigger);
506
496
  appendResponsibilityWarning(lines, result.boundaryWarnings);
507
497
  appendBoundaryWarnings(lines, result.boundaryWarnings);
@@ -604,10 +594,7 @@ async function main() {
604
594
  titleBodyMismatchCandidateCount: summaryBase.titleBodyMismatchCandidateCount,
605
595
  });
606
596
  const lines = [];
607
- lines.push(`project: ${result.project}`);
608
597
  appendStorageContext(lines);
609
- appendScopeLabel(lines, TOOL_SCOPE_LABELS.lint_structure);
610
- lines.push(`response_mode: ${responseMode}`);
611
598
  appendAuditResponseSummary(lines, summary);
612
599
  appendChangeTriggerSummary(lines, changeTrigger);
613
600
  lines.push(`notes: ${result.noteCount}`);
@@ -723,11 +710,6 @@ async function main() {
723
710
  });
724
711
  const flowLines = [
725
712
  "flow ノートを作成/更新しました。",
726
- `project: ${flowResult.project}`,
727
- `scope_label: ${TOOL_SCOPE_LABELS.write_flow_note}`,
728
- `primary_navigation_signal: ${flowSummary.primaryNavigationSignal}`,
729
- `primary_quality_signal: ${flowSummary.primaryQualitySignal}`,
730
- `next_recommended_action: ${flowSummary.nextRecommendedAction}`,
731
713
  `operation: ${flowResult.operation}`,
732
714
  `file: ${flowResult.relativePath}`,
733
715
  `permalink: ${flowResult.permalink}`,
@@ -740,10 +722,6 @@ async function main() {
740
722
  ];
741
723
  if (flowResult.orphanWarning)
742
724
  flowLines.push(`orphan_warning: yes`);
743
- flowLines.splice(2, 0, ...storageContextLines());
744
- if (flowSummary.nextRecommendedTarget) {
745
- insertBeforeLine(flowLines, "next_recommended_action:", `next_recommended_target: ${flowSummary.nextRecommendedTarget}`);
746
- }
747
725
  appendConflictSummary(flowLines, summarizeNoConflict({ serverUpdated: flowResult.serverUpdated }));
748
726
  appendResponsibilityWarning(flowLines, flowResult.boundaryWarnings);
749
727
  appendStructureScore(flowLines, flowResult.structureScore);
@@ -775,11 +753,6 @@ async function main() {
775
753
  });
776
754
  const lines = [
777
755
  "ノートを作成/更新しました。",
778
- `project: ${result.project}`,
779
- `scope_label: ${TOOL_SCOPE_LABELS.write_note}`,
780
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
781
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
782
- `next_recommended_action: ${summary.nextRecommendedAction}`,
783
756
  `operation: ${result.operation}`,
784
757
  `file: ${result.relativePath}`,
785
758
  `permalink: ${result.permalink}`,
@@ -787,10 +760,6 @@ async function main() {
787
760
  `link_health: ${result.linkHealth.resolved}/${result.linkHealth.total} resolved`,
788
761
  `backlinks: ${result.backlinkCount}`,
789
762
  ];
790
- lines.splice(2, 0, ...storageContextLines());
791
- if (summary.nextRecommendedTarget) {
792
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
793
- }
794
763
  appendConflictSummary(lines, summarizeNoConflict({ serverUpdated: result.serverUpdated }));
795
764
  appendResponsibilityWarning(lines, result.boundaryWarnings);
796
765
  appendStructureScore(lines, result.structureScore);
@@ -830,11 +799,6 @@ async function main() {
830
799
  });
831
800
  const lines = [
832
801
  "flow を stock に昇格しました。",
833
- `project: ${result.project}`,
834
- `scope_label: ${TOOL_SCOPE_LABELS.promote_to_stock}`,
835
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
836
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
837
- `next_recommended_action: ${summary.nextRecommendedAction}`,
838
802
  `source_flow: ${result.sourceFlow.title}`,
839
803
  `source_file: ${result.sourceFlow.relativePath}`,
840
804
  `source_permalink: ${result.sourceFlow.permalink}`,
@@ -843,10 +807,6 @@ async function main() {
843
807
  `stock_permalink: ${result.stock.permalink}`,
844
808
  `flow_state: ${result.flowState}`,
845
809
  ];
846
- lines.splice(2, 0, ...storageContextLines());
847
- if (summary.nextRecommendedTarget) {
848
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
849
- }
850
810
  appendTemplateHints(lines, {
851
811
  primary: "stock",
852
812
  alternatives: ["index"],
@@ -883,11 +843,6 @@ async function main() {
883
843
  });
884
844
  const lines = [
885
845
  "ノートを処理しました。",
886
- `project: ${result.project}`,
887
- `scope_label: ${TOOL_SCOPE_LABELS.append_note}`,
888
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
889
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
890
- `next_recommended_action: ${summary.nextRecommendedAction}`,
891
846
  `operation: ${result.operation}`,
892
847
  `file: ${result.relativePath}`,
893
848
  `permalink: ${result.permalink}`,
@@ -895,10 +850,6 @@ async function main() {
895
850
  `link_health: ${result.linkHealth.resolved}/${result.linkHealth.total} resolved`,
896
851
  `backlinks: ${result.backlinkCount}`,
897
852
  ];
898
- lines.splice(2, 0, ...storageContextLines());
899
- if (summary.nextRecommendedTarget) {
900
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
901
- }
902
853
  appendConflictSummary(lines, summarizeNoConflict({ serverUpdated: result.serverUpdated }));
903
854
  appendResponsibilityWarning(lines, result.boundaryWarnings);
904
855
  appendStructureScore(lines, result.structureScore);
@@ -937,11 +888,6 @@ async function main() {
937
888
  });
938
889
  const lines = [
939
890
  "ノートを削除しました。",
940
- `project: ${result.project}`,
941
- `scope_label: ${TOOL_SCOPE_LABELS.delete_note}`,
942
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
943
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
944
- `next_recommended_action: ${summary.nextRecommendedAction}`,
945
891
  `deleted: ${result.title} (${result.relativePath})`,
946
892
  `permalink: ${result.permalink}`,
947
893
  `backlinks_to_deleted: ${result.backlinksToDeleted}`,
@@ -950,10 +896,6 @@ async function main() {
950
896
  `project_link_health_after: ${result.projectLinkHealthAfter.resolved}/${result.projectLinkHealthAfter.total}`,
951
897
  `project_unresolved_delta: ${projectUnresolvedDelta}`,
952
898
  ];
953
- lines.splice(2, 0, ...storageContextLines());
954
- if (summary.nextRecommendedTarget) {
955
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
956
- }
957
899
  appendConflictSummary(lines, summarizeNoConflict({ serverUpdated: result.serverUpdated }));
958
900
  appendOperationImpact(lines, impact);
959
901
  appendStructureScore(lines, result.structureScoreBeforeDelete);
@@ -995,11 +937,6 @@ async function main() {
995
937
  });
996
938
  const lines = [
997
939
  "ノートをリネームしました。",
998
- `project: ${result.project}`,
999
- `scope_label: ${TOOL_SCOPE_LABELS.rename_note}`,
1000
- `primary_navigation_signal: ${summary.primaryNavigationSignal}`,
1001
- `primary_quality_signal: ${summary.primaryQualitySignal}`,
1002
- `next_recommended_action: ${summary.nextRecommendedAction}`,
1003
940
  `old: ${result.oldTitle} (${result.oldRelativePath})`,
1004
941
  `new: ${result.newTitle} (${result.newRelativePath})`,
1005
942
  `links_updated: ${result.updatedLinks}`,
@@ -1010,10 +947,6 @@ async function main() {
1010
947
  `project_link_health_after: ${result.projectLinkHealthAfter.resolved}/${result.projectLinkHealthAfter.total}`,
1011
948
  `project_unresolved_delta: ${projectUnresolvedDelta}`,
1012
949
  ];
1013
- lines.splice(2, 0, ...storageContextLines());
1014
- if (summary.nextRecommendedTarget) {
1015
- insertBeforeLine(lines, "next_recommended_action:", `next_recommended_target: ${summary.nextRecommendedTarget}`);
1016
- }
1017
950
  appendConflictSummary(lines, summarizeNoConflict({ serverUpdated: result.serverUpdated }));
1018
951
  appendOperationImpact(lines, impact);
1019
952
  appendStructureScore(lines, result.structureScore);
@@ -2821,14 +2821,16 @@ export class LocalNoteStore {
2821
2821
  const notes = await this.loadProjectNotes();
2822
2822
  const lookup = this.buildLookup(notes);
2823
2823
  const thought = args.thought.trim();
2824
- // Record observation signal if present
2825
- if (args.observation && args.signalLog) {
2826
- const signalType = `human_${args.observation.signal}`;
2827
- const resolved = this.resolveWikiTarget(args.observation.note, lookup);
2828
- const noteId = resolved.status === "resolved" && resolved.note
2829
- ? resolved.note.permalink
2830
- : args.observation.note;
2831
- args.signalLog.record(signalType, noteId, thought.slice(0, 120));
2824
+ // Record observation signals if present
2825
+ if (args.observations && args.signalLog) {
2826
+ for (const obs of args.observations) {
2827
+ const signalType = `human_${obs.signal}`;
2828
+ const resolved = this.resolveWikiTarget(obs.note, lookup);
2829
+ const noteId = resolved.status === "resolved" && resolved.note
2830
+ ? resolved.note.permalink
2831
+ : obs.note;
2832
+ args.signalLog.record(signalType, noteId, thought.slice(0, 120));
2833
+ }
2832
2834
  }
2833
2835
  // Record orient references as signals
2834
2836
  if (args.references && args.signalLog) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomingtoming/kioq",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Japanese-first local markdown MCP server",
5
5
  "type": "module",
6
6
  "bin": {