@agentuity/opencode 0.1.37 → 0.1.38
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/dist/agents/memory.d.ts +1 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +170 -93
- package/dist/agents/memory.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/hooks/cadence.d.ts +14 -2
- package/dist/plugin/hooks/cadence.d.ts.map +1 -1
- package/dist/plugin/hooks/cadence.js +60 -28
- package/dist/plugin/hooks/cadence.js.map +1 -1
- package/dist/plugin/hooks/keyword.d.ts +3 -2
- package/dist/plugin/hooks/keyword.d.ts.map +1 -1
- package/dist/plugin/hooks/keyword.js.map +1 -1
- package/dist/plugin/hooks/params.d.ts +3 -2
- package/dist/plugin/hooks/params.d.ts.map +1 -1
- package/dist/plugin/hooks/params.js +5 -2
- package/dist/plugin/hooks/params.js.map +1 -1
- package/dist/plugin/hooks/session-memory.d.ts +25 -0
- package/dist/plugin/hooks/session-memory.d.ts.map +1 -0
- package/dist/plugin/hooks/session-memory.js +111 -0
- package/dist/plugin/hooks/session-memory.js.map +1 -0
- package/dist/plugin/hooks/session.d.ts +3 -2
- package/dist/plugin/hooks/session.d.ts.map +1 -1
- package/dist/plugin/hooks/session.js.map +1 -1
- package/dist/plugin/hooks/tools.d.ts +3 -2
- package/dist/plugin/hooks/tools.d.ts.map +1 -1
- package/dist/plugin/hooks/tools.js +5 -2
- package/dist/plugin/hooks/tools.js.map +1 -1
- package/dist/plugin/plugin.d.ts +2 -2
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +41 -3
- package/dist/plugin/plugin.js.map +1 -1
- package/dist/types.d.ts +1 -61
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +4 -3
- package/src/agents/memory.ts +170 -93
- package/src/index.ts +3 -3
- package/src/plugin/hooks/cadence.ts +71 -32
- package/src/plugin/hooks/keyword.ts +3 -2
- package/src/plugin/hooks/params.ts +8 -4
- package/src/plugin/hooks/session-memory.ts +137 -0
- package/src/plugin/hooks/session.ts +3 -2
- package/src/plugin/hooks/tools.ts +12 -5
- package/src/plugin/plugin.ts +51 -7
- package/src/types.ts +10 -54
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export type { Plugin, PluginInput, Hooks as PluginHooks, ToolDefinition, } from '@opencode-ai/plugin';
|
|
2
3
|
export declare const AgentRoleSchema: z.ZodEnum<{
|
|
3
4
|
lead: "lead";
|
|
4
5
|
scout: "scout";
|
|
@@ -123,62 +124,6 @@ export interface McpConfig {
|
|
|
123
124
|
enabled: boolean;
|
|
124
125
|
headers?: Record<string, string>;
|
|
125
126
|
}
|
|
126
|
-
export interface PluginClient {
|
|
127
|
-
app: {
|
|
128
|
-
log: (options: {
|
|
129
|
-
body: {
|
|
130
|
-
service: string;
|
|
131
|
-
level: string;
|
|
132
|
-
message: string;
|
|
133
|
-
extra?: unknown;
|
|
134
|
-
};
|
|
135
|
-
}) => void;
|
|
136
|
-
};
|
|
137
|
-
tui?: {
|
|
138
|
-
showToast?: (options: {
|
|
139
|
-
body: {
|
|
140
|
-
message: string;
|
|
141
|
-
};
|
|
142
|
-
}) => void;
|
|
143
|
-
};
|
|
144
|
-
session?: {
|
|
145
|
-
prompt?: (options: {
|
|
146
|
-
path: {
|
|
147
|
-
id: string;
|
|
148
|
-
};
|
|
149
|
-
body: {
|
|
150
|
-
parts: Array<{
|
|
151
|
-
type: 'text';
|
|
152
|
-
text: string;
|
|
153
|
-
}>;
|
|
154
|
-
agent?: string;
|
|
155
|
-
};
|
|
156
|
-
noReply?: boolean;
|
|
157
|
-
}) => Promise<unknown>;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
export interface PluginContext {
|
|
161
|
-
directory: string;
|
|
162
|
-
client: PluginClient;
|
|
163
|
-
}
|
|
164
|
-
export interface CompactingInput {
|
|
165
|
-
sessionID: string;
|
|
166
|
-
}
|
|
167
|
-
export interface CompactingOutput {
|
|
168
|
-
context: string[];
|
|
169
|
-
prompt?: string;
|
|
170
|
-
}
|
|
171
|
-
export interface PluginHooks {
|
|
172
|
-
agents?: Record<string, AgentConfig>;
|
|
173
|
-
tool?: Record<string, unknown>;
|
|
174
|
-
config?: (config: Record<string, unknown>) => Promise<void>;
|
|
175
|
-
'chat.message'?: (input: unknown, output: unknown) => Promise<void>;
|
|
176
|
-
'chat.params'?: (input: unknown, output: unknown) => Promise<void>;
|
|
177
|
-
'tool.execute.before'?: (input: unknown, output: unknown) => Promise<void>;
|
|
178
|
-
'tool.execute.after'?: (input: unknown, output: unknown) => Promise<void>;
|
|
179
|
-
event?: (input: unknown) => Promise<void>;
|
|
180
|
-
'experimental.session.compacting'?: (input: CompactingInput, output: CompactingOutput) => Promise<void>;
|
|
181
|
-
}
|
|
182
127
|
export interface CommandDefinition {
|
|
183
128
|
name: string;
|
|
184
129
|
description?: string;
|
|
@@ -189,9 +134,4 @@ export interface CommandDefinition {
|
|
|
189
134
|
/** Force command to run as subagent for context isolation */
|
|
190
135
|
subtask?: boolean;
|
|
191
136
|
}
|
|
192
|
-
export interface ToolDefinition {
|
|
193
|
-
description: string;
|
|
194
|
-
args: unknown;
|
|
195
|
-
execute: (args: unknown, context: unknown) => Promise<unknown>;
|
|
196
|
-
}
|
|
197
137
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CA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E,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;iBAa5B,CAAC;AAEH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAID,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGpG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,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5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"description": "Agentuity Open Code plugin with specialized AI coding agents",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"prepublishOnly": "bun run clean && bun run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@agentuity/core": "0.1.
|
|
43
|
+
"@agentuity/core": "0.1.38",
|
|
44
|
+
"@opencode-ai/plugin": "^1.1.36",
|
|
44
45
|
"zod": "^4.3.5"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@agentuity/test-utils": "0.1.
|
|
48
|
+
"@agentuity/test-utils": "0.1.38",
|
|
48
49
|
"@types/bun": "latest",
|
|
49
50
|
"bun-types": "latest",
|
|
50
51
|
"typescript": "^5.9.0"
|
package/src/agents/memory.ts
CHANGED
|
@@ -49,6 +49,97 @@ You are the **librarian, archivist, and curator** of the Agentuity Coder team. Y
|
|
|
49
49
|
|
|
50
50
|
---
|
|
51
51
|
|
|
52
|
+
## Unified Session Record Structure
|
|
53
|
+
|
|
54
|
+
All sessions (Cadence and non-Cadence) use the same unified structure in KV:
|
|
55
|
+
|
|
56
|
+
### Session Record Schema
|
|
57
|
+
|
|
58
|
+
\`\`\`bash
|
|
59
|
+
# Key: session:{sessionId} in agentuity-opencode-memory
|
|
60
|
+
{
|
|
61
|
+
"sessionId": "ses_xxx",
|
|
62
|
+
"projectLabel": "github.com/acme/repo",
|
|
63
|
+
"createdAt": "2026-01-27T09:00:00Z",
|
|
64
|
+
"updatedAt": "2026-01-27T13:00:00Z",
|
|
65
|
+
|
|
66
|
+
# Session summary (from /agentuity-memory-save or memorialization)
|
|
67
|
+
"title": "Feature implementation",
|
|
68
|
+
"summary": "Overall session summary...",
|
|
69
|
+
"decisions": [
|
|
70
|
+
{ "decision": "Use X approach", "why": "Because Y" }
|
|
71
|
+
],
|
|
72
|
+
"corrections": [
|
|
73
|
+
{ "correction": "Don't do X", "why": "User corrected", "confidence": "high" }
|
|
74
|
+
],
|
|
75
|
+
"files": ["src/foo.ts", "src/bar.ts"],
|
|
76
|
+
|
|
77
|
+
# Rolling compaction history (appended on each compaction)
|
|
78
|
+
"compactions": [
|
|
79
|
+
{ "timestamp": "2026-01-27T10:00:00Z", "summary": "First compaction..." },
|
|
80
|
+
{ "timestamp": "2026-01-27T11:30:00Z", "summary": "Second compaction..." }
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
# Cadence-specific (only present if Cadence mode)
|
|
84
|
+
"cadence": {
|
|
85
|
+
"loopId": "lp_xxx",
|
|
86
|
+
"status": "active", // "active" | "completed" | "cancelled"
|
|
87
|
+
"startedAt": "2026-01-27T09:00:00Z",
|
|
88
|
+
"iteration": 5,
|
|
89
|
+
"maxIterations": 50,
|
|
90
|
+
"checkpoints": [
|
|
91
|
+
{ "iteration": 1, "timestamp": "...", "summary": "..." },
|
|
92
|
+
{ "iteration": 3, "timestamp": "...", "summary": "..." }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
### Adding a Compaction (Most Common Operation)
|
|
99
|
+
|
|
100
|
+
When Lead says "save this compaction summary":
|
|
101
|
+
|
|
102
|
+
1. **Fetch** existing session:
|
|
103
|
+
\`\`\`bash
|
|
104
|
+
agentuity cloud kv get agentuity-opencode-memory "session:{sessionId}" --json --region use
|
|
105
|
+
\`\`\`
|
|
106
|
+
|
|
107
|
+
2. **If not exists**, create new session record with basic fields
|
|
108
|
+
|
|
109
|
+
3. **Append** to \`compactions\` array:
|
|
110
|
+
\`\`\`json
|
|
111
|
+
{ "timestamp": "2026-01-27T10:00:00Z", "summary": "The compaction summary text from above..." }
|
|
112
|
+
\`\`\`
|
|
113
|
+
|
|
114
|
+
4. **Update** \`updatedAt\` timestamp
|
|
115
|
+
|
|
116
|
+
5. **For Cadence sessions**, also ensure \`cadence\` object is present and updated
|
|
117
|
+
|
|
118
|
+
6. **Save** back to KV:
|
|
119
|
+
\`\`\`bash
|
|
120
|
+
agentuity cloud kv set agentuity-opencode-memory "session:{sessionId}" '{...}' --region use
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
7. **Upsert FULL document to Vector** for semantic search:
|
|
124
|
+
\`\`\`bash
|
|
125
|
+
agentuity cloud vector upsert agentuity-opencode-sessions "session:{sessionId}" \\
|
|
126
|
+
--document "<full formatted document>" \\
|
|
127
|
+
--metadata '{"sessionId":"...","projectLabel":"..."}' --region use
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
**IMPORTANT:** Format the full session record as a readable markdown document for \`--document\`. Include ALL content: title, project, summary, every decision, every file, and every compaction summary. This enables semantic search across all session details. Do NOT use a condensed one-liner.
|
|
131
|
+
|
|
132
|
+
### Compactions vs Cadence Checkpoints
|
|
133
|
+
|
|
134
|
+
| Type | Trigger | Purpose |
|
|
135
|
+
|------|---------|---------|
|
|
136
|
+
| \`compactions[]\` | Token limit (OpenCode) | Context window management |
|
|
137
|
+
| \`cadence.checkpoints[]\` | Iteration boundary | Loop progress tracking |
|
|
138
|
+
|
|
139
|
+
Both arrays grow over time within the same session record.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
52
143
|
## Project Identification
|
|
53
144
|
|
|
54
145
|
Projects may be identified by (use best available):
|
|
@@ -95,11 +186,19 @@ agentuity cloud kv delete agentuity-opencode-memory "pattern:auth-flow"
|
|
|
95
186
|
|
|
96
187
|
## Vector Storage Commands
|
|
97
188
|
|
|
189
|
+
**CRITICAL: Vector documents must be FULL content, not summaries.**
|
|
190
|
+
|
|
191
|
+
The \`--document\` parameter is what gets embedded for semantic search. Format the complete session record as a readable markdown document so searches can match against any detail (decisions, file names, compaction summaries, corrections, etc.).
|
|
192
|
+
|
|
193
|
+
❌ WRONG: \`--document "Implemented auth feature. Tests pass."\`
|
|
194
|
+
✅ RIGHT: Full markdown document with title, project, summary, all decisions, all files, all compactions
|
|
195
|
+
|
|
98
196
|
\`\`\`bash
|
|
99
197
|
# Upsert a session memory (semantic searchable)
|
|
100
198
|
# Note: metadata values must be string, boolean, or number (not arrays - use pipe-delimited strings)
|
|
199
|
+
# IMPORTANT: Format the full session record as a readable markdown document for --document
|
|
101
200
|
agentuity cloud vector upsert agentuity-opencode-sessions "session:ses_abc123" \\
|
|
102
|
-
--document "
|
|
201
|
+
--document "<full formatted markdown document with all session content>" \\
|
|
103
202
|
--metadata '{"sessionId":"ses_abc123","projectLabel":"github.com/org/repo","importance":"high","hasCorrections":"true","files":"src/a.ts|src/b.ts"}'
|
|
104
203
|
|
|
105
204
|
# Semantic search for past sessions
|
|
@@ -255,10 +354,11 @@ Agents Involved: {Lead, Scout, Builder, etc.}
|
|
|
255
354
|
1. Extract key information from the session
|
|
256
355
|
2. Build summary using the template above
|
|
257
356
|
3. **Identify corrections/mistakes** — these are high-value
|
|
258
|
-
4. Upsert to Vector:
|
|
357
|
+
4. **Upsert FULL document to Vector** (not a condensed summary):
|
|
259
358
|
\`\`\`bash
|
|
359
|
+
# Build the full document with ALL session content
|
|
260
360
|
agentuity cloud vector upsert agentuity-opencode-sessions "session:{sessionId}" \\
|
|
261
|
-
--document "{summary text}" \\
|
|
361
|
+
--document "{FULL summary text - include all sections: PROBLEM, CONTEXT, DECISIONS, CORRECTIONS, SOLUTIONS, PATTERNS, FILES, TOOLS, OPEN QUESTIONS}" \\
|
|
262
362
|
--metadata '{...}'
|
|
263
363
|
\`\`\`
|
|
264
364
|
5. Store session pointer in KV:
|
|
@@ -420,12 +520,19 @@ The metadata is for filtering/search. The document is for **reading and reasonin
|
|
|
420
520
|
|
|
421
521
|
When working with Cadence (long-running loops), you provide specialized support for context management across iterations.
|
|
422
522
|
|
|
523
|
+
**IMPORTANT:** Cadence sessions use the **unified session record structure** (see above). All data is stored in \`session:{sessionId}\` with a \`cadence\` object for Cadence-specific state.
|
|
524
|
+
|
|
423
525
|
### Iteration Checkpoints
|
|
424
526
|
|
|
425
|
-
When Lead asks "Store checkpoint for iteration {N}",
|
|
527
|
+
When Lead asks "Store checkpoint for iteration {N}", add to the session's \`cadence.checkpoints\` array:
|
|
426
528
|
|
|
427
529
|
\`\`\`bash
|
|
428
|
-
|
|
530
|
+
# First, get the existing session record
|
|
531
|
+
agentuity cloud kv get agentuity-opencode-memory "session:{sessionId}" --json --region use
|
|
532
|
+
|
|
533
|
+
# Then update the cadence.checkpoints array and save back
|
|
534
|
+
# The checkpoint entry:
|
|
535
|
+
{
|
|
429
536
|
"iteration": 3,
|
|
430
537
|
"timestamp": "...",
|
|
431
538
|
"summary": "Implemented auth service, tests passing",
|
|
@@ -433,7 +540,7 @@ agentuity cloud kv set agentuity-opencode-tasks "loop:{loopId}:checkpoint:{itera
|
|
|
433
540
|
"nextStep": "Add frontend login form",
|
|
434
541
|
"blockers": [],
|
|
435
542
|
"corrections": ["Use bcrypt not md5 for password hashing"]
|
|
436
|
-
}
|
|
543
|
+
}
|
|
437
544
|
\`\`\`
|
|
438
545
|
|
|
439
546
|
Keep checkpoints **brief** (10-30 lines max). Focus on:
|
|
@@ -446,9 +553,11 @@ Keep checkpoints **brief** (10-30 lines max). Focus on:
|
|
|
446
553
|
|
|
447
554
|
When Lead asks "Any context for iteration {N}?":
|
|
448
555
|
|
|
449
|
-
1. Get the
|
|
450
|
-
2.
|
|
451
|
-
3.
|
|
556
|
+
1. Get the session record: \`agentuity cloud kv get agentuity-opencode-memory "session:{sessionId}" --json --region use\`
|
|
557
|
+
2. Look at the last 2-3 entries in \`cadence.checkpoints\`
|
|
558
|
+
3. Check \`compactions\` array for recent compaction summaries
|
|
559
|
+
4. Get any corrections relevant to the next step
|
|
560
|
+
5. Return a focused summary, not the full history
|
|
452
561
|
|
|
453
562
|
Example response:
|
|
454
563
|
\`\`\`markdown
|
|
@@ -473,116 +582,84 @@ Add frontend login form
|
|
|
473
582
|
|
|
474
583
|
When Lead says "context is getting heavy" or asks for a "handoff packet":
|
|
475
584
|
|
|
476
|
-
Create a condensed summary
|
|
585
|
+
Create a condensed summary in the session record's \`summary\` field:
|
|
477
586
|
|
|
478
587
|
\`\`\`bash
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
588
|
+
# Update the session record with handoff summary
|
|
589
|
+
agentuity cloud kv get agentuity-opencode-memory "session:{sessionId}" --json --region use
|
|
590
|
+
|
|
591
|
+
# Update these fields:
|
|
592
|
+
{
|
|
483
593
|
"summary": "Payment integration project. Stripe API integrated, checkout flow 80% complete.",
|
|
484
|
-
"
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
"Using Stripe Checkout for simplicity",
|
|
488
|
-
"Webhook handler in /api/webhooks/stripe"
|
|
594
|
+
"decisions": [
|
|
595
|
+
{"decision": "Using Stripe Checkout", "why": "Simpler than custom flow, handles PCI compliance"},
|
|
596
|
+
{"decision": "Webhook handler in /api/webhooks/stripe", "why": "Standard pattern"}
|
|
489
597
|
],
|
|
490
598
|
"corrections": [
|
|
491
|
-
"Use bcrypt for passwords",
|
|
492
|
-
"Sandbox working dir is /home/agentuity not /app"
|
|
493
|
-
],
|
|
494
|
-
"nextActions": [
|
|
495
|
-
"Complete checkout form component",
|
|
496
|
-
"Add error handling UI"
|
|
599
|
+
{"correction": "Use bcrypt for passwords", "why": "Security requirement", "confidence": "high"},
|
|
600
|
+
{"correction": "Sandbox working dir is /home/agentuity not /app", "why": "Commands fail otherwise", "confidence": "high"}
|
|
497
601
|
],
|
|
498
|
-
"
|
|
499
|
-
"
|
|
500
|
-
"
|
|
602
|
+
"cadence": {
|
|
603
|
+
"loopId": "lp_...",
|
|
604
|
+
"status": "active",
|
|
605
|
+
"iteration": 10,
|
|
606
|
+
"maxIterations": 50,
|
|
607
|
+
"currentPhase": "frontend",
|
|
608
|
+
"completedPhases": ["research", "backend", "tests"],
|
|
609
|
+
"nextActions": ["Complete checkout form component", "Add error handling UI"],
|
|
610
|
+
"checkpoints": [...]
|
|
501
611
|
}
|
|
502
|
-
}
|
|
612
|
+
}
|
|
503
613
|
\`\`\`
|
|
504
614
|
|
|
505
615
|
A handoff packet should contain everything needed to resume work without the original conversation history.
|
|
506
616
|
|
|
507
|
-
### Compaction
|
|
617
|
+
### Compaction Handling
|
|
508
618
|
|
|
509
|
-
When
|
|
619
|
+
When Lead says "save this compaction summary" (triggered automatically after OpenCode compacts):
|
|
510
620
|
|
|
511
|
-
**
|
|
512
|
-
- Capture as much detail as possible so future questions can reference it
|
|
513
|
-
- Enable the session to continue seamlessly after compaction
|
|
514
|
-
- Preserve the "why" behind decisions, not just the "what"
|
|
621
|
+
1. **Get** the session record: \`agentuity cloud kv get agentuity-opencode-memory "session:{sessionId}" --json --region use\`
|
|
515
622
|
|
|
516
|
-
**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
"iteration": 15,
|
|
524
|
-
"currentPhase": "frontend",
|
|
525
|
-
|
|
526
|
-
"summary": "Detailed summary of what has been accomplished so far...",
|
|
527
|
-
|
|
528
|
-
"keyDecisions": [
|
|
529
|
-
{"decision": "Use Stripe Checkout", "rationale": "Simpler than custom flow, handles PCI compliance"},
|
|
530
|
-
{"decision": "JWT in httpOnly cookies", "rationale": "More secure than localStorage"}
|
|
531
|
-
],
|
|
532
|
-
|
|
533
|
-
"corrections": [
|
|
534
|
-
{"correction": "Sandbox path is /home/agentuity not /app", "context": "Commands were failing"},
|
|
535
|
-
{"correction": "Use bcrypt not md5", "context": "Security requirement"}
|
|
536
|
-
],
|
|
537
|
-
|
|
538
|
-
"codeChanges": [
|
|
539
|
-
{"file": "src/payments/stripe.ts", "change": "Created payment service with createCheckout, handleWebhook"},
|
|
540
|
-
{"file": "src/api/webhooks/stripe.ts", "change": "Added webhook endpoint with signature verification"}
|
|
541
|
-
],
|
|
542
|
-
|
|
543
|
-
"pendingWork": [
|
|
544
|
-
"Complete checkout form component",
|
|
545
|
-
"Add error handling UI",
|
|
546
|
-
"Write integration tests"
|
|
547
|
-
],
|
|
548
|
-
|
|
549
|
-
"contextNotes": [
|
|
550
|
-
"User prefers minimal dependencies",
|
|
551
|
-
"Project uses Tailwind CSS",
|
|
552
|
-
"Tests should use vitest"
|
|
553
|
-
],
|
|
554
|
-
|
|
555
|
-
"filesInScope": ["src/payments/", "src/api/webhooks/", "src/components/checkout/"],
|
|
556
|
-
|
|
557
|
-
"nextAction": "Implement CheckoutForm.tsx component with Stripe Elements"
|
|
558
|
-
}'
|
|
559
|
-
\`\`\`
|
|
623
|
+
2. **Append** to the \`compactions\` array:
|
|
624
|
+
\`\`\`json
|
|
625
|
+
{
|
|
626
|
+
"timestamp": "2026-01-27T10:00:00Z",
|
|
627
|
+
"summary": "The compaction summary text from the context above..."
|
|
628
|
+
}
|
|
629
|
+
\`\`\`
|
|
560
630
|
|
|
561
|
-
**
|
|
631
|
+
3. **For Cadence sessions**, also update the \`cadence\` object:
|
|
632
|
+
- Update \`iteration\` to current value
|
|
633
|
+
- Update \`status\` if changed
|
|
634
|
+
- Optionally add to \`checkpoints\` if at iteration boundary
|
|
562
635
|
|
|
563
|
-
|
|
564
|
-
agentuity cloud vector upsert agentuity-opencode-sessions "compaction:{loopId}:{N}" \\
|
|
565
|
-
--document "Compaction snapshot for loop {loopId} at iteration {iteration}. [Full prose summary of work done, decisions made, patterns used, corrections learned, and what comes next. Be comprehensive - this is the canonical record of this phase of work.]" \\
|
|
566
|
-
--metadata '{"type":"compaction","loopId":"lp_...","iteration":"15","phase":"frontend"}'
|
|
567
|
-
\`\`\`
|
|
636
|
+
4. **Save** back to KV and **upsert** to Vector
|
|
568
637
|
|
|
569
638
|
**When answering questions about previous compaction cycles:**
|
|
570
|
-
1.
|
|
571
|
-
2. Search Vector for
|
|
639
|
+
1. Get the session record and look at the \`compactions\` array
|
|
640
|
+
2. Search Vector for the session to find semantic summaries
|
|
572
641
|
3. Combine findings to provide comprehensive context
|
|
573
642
|
|
|
574
643
|
### Cadence Loop Completion
|
|
575
644
|
|
|
576
645
|
When a Cadence loop completes (Lead outputs \`<promise>DONE</promise>\`):
|
|
577
646
|
|
|
578
|
-
1.
|
|
579
|
-
|
|
647
|
+
1. Update the session record:
|
|
648
|
+
- Set \`cadence.status\` to \`"completed"\`
|
|
649
|
+
- Add final checkpoint to \`cadence.checkpoints\`
|
|
650
|
+
- Update \`summary\` with completion summary
|
|
651
|
+
|
|
652
|
+
2. **Upsert FULL session document to Vector** (not just a one-liner):
|
|
580
653
|
\`\`\`bash
|
|
581
|
-
agentuity cloud vector upsert agentuity-opencode-sessions "
|
|
582
|
-
--document "
|
|
583
|
-
--metadata '{"loopId":"lp_...","iterations":"15","classification":"feature"}'
|
|
654
|
+
agentuity cloud vector upsert agentuity-opencode-sessions "session:{sessionId}" \\
|
|
655
|
+
--document "<full formatted markdown document with all session content including cadence state>" \\
|
|
656
|
+
--metadata '{"sessionId":"...","loopId":"lp_...","iterations":"15","classification":"feature","cadenceStatus":"completed"}' \\
|
|
657
|
+
--region use
|
|
584
658
|
\`\`\`
|
|
585
|
-
|
|
659
|
+
|
|
660
|
+
Format the full session record as a readable markdown document. Include: title, project, summary, all decisions, all files, all compactions, and all cadence checkpoints.
|
|
661
|
+
|
|
662
|
+
3. The session record remains in KV for future reference (no cleanup needed)
|
|
586
663
|
|
|
587
664
|
---
|
|
588
665
|
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createCoderPlugin } from './plugin/plugin';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginInput, PluginHooks } from './types';
|
|
3
3
|
|
|
4
4
|
// NOTE: Do NOT export functions from main index.ts!
|
|
5
5
|
// OpenCode treats ALL exports as plugin instances and calls them.
|
|
6
6
|
// Only the default export should be a function.
|
|
7
7
|
|
|
8
8
|
// Re-export types only (not functions)
|
|
9
|
-
export type {
|
|
9
|
+
export type { PluginInput, PluginHooks } from './types';
|
|
10
10
|
export type {
|
|
11
11
|
AgentRole,
|
|
12
12
|
AgentConfig,
|
|
@@ -17,7 +17,7 @@ export type {
|
|
|
17
17
|
TaskStatus,
|
|
18
18
|
} from './types';
|
|
19
19
|
|
|
20
|
-
const Coder = async (ctx:
|
|
20
|
+
const Coder = async (ctx: PluginInput): Promise<PluginHooks> => {
|
|
21
21
|
return createCoderPlugin(ctx);
|
|
22
22
|
};
|
|
23
23
|
|