ostacky 0.7.4 → 0.8.1
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/README.md +62 -27
- package/assets/agents/ostacky.md +45 -512
- package/assets/commands/install-stack.md +2 -2
- package/assets/docs/engram-protocol.md +79 -0
- package/assets/docs/ostacky-reference.md +79 -0
- package/assets/mcp/ostacky-controller/index.js +169 -69
- package/assets/mcp/ostacky-controller/package.json +1 -1
- package/assets/plugins/engram.ts +47 -79
- package/assets/plugins/ostacky-plugin.ts +694 -0
- package/assets/skills/brainstorming/SKILL.md +14 -14
- package/assets/skills/execution-mode-evaluation/SKILL.md +9 -9
- package/dist/cli.js +388 -106
- package/manifest.json +30 -30
- package/package.json +1 -1
- package/assets/plugins/ostacky-guard.ts +0 -212
package/assets/plugins/engram.ts
CHANGED
|
@@ -54,86 +54,17 @@ const ENGRAM_TOOLS = new Set([
|
|
|
54
54
|
])
|
|
55
55
|
|
|
56
56
|
// ─── Memory Instructions ─────────────────────────────────────────────────────
|
|
57
|
-
//
|
|
57
|
+
// Lazy: full protocol lives in assets/docs/engram-protocol.md (on-demand via Read).
|
|
58
|
+
// System injects only pointer + nudge, not full 1.2k. Source-of-truth: src/tiered.ts for isTrivial.
|
|
58
59
|
|
|
59
|
-
const
|
|
60
|
+
const MEMORY_POINTER = "Engram disponible — para formato mem_save/mem_search lee assets/docs/engram-protocol.md (on-demand). Usa mem_search proactivamente si el tema pudo verse antes."
|
|
61
|
+
const MEMORY_INSTRUCTIONS_LAZY = `## Engram — pointer (lazy)
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
${MEMORY_POINTER}
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- Bug fix completed
|
|
67
|
-
- Architecture or design decision made
|
|
68
|
-
- Non-obvious discovery about the codebase
|
|
69
|
-
- Configuration change or environment setup
|
|
70
|
-
- Pattern established (naming, structure, convention)
|
|
71
|
-
- User preference or constraint learned
|
|
72
|
-
|
|
73
|
-
Format for \`mem_save\`:
|
|
74
|
-
- **title**: Verb + what — short, searchable (e.g. "Fixed N+1 query in UserList", "Chose Zustand over Redux")
|
|
75
|
-
- **type**: bugfix | decision | architecture | discovery | pattern | config | preference
|
|
76
|
-
- **scope**: \`project\` (default) | \`personal\`
|
|
77
|
-
- **topic_key** (optional, recommended for evolving decisions): stable key like \`architecture/auth-model\`
|
|
78
|
-
- **content**:
|
|
79
|
-
**What**: One sentence — what was done
|
|
80
|
-
**Why**: What motivated it (user request, bug, performance, etc.)
|
|
81
|
-
**Where**: Files or paths affected
|
|
82
|
-
**Learned**: Gotchas, edge cases, things that surprised you (omit if none)
|
|
83
|
-
|
|
84
|
-
Topic rules:
|
|
85
|
-
- Different topics must not overwrite each other (e.g. architecture vs bugfix)
|
|
86
|
-
- Reuse the same \`topic_key\` to update an evolving topic instead of creating new observations
|
|
87
|
-
- If unsure about the key, call \`mem_suggest_topic_key\` first and then reuse it
|
|
88
|
-
- Use \`mem_update\` when you have an exact observation ID to correct
|
|
89
|
-
|
|
90
|
-
### WHEN TO SEARCH MEMORY
|
|
91
|
-
|
|
92
|
-
When the user asks to recall something — any variation of "remember", "recall", "what did we do",
|
|
93
|
-
"how did we solve", or the equivalent in the user's language, or references to past work:
|
|
94
|
-
1. First call \`mem_context\` — checks recent session history (fast, cheap)
|
|
95
|
-
2. If not found, call \`mem_search\` with relevant keywords (FTS5 full-text search)
|
|
96
|
-
3. If you find a match, use \`mem_get_observation\` for full untruncated content
|
|
97
|
-
|
|
98
|
-
Also search memory PROACTIVELY when:
|
|
99
|
-
- Starting work on something that might have been done before
|
|
100
|
-
- The user mentions a topic you have no context on — check if past sessions covered it
|
|
101
|
-
- The user's FIRST message references the project, a feature, or a problem — call \`mem_search\` with keywords from their message to check for prior work before responding
|
|
102
|
-
|
|
103
|
-
### SESSION CLOSE PROTOCOL (mandatory)
|
|
104
|
-
|
|
105
|
-
Before ending a session or saying "done" / "that's it", you MUST:
|
|
106
|
-
1. Call \`mem_session_summary\` with this structure:
|
|
107
|
-
|
|
108
|
-
## Goal
|
|
109
|
-
[What we were working on this session]
|
|
110
|
-
|
|
111
|
-
## Instructions
|
|
112
|
-
[User preferences or constraints discovered — skip if none]
|
|
113
|
-
|
|
114
|
-
## Discoveries
|
|
115
|
-
- [Technical findings, gotchas, non-obvious learnings]
|
|
116
|
-
|
|
117
|
-
## Accomplished
|
|
118
|
-
- [Completed items with key details]
|
|
119
|
-
|
|
120
|
-
## Next Steps
|
|
121
|
-
- [What remains to be done — for the next session]
|
|
122
|
-
|
|
123
|
-
## Relevant Files
|
|
124
|
-
- path/to/file — [what it does or what changed]
|
|
125
|
-
|
|
126
|
-
This is NOT optional. If you skip this, the next session starts blind.
|
|
127
|
-
|
|
128
|
-
### AFTER COMPACTION
|
|
129
|
-
|
|
130
|
-
If you see a message about compaction or context reset, or if you see "FIRST ACTION REQUIRED" in your context:
|
|
131
|
-
1. IMMEDIATELY call \`mem_session_summary\` with the compacted summary content — this persists what was done before compaction
|
|
132
|
-
2. Then call \`mem_context\` to recover any additional context from previous sessions
|
|
133
|
-
3. Only THEN continue working
|
|
134
|
-
|
|
135
|
-
Do not skip step 1. Without it, everything done before compaction is lost from memory.
|
|
136
|
-
`
|
|
65
|
+
Cuando necesites guardar/buscar, lee el protocolo completo con Read. No alucines formato.`
|
|
66
|
+
// Compat: keep full for fallback if file missing — but never inject full in system.transform
|
|
67
|
+
const MEMORY_INSTRUCTIONS = MEMORY_INSTRUCTIONS_LAZY
|
|
137
68
|
|
|
138
69
|
// ─── HTTP Client ─────────────────────────────────────────────────────────────
|
|
139
70
|
|
|
@@ -270,6 +201,26 @@ export const Engram: Plugin = async (ctx) => {
|
|
|
270
201
|
// inflation (e.g. 170 sessions for 1 real conversation, issue #116).
|
|
271
202
|
const subAgentSessions = new Set<string>()
|
|
272
203
|
|
|
204
|
+
// Tiered cache-friendly: single source of truth via src/tiered.ts
|
|
205
|
+
const trivialBySession = new Map<string, boolean>()
|
|
206
|
+
// isTrivial y getControllerState importados lógicamente desde src/tiered.ts
|
|
207
|
+
// Inlined para evitar import dinámico en plugin bundle — mantener regex idéntico a src/tiered.ts
|
|
208
|
+
function isTrivialMessage(msg: string, state: string): boolean {
|
|
209
|
+
if (!msg || state !== "DONE") return false
|
|
210
|
+
if (msg.trim().length >= 30) return false
|
|
211
|
+
if (!/^(hola|hey|gracias|buenas|hi|hello)\b/i.test(msg.trim())) return false
|
|
212
|
+
if (/(necesito|quiero|agregá|fix|bug|feature|auth|spec|implementar)/i.test(msg)) return false
|
|
213
|
+
return true
|
|
214
|
+
}
|
|
215
|
+
function getControllerState(directory: string): string {
|
|
216
|
+
try {
|
|
217
|
+
const statePath = process.env.OSTACKY_STATE_PATH || join(directory, ".opencode", "ostacky-state.json")
|
|
218
|
+
const raw = readFileSync(statePath, "utf-8")
|
|
219
|
+
const j = JSON.parse(raw)
|
|
220
|
+
return j.state ?? "DONE"
|
|
221
|
+
} catch { return "DONE" }
|
|
222
|
+
}
|
|
223
|
+
|
|
273
224
|
/**
|
|
274
225
|
* Ensure a session exists in engram. Idempotent — calls POST /sessions
|
|
275
226
|
* which uses INSERT OR IGNORE. Safe to call multiple times.
|
|
@@ -407,6 +358,12 @@ export const Engram: Plugin = async (ctx) => {
|
|
|
407
358
|
|
|
408
359
|
const finalContent = content || fallback
|
|
409
360
|
|
|
361
|
+
// Tiered: set trivial flag for system.transform lazy
|
|
362
|
+
try {
|
|
363
|
+
const state = getControllerState(ctx.directory)
|
|
364
|
+
trivialBySession.set(sessionId, isTrivialMessage(finalContent, state))
|
|
365
|
+
} catch {}
|
|
366
|
+
|
|
410
367
|
// Only capture non-trivial prompts (>10 chars)
|
|
411
368
|
if (finalContent.length > 10) {
|
|
412
369
|
await ensureSession(sessionId)
|
|
@@ -465,13 +422,24 @@ export const Engram: Plugin = async (ctx) => {
|
|
|
465
422
|
// messages that would break these models. See: GitHub issue #23.
|
|
466
423
|
|
|
467
424
|
"experimental.chat.system.transform": async (input, output) => {
|
|
425
|
+
// Tiered lazy: SIEMPRE pointer (cache-friendly, ~1 línea). Full vive en assets/docs/engram-protocol.md on-demand.
|
|
426
|
+
const sessionId: string = (input as any).sessionID ?? ""
|
|
427
|
+
const isTrivial = trivialBySession.get(sessionId) ?? false
|
|
428
|
+
const state = getControllerState(ctx.directory)
|
|
429
|
+
const shouldBeTrivial = isTrivial && state === "DONE"
|
|
430
|
+
const pointer = shouldBeTrivial
|
|
431
|
+
? "Engram disponible — detalles a demanda (usa mem_search si necesitas recordar)."
|
|
432
|
+
: MEMORY_POINTER
|
|
468
433
|
if (output.system.length > 0) {
|
|
469
|
-
output.system[output.system.length - 1] += "\n\n" +
|
|
434
|
+
output.system[output.system.length - 1] += "\n\n" + pointer
|
|
470
435
|
} else {
|
|
471
|
-
output.system.push(
|
|
436
|
+
output.system.push(pointer)
|
|
472
437
|
}
|
|
438
|
+
// No inyectar MEMORY_INSTRUCTIONS completo nunca — se lee on-demand via Read
|
|
473
439
|
|
|
474
440
|
// ── Save nudge ──────────────────────────────────────────────────────────
|
|
441
|
+
// Skip nudge for trivial greeting (cache-friendly, no extra injection)
|
|
442
|
+
if (shouldBeTrivial) return
|
|
475
443
|
// If it has been a long time since the last mem_save, append a reminder
|
|
476
444
|
// to the system prompt so the agent notices. All fetches are fire-and-
|
|
477
445
|
// forget with short timeouts — any failure silently skips the nudge.
|