@hasna/hook-knowledge-context 0.1.2 → 0.1.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/README.md CHANGED
@@ -43,7 +43,7 @@ bad stdin, or empty packs return `{"continue":true}` without context.
43
43
  export HOOKS_KNOWLEDGE_CONTEXT_DISABLE=1 # Kill switch
44
44
  export HOOKS_KNOWLEDGE_COMMAND=knowledge # CLI command/path
45
45
  export HOOKS_KNOWLEDGE_TIMEOUT_MS=5000 # Per-call timeout
46
- export HOOKS_KNOWLEDGE_MAX_ITEMS=6 # Context pack item budget
46
+ export HOOKS_KNOWLEDGE_MAX_ITEMS=3 # Context pack item budget
47
47
  export HOOKS_KNOWLEDGE_MAX_TOKENS=1200 # Context pack token budget
48
48
  export HOOKS_KNOWLEDGE_MAX_QUERY_CHARS=1200 # Redacted query bound
49
49
  export HOOKS_KNOWLEDGE_MAX_OUTPUT_CHARS=8000
package/dist/hook.js CHANGED
@@ -5,7 +5,7 @@
5
5
  import { readFileSync } from "fs";
6
6
  import { spawn } from "child_process";
7
7
  var DEFAULT_TIMEOUT_MS = 5000;
8
- var DEFAULT_MAX_ITEMS = 6;
8
+ var DEFAULT_MAX_ITEMS = 3;
9
9
  var DEFAULT_MAX_TOKENS = 1200;
10
10
  var DEFAULT_MAX_QUERY_CHARS = 1200;
11
11
  var DEFAULT_MAX_OUTPUT_CHARS = 8000;
@@ -193,7 +193,7 @@ function formatPackItems(items) {
193
193
  const citationId = firstString(obj, ["id", "citation_id", "citationId"]);
194
194
  const source = firstSourceString(obj);
195
195
  const itemId = knowledgeItemId(source);
196
- const title = firstString(obj, ["title", "name"]) || (itemId ? `Knowledge item ${itemId}` : citationId || `item ${index + 1}`);
196
+ const title = firstString(obj, ["title", "name"]) || itemId || citationId || `item ${index + 1}`;
197
197
  const body = firstString(obj, [
198
198
  "summary",
199
199
  "text",
@@ -210,12 +210,12 @@ function formatPackItems(items) {
210
210
  continue;
211
211
  const suffixParts = [
212
212
  citationId && citationId !== title ? citationId : null,
213
- source ? `source: ${truncate(source, 180)}` : null
213
+ source && !itemId ? `source: ${truncate(source, 180)}` : null
214
214
  ].filter(Boolean);
215
215
  const suffix = suffixParts.length > 0 ? ` (${suffixParts.join("; ")})` : "";
216
216
  lines.push(`- ${truncate(title, 160)}${suffix}${body ? `: ${truncate(compactText(body), 520)}` : ""}`);
217
217
  if (itemId) {
218
- lines.push(` read: knowledge get --id ${itemId} --json`);
218
+ lines.push(` open: knowledge get --id ${itemId} --json`);
219
219
  }
220
220
  }
221
221
  return lines.length > 0 ? lines.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/hook-knowledge-context",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Codewith hook that injects deterministic Knowledge context packs into lifecycle events",
5
5
  "type": "module",
6
6
  "main": "./dist/hook.js",