@cortexkit/pi-magic-context 0.40.0 → 0.41.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/README.md +9 -0
- package/dist/historian-calibration-extension.js +58 -0
- package/dist/index-3k71e196.js +378 -0
- package/dist/{index-kamc8t8p.js → index-ts6nabp0.js} +429 -282
- package/dist/index.js +1109 -455
- package/dist/{safe-notification-target-q00qgjm6.js → safe-notification-target-g8fx80va.js} +1 -1
- package/dist/subagent-entry.js +2 -2
- package/package.json +87 -87
- package/dist/index-hk6sj7dn.js +0 -147
- /package/dist/{index-8sseka65.js → index-wnrygn5h.js} +0 -0
package/dist/subagent-entry.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
registerMagicContextTools,
|
|
6
6
|
resolveProjectIdentityForSession,
|
|
7
7
|
setStoragePrivatePermissionEnforcement
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-ts6nabp0.js";
|
|
9
9
|
import {
|
|
10
10
|
log,
|
|
11
11
|
setHarness
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-3k71e196.js";
|
|
13
13
|
import"./index-1yh8g550.js";
|
|
14
14
|
|
|
15
15
|
// src/subagent-entry.ts
|
package/package.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
2
|
+
"name": "@cortexkit/pi-magic-context",
|
|
3
|
+
"version": "0.41.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "ualtinok",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"pi",
|
|
11
|
+
"pi-coding-agent",
|
|
12
|
+
"omp",
|
|
13
|
+
"oh-my-pi",
|
|
14
|
+
"extension",
|
|
15
|
+
"context",
|
|
16
|
+
"memory",
|
|
17
|
+
"magic-context",
|
|
18
|
+
"ai",
|
|
19
|
+
"llm"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/cortexkit/magic-context",
|
|
24
|
+
"directory": "packages/pi-plugin"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p ../retina-local-fs/tsconfig.build.json && rm -f dist/index.js dist/subagent-entry.js dist/historian-calibration-extension.js dist/*-*.js && bun build src/index.ts src/subagent-entry.ts src/historian-calibration-extension.ts --outdir dist --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external @huggingface/transformers --external node:sqlite",
|
|
32
|
+
"build:e2e-argv": "bun build src/subagent-runner.ts --outfile ../../tests/docker/.generated/subagent-runner-e2e.mjs --target node --format esm --external node:sqlite",
|
|
33
|
+
"typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
|
|
34
|
+
"test": "bun install --frozen-lockfile && bun test",
|
|
35
|
+
"lint": "biome check src",
|
|
36
|
+
"lint:fix": "biome check --write src",
|
|
37
|
+
"format": "biome format --write src",
|
|
38
|
+
"format:check": "biome format src",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"prepublishOnly": "bun run build"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@cortexkit/subc-client": "0.4.1",
|
|
44
|
+
"@huggingface/transformers": "^4.1.0",
|
|
45
|
+
"@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0",
|
|
46
|
+
"ai-tokenizer": "^1.0.6",
|
|
47
|
+
"comment-json": "^5.0.0",
|
|
48
|
+
"quickjs-emscripten": "^0.32.0",
|
|
49
|
+
"typebox": "^1.3.1",
|
|
50
|
+
"zod": "^4.1.8"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@biomejs/biome": "^2.5.1",
|
|
54
|
+
"@earendil-works/pi-ai": "0.83.0",
|
|
55
|
+
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
56
|
+
"@earendil-works/pi-tui": "0.83.0",
|
|
57
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
58
|
+
"@types/bun": "^1.3.10",
|
|
59
|
+
"@types/node": "^22.20.0",
|
|
60
|
+
"typescript": "^5.8.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
64
|
+
"@earendil-works/pi-tui": "^0.80.2"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@earendil-works/pi-coding-agent": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"@earendil-works/pi-tui": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"exports": {
|
|
75
|
+
".": {
|
|
76
|
+
"import": "./dist/index.js"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"pi": {
|
|
80
|
+
"extensions": [
|
|
81
|
+
"./dist/index.js"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"omp": {
|
|
85
|
+
"extensions": [
|
|
86
|
+
"./dist/index.js"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
89
|
}
|
package/dist/index-hk6sj7dn.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// ../plugin/src/shared/harness.ts
|
|
2
|
-
var currentHarness = "opencode";
|
|
3
|
-
var harnessLocked = false;
|
|
4
|
-
function setHarness(value) {
|
|
5
|
-
if (harnessLocked && currentHarness !== value) {
|
|
6
|
-
throw new Error(`Magic Context: harness already locked to "${currentHarness}"; cannot change to "${value}"`);
|
|
7
|
-
}
|
|
8
|
-
currentHarness = value;
|
|
9
|
-
harnessLocked = true;
|
|
10
|
-
}
|
|
11
|
-
function getHarness() {
|
|
12
|
-
return currentHarness;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// ../plugin/src/shared/data-path.ts
|
|
16
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
-
import * as os from "node:os";
|
|
18
|
-
import * as path from "node:path";
|
|
19
|
-
function getDataDir() {
|
|
20
|
-
return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
|
|
21
|
-
}
|
|
22
|
-
function getMagicContextTempDir(harness = getHarness()) {
|
|
23
|
-
return path.join(os.tmpdir(), harness, "magic-context");
|
|
24
|
-
}
|
|
25
|
-
function getMagicContextLogPath(harness = getHarness()) {
|
|
26
|
-
const envPath = process.env.MAGIC_CONTEXT_LOG_PATH?.trim();
|
|
27
|
-
if (envPath)
|
|
28
|
-
return envPath;
|
|
29
|
-
return path.join(getMagicContextTempDir(harness), "magic-context.log");
|
|
30
|
-
}
|
|
31
|
-
function getProjectMagicContextDir(directory) {
|
|
32
|
-
return path.join(directory, ".cortexkit", "magic-context");
|
|
33
|
-
}
|
|
34
|
-
var GITIGNORE_GUARD_OPEN = "# >>> cortexkit:magic-context";
|
|
35
|
-
var GITIGNORE_GUARD_CLOSE = "# <<< cortexkit:magic-context";
|
|
36
|
-
function ensureCortexKitArtifactGitignore(directory) {
|
|
37
|
-
try {
|
|
38
|
-
const cortexKitDir = path.join(directory, ".cortexkit");
|
|
39
|
-
const gitignorePath = path.join(cortexKitDir, ".gitignore");
|
|
40
|
-
let existing = "";
|
|
41
|
-
if (existsSync(gitignorePath)) {
|
|
42
|
-
existing = readFileSync(gitignorePath, "utf8");
|
|
43
|
-
if (existing.includes(GITIGNORE_GUARD_OPEN))
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const block = `${GITIGNORE_GUARD_OPEN}
|
|
47
|
-
magic-context/
|
|
48
|
-
${GITIGNORE_GUARD_CLOSE}
|
|
49
|
-
`;
|
|
50
|
-
const needsLeadingNewline = existing.length > 0 && !existing.endsWith(`
|
|
51
|
-
`);
|
|
52
|
-
const next = existing + (needsLeadingNewline ? `
|
|
53
|
-
` : "") + block;
|
|
54
|
-
mkdirSync(cortexKitDir, { recursive: true });
|
|
55
|
-
writeFileSync(gitignorePath, next, "utf8");
|
|
56
|
-
} catch {}
|
|
57
|
-
}
|
|
58
|
-
function getProjectMagicContextHistorianDir(directory) {
|
|
59
|
-
return path.join(getProjectMagicContextDir(directory), "historian");
|
|
60
|
-
}
|
|
61
|
-
function getOpenCodeStorageDir() {
|
|
62
|
-
return path.join(getDataDir(), "opencode", "storage");
|
|
63
|
-
}
|
|
64
|
-
function getMagicContextStorageDir() {
|
|
65
|
-
if (!process.env.XDG_DATA_HOME) {
|
|
66
|
-
const testDataDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR;
|
|
67
|
-
if (testDataDir) {
|
|
68
|
-
return path.join(testDataDir, "cortexkit", "magic-context");
|
|
69
|
-
}
|
|
70
|
-
if (false) {}
|
|
71
|
-
}
|
|
72
|
-
return path.join(getDataDir(), "cortexkit", "magic-context");
|
|
73
|
-
}
|
|
74
|
-
function getLegacyOpenCodeMagicContextStorageDir() {
|
|
75
|
-
return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ../plugin/src/shared/logger.ts
|
|
79
|
-
import * as fs from "node:fs";
|
|
80
|
-
import * as path2 from "node:path";
|
|
81
|
-
var isTestEnv = false;
|
|
82
|
-
var buffer = [];
|
|
83
|
-
var flushTimer = null;
|
|
84
|
-
var FLUSH_INTERVAL_MS = 500;
|
|
85
|
-
var BUFFER_SIZE_LIMIT = 50;
|
|
86
|
-
var swallowedWriteCount = 0;
|
|
87
|
-
var lastErrorMessage = null;
|
|
88
|
-
var lastErrorTime = null;
|
|
89
|
-
function recordSwallowedWrite(error) {
|
|
90
|
-
try {
|
|
91
|
-
swallowedWriteCount++;
|
|
92
|
-
lastErrorMessage = error instanceof Error ? error.message : String(error);
|
|
93
|
-
lastErrorTime = new Date().toISOString();
|
|
94
|
-
} catch {}
|
|
95
|
-
}
|
|
96
|
-
function ensureDir(filePath) {
|
|
97
|
-
fs.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
98
|
-
}
|
|
99
|
-
function flush() {
|
|
100
|
-
if (flushTimer) {
|
|
101
|
-
clearTimeout(flushTimer);
|
|
102
|
-
flushTimer = null;
|
|
103
|
-
}
|
|
104
|
-
if (buffer.length === 0)
|
|
105
|
-
return;
|
|
106
|
-
const data = buffer.join("");
|
|
107
|
-
buffer = [];
|
|
108
|
-
try {
|
|
109
|
-
const logFile = getMagicContextLogPath();
|
|
110
|
-
ensureDir(logFile);
|
|
111
|
-
fs.appendFileSync(logFile, data);
|
|
112
|
-
} catch (error) {
|
|
113
|
-
recordSwallowedWrite(error);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function scheduleFlush() {
|
|
117
|
-
if (flushTimer)
|
|
118
|
-
return;
|
|
119
|
-
flushTimer = setTimeout(() => {
|
|
120
|
-
flushTimer = null;
|
|
121
|
-
flush();
|
|
122
|
-
}, FLUSH_INTERVAL_MS);
|
|
123
|
-
}
|
|
124
|
-
function log(message, data) {
|
|
125
|
-
if (isTestEnv)
|
|
126
|
-
return;
|
|
127
|
-
try {
|
|
128
|
-
const timestamp = new Date().toISOString();
|
|
129
|
-
const serialized = data === undefined ? "" : data instanceof Error ? ` ${data.message}${data.stack ? `
|
|
130
|
-
${data.stack}` : ""}` : ` ${JSON.stringify(data)}`;
|
|
131
|
-
buffer.push(`[${timestamp}] ${message}${serialized}
|
|
132
|
-
`);
|
|
133
|
-
if (buffer.length >= BUFFER_SIZE_LIMIT) {
|
|
134
|
-
flush();
|
|
135
|
-
} else {
|
|
136
|
-
scheduleFlush();
|
|
137
|
-
}
|
|
138
|
-
} catch {}
|
|
139
|
-
}
|
|
140
|
-
function sessionLog(sessionId, message, data) {
|
|
141
|
-
log(`[magic-context][${sessionId}] ${message}`, data);
|
|
142
|
-
}
|
|
143
|
-
if (!isTestEnv) {
|
|
144
|
-
process.on("exit", flush);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export { setHarness, getHarness, getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, log, sessionLog };
|
|
File without changes
|