@ksm0709/context 0.0.2 → 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +16 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1073,26 +1073,33 @@ ${lines}` }];
1073
1073
  }
1074
1074
  },
1075
1075
  "experimental.chat.system.transform": async (_input, output) => {
1076
- const turnStartPath = join4(directory, config.prompts.turnStart ?? join4(DEFAULTS.promptDir, DEFAULTS.turnStartFile));
1077
- const turnStart = readPromptFile(turnStartPath);
1078
1076
  const knowledgeSources = [config.knowledge.dir, ...config.knowledge.sources].filter((s) => Boolean(s));
1079
1077
  const entries = buildKnowledgeIndex(directory, knowledgeSources);
1080
1078
  const indexContent = formatKnowledgeIndex(entries);
1081
- if (turnStart)
1082
- output.system.push(turnStart);
1083
1079
  if (indexContent)
1084
1080
  output.system.push(indexContent);
1085
1081
  },
1086
1082
  "experimental.chat.messages.transform": async (_input, output) => {
1087
- const turnEndPath = join4(directory, config.prompts.turnEnd ?? join4(DEFAULTS.promptDir, DEFAULTS.turnEndFile));
1088
- const turnEnd = readPromptFile(turnEndPath);
1089
- if (!turnEnd)
1090
- return;
1091
1083
  if (output.messages.length === 0)
1092
1084
  return;
1093
1085
  const lastUserMsg = output.messages.filter((m) => m.info.role === "user").at(-1);
1094
1086
  if (!lastUserMsg)
1095
1087
  return;
1088
+ const turnStartPath = join4(directory, config.prompts.turnStart ?? join4(DEFAULTS.promptDir, DEFAULTS.turnStartFile));
1089
+ const turnStart = readPromptFile(turnStartPath);
1090
+ if (turnStart) {
1091
+ lastUserMsg.parts.push({
1092
+ id: `context-turn-start-${Date.now()}`,
1093
+ sessionID: lastUserMsg.info.sessionID,
1094
+ messageID: lastUserMsg.info.id,
1095
+ type: "text",
1096
+ text: turnStart
1097
+ });
1098
+ }
1099
+ const turnEndPath = join4(directory, config.prompts.turnEnd ?? join4(DEFAULTS.promptDir, DEFAULTS.turnEndFile));
1100
+ const turnEnd = readPromptFile(turnEndPath);
1101
+ if (!turnEnd)
1102
+ return;
1096
1103
  const msgId = `context-turn-end-${Date.now()}`;
1097
1104
  output.messages.push({
1098
1105
  info: {
@@ -1111,8 +1118,7 @@ ${lines}` }];
1111
1118
  type: "text",
1112
1119
  text: `<system-reminder>
1113
1120
  ${turnEnd}
1114
- </system-reminder>`,
1115
- synthetic: true
1121
+ </system-reminder>`
1116
1122
  }
1117
1123
  ]
1118
1124
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ksm0709/context",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Intent tools for Bun",
5
5
  "author": {
6
6
  "name": "TaehoKang",