@eddacraft/kindling-adapter-opencode 0.1.0
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/LICENSE +190 -0
- package/README.md +192 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/opencode/commands/export.d.ts +67 -0
- package/dist/opencode/commands/export.d.ts.map +1 -0
- package/dist/opencode/commands/export.js +76 -0
- package/dist/opencode/commands/export.js.map +1 -0
- package/dist/opencode/commands/forget.d.ts +50 -0
- package/dist/opencode/commands/forget.d.ts.map +1 -0
- package/dist/opencode/commands/forget.js +63 -0
- package/dist/opencode/commands/forget.js.map +1 -0
- package/dist/opencode/commands/index.d.ts +11 -0
- package/dist/opencode/commands/index.d.ts.map +1 -0
- package/dist/opencode/commands/index.js +11 -0
- package/dist/opencode/commands/index.js.map +1 -0
- package/dist/opencode/commands/pin.d.ts +64 -0
- package/dist/opencode/commands/pin.d.ts.map +1 -0
- package/dist/opencode/commands/pin.js +74 -0
- package/dist/opencode/commands/pin.js.map +1 -0
- package/dist/opencode/commands/search.d.ts +43 -0
- package/dist/opencode/commands/search.d.ts.map +1 -0
- package/dist/opencode/commands/search.js +90 -0
- package/dist/opencode/commands/search.js.map +1 -0
- package/dist/opencode/commands/status.d.ts +65 -0
- package/dist/opencode/commands/status.d.ts.map +1 -0
- package/dist/opencode/commands/status.js +64 -0
- package/dist/opencode/commands/status.js.map +1 -0
- package/dist/opencode/events.d.ts +95 -0
- package/dist/opencode/events.d.ts.map +1 -0
- package/dist/opencode/events.js +19 -0
- package/dist/opencode/events.js.map +1 -0
- package/dist/opencode/filter.d.ts +88 -0
- package/dist/opencode/filter.d.ts.map +1 -0
- package/dist/opencode/filter.js +150 -0
- package/dist/opencode/filter.js.map +1 -0
- package/dist/opencode/index.d.ts +10 -0
- package/dist/opencode/index.d.ts.map +1 -0
- package/dist/opencode/index.js +10 -0
- package/dist/opencode/index.js.map +1 -0
- package/dist/opencode/mapping.d.ts +37 -0
- package/dist/opencode/mapping.d.ts.map +1 -0
- package/dist/opencode/mapping.js +160 -0
- package/dist/opencode/mapping.js.map +1 -0
- package/dist/opencode/provenance.d.ts +27 -0
- package/dist/opencode/provenance.d.ts.map +1 -0
- package/dist/opencode/provenance.js +105 -0
- package/dist/opencode/provenance.js.map +1 -0
- package/dist/opencode/session.d.ts +108 -0
- package/dist/opencode/session.d.ts.map +1 -0
- package/dist/opencode/session.js +194 -0
- package/dist/opencode/session.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forget.js","sourceRoot":"","sources":["../../../src/opencode/commands/forget.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,OAAsB;IACrE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAElC,4BAA4B;IAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAE5D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;YACL,aAAa;YACb,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,eAAe,aAAa,YAAY;SAChD,CAAC;IACJ,CAAC;IAED,4BAA4B;IAC5B,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO;YACL,aAAa;YACb,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,8BAA8B;SACtC,CAAC;IACJ,CAAC;IAED,qBAAqB;IACrB,IAAI,CAAC;QACH,KAAK,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAEvC,OAAO;YACL,aAAa;YACb,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,aAAa;YACb,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAC5D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACrD,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,OAAO,uBAAuB,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,OAAO,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,6BAA6B,MAAM,CAAC,aAAa,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory commands for OpenCode
|
|
3
|
+
*
|
|
4
|
+
* CLI-style commands for interacting with Kindling memory from OpenCode.
|
|
5
|
+
*/
|
|
6
|
+
export * from './status.js';
|
|
7
|
+
export * from './search.js';
|
|
8
|
+
export * from './pin.js';
|
|
9
|
+
export * from './forget.js';
|
|
10
|
+
export * from './export.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory commands for OpenCode
|
|
3
|
+
*
|
|
4
|
+
* CLI-style commands for interacting with Kindling memory from OpenCode.
|
|
5
|
+
*/
|
|
6
|
+
export * from './status.js';
|
|
7
|
+
export * from './search.js';
|
|
8
|
+
export * from './pin.js';
|
|
9
|
+
export * from './forget.js';
|
|
10
|
+
export * from './export.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/opencode/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory pin command
|
|
3
|
+
*
|
|
4
|
+
* Pins observations or summaries for persistent retrieval
|
|
5
|
+
*/
|
|
6
|
+
import type { Pin, ScopeIds, ID } from '@eddacraft/kindling-core';
|
|
7
|
+
/**
|
|
8
|
+
* Store interface for pin command
|
|
9
|
+
*/
|
|
10
|
+
export interface PinStore {
|
|
11
|
+
insertPin(pin: Pin): void;
|
|
12
|
+
getObservationById(id: ID): {
|
|
13
|
+
id: ID;
|
|
14
|
+
} | undefined;
|
|
15
|
+
getSummaryById(id: ID): {
|
|
16
|
+
id: ID;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Pin options
|
|
21
|
+
*/
|
|
22
|
+
export interface PinOptions {
|
|
23
|
+
/** Type of target to pin */
|
|
24
|
+
targetType: 'observation' | 'summary';
|
|
25
|
+
/** ID of target to pin */
|
|
26
|
+
targetId: ID;
|
|
27
|
+
/** Optional reason for pinning */
|
|
28
|
+
reason?: string;
|
|
29
|
+
/** Scope for the pin */
|
|
30
|
+
scopeIds: ScopeIds;
|
|
31
|
+
/** Optional expiry time (timestamp) */
|
|
32
|
+
expiresAt?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Pin result
|
|
36
|
+
*/
|
|
37
|
+
export interface PinResult {
|
|
38
|
+
/** Pin ID */
|
|
39
|
+
pinId: ID;
|
|
40
|
+
/** Target ID that was pinned */
|
|
41
|
+
targetId: ID;
|
|
42
|
+
/** Target type */
|
|
43
|
+
targetType: 'observation' | 'summary';
|
|
44
|
+
/** Whether pin was created */
|
|
45
|
+
created: boolean;
|
|
46
|
+
/** Error if any */
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Execute /memory pin command
|
|
51
|
+
*
|
|
52
|
+
* @param store - Pin store
|
|
53
|
+
* @param options - Pin options
|
|
54
|
+
* @returns Pin result
|
|
55
|
+
*/
|
|
56
|
+
export declare function memoryPin(store: PinStore, options: PinOptions): PinResult;
|
|
57
|
+
/**
|
|
58
|
+
* Format pin result as human-readable text
|
|
59
|
+
*
|
|
60
|
+
* @param result - Pin result
|
|
61
|
+
* @returns Formatted pin result
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatPinResult(result: PinResult): string;
|
|
64
|
+
//# sourceMappingURL=pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/pin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,kBAAkB,CAAC,EAAE,EAAE,EAAE,GAAG;QAAE,EAAE,EAAE,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IACnD,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG;QAAE,EAAE,EAAE,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;IACtC,0BAA0B;IAC1B,QAAQ,EAAE,EAAE,CAAC;IACb,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,aAAa;IACb,KAAK,EAAE,EAAE,CAAC;IACV,gCAAgC;IAChC,QAAQ,EAAE,EAAE,CAAC;IACb,kBAAkB;IAClB,UAAU,EAAE,aAAa,GAAG,SAAS,CAAC;IACtC,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,CAqDzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAMzD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory pin command
|
|
3
|
+
*
|
|
4
|
+
* Pins observations or summaries for persistent retrieval
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Execute /memory pin command
|
|
8
|
+
*
|
|
9
|
+
* @param store - Pin store
|
|
10
|
+
* @param options - Pin options
|
|
11
|
+
* @returns Pin result
|
|
12
|
+
*/
|
|
13
|
+
export function memoryPin(store, options) {
|
|
14
|
+
const { targetType, targetId, reason, scopeIds, expiresAt } = options;
|
|
15
|
+
// Verify target exists
|
|
16
|
+
let targetExists = false;
|
|
17
|
+
if (targetType === 'observation') {
|
|
18
|
+
targetExists = !!store.getObservationById(targetId);
|
|
19
|
+
}
|
|
20
|
+
else if (targetType === 'summary') {
|
|
21
|
+
targetExists = !!store.getSummaryById(targetId);
|
|
22
|
+
}
|
|
23
|
+
if (!targetExists) {
|
|
24
|
+
return {
|
|
25
|
+
pinId: '',
|
|
26
|
+
targetId,
|
|
27
|
+
targetType,
|
|
28
|
+
created: false,
|
|
29
|
+
error: `${targetType} ${targetId} not found`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Create pin
|
|
33
|
+
const pinId = `pin-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
34
|
+
const pin = {
|
|
35
|
+
id: pinId,
|
|
36
|
+
targetType,
|
|
37
|
+
targetId,
|
|
38
|
+
reason,
|
|
39
|
+
createdAt: Date.now(),
|
|
40
|
+
scopeIds,
|
|
41
|
+
expiresAt,
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
store.insertPin(pin);
|
|
45
|
+
return {
|
|
46
|
+
pinId,
|
|
47
|
+
targetId,
|
|
48
|
+
targetType,
|
|
49
|
+
created: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return {
|
|
54
|
+
pinId: '',
|
|
55
|
+
targetId,
|
|
56
|
+
targetType,
|
|
57
|
+
created: false,
|
|
58
|
+
error: err instanceof Error ? err.message : 'Unknown error',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Format pin result as human-readable text
|
|
64
|
+
*
|
|
65
|
+
* @param result - Pin result
|
|
66
|
+
* @returns Formatted pin result
|
|
67
|
+
*/
|
|
68
|
+
export function formatPinResult(result) {
|
|
69
|
+
if (!result.created) {
|
|
70
|
+
return `❌ Failed to pin: ${result.error}`;
|
|
71
|
+
}
|
|
72
|
+
return `📌 Pinned ${result.targetType} ${result.targetId}`;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=pin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.js","sourceRoot":"","sources":["../../../src/opencode/commands/pin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6CH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CA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AAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAC5D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,oBAAoB,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,aAAa,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory search command
|
|
3
|
+
*
|
|
4
|
+
* Searches memory and returns relevant context
|
|
5
|
+
*/
|
|
6
|
+
import type { RetrieveResult, ScopeIds } from '@eddacraft/kindling-core';
|
|
7
|
+
/**
|
|
8
|
+
* Retrieval service interface
|
|
9
|
+
*/
|
|
10
|
+
export interface RetrievalService {
|
|
11
|
+
retrieve(options: {
|
|
12
|
+
query: string;
|
|
13
|
+
scopeIds: ScopeIds;
|
|
14
|
+
maxCandidates?: number;
|
|
15
|
+
}): Promise<RetrieveResult>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Search options
|
|
19
|
+
*/
|
|
20
|
+
export interface SearchOptions {
|
|
21
|
+
/** Search query */
|
|
22
|
+
query: string;
|
|
23
|
+
/** Scope for search */
|
|
24
|
+
scopeIds: ScopeIds;
|
|
25
|
+
/** Maximum results to return */
|
|
26
|
+
maxResults?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Execute /memory search command
|
|
30
|
+
*
|
|
31
|
+
* @param service - Retrieval service
|
|
32
|
+
* @param options - Search options
|
|
33
|
+
* @returns Retrieval result
|
|
34
|
+
*/
|
|
35
|
+
export declare function memorySearch(service: RetrievalService, options: SearchOptions): Promise<RetrieveResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Format search results as human-readable text
|
|
38
|
+
*
|
|
39
|
+
* @param result - Retrieval result
|
|
40
|
+
* @returns Formatted search results
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatSearchResults(result: RetrieveResult): string;
|
|
43
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,QAAQ,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CA8DlE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory search command
|
|
3
|
+
*
|
|
4
|
+
* Searches memory and returns relevant context
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Execute /memory search command
|
|
8
|
+
*
|
|
9
|
+
* @param service - Retrieval service
|
|
10
|
+
* @param options - Search options
|
|
11
|
+
* @returns Retrieval result
|
|
12
|
+
*/
|
|
13
|
+
export async function memorySearch(service, options) {
|
|
14
|
+
const { query, scopeIds, maxResults = 10 } = options;
|
|
15
|
+
return service.retrieve({
|
|
16
|
+
query,
|
|
17
|
+
scopeIds,
|
|
18
|
+
maxCandidates: maxResults,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Format search results as human-readable text
|
|
23
|
+
*
|
|
24
|
+
* @param result - Retrieval result
|
|
25
|
+
* @returns Formatted search results
|
|
26
|
+
*/
|
|
27
|
+
export function formatSearchResults(result) {
|
|
28
|
+
const lines = [];
|
|
29
|
+
lines.push('Search Results');
|
|
30
|
+
lines.push('==============');
|
|
31
|
+
lines.push('');
|
|
32
|
+
lines.push(`Query: "${result.provenance.query}"`);
|
|
33
|
+
lines.push(`Found: ${result.provenance.totalCandidates} results (showing ${result.provenance.returnedCandidates})`);
|
|
34
|
+
lines.push('');
|
|
35
|
+
// Pinned items
|
|
36
|
+
if (result.pins.length > 0) {
|
|
37
|
+
lines.push('📌 Pinned:');
|
|
38
|
+
lines.push('');
|
|
39
|
+
for (const pinResult of result.pins) {
|
|
40
|
+
const preview = truncateContent(pinResult.target.content, 200);
|
|
41
|
+
lines.push(` [${pinResult.target.id}]`);
|
|
42
|
+
lines.push(` ${preview}`);
|
|
43
|
+
if (pinResult.pin.reason) {
|
|
44
|
+
lines.push(` Reason: ${pinResult.pin.reason}`);
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Current summary
|
|
50
|
+
if (result.currentSummary) {
|
|
51
|
+
lines.push('📝 Current Session Summary:');
|
|
52
|
+
lines.push('');
|
|
53
|
+
lines.push(` ${result.currentSummary.content}`);
|
|
54
|
+
lines.push(` Confidence: ${(result.currentSummary.confidence * 100).toFixed(0)}%`);
|
|
55
|
+
lines.push('');
|
|
56
|
+
}
|
|
57
|
+
// Candidates
|
|
58
|
+
if (result.candidates.length > 0) {
|
|
59
|
+
lines.push('🔍 Search Results:');
|
|
60
|
+
lines.push('');
|
|
61
|
+
for (const candidate of result.candidates) {
|
|
62
|
+
const preview = truncateContent(candidate.entity.content, 200);
|
|
63
|
+
const score = (candidate.score * 100).toFixed(0);
|
|
64
|
+
lines.push(` [${candidate.entity.id}] (score: ${score}%)`);
|
|
65
|
+
lines.push(` ${preview}`);
|
|
66
|
+
if (candidate.matchContext) {
|
|
67
|
+
lines.push(` Match: ${candidate.matchContext}`);
|
|
68
|
+
}
|
|
69
|
+
lines.push('');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (result.pins.length === 0 && !result.currentSummary && result.candidates.length === 0) {
|
|
73
|
+
lines.push('No results found.');
|
|
74
|
+
}
|
|
75
|
+
return lines.join('\n');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Truncate content to max length
|
|
79
|
+
*
|
|
80
|
+
* @param content - Content to truncate
|
|
81
|
+
* @param maxLength - Maximum length
|
|
82
|
+
* @returns Truncated content
|
|
83
|
+
*/
|
|
84
|
+
function truncateContent(content, maxLength) {
|
|
85
|
+
if (content.length <= maxLength) {
|
|
86
|
+
return content;
|
|
87
|
+
}
|
|
88
|
+
return content.substring(0, maxLength) + '...';
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/opencode/commands/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAyB,EACzB,OAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAErD,OAAO,OAAO,CAAC,QAAQ,CAAC;QACtB,KAAK;QACL,QAAQ;QACR,aAAa,EAAE,UAAU;KAC1B,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UA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C,cAAc,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzF,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAe,EAAE,SAAiB;IACzD,IAAI,OAAO,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory status command
|
|
3
|
+
*
|
|
4
|
+
* Shows memory system status and statistics
|
|
5
|
+
*/
|
|
6
|
+
import type { ScopeIds } from '@eddacraft/kindling-core';
|
|
7
|
+
/**
|
|
8
|
+
* Store interface for status command
|
|
9
|
+
*/
|
|
10
|
+
export interface StatusStore {
|
|
11
|
+
queryObservations(scopeIds?: Partial<ScopeIds>, fromTs?: number, toTs?: number, limit?: number): {
|
|
12
|
+
id: string;
|
|
13
|
+
}[];
|
|
14
|
+
getCapsules(scopeIds?: Partial<ScopeIds>): {
|
|
15
|
+
id: string;
|
|
16
|
+
status: string;
|
|
17
|
+
}[];
|
|
18
|
+
getSummaries(scopeIds?: Partial<ScopeIds>): {
|
|
19
|
+
id: string;
|
|
20
|
+
createdAt: number;
|
|
21
|
+
}[];
|
|
22
|
+
getPins(scopeIds?: Partial<ScopeIds>): {
|
|
23
|
+
id: string;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Status command options
|
|
28
|
+
*/
|
|
29
|
+
export interface StatusOptions {
|
|
30
|
+
/** Scope to show status for */
|
|
31
|
+
scopeIds?: Partial<ScopeIds>;
|
|
32
|
+
/** Database file path */
|
|
33
|
+
dbPath?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Status result
|
|
37
|
+
*/
|
|
38
|
+
export interface StatusResult {
|
|
39
|
+
observations: number;
|
|
40
|
+
capsules: {
|
|
41
|
+
total: number;
|
|
42
|
+
open: number;
|
|
43
|
+
closed: number;
|
|
44
|
+
};
|
|
45
|
+
summaries: number;
|
|
46
|
+
pins: number;
|
|
47
|
+
lastSummaryAt?: number;
|
|
48
|
+
dbPath?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Execute /memory status command
|
|
52
|
+
*
|
|
53
|
+
* @param store - Status store
|
|
54
|
+
* @param options - Command options
|
|
55
|
+
* @returns Status result
|
|
56
|
+
*/
|
|
57
|
+
export declare function memoryStatus(store: StatusStore, options?: StatusOptions): StatusResult;
|
|
58
|
+
/**
|
|
59
|
+
* Format status result as human-readable text
|
|
60
|
+
*
|
|
61
|
+
* @param result - Status result
|
|
62
|
+
* @returns Formatted status text
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatStatus(result: StatusResult): string;
|
|
65
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iBAAiB,CACf,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC5B,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAEpB,WAAW,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5E,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChF,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7B,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,CA8B1F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAwBzD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /memory status command
|
|
3
|
+
*
|
|
4
|
+
* Shows memory system status and statistics
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Execute /memory status command
|
|
8
|
+
*
|
|
9
|
+
* @param store - Status store
|
|
10
|
+
* @param options - Command options
|
|
11
|
+
* @returns Status result
|
|
12
|
+
*/
|
|
13
|
+
export function memoryStatus(store, options = {}) {
|
|
14
|
+
const { scopeIds, dbPath } = options;
|
|
15
|
+
// Count observations
|
|
16
|
+
const observations = store.queryObservations(scopeIds);
|
|
17
|
+
// Count capsules
|
|
18
|
+
const capsules = store.getCapsules(scopeIds);
|
|
19
|
+
const open = capsules.filter((c) => c.status === 'open').length;
|
|
20
|
+
const closed = capsules.filter((c) => c.status === 'closed').length;
|
|
21
|
+
// Count summaries and get latest
|
|
22
|
+
const summaries = store.getSummaries(scopeIds);
|
|
23
|
+
const lastSummary = summaries.sort((a, b) => b.createdAt - a.createdAt)[0];
|
|
24
|
+
// Count pins
|
|
25
|
+
const pins = store.getPins(scopeIds);
|
|
26
|
+
return {
|
|
27
|
+
observations: observations.length,
|
|
28
|
+
capsules: {
|
|
29
|
+
total: capsules.length,
|
|
30
|
+
open,
|
|
31
|
+
closed,
|
|
32
|
+
},
|
|
33
|
+
summaries: summaries.length,
|
|
34
|
+
pins: pins.length,
|
|
35
|
+
lastSummaryAt: lastSummary?.createdAt,
|
|
36
|
+
dbPath,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Format status result as human-readable text
|
|
41
|
+
*
|
|
42
|
+
* @param result - Status result
|
|
43
|
+
* @returns Formatted status text
|
|
44
|
+
*/
|
|
45
|
+
export function formatStatus(result) {
|
|
46
|
+
const lines = [];
|
|
47
|
+
lines.push('Memory Status');
|
|
48
|
+
lines.push('=============');
|
|
49
|
+
lines.push('');
|
|
50
|
+
lines.push(`Observations: ${result.observations}`);
|
|
51
|
+
lines.push(`Capsules: ${result.capsules.total} (${result.capsules.open} open, ${result.capsules.closed} closed)`);
|
|
52
|
+
lines.push(`Summaries: ${result.summaries}`);
|
|
53
|
+
lines.push(`Pins: ${result.pins}`);
|
|
54
|
+
if (result.lastSummaryAt) {
|
|
55
|
+
const date = new Date(result.lastSummaryAt);
|
|
56
|
+
lines.push(`Last summary: ${date.toISOString()}`);
|
|
57
|
+
}
|
|
58
|
+
if (result.dbPath) {
|
|
59
|
+
lines.push('');
|
|
60
|
+
lines.push(`Database: ${result.dbPath}`);
|
|
61
|
+
}
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/opencode/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0CH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,UAAyB,EAAE;IAC1E,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAErC,qBAAqB;IACrB,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAEvD,iBAAiB;IACjB,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAChE,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;IAEpE,iCAAiC;IACjC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,aAAa;IACb,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAErC,OAAO;QAC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AAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode event type definitions
|
|
3
|
+
*
|
|
4
|
+
* These represent events emitted by OpenCode during development sessions.
|
|
5
|
+
* Note: These are example types - adapt to actual OpenCode event schema.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base event structure
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseEvent {
|
|
11
|
+
type: string;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
repoId?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tool call event
|
|
18
|
+
*
|
|
19
|
+
* Fired when a tool is invoked (e.g., file read, command execution)
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolCallEvent extends BaseEvent {
|
|
22
|
+
type: 'tool_call';
|
|
23
|
+
toolName: string;
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
result?: unknown;
|
|
26
|
+
duration_ms?: number;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Command execution event
|
|
31
|
+
*
|
|
32
|
+
* Fired when a shell command is executed
|
|
33
|
+
*/
|
|
34
|
+
export interface CommandEvent extends BaseEvent {
|
|
35
|
+
type: 'command';
|
|
36
|
+
command: string;
|
|
37
|
+
exitCode: number;
|
|
38
|
+
stdout?: string;
|
|
39
|
+
stderr?: string;
|
|
40
|
+
cwd?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* File change event
|
|
44
|
+
*
|
|
45
|
+
* Fired when files are modified
|
|
46
|
+
*/
|
|
47
|
+
export interface FileChangeEvent extends BaseEvent {
|
|
48
|
+
type: 'file_change';
|
|
49
|
+
paths: string[];
|
|
50
|
+
diff?: string;
|
|
51
|
+
additions?: number;
|
|
52
|
+
deletions?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error event
|
|
56
|
+
*
|
|
57
|
+
* Fired when an error occurs
|
|
58
|
+
*/
|
|
59
|
+
export interface ErrorEvent extends BaseEvent {
|
|
60
|
+
type: 'error';
|
|
61
|
+
message: string;
|
|
62
|
+
stack?: string;
|
|
63
|
+
source?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Message event
|
|
67
|
+
*
|
|
68
|
+
* Fired for user/assistant messages
|
|
69
|
+
*/
|
|
70
|
+
export interface MessageEvent extends BaseEvent {
|
|
71
|
+
type: 'message';
|
|
72
|
+
role: 'user' | 'assistant';
|
|
73
|
+
content: string;
|
|
74
|
+
model?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Session lifecycle events
|
|
78
|
+
*/
|
|
79
|
+
export interface SessionStartEvent extends BaseEvent {
|
|
80
|
+
type: 'session_start';
|
|
81
|
+
intent?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface SessionEndEvent extends BaseEvent {
|
|
84
|
+
type: 'session_end';
|
|
85
|
+
reason?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Union of all event types
|
|
89
|
+
*/
|
|
90
|
+
export type OpenCodeEvent = ToolCallEvent | CommandEvent | FileChangeEvent | ErrorEvent | MessageEvent | SessionStartEvent | SessionEndEvent;
|
|
91
|
+
/**
|
|
92
|
+
* Type guard for OpenCode events
|
|
93
|
+
*/
|
|
94
|
+
export declare function isOpenCodeEvent(event: unknown): event is OpenCodeEvent;
|
|
95
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/opencode/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB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;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,YAAY,GACZ,eAAe,GACf,UAAU,GACV,YAAY,GACZ,iBAAiB,GACjB,eAAe,CAAC;AAEpB;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAWtE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode event type definitions
|
|
3
|
+
*
|
|
4
|
+
* These represent events emitted by OpenCode during development sessions.
|
|
5
|
+
* Note: These are example types - adapt to actual OpenCode event schema.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard for OpenCode events
|
|
9
|
+
*/
|
|
10
|
+
export function isOpenCodeEvent(event) {
|
|
11
|
+
if (typeof event !== 'object' || event === null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const e = event;
|
|
15
|
+
return (typeof e.type === 'string' &&
|
|
16
|
+
typeof e.timestamp === 'number' &&
|
|
17
|
+
typeof e.sessionId === 'string');
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/opencode/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsGH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CACL,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAC/B,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC"}
|