@hanhnd/agent-kit 1.0.32 → 1.0.33

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 (107) hide show
  1. package/dist/cli/commands/cli-digest-pending.test.js +111 -0
  2. package/dist/cli/commands/cli-memory.test.js +34 -0
  3. package/dist/cli/{memory.js → commands/memory.js} +24 -11
  4. package/dist/cli/index.js +2 -2
  5. package/dist/{utils → cli/utils}/args.d.ts +2 -1
  6. package/dist/{kit-cli.js → cli.js} +342 -58
  7. package/dist/{tools/config.d.ts → core/config/index.d.ts} +2 -7
  8. package/dist/{tools/config.js → core/config/index.js} +2 -13
  9. package/dist/core/handoffs/index.d.ts +16 -0
  10. package/dist/{tools/handoffs.js → core/handoffs/index.js} +3 -3
  11. package/dist/{tools/security.d.ts → core/security/index.d.ts} +0 -19
  12. package/dist/{tools/security.js → core/security/index.js} +3 -76
  13. package/dist/entrypoints/cli.js +11 -0
  14. package/dist/entrypoints/server.js +37 -0
  15. package/dist/{tools → mcp}/agent.js +1 -1
  16. package/dist/{tools → mcp}/core.d.ts +1 -1
  17. package/dist/{tools → mcp}/core.js +2 -2
  18. package/dist/{tools → mcp}/integration.js +3 -3
  19. package/dist/mcp/memory.d.ts +15 -0
  20. package/dist/{tools → mcp}/memory.js +15 -13
  21. package/dist/{kit-server.js → server.js} +80 -70
  22. package/dist/services/digest/background.d.ts +11 -0
  23. package/dist/services/digest/background.js +258 -0
  24. package/dist/{memory → services}/digest/constants.d.ts +4 -1
  25. package/dist/{memory → services}/digest/constants.js +6 -2
  26. package/dist/services/digest/digest-background.test.js +206 -0
  27. package/dist/{tools/__tests__ → services/digest}/digest-init.test.js +4 -3
  28. package/dist/{memory/__tests__ → services/digest}/digest-llama-local.test.js +1 -13
  29. package/dist/{memory/__tests__ → services/digest}/digest-pending.test.js +39 -11
  30. package/dist/{memory/__tests__ → services/digest}/digest-processor.test.js +5 -7
  31. package/dist/{memory → services}/digest/files.d.ts +0 -1
  32. package/dist/{memory → services}/digest/files.js +2 -2
  33. package/dist/services/digest/model-registry.d.ts +2 -0
  34. package/dist/{memory → services}/digest/model-registry.js +9 -8
  35. package/dist/services/digest/processor.d.ts +13 -0
  36. package/dist/{memory → services}/digest/processor.js +48 -31
  37. package/dist/services/digest/providers/llama-local.d.ts +2 -0
  38. package/dist/{memory → services}/digest/providers/llama-local.js +3 -4
  39. package/dist/{memory → services}/digest/types.d.ts +34 -2
  40. package/dist/services/digest/types.js +6 -0
  41. package/dist/{memory → services}/digest/worker.d.ts +0 -1
  42. package/dist/{memory → services}/digest/worker.js +2 -2
  43. package/dist/{utils → services/integration}/credentials.js +1 -1
  44. package/dist/{utils/parser.js → services/integration/parser/adf.js} +1 -0
  45. package/dist/{memory → services/memory}/chunker.d.ts +0 -2
  46. package/dist/{memory → services/memory}/chunker.js +3 -3
  47. package/dist/{memory/__tests__ → services/memory}/chunker.test.js +1 -34
  48. package/dist/{memory → services/memory}/constants.d.ts +1 -1
  49. package/dist/{memory → services/memory}/constants.js +2 -1
  50. package/dist/{memory → services/memory}/embedder.d.ts +2 -2
  51. package/dist/{memory → services/memory}/embedder.js +5 -5
  52. package/dist/services/memory/embedder.test.js +13 -0
  53. package/dist/{memory → services/memory}/indexer.d.ts +2 -1
  54. package/dist/{memory → services/memory}/indexer.js +1 -1
  55. package/dist/{memory/__tests__ → services/memory}/indexer.test.js +4 -3
  56. package/dist/{tools/__tests__ → services/memory}/memory.test.js +54 -13
  57. package/dist/{memory/__tests__ → services/memory}/store.test.js +3 -2
  58. package/dist/{memory → services/memory}/types.d.ts +7 -2
  59. package/dist/services/memory/types.js +6 -0
  60. package/dist/utils/files.d.ts +0 -1
  61. package/dist/utils/files.js +1 -1
  62. package/dist/{memory/__tests__/lockfile.test.js → utils/files.test.js} +14 -14
  63. package/dist/utils/index.d.ts +6 -0
  64. package/dist/utils/index.js +6 -0
  65. package/dist/utils/json.d.ts +0 -1
  66. package/dist/utils/json.js +0 -10
  67. package/dist/utils/paths.d.ts +0 -1
  68. package/dist/utils/paths.js +1 -1
  69. package/package.json +6 -6
  70. package/dist/memory/__tests__/digest-worker.test.js +0 -46
  71. package/dist/memory/__tests__/embedder.test.js +0 -14
  72. package/dist/memory/digest/model-registry.d.ts +0 -6
  73. package/dist/memory/digest/processor.d.ts +0 -7
  74. package/dist/memory/digest/providers/llama-local.d.ts +0 -7
  75. package/dist/memory/digest/types.js +0 -1
  76. package/dist/memory/types.js +0 -1
  77. package/dist/tools/__tests__/cli-digest-pending.test.js +0 -51
  78. package/dist/tools/__tests__/cli-memory.test.js +0 -22
  79. package/dist/tools/handoffs.d.ts +0 -22
  80. package/dist/tools/memory.d.ts +0 -16
  81. /package/dist/{tools/__tests__ → cli/commands}/cli-digest-pending.test.d.ts +0 -0
  82. /package/dist/{tools/__tests__ → cli/commands}/cli-memory.test.d.ts +0 -0
  83. /package/dist/cli/{memory.d.ts → commands/memory.d.ts} +0 -0
  84. /package/dist/{utils → cli/utils}/args.js +0 -0
  85. /package/dist/{kit-cli.d.ts → entrypoints/cli.d.ts} +0 -0
  86. /package/dist/{kit-server.d.ts → entrypoints/server.d.ts} +0 -0
  87. /package/dist/{tools → mcp}/agent.d.ts +0 -0
  88. /package/dist/{tools → mcp}/integration.d.ts +0 -0
  89. /package/dist/{memory/__tests__/chunker.test.d.ts → services/digest/digest-background.test.d.ts} +0 -0
  90. /package/dist/{tools/__tests__ → services/digest}/digest-init.test.d.ts +0 -0
  91. /package/dist/{memory/__tests__ → services/digest}/digest-llama-local.test.d.ts +0 -0
  92. /package/dist/{memory/__tests__ → services/digest}/digest-pending.test.d.ts +0 -0
  93. /package/dist/{memory/__tests__ → services/digest}/digest-processor.test.d.ts +0 -0
  94. /package/dist/{utils → services/integration}/credentials.d.ts +0 -0
  95. /package/dist/{utils/parser.d.ts → services/integration/parser/adf.d.ts} +0 -0
  96. /package/dist/{memory/__tests__/digest-worker.test.d.ts → services/memory/chunker.test.d.ts} +0 -0
  97. /package/dist/{memory/__tests__ → services/memory}/embedder.test.d.ts +0 -0
  98. /package/dist/{memory → services/memory}/index.d.ts +0 -0
  99. /package/dist/{memory → services/memory}/index.js +0 -0
  100. /package/dist/{memory/__tests__ → services/memory}/indexer.test.d.ts +0 -0
  101. /package/dist/{tools/__tests__ → services/memory}/memory.test.d.ts +0 -0
  102. /package/dist/{memory → services/memory}/store.d.ts +0 -0
  103. /package/dist/{memory → services/memory}/store.js +0 -0
  104. /package/dist/{memory/__tests__ → services/memory}/store.test.d.ts +0 -0
  105. /package/dist/{memory/__tests__/lockfile.test.d.ts → utils/files.test.d.ts} +0 -0
  106. /package/dist/{__tests__/temp-dir.d.ts → utils/temp-dir.test.d.ts} +0 -0
  107. /package/dist/{__tests__/temp-dir.js → utils/temp-dir.test.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import * as os from 'os';
2
2
  import * as path from 'path';
3
- export const AGENT_KIT_HOME = path.join(os.homedir(), '.agent-kit');
3
+ const AGENT_KIT_HOME = path.join(os.homedir(), '.agent-kit');
4
4
  export const CREDENTIALS_FILE = path.join(AGENT_KIT_HOME, 'credentials');
5
5
  export const MODEL_CACHE_DIR = path.join(AGENT_KIT_HOME, 'cache', 'models');
6
6
  export const FASTEMBED_CACHE_DIR = path.join(MODEL_CACHE_DIR, 'fastembed');
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@hanhnd/agent-kit",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Agent Kit MCP server for software development agent workflows",
5
5
  "type": "module",
6
- "main": "dist/kit-server.js",
6
+ "main": "dist/server.js",
7
7
  "bin": {
8
- "agent-kit": "dist/kit-server.js",
9
- "agent-kit-cli": "dist/kit-cli.js"
8
+ "agent-kit": "dist/server.js",
9
+ "cli": "dist/cli.js"
10
10
  },
11
11
  "files": [
12
12
  "dist",
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "scripts": {
24
24
  "build": "rm -rf dist && tsc && npm run bundle",
25
- "bundle": "esbuild src/kit-server.ts src/kit-cli.ts --bundle --platform=node --format=esm --outdir=dist --external:node:* --external:better-sqlite3 --external:sqlite-vec --external:fastembed --external:node-llama-cpp --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\"",
25
+ "bundle": "esbuild src/entrypoints/server.ts src/entrypoints/cli.ts --bundle --platform=node --format=esm --outdir=dist --external:node:* --external:better-sqlite3 --external:sqlite-vec --external:fastembed --external:node-llama-cpp --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\"",
26
26
  "dev": "tsc --watch",
27
27
  "prepublishOnly": "npm run build",
28
- "test": "tsc && node --test $(find src/memory/__tests__ src/tools/__tests__ -name '*.test.ts' | sed 's#^src/#dist/#; s#\\.ts$#.js#' | tr '\\n' ' ')"
28
+ "test": "tsc && node --test $(find dist -name '*.test.js' | tr '\\n' ' ')"
29
29
  },
30
30
  "dependencies": {
31
31
  "node-llama-cpp": "^3.0.0",
@@ -1,46 +0,0 @@
1
- import * as assert from 'node:assert/strict';
2
- import { describe, test } from 'node:test';
3
- import { parseDigestWorkerSuccess } from '../digest/worker.js';
4
- import { DIGEST_WORKER_RESULT_PREFIX } from '../digest/constants.js';
5
- function workerResultLine(result) {
6
- return DIGEST_WORKER_RESULT_PREFIX + JSON.stringify(result);
7
- }
8
- describe('parseDigestWorkerSuccess', () => {
9
- test('accepts a structured provisional digest worker line', () => {
10
- const stdout = [
11
- '[memory-kit] model-load: 612ms',
12
- workerResultLine({
13
- markdown: '/tmp/conversation-digests/abc-conv.md',
14
- status: 'provisional',
15
- contentHash: 'abc',
16
- indexed: true,
17
- skipped: false,
18
- }),
19
- ].join('\n');
20
- assert.equal(parseDigestWorkerSuccess(stdout), true);
21
- });
22
- test('rejects stdout that only mentions markdown as plain text', () => {
23
- const stdout = 'The model produced markdown but no digest result envelope.';
24
- assert.equal(parseDigestWorkerSuccess(stdout), false);
25
- });
26
- test('rejects unprefixed JSON objects', () => {
27
- const stdout = [
28
- JSON.stringify({ markdown: '/tmp/file.md', status: 'draft' }),
29
- JSON.stringify({ markdown: '/tmp/file.md', status: 'provisional' }),
30
- ].join('\n');
31
- assert.equal(parseDigestWorkerSuccess(stdout), false);
32
- });
33
- test('uses the last valid digest worker line after noisy output', () => {
34
- const stdout = [
35
- JSON.stringify({ event: 'model-load', markdown: false }),
36
- 'Metal cleanup warning',
37
- workerResultLine({ markdown: '/tmp/final.md', status: 'provisional' }),
38
- 'trailing non-json output',
39
- ].join('\n');
40
- assert.equal(parseDigestWorkerSuccess(stdout), true);
41
- });
42
- test('rejects malformed digest worker lines', () => {
43
- const stdout = ['[memory-kit] model-load: 612ms', DIGEST_WORKER_RESULT_PREFIX + '{"markdown":'].join('\n');
44
- assert.equal(parseDigestWorkerSuccess(stdout), false);
45
- });
46
- });
@@ -1,14 +0,0 @@
1
- import * as assert from 'node:assert/strict';
2
- import * as os from 'node:os';
3
- import * as path from 'node:path';
4
- import { describe, test } from 'node:test';
5
- import { DEFAULT_MODEL_CACHE_DIR, FASTEMBED_CACHE_DIR } from '../embedder.js';
6
- import { AGENT_KIT_HOME, CREDENTIALS_FILE } from '../../utils/paths.js';
7
- describe('Embedder cache paths', () => {
8
- test('uses global Agent Kit home for user-level files', () => {
9
- assert.equal(AGENT_KIT_HOME, path.join(os.homedir(), '.agent-kit'));
10
- assert.equal(CREDENTIALS_FILE, path.join(AGENT_KIT_HOME, 'credentials'));
11
- assert.equal(DEFAULT_MODEL_CACHE_DIR, path.join(AGENT_KIT_HOME, 'cache', 'models'));
12
- assert.equal(FASTEMBED_CACHE_DIR, path.join(DEFAULT_MODEL_CACHE_DIR, 'fastembed'));
13
- });
14
- });
@@ -1,6 +0,0 @@
1
- import type { DigestModelSpec } from './types.js';
2
- export declare class DigestModelRegistryError extends Error {
3
- constructor(message: string);
4
- }
5
- export declare const DIGEST_MODEL_REGISTRY: Record<string, DigestModelSpec>;
6
- export declare function getDigestModelSpec(modelId: string): DigestModelSpec;
@@ -1,7 +0,0 @@
1
- import type { DigestFileOptions, DigestPendingResult, ProvisionalDigestResult, ConversationDigestInitResult, InitializeConversationDigestInput } from './types.js';
2
- export declare function digestConversationFile(options: DigestFileOptions): Promise<ProvisionalDigestResult>;
3
- export declare function digestPendingConversations({ workspaceRoot, digestFn, }: {
4
- workspaceRoot: string;
5
- digestFn?: (opts: DigestFileOptions) => Promise<ProvisionalDigestResult>;
6
- }): Promise<DigestPendingResult>;
7
- export declare function initializeConversationDigestModel(input: InitializeConversationDigestInput): Promise<ConversationDigestInitResult>;
@@ -1,7 +0,0 @@
1
- import type { ConversationDigestProvider } from '../types.js';
2
- export declare class LlamaLocalDigestProviderError extends Error {
3
- constructor(message: string);
4
- }
5
- export declare function trimConversationExport(content: string, maxInputChars: number): string;
6
- export declare function sanitizeConversationDigestMarkdown(generatedText: string): string;
7
- export declare function createLlamaLocalDigestProvider(modelId: string): Promise<ConversationDigestProvider>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import * as assert from 'node:assert/strict';
2
- import { afterEach, describe, test } from 'node:test';
3
- import { createTempDirTracker } from '../../__tests__/temp-dir.js';
4
- import { runMemoryCli } from '../../cli/memory.js';
5
- const tempDirs = createTempDirTracker();
6
- afterEach(() => {
7
- tempDirs.cleanup();
8
- });
9
- describe('cmdDigestPending CLI', () => {
10
- test('C22: no --hook flag → writes usage to stderr and returns 1', async () => {
11
- const stderrChunks = [];
12
- const origWrite = process.stderr.write.bind(process.stderr);
13
- process.stderr.write = (chunk) => {
14
- stderrChunks.push(String(chunk));
15
- return true;
16
- };
17
- let code;
18
- try {
19
- code = await runMemoryCli(['digest-pending'], process.env);
20
- }
21
- finally {
22
- process.stderr.write = origWrite;
23
- }
24
- assert.equal(code, 1);
25
- assert.ok(stderrChunks.some((s) => s.includes('Usage')));
26
- });
27
- test('C23: --hook returns 0 and emits one JSON line matching DigestPendingResult', async () => {
28
- const workspace = tempDirs.makeTempDir('cli-pending-c23-');
29
- const stdoutChunks = [];
30
- const origWrite = process.stdout.write.bind(process.stdout);
31
- process.stdout.write = (chunk) => {
32
- stdoutChunks.push(String(chunk));
33
- return true;
34
- };
35
- let code;
36
- try {
37
- code = await runMemoryCli(['digest-pending', '--hook'], {
38
- ...process.env,
39
- WORKSPACE_DIR: workspace,
40
- });
41
- }
42
- finally {
43
- process.stdout.write = origWrite;
44
- }
45
- assert.equal(code, 0);
46
- const output = stdoutChunks.join('');
47
- const parsed = JSON.parse(output.trim());
48
- assert.ok('ok' in parsed, 'result must have ok field');
49
- assert.ok('action' in parsed, 'result must have action field');
50
- });
51
- });
@@ -1,22 +0,0 @@
1
- import * as assert from 'node:assert/strict';
2
- import { afterEach, describe, test } from 'node:test';
3
- import { createTempDirTracker } from '../../__tests__/temp-dir.js';
4
- import { runMemoryCli } from '../../cli/memory.js';
5
- const tempDirs = createTempDirTracker();
6
- afterEach(() => {
7
- tempDirs.cleanup();
8
- });
9
- describe('memory CLI', () => {
10
- test('digest-pending --hook returns 0 when settings are missing', async () => {
11
- const workspace = tempDirs.makeTempDir('digest-pending-');
12
- const code = await runMemoryCli(['digest-pending', '--hook'], {
13
- ...process.env,
14
- WORKSPACE_DIR: workspace,
15
- });
16
- assert.equal(code, 0);
17
- });
18
- test('unknown command returns 1', async () => {
19
- const code = await runMemoryCli(['unknown'], process.env);
20
- assert.equal(code, 1);
21
- });
22
- });
@@ -1,22 +0,0 @@
1
- export declare const HANDOFF_TYPES: readonly ["brainstorm", "clarification", "plan", "ticket", "research", "scenario", "investigation"];
2
- export type HandoffType = (typeof HANDOFF_TYPES)[number];
3
- export type CanonicalHandoffType = 'brainstorm' | 'clarification' | 'plan' | 'ticket' | 'research' | 'scenario' | 'investigation';
4
- export interface SavedHandoffLocation {
5
- featureSlug: string;
6
- canonicalType: CanonicalHandoffType;
7
- filePath: string;
8
- relativePath: string;
9
- }
10
- export declare function sanitizeFeatureSlug(value: string): string;
11
- export declare function normalizeHandoffType(type: HandoffType): CanonicalHandoffType;
12
- export declare function deriveFeatureSlug(input: {
13
- requestedSlug: string;
14
- content: string;
15
- type: CanonicalHandoffType;
16
- }): string;
17
- export declare function resolveHandoffPath(input: {
18
- workspaceRoot: string;
19
- type: HandoffType;
20
- slug: string;
21
- content: string;
22
- }): SavedHandoffLocation;
@@ -1,16 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { MemoryIndexer } from '../memory/indexer.js';
3
- import { MemoryStore } from '../memory/store.js';
4
- import type { MemoryConfig } from '../memory/types.js';
5
- import { type ProjectSettings } from './config.js';
6
- /**
7
- * Registers tool handlers onto an already-constructed indexer/store pair.
8
- * Exported for unit testing with mocks.
9
- */
10
- export declare function registerMemoryToolHandlers(server: McpServer, indexer: MemoryIndexer, store: MemoryStore, config: MemoryConfig, workspaceRoot?: string): void;
11
- /**
12
- * Initializes the memory subsystem and registers all memory tools.
13
- * Returns the MemoryIndexer so the caller can fire startupIndex() after server.connect().
14
- * Returns null when memory is disabled (settings.memory.enabled !== true).
15
- */
16
- export declare function registerMemoryTools(server: McpServer, settings: ProjectSettings, workspaceRoot: string): MemoryIndexer | null;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes