@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.
Files changed (55) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +192 -0
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +7 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/opencode/commands/export.d.ts +67 -0
  8. package/dist/opencode/commands/export.d.ts.map +1 -0
  9. package/dist/opencode/commands/export.js +76 -0
  10. package/dist/opencode/commands/export.js.map +1 -0
  11. package/dist/opencode/commands/forget.d.ts +50 -0
  12. package/dist/opencode/commands/forget.d.ts.map +1 -0
  13. package/dist/opencode/commands/forget.js +63 -0
  14. package/dist/opencode/commands/forget.js.map +1 -0
  15. package/dist/opencode/commands/index.d.ts +11 -0
  16. package/dist/opencode/commands/index.d.ts.map +1 -0
  17. package/dist/opencode/commands/index.js +11 -0
  18. package/dist/opencode/commands/index.js.map +1 -0
  19. package/dist/opencode/commands/pin.d.ts +64 -0
  20. package/dist/opencode/commands/pin.d.ts.map +1 -0
  21. package/dist/opencode/commands/pin.js +74 -0
  22. package/dist/opencode/commands/pin.js.map +1 -0
  23. package/dist/opencode/commands/search.d.ts +43 -0
  24. package/dist/opencode/commands/search.d.ts.map +1 -0
  25. package/dist/opencode/commands/search.js +90 -0
  26. package/dist/opencode/commands/search.js.map +1 -0
  27. package/dist/opencode/commands/status.d.ts +65 -0
  28. package/dist/opencode/commands/status.d.ts.map +1 -0
  29. package/dist/opencode/commands/status.js +64 -0
  30. package/dist/opencode/commands/status.js.map +1 -0
  31. package/dist/opencode/events.d.ts +95 -0
  32. package/dist/opencode/events.d.ts.map +1 -0
  33. package/dist/opencode/events.js +19 -0
  34. package/dist/opencode/events.js.map +1 -0
  35. package/dist/opencode/filter.d.ts +88 -0
  36. package/dist/opencode/filter.d.ts.map +1 -0
  37. package/dist/opencode/filter.js +150 -0
  38. package/dist/opencode/filter.js.map +1 -0
  39. package/dist/opencode/index.d.ts +10 -0
  40. package/dist/opencode/index.d.ts.map +1 -0
  41. package/dist/opencode/index.js +10 -0
  42. package/dist/opencode/index.js.map +1 -0
  43. package/dist/opencode/mapping.d.ts +37 -0
  44. package/dist/opencode/mapping.d.ts.map +1 -0
  45. package/dist/opencode/mapping.js +160 -0
  46. package/dist/opencode/mapping.js.map +1 -0
  47. package/dist/opencode/provenance.d.ts +27 -0
  48. package/dist/opencode/provenance.d.ts.map +1 -0
  49. package/dist/opencode/provenance.js +105 -0
  50. package/dist/opencode/provenance.js.map +1 -0
  51. package/dist/opencode/session.d.ts +108 -0
  52. package/dist/opencode/session.d.ts.map +1 -0
  53. package/dist/opencode/session.js +194 -0
  54. package/dist/opencode/session.js.map +1 -0
  55. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on behalf
53
+ of the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 EddaCraft
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # @eddacraft/kindling-adapter-opencode
2
+
3
+ OpenCode session adapter for Kindling - capture tool calls, commands, and file changes from AI coding sessions.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@eddacraft/kindling-adapter-opencode.svg)](https://www.npmjs.com/package/@eddacraft/kindling-adapter-opencode)
6
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](../../LICENSE)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @eddacraft/kindling-adapter-opencode
12
+ ```
13
+
14
+ ## Overview
15
+
16
+ Captures observations from OpenCode development sessions for local memory and continuity.
17
+
18
+ ## What is Captured
19
+
20
+ The OpenCode adapter automatically captures the following types of events from your development sessions:
21
+
22
+ ### Tool Calls
23
+
24
+ - **Tool name** and **arguments**
25
+ - **Results** or **errors**
26
+ - **Duration** (execution time)
27
+ - **Timestamp**
28
+
29
+ ### Command Execution
30
+
31
+ - **Command text** (e.g., `git status`, `npm test`)
32
+ - **Exit code**
33
+ - **stdout** and **stderr** output
34
+ - **Working directory**
35
+
36
+ ### File Changes
37
+
38
+ - **File paths** modified
39
+ - **Diff** content (additions/deletions)
40
+ - **Change summary** (lines added/deleted)
41
+
42
+ ### Errors
43
+
44
+ - **Error message**
45
+ - **Stack trace** preview
46
+ - **Error source** (runtime, validation, etc.)
47
+
48
+ ### Messages
49
+
50
+ - **User messages** (prompts, questions)
51
+ - **Assistant messages** (responses, explanations)
52
+ - **Message length** and **model** used
53
+
54
+ ## What is NOT Captured
55
+
56
+ Session lifecycle events (`session_start`, `session_end`) are **skipped** - they are used to manage capsules but not stored as observations.
57
+
58
+ ## Safety & Privacy
59
+
60
+ ### Automatic Redaction
61
+
62
+ The adapter automatically detects and redacts sensitive information:
63
+
64
+ - **API keys, tokens, passwords**: Patterns like `api_key=`, `token:`, `password=` are detected and values replaced with `[REDACTED]`
65
+ - **AWS credentials**: AWS secret access keys are masked
66
+ - **Bearer/Basic auth**: Authorization headers are sanitized
67
+ - **Long secret-like strings**: 32+ character alphanumeric strings with mixed letters/numbers are flagged as potential tokens
68
+
69
+ ### Excluded Files
70
+
71
+ The following file paths are automatically excluded from capture:
72
+
73
+ - `node_modules/` directories
74
+ - `.git/` directories
75
+ - `.env` files
76
+ - `.pem`, `.key` certificate files
77
+ - Files containing `credentials` or `secrets` in the path
78
+
79
+ ### Content Truncation
80
+
81
+ Large outputs are automatically truncated to **50,000 characters** to prevent excessive storage usage. A truncation notice is appended when content is shortened.
82
+
83
+ ## Usage
84
+
85
+ ### Starting a Session
86
+
87
+ ```typescript
88
+ import { SessionManager } from '@eddacraft/kindling-adapter-opencode';
89
+ import { SqliteKindlingStore, initializeDatabase } from '@eddacraft/kindling-store-sqlite';
90
+
91
+ // Initialize store
92
+ const db = initializeDatabase(':memory:');
93
+ const store = new SqliteKindlingStore(db);
94
+
95
+ // Create session manager
96
+ const manager = new SessionManager(store);
97
+
98
+ // Start session
99
+ const context = manager.onSessionStart({
100
+ sessionId: 'session-123',
101
+ intent: 'Fix authentication bug',
102
+ repoId: '/home/user/my-project',
103
+ });
104
+ ```
105
+
106
+ ### Processing Events
107
+
108
+ ```typescript
109
+ // Process tool call event
110
+ manager.onEvent({
111
+ type: 'tool_call',
112
+ timestamp: Date.now(),
113
+ sessionId: 'session-123',
114
+ toolName: 'read_file',
115
+ args: { path: 'src/auth.ts' },
116
+ result: 'file contents...',
117
+ });
118
+
119
+ // Process command event
120
+ manager.onEvent({
121
+ type: 'command',
122
+ timestamp: Date.now(),
123
+ sessionId: 'session-123',
124
+ command: 'npm test',
125
+ exitCode: 0,
126
+ stdout: 'All tests passed',
127
+ });
128
+ ```
129
+
130
+ ### Ending a Session
131
+
132
+ ```typescript
133
+ // End session with optional summary
134
+ manager.onSessionEnd('session-123', {
135
+ reason: 'completed',
136
+ summaryContent: 'Fixed JWT validation in auth middleware',
137
+ summaryConfidence: 0.9,
138
+ });
139
+ ```
140
+
141
+ ### Content Filtering
142
+
143
+ ```typescript
144
+ import { filterContent, truncateContent, maskSecrets } from '@eddacraft/kindling-adapter-opencode';
145
+
146
+ // Apply all safety filters
147
+ const filtered = filterContent(content, {
148
+ maxLength: 10000,
149
+ maskSecrets: true,
150
+ showTruncationNotice: true,
151
+ });
152
+
153
+ // Just truncate
154
+ const truncated = truncateContent(longContent, { maxLength: 5000 });
155
+
156
+ // Just mask secrets
157
+ const masked = maskSecrets(contentWithSecrets);
158
+ ```
159
+
160
+ ## Configuration
161
+
162
+ Currently, safety filters are applied by default and cannot be disabled. Future versions may add opt-in/opt-out configuration.
163
+
164
+ ## Data Storage
165
+
166
+ All captured observations are stored locally in SQLite via `@eddacraft/kindling-store-sqlite`. No data is sent to external services.
167
+
168
+ Observations are:
169
+
170
+ - **Deterministically ordered** by timestamp and sequence number
171
+ - **Scoped** to session, repository, agent, and user
172
+ - **Queryable** via full-text search and filters
173
+ - **Redactable** after capture if needed
174
+
175
+ ## Privacy Considerations
176
+
177
+ **What you should know:**
178
+
179
+ 1. **Local only**: All data stays on your machine in a local SQLite database
180
+ 2. **Automatic sanitization**: Sensitive data is detected and redacted automatically
181
+ 3. **Manual review**: You can inspect and redact observations after capture
182
+ 4. **Export/forget**: Observations can be exported or permanently deleted
183
+
184
+ **What you should check:**
185
+
186
+ - Review captured observations periodically for accidentally captured secrets
187
+ - Use `/memory forget <id>` to redact specific observations
188
+ - Consider excluding sensitive repositories from capture
189
+
190
+ ## License
191
+
192
+ Apache-2.0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Kindling OpenCode Adapter
3
+ *
4
+ * Captures observations from OpenCode development sessions.
5
+ */
6
+ export * from './opencode/index.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Kindling OpenCode Adapter
3
+ *
4
+ * Captures observations from OpenCode development sessions.
5
+ */
6
+ export * from './opencode/index.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * /memory export command
3
+ *
4
+ * Exports memory to a portable bundle
5
+ */
6
+ import type { ScopeIds, ExportBundle } from '@eddacraft/kindling-core';
7
+ /**
8
+ * Export service interface
9
+ */
10
+ export interface ExportService {
11
+ createExportBundle(options?: {
12
+ scope?: Partial<ScopeIds>;
13
+ includeRedacted?: boolean;
14
+ limit?: number;
15
+ metadata?: {
16
+ description?: string;
17
+ tags?: string[];
18
+ [key: string]: unknown;
19
+ };
20
+ }): ExportBundle;
21
+ serializeBundle(bundle: ExportBundle, pretty?: boolean): string;
22
+ }
23
+ /**
24
+ * Export options
25
+ */
26
+ export interface ExportOptions {
27
+ /** Optional scope filter */
28
+ scope?: Partial<ScopeIds>;
29
+ /** Include redacted observations */
30
+ includeRedacted?: boolean;
31
+ /** Output file path (default: auto-generated) */
32
+ outputPath?: string;
33
+ /** Export description */
34
+ description?: string;
35
+ }
36
+ /**
37
+ * Export result
38
+ */
39
+ export interface ExportResult {
40
+ /** Path to exported file */
41
+ filePath: string;
42
+ /** Number of entities exported */
43
+ stats: {
44
+ observations: number;
45
+ capsules: number;
46
+ summaries: number;
47
+ pins: number;
48
+ };
49
+ /** Error if any */
50
+ error?: string;
51
+ }
52
+ /**
53
+ * Execute /memory export command
54
+ *
55
+ * @param service - Export service
56
+ * @param options - Export options
57
+ * @returns Export result
58
+ */
59
+ export declare function memoryExport(service: ExportService, options?: ExportOptions): ExportResult;
60
+ /**
61
+ * Format export result as human-readable text
62
+ *
63
+ * @param result - Export result
64
+ * @returns Formatted export result
65
+ */
66
+ export declare function formatExportResult(result: ExportResult): string;
67
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/export.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIvE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE;YACT,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;YAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH,GAAG,YAAY,CAAC;IAEjB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1B,oCAAoC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,CAyC9F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAkB/D"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * /memory export command
3
+ *
4
+ * Exports memory to a portable bundle
5
+ */
6
+ import { writeFileSync } from 'fs';
7
+ import { join } from 'path';
8
+ /**
9
+ * Execute /memory export command
10
+ *
11
+ * @param service - Export service
12
+ * @param options - Export options
13
+ * @returns Export result
14
+ */
15
+ export function memoryExport(service, options = {}) {
16
+ const { scope, includeRedacted = false, outputPath, description } = options;
17
+ try {
18
+ // Create export bundle
19
+ const bundle = service.createExportBundle({
20
+ scope,
21
+ includeRedacted,
22
+ metadata: description ? { description } : undefined,
23
+ });
24
+ // Generate file path if not provided
25
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
26
+ const defaultPath = join(process.cwd(), `kindling-export-${timestamp}.json`);
27
+ const filePath = outputPath || defaultPath;
28
+ // Serialize and write bundle
29
+ const json = service.serializeBundle(bundle, true);
30
+ writeFileSync(filePath, json, 'utf-8');
31
+ return {
32
+ filePath,
33
+ stats: {
34
+ observations: bundle.dataset.observations.length,
35
+ capsules: bundle.dataset.capsules.length,
36
+ summaries: bundle.dataset.summaries.length,
37
+ pins: bundle.dataset.pins.length,
38
+ },
39
+ };
40
+ }
41
+ catch (err) {
42
+ return {
43
+ filePath: '',
44
+ stats: {
45
+ observations: 0,
46
+ capsules: 0,
47
+ summaries: 0,
48
+ pins: 0,
49
+ },
50
+ error: err instanceof Error ? err.message : 'Unknown error',
51
+ };
52
+ }
53
+ }
54
+ /**
55
+ * Format export result as human-readable text
56
+ *
57
+ * @param result - Export result
58
+ * @returns Formatted export result
59
+ */
60
+ export function formatExportResult(result) {
61
+ if (result.error) {
62
+ return `❌ Export failed: ${result.error}`;
63
+ }
64
+ const lines = [];
65
+ lines.push('📦 Export complete');
66
+ lines.push('');
67
+ lines.push(`File: ${result.filePath}`);
68
+ lines.push('');
69
+ lines.push('Exported:');
70
+ lines.push(` ${result.stats.observations} observations`);
71
+ lines.push(` ${result.stats.capsules} capsules`);
72
+ lines.push(` ${result.stats.summaries} summaries`);
73
+ lines.push(` ${result.stats.pins} pins`);
74
+ return lines.join('\n');
75
+ }
76
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/opencode/commands/export.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * /memory forget command
3
+ *
4
+ * Redacts observations to protect privacy
5
+ */
6
+ import type { ID } from '@eddacraft/kindling-core';
7
+ /**
8
+ * Store interface for forget command
9
+ */
10
+ export interface ForgetStore {
11
+ redactObservation(id: ID): void;
12
+ getObservationById(id: ID): {
13
+ id: ID;
14
+ redacted: boolean;
15
+ } | undefined;
16
+ }
17
+ /**
18
+ * Forget options
19
+ */
20
+ export interface ForgetOptions {
21
+ /** ID of observation to forget */
22
+ observationId: ID;
23
+ }
24
+ /**
25
+ * Forget result
26
+ */
27
+ export interface ForgetResult {
28
+ /** Observation ID */
29
+ observationId: ID;
30
+ /** Whether observation was redacted */
31
+ redacted: boolean;
32
+ /** Error if any */
33
+ error?: string;
34
+ }
35
+ /**
36
+ * Execute /memory forget command
37
+ *
38
+ * @param store - Forget store
39
+ * @param options - Forget options
40
+ * @returns Forget result
41
+ */
42
+ export declare function memoryForget(store: ForgetStore, options: ForgetOptions): ForgetResult;
43
+ /**
44
+ * Format forget result as human-readable text
45
+ *
46
+ * @param result - Forget result
47
+ * @returns Formatted forget result
48
+ */
49
+ export declare function formatForgetResult(result: ForgetResult): string;
50
+ //# sourceMappingURL=forget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forget.d.ts","sourceRoot":"","sources":["../../../src/opencode/commands/forget.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iBAAiB,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAChC,kBAAkB,CAAC,EAAE,EAAE,EAAE,GAAG;QAAE,EAAE,EAAE,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,aAAa,EAAE,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,aAAa,EAAE,EAAE,CAAC;IAClB,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,YAAY,CAsCrF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAU/D"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * /memory forget command
3
+ *
4
+ * Redacts observations to protect privacy
5
+ */
6
+ /**
7
+ * Execute /memory forget command
8
+ *
9
+ * @param store - Forget store
10
+ * @param options - Forget options
11
+ * @returns Forget result
12
+ */
13
+ export function memoryForget(store, options) {
14
+ const { observationId } = options;
15
+ // Verify observation exists
16
+ const observation = store.getObservationById(observationId);
17
+ if (!observation) {
18
+ return {
19
+ observationId,
20
+ redacted: false,
21
+ error: `Observation ${observationId} not found`,
22
+ };
23
+ }
24
+ // Check if already redacted
25
+ if (observation.redacted) {
26
+ return {
27
+ observationId,
28
+ redacted: true,
29
+ error: 'Observation already redacted',
30
+ };
31
+ }
32
+ // Redact observation
33
+ try {
34
+ store.redactObservation(observationId);
35
+ return {
36
+ observationId,
37
+ redacted: true,
38
+ };
39
+ }
40
+ catch (err) {
41
+ return {
42
+ observationId,
43
+ redacted: false,
44
+ error: err instanceof Error ? err.message : 'Unknown error',
45
+ };
46
+ }
47
+ }
48
+ /**
49
+ * Format forget result as human-readable text
50
+ *
51
+ * @param result - Forget result
52
+ * @returns Formatted forget result
53
+ */
54
+ export function formatForgetResult(result) {
55
+ if (result.error && !result.redacted) {
56
+ return `❌ Failed to redact: ${result.error}`;
57
+ }
58
+ if (result.error && result.redacted) {
59
+ return `⚠️ ${result.error}`;
60
+ }
61
+ return `🗑️ Redacted observation ${result.observationId}`;
62
+ }
63
+ //# sourceMappingURL=forget.js.map