@hasna/hooks 0.3.3 → 0.3.5

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/bin/index.js CHANGED
@@ -2089,7 +2089,7 @@ var init_registry = __esm(() => {
2089
2089
  name: "knowledge-context",
2090
2090
  displayName: "Knowledge Context",
2091
2091
  description: "Injects deterministic Knowledge context packs into Codewith SessionStart, UserPromptSubmit, and SubagentStart",
2092
- version: "0.1.2",
2092
+ version: "0.1.4",
2093
2093
  category: "Context Management",
2094
2094
  event: "SessionStart",
2095
2095
  events: ["SessionStart", "UserPromptSubmit", "SubagentStart"],
package/dist/index.js CHANGED
@@ -1010,7 +1010,7 @@ var HOOKS = [
1010
1010
  name: "knowledge-context",
1011
1011
  displayName: "Knowledge Context",
1012
1012
  description: "Injects deterministic Knowledge context packs into Codewith SessionStart, UserPromptSubmit, and SubagentStart",
1013
- version: "0.1.2",
1013
+ version: "0.1.4",
1014
1014
  category: "Context Management",
1015
1015
  event: "SessionStart",
1016
1016
  events: ["SessionStart", "UserPromptSubmit", "SubagentStart"],
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/hook-knowledge-context",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Codewith hook that injects deterministic Knowledge context packs into lifecycle events",
5
5
  "type": "module",
6
6
  "main": "./dist/hook.js",
@@ -16,7 +16,7 @@
16
16
  "README.md"
17
17
  ],
18
18
  "scripts": {
19
- "build": "rm -rf dist && bun build ./src/hook.ts --outdir ./dist --target node && tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap false --noEmit false",
19
+ "build": "rm -rf dist && bun build ./src/hook.ts --outdir ./dist --target bun && tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap false --noEmit false",
20
20
  "prepublishOnly": "bun run build",
21
21
  "typecheck": "tsc --noEmit"
22
22
  },
@@ -14,7 +14,7 @@ import {
14
14
  const baseConfig: KnowledgeContextConfig = {
15
15
  command: "knowledge",
16
16
  timeoutMs: 5000,
17
- maxItems: 6,
17
+ maxItems: 3,
18
18
  maxTokens: 1200,
19
19
  maxQueryChars: 1200,
20
20
  maxOutputChars: 8000,
@@ -23,6 +23,7 @@ const baseConfig: KnowledgeContextConfig = {
23
23
  describe("hook-knowledge-context", () => {
24
24
  test("defaults Knowledge CLI timeout to 5000ms and keeps env override", () => {
25
25
  expect(getConfig({}).timeoutMs).toBe(5000);
26
+ expect(getConfig({}).maxItems).toBe(3);
26
27
  expect(getConfig({ HOOKS_KNOWLEDGE_TIMEOUT_MS: "2345" }).timeoutMs).toBe(2345);
27
28
  });
28
29
 
@@ -36,7 +37,7 @@ describe("hook-knowledge-context", () => {
36
37
  "--from",
37
38
  "search",
38
39
  "--max-items",
39
- "6",
40
+ "3",
40
41
  "--max-tokens",
41
42
  "1200",
42
43
  "--json",
@@ -171,7 +172,7 @@ describe("hook-knowledge-context", () => {
171
172
  expect(extractContextText([{ title: "One", text: "Body", uri: "knowledge://item/one" }])).toContain("Body");
172
173
  });
173
174
 
174
- test("formats citation previews as useful progressive blurbs with read commands", () => {
175
+ test("formats citation previews as useful progressive blurbs with compact open commands", () => {
175
176
  const text = extractContextText({
176
177
  citations: [
177
178
  {
@@ -182,9 +183,10 @@ describe("hook-knowledge-context", () => {
182
183
  ],
183
184
  });
184
185
 
185
- expect(text).toContain("Knowledge item k_example");
186
+ expect(text).toContain("- k_example (cite_123): A short preview");
186
187
  expect(text).toContain("cite_123");
187
188
  expect(text).toContain("A short preview");
188
- expect(text).toContain("read: knowledge get --id k_example --json");
189
+ expect(text).toContain("open: knowledge get --id k_example --json");
190
+ expect(text).not.toContain("source: knowledge://item/k_example");
189
191
  });
190
192
  });
@@ -56,7 +56,7 @@ export type KnowledgeExecutor = (
56
56
  ) => Promise<KnowledgeExecResult>;
57
57
 
58
58
  const DEFAULT_TIMEOUT_MS = 5000;
59
- const DEFAULT_MAX_ITEMS = 6;
59
+ const DEFAULT_MAX_ITEMS = 3;
60
60
  const DEFAULT_MAX_TOKENS = 1200;
61
61
  const DEFAULT_MAX_QUERY_CHARS = 1200;
62
62
  const DEFAULT_MAX_OUTPUT_CHARS = 8000;
@@ -278,7 +278,9 @@ function formatPackItems(items: unknown[]): string | null {
278
278
  const itemId = knowledgeItemId(source);
279
279
  const title =
280
280
  firstString(obj, ["title", "name"]) ||
281
- (itemId ? `Knowledge item ${itemId}` : citationId || `item ${index + 1}`);
281
+ itemId ||
282
+ citationId ||
283
+ `item ${index + 1}`;
282
284
  const body = firstString(obj, [
283
285
  "summary",
284
286
  "text",
@@ -295,12 +297,12 @@ function formatPackItems(items: unknown[]): string | null {
295
297
 
296
298
  const suffixParts = [
297
299
  citationId && citationId !== title ? citationId : null,
298
- source ? `source: ${truncate(source, 180)}` : null,
300
+ source && !itemId ? `source: ${truncate(source, 180)}` : null,
299
301
  ].filter(Boolean);
300
302
  const suffix = suffixParts.length > 0 ? ` (${suffixParts.join("; ")})` : "";
301
303
  lines.push(`- ${truncate(title, 160)}${suffix}${body ? `: ${truncate(compactText(body), 520)}` : ""}`);
302
304
  if (itemId) {
303
- lines.push(` read: knowledge get --id ${itemId} --json`);
305
+ lines.push(` open: knowledge get --id ${itemId} --json`);
304
306
  }
305
307
  }
306
308
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/hooks",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Open source hooks library for AI coding agents - Install safety, quality, and automation hooks with a single command",
5
5
  "type": "module",
6
6
  "bin": {