@cortexkit/opencode-magic-context 0.8.7 → 0.8.8
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/features/magic-context/dreamer/runner.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +8 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/index.js +72 -37
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA2C3D,UAAU,6BAA6B;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,6BAA6B,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9F;AAMD,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,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= "You are a memory maintenance agent for the magic-context system.\nYou run during scheduled dream windows to maintain a project's cross-session memory store and codebase documentation.\n\n## Available Tools\n\n**Memory operations** (ctx_memory with extended dreamer actions):\n- `action=\"list\"` \u2014 browse all active memories, optionally filter by category\n- `action=\"update\", id=N, content=\"...\"` \u2014 rewrite a memory's content\n- `action=\"merge\", ids=[N,M,...], content=\"...\", category=\"...\"` \u2014 consolidate duplicates into one canonical memory\n- `action=\"archive\", id=N, reason=\"...\"` \u2014 archive a stale memory with provenance\n- `action=\"write\", category=\"...\", content=\"...\"` \u2014 create a new memory\n- `action=\"delete\", id=N` \u2014 permanently remove a memory\n\n**Codebase tools** (standard OpenCode tools):\n- Read files, grep, glob, bash \u2014 for verification against actual code\n\n## Rules\n\n1. **Work methodically.** Decide your own batch size based on the task \u2014 process as many items per round as makes sense.\n2. **Always verify against actual files** before declaring a memory stale or updating it.\n3. **Be conservative with archives.** Only archive when the codebase clearly contradicts the memory.\n4. **Explain reasoning briefly** before each action \u2014 one line is enough.\n5. **Use present-tense operational language** in all memory rewrites. \"X uses Y\" not \"X was changed to use Y.\"\n6. **One rule/fact per memory.** Split compound memories during improvement.\n7. **Never read or quote secrets** from .env, credentials, keys, or similar sensitive files.\n8. **Do not commit changes.** The user handles git operations.";
|
|
3
3
|
export declare function buildConsolidatePrompt(projectPath: string): string;
|
|
4
4
|
export declare function buildVerifyPrompt(projectPath: string): string;
|
|
5
|
-
export declare function buildArchiveStalePrompt(projectPath: string
|
|
5
|
+
export declare function buildArchiveStalePrompt(projectPath: string, userMemories?: Array<{
|
|
6
|
+
id: number;
|
|
7
|
+
content: string;
|
|
8
|
+
}>): string;
|
|
6
9
|
export declare function buildImprovePrompt(projectPath: string): string;
|
|
7
10
|
export declare function buildMaintainDocsPrompt(projectPath: string, lastDreamAt: string | null, existingDocs: {
|
|
8
11
|
architecture: boolean;
|
|
@@ -15,5 +18,9 @@ export declare function buildDreamTaskPrompt(task: DreamingTask, args: {
|
|
|
15
18
|
architecture: boolean;
|
|
16
19
|
structure: boolean;
|
|
17
20
|
};
|
|
21
|
+
userMemories?: Array<{
|
|
22
|
+
id: number;
|
|
23
|
+
content: string;
|
|
24
|
+
}>;
|
|
18
25
|
}): string;
|
|
19
26
|
//# sourceMappingURL=task-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-prompts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIzE,eAAO,MAAM,qBAAqB,wqDAyB6B,CAAC;AAIhE,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA+BlE;AAID,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoC7D;AAID,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"task-prompts.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIzE,eAAO,MAAM,qBAAqB,wqDAyB6B,CAAC;AAIhE,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA+BlE;AAID,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoC7D;AAID,wBAAgB,uBAAuB,CACnC,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACtD,MAAM,CA0ER;AAID,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA0C9D;AAID,wBAAgB,uBAAuB,CACnC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,YAAY,EAA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AAE,EACvB,QAAQ,EAAE,4BAA4B,GACvC,0BAA0B,CAyB5B"}
|
package/dist/index.js
CHANGED
|
@@ -19775,15 +19775,28 @@ ${sections.join(`
|
|
|
19775
19775
|
`)}
|
|
19776
19776
|
</project-memory>`;
|
|
19777
19777
|
}
|
|
19778
|
+
function utilityTier(m) {
|
|
19779
|
+
if (m.retrievalCount > 0)
|
|
19780
|
+
return 0;
|
|
19781
|
+
if (CONSTRAINT_KEYWORDS.test(m.content))
|
|
19782
|
+
return 1;
|
|
19783
|
+
return 2;
|
|
19784
|
+
}
|
|
19778
19785
|
function trimMemoriesToBudget(sessionId, memories, budgetTokens) {
|
|
19779
19786
|
const sorted = [...memories].sort((a, b) => {
|
|
19780
19787
|
if (a.status === "permanent" && b.status !== "permanent")
|
|
19781
19788
|
return -1;
|
|
19782
19789
|
if (b.status === "permanent" && a.status !== "permanent")
|
|
19783
19790
|
return 1;
|
|
19791
|
+
const tierDiff = utilityTier(a) - utilityTier(b);
|
|
19792
|
+
if (tierDiff !== 0)
|
|
19793
|
+
return tierDiff;
|
|
19784
19794
|
const seenDiff = b.seenCount - a.seenCount;
|
|
19785
19795
|
if (seenDiff !== 0)
|
|
19786
19796
|
return seenDiff;
|
|
19797
|
+
const lenDiff = a.content.length - b.content.length;
|
|
19798
|
+
if (lenDiff !== 0)
|
|
19799
|
+
return lenDiff;
|
|
19787
19800
|
return a.id - b.id;
|
|
19788
19801
|
});
|
|
19789
19802
|
const result = [];
|
|
@@ -19917,13 +19930,14 @@ function findFirstTextPart(parts) {
|
|
|
19917
19930
|
function isDroppedPlaceholder(text) {
|
|
19918
19931
|
return /^\[dropped \u00A7\d+\u00A7\]$/.test(text.trim());
|
|
19919
19932
|
}
|
|
19920
|
-
var injectionCache, CHARS_PER_TOKEN_ESTIMATE = 4;
|
|
19933
|
+
var injectionCache, CHARS_PER_TOKEN_ESTIMATE = 4, CONSTRAINT_KEYWORDS;
|
|
19921
19934
|
var init_inject_compartments = __esm(() => {
|
|
19922
19935
|
init_compartment_storage();
|
|
19923
19936
|
init_constants();
|
|
19924
19937
|
init_storage_memory();
|
|
19925
19938
|
init_logger();
|
|
19926
19939
|
injectionCache = new Map;
|
|
19940
|
+
CONSTRAINT_KEYWORDS = /\b(must|never|always|cannot|should not|must not)\b/i;
|
|
19927
19941
|
});
|
|
19928
19942
|
|
|
19929
19943
|
// src/hooks/magic-context/compartment-runner-incremental.ts
|
|
@@ -28469,58 +28483,75 @@ Check verifiable memories against actual repository state. Update stale wording,
|
|
|
28469
28483
|
- No memories reference files or paths that no longer exist.
|
|
28470
28484
|
- Updated memories use current naming and paths.`;
|
|
28471
28485
|
}
|
|
28472
|
-
function buildArchiveStalePrompt(projectPath) {
|
|
28486
|
+
function buildArchiveStalePrompt(projectPath, userMemories) {
|
|
28487
|
+
const userProfileBlock = userMemories && userMemories.length > 0 ? `
|
|
28488
|
+
### Global User Profile (already injected into ALL sessions across ALL projects)
|
|
28489
|
+
These user memories are ALREADY available to the agent globally. Project memories that merely restate the same preference/rule are redundant and should be archived \u2014 but ONLY if the project memory adds ZERO project-specific detail beyond what the global memory already says.
|
|
28490
|
+
|
|
28491
|
+
${userMemories.map((um) => `- [U${um.id}] ${um.content}`).join(`
|
|
28492
|
+
`)}
|
|
28493
|
+
` : "";
|
|
28473
28494
|
return `## Task: Archive Stale Memories
|
|
28474
28495
|
|
|
28475
28496
|
**Project:** ${projectPath}
|
|
28476
28497
|
|
|
28477
28498
|
### Goal
|
|
28478
|
-
Find and archive memories that
|
|
28499
|
+
Find and archive memories that waste the limited injection budget (~6000 tokens, fits ~150 memories).
|
|
28500
|
+
${userProfileBlock}
|
|
28501
|
+
### Archive criteria (archive IF any apply)
|
|
28502
|
+
|
|
28503
|
+
1. **Code restatement without rationale** \u2014 merely describes what code does without explaining WHY or what would break if changed.
|
|
28504
|
+
- Archive: "Tag assignment uses one DB transaction" (obvious from code)
|
|
28505
|
+
- Keep: "Tag assignment uses one DB transaction because tags rows and session_meta.counter must stay in sync" (explains the constraint)
|
|
28506
|
+
|
|
28507
|
+
2. **Redundant with other memories** \u2014 same information expressed differently. Keep the better-worded one.
|
|
28508
|
+
|
|
28509
|
+
3. **Stale implementation detail** \u2014 references specific functions, line numbers, or internal structures that change frequently and are better found by reading code.
|
|
28510
|
+
- Archive: "Function X is called at line 289 of file Y"
|
|
28511
|
+
- Keep: "Feature X requires Y to be initialized before Z" (design constraint)
|
|
28512
|
+
|
|
28513
|
+
4. **Low retrieval signal** \u2014 seen_count=1, retrieval_count=0, and no constraint language. These were promoted once but never needed again.
|
|
28514
|
+
|
|
28515
|
+
5. **Redundant with global user profile** \u2014 ONLY if the project memory adds ZERO project-specific detail beyond what the global memory already says. A project memory that applies a global principle to a specific context (e.g., "cache awareness is highest priority" applies a general principle to THIS project's north star) is NOT redundant \u2014 it narrows the global principle.
|
|
28516
|
+
|
|
28517
|
+
6. **Bare config defaults** \u2014 single-line values like \`enabled=true\` or \`experimental.X=false\` with no surrounding explanation or rationale.
|
|
28518
|
+
|
|
28519
|
+
7. **Completed one-time instructions** \u2014 imperative USER_DIRECTIVES like "Add X", "Create Y", "Publish as Z" where the action has clearly been done.
|
|
28520
|
+
|
|
28521
|
+
### Keep criteria (keep IF ANY apply \u2014 these OVERRIDE archive criteria)
|
|
28522
|
+
|
|
28523
|
+
1. **Contains constraint/rule** \u2014 uses "must", "never", "always", "cannot", "should not". CONSTRAINTS category gets extra protection: only archive if the EXACT same constraint exists word-for-word in another memory.
|
|
28524
|
+
2. **Captures non-obvious design reasoning** \u2014 explains WHY, not just WHAT. Look for "because", "so that", "to prevent", "to avoid".
|
|
28525
|
+
3. **Project-specific behavioral rule** \u2014 even if it sounds generic, if it's in USER_DIRECTIVES it was explicitly stated by the user for this project. Only archive if: (a) the action is clearly completed, or (b) it is 100% identical in scope to a global user memory.
|
|
28526
|
+
4. **Post-failure learning** \u2014 memories that encode lessons learned from real bugs, regressions, or user corrections. These prevent re-encountering the same problem.
|
|
28527
|
+
5. **Environment/path information** \u2014 saves agent from hunting for locations.
|
|
28528
|
+
6. **Config defaults with context** \u2014 prevents wrong assumptions. Archive ONLY bare values with no surrounding explanation.
|
|
28529
|
+
7. **Known issues** \u2014 prevents re-encountering solved problems. NEVER archive KNOWN_ISSUES.
|
|
28530
|
+
8. **High retrieval signal** \u2014 retrieval_count > 0 means the agent actually searched for this.
|
|
28531
|
+
9. **Priority/philosophy statements** \u2014 "X is the highest priority" or "north star" type directives that shape all decisions.
|
|
28479
28532
|
|
|
28480
28533
|
### Process
|
|
28481
28534
|
|
|
28482
28535
|
1. **List all active memories** with \`ctx_memory(action="list")\`.
|
|
28483
|
-
2. **
|
|
28484
|
-
- References to tools that no longer exist (grep the tool registry)
|
|
28485
|
-
- References to files or directories that were deleted or renamed
|
|
28486
|
-
- References to old repository names, branches, or workflows
|
|
28487
|
-
- References to features explicitly described as "removed" or "replaced"
|
|
28488
|
-
- References to config keys that no longer appear in the schema
|
|
28489
|
-
- Session-local context that has no ongoing value ("in this session", "earlier today")
|
|
28490
|
-
- **Completed one-time instructions** in USER_DIRECTIVES \u2014 imperative directives like "Add X", "Create Y", "License as MIT", "Publish as Z" where the action has clearly been done (check the codebase to confirm completion)
|
|
28491
|
-
- **Low-value implementation minutiae** in ARCHITECTURE_DECISIONS \u2014 single-line statements that merely restate what code does without explaining WHY or capturing a non-obvious constraint. Example: "Tag assignment uses one DB transaction" just restates code behavior \u2014 this belongs in source comments, not project memory. Keep memories that explain *why* a design choice was made, *what constraint* drove it, or *what would break* if it changed.
|
|
28536
|
+
2. **Apply the archive and keep criteria above to each memory.**
|
|
28492
28537
|
3. **Verify each candidate** against the codebase before archiving:
|
|
28493
28538
|
- Check if the file/tool/path actually exists
|
|
28494
|
-
-
|
|
28495
|
-
- For USER_DIRECTIVES: verify the instructed action was completed (e.g., "License as MIT" \u2192 check LICENSE file exists)
|
|
28539
|
+
- For USER_DIRECTIVES: verify the instructed action was completed
|
|
28496
28540
|
- If the reference is ambiguous, leave it alone
|
|
28497
28541
|
4. **Archive** with \`ctx_memory(action="archive", id=N, reason="...")\`. Always include a specific reason.
|
|
28498
28542
|
|
|
28499
|
-
###
|
|
28500
|
-
-
|
|
28501
|
-
-
|
|
28502
|
-
-
|
|
28503
|
-
-
|
|
28504
|
-
-
|
|
28505
|
-
- Completed setup/publishing/licensing instructions that are done and won't recur
|
|
28506
|
-
- Implementation details that simply restate code behavior without adding design rationale
|
|
28507
|
-
|
|
28508
|
-
### USER_DIRECTIVES handling
|
|
28509
|
-
- **Archive** completed one-time instructions: "License as MIT", "Publish as @cortexkit/...", "Add changelog to releases", "For the README animation, emphasize X"
|
|
28510
|
-
- **Keep** ongoing preferences and behavioral rules: "Ask before changing behavior when audit finding is ambiguous", "Cache awareness is the highest-priority feature"
|
|
28511
|
-
- **Keep** workflow preferences that apply to future work: "Always use scripts/release.sh for releases"
|
|
28512
|
-
- Rule of thumb: if the directive uses imperative "do this" language and the action is done, archive it. If it describes how to behave going forward, keep it.
|
|
28513
|
-
|
|
28514
|
-
### ARCHITECTURE_DECISIONS pruning
|
|
28515
|
-
- **Archive** memories that only restate what code does: "Function X calls Y", "Module A imports B"
|
|
28516
|
-
- **Keep** memories that explain constraints, tradeoffs, or non-obvious design reasoning: "X uses Y because Z would cause cache busts"
|
|
28517
|
-
- **Keep** memories that warn about gotchas: "Don't use cwd fallback because it causes cross-project contamination"
|
|
28518
|
-
- Rule of thumb: if removing the memory would cause someone to make a wrong design decision, keep it. If it's just restating navigable code structure, archive it \u2014 ARCHITECTURE.md covers that.
|
|
28543
|
+
### Category-specific rules
|
|
28544
|
+
- **CONSTRAINTS**: archive ONLY when provably redundant with another specific constraint (not just thematically similar). Each constraint typically guards against a specific bug \u2014 losing it means the bug can return.
|
|
28545
|
+
- **USER_DIRECTIVES**: archive ONLY completed one-time tasks or exact duplicates of global user profile entries. Keep ongoing behavioral rules even if they have low retrieval.
|
|
28546
|
+
- **KNOWN_ISSUES**: NEVER archive \u2014 these prevent re-encountering bugs.
|
|
28547
|
+
- **ARCHITECTURE_DECISIONS**: archive code restatements freely, keep anything with "because", "so that", "to prevent", "to avoid".
|
|
28548
|
+
- **CONFIG_DEFAULTS**: archive bare values with no context, keep values that include rationale or prevent wrong assumptions.
|
|
28519
28549
|
|
|
28520
28550
|
### Success criteria
|
|
28521
28551
|
- No active memories reference non-existent files, tools, or paths.
|
|
28522
28552
|
- No completed one-time instructions remain in USER_DIRECTIVES.
|
|
28523
28553
|
- ARCHITECTURE_DECISIONS contains design reasoning, not code restatements.
|
|
28554
|
+
- CONSTRAINTS are preserved unless provably duplicated.
|
|
28524
28555
|
- Every archived memory has a specific reason.
|
|
28525
28556
|
- Conservative \u2014 when in doubt, leave it active.`;
|
|
28526
28557
|
}
|
|
@@ -28714,7 +28745,7 @@ function buildDreamTaskPrompt(task, args) {
|
|
|
28714
28745
|
case "verify":
|
|
28715
28746
|
return buildVerifyPrompt(args.projectPath);
|
|
28716
28747
|
case "archive-stale":
|
|
28717
|
-
return buildArchiveStalePrompt(args.projectPath);
|
|
28748
|
+
return buildArchiveStalePrompt(args.projectPath, args.userMemories);
|
|
28718
28749
|
case "improve":
|
|
28719
28750
|
return buildImprovePrompt(args.projectPath);
|
|
28720
28751
|
case "maintain-docs":
|
|
@@ -29317,7 +29348,6 @@ If no promotions are warranted, return empty arrays. Always consume reviewed can
|
|
|
29317
29348
|
}
|
|
29318
29349
|
}
|
|
29319
29350
|
}
|
|
29320
|
-
|
|
29321
29351
|
// src/features/magic-context/dreamer/storage-dream-runs.ts
|
|
29322
29352
|
var insertDreamRunStatements = new WeakMap;
|
|
29323
29353
|
var getDreamRunsByProjectStatements = new Map;
|
|
@@ -29608,10 +29638,15 @@ async function runDream(args) {
|
|
|
29608
29638
|
architecture: existsSync4(join8(docsDir, "ARCHITECTURE.md")),
|
|
29609
29639
|
structure: existsSync4(join8(docsDir, "STRUCTURE.md"))
|
|
29610
29640
|
} : undefined;
|
|
29641
|
+
const userMemories = taskName === "archive-stale" ? getActiveUserMemories(args.db).map((um) => ({
|
|
29642
|
+
id: um.id,
|
|
29643
|
+
content: um.content
|
|
29644
|
+
})) : undefined;
|
|
29611
29645
|
const taskPrompt = buildDreamTaskPrompt(taskName, {
|
|
29612
29646
|
projectPath: args.projectIdentity,
|
|
29613
29647
|
lastDreamAt,
|
|
29614
|
-
existingDocs
|
|
29648
|
+
existingDocs,
|
|
29649
|
+
userMemories
|
|
29615
29650
|
});
|
|
29616
29651
|
const createResponse = await args.client.session.create({
|
|
29617
29652
|
body: {
|
package/package.json
CHANGED