@wolfx/opencode-magic-context 0.21.8-patch.5 → 0.21.8-patch.7
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/permissions.d.ts +1 -1
- package/dist/hooks/magic-context/historian-state-file.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/shared/data-path.d.ts +9 -11
- package/dist/shared/data-path.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/data-path.test.ts +9 -10
- package/src/shared/data-path.ts +10 -12
- package/src/tui/slots/sidebar-content.tsx +1 -1
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* - **historian / historian-editor / compressor**: `read` plus the
|
|
43
43
|
* read-only AFT navigation tools `aft_outline` and `aft_zoom`.
|
|
44
44
|
* The runner offloads large existing-state XML to a temp file
|
|
45
|
-
* under `<project>/.
|
|
45
|
+
* under `<project>/.magic-context/historian/` and the
|
|
46
46
|
* prompt instructs the model to read that file. AFT navigation
|
|
47
47
|
* is allowed so historian can verify a symbol or file structure
|
|
48
48
|
* when writing accurate compartment summaries.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* When the existing-state XML (prior compartments + facts + project memory)
|
|
5
5
|
* exceeds {@link HISTORIAN_STATE_INLINE_THRESHOLD} characters, the historian
|
|
6
6
|
* caller writes it to a temp file under the project-local historian dir
|
|
7
|
-
* (`<project>/.
|
|
7
|
+
* (`<project>/.magic-context/historian/`) and the prompt instructs
|
|
8
8
|
* the model to `Read this file first`. This avoids pushing 100K+ chars of
|
|
9
9
|
* inline reference state through the model's input on long sessions, which
|
|
10
10
|
* on some provider/model combinations (notably github-copilot/gpt-5.4 via
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* The state file lives INSIDE the project directory rather than under
|
|
15
15
|
* `os.tmpdir()` because OpenCode's `external_directory` permission system
|
|
16
16
|
* asks the user before letting the historian subagent's Read tool open any
|
|
17
|
-
* file outside the project. Anchoring under `<project>/.
|
|
17
|
+
* file outside the project. Anchoring under `<project>/.magic-context/` keeps
|
|
18
18
|
* the file inside the project boundary so historian runs never trigger a
|
|
19
19
|
* permission prompt.
|
|
20
20
|
*
|
|
@@ -33,9 +33,9 @@ export declare const HISTORIAN_STATE_INLINE_THRESHOLD = 30000;
|
|
|
33
33
|
* writing fails (in which case the caller should fall back to inline).
|
|
34
34
|
*
|
|
35
35
|
* `directory` is the project directory; the helper writes under
|
|
36
|
-
* `<directory>/.
|
|
36
|
+
* `<directory>/.magic-context/historian/`. The dir is created
|
|
37
37
|
* recursively on first write, so the call is safe on fresh projects that have
|
|
38
|
-
* never had a `.
|
|
38
|
+
* never had a `.magic-context/` subtree.
|
|
39
39
|
*/
|
|
40
40
|
export declare function maybeWriteHistorianStateFile(sessionId: string, existingState: string, directory: string): string | undefined;
|
|
41
41
|
/** Delete a previously written state file. Safe to call with undefined. */
|
package/dist/index.js
CHANGED
|
@@ -15078,7 +15078,7 @@ function getMagicContextLogPath(harness = getHarness()) {
|
|
|
15078
15078
|
return path2.join(getMagicContextTempDir(harness), "magic-context.log");
|
|
15079
15079
|
}
|
|
15080
15080
|
function getProjectMagicContextDir(directory) {
|
|
15081
|
-
return path2.join(directory, ".
|
|
15081
|
+
return path2.join(directory, ".magic-context");
|
|
15082
15082
|
}
|
|
15083
15083
|
function getProjectMagicContextHistorianDir(directory) {
|
|
15084
15084
|
return path2.join(getProjectMagicContextDir(directory), "historian");
|
|
@@ -47,21 +47,18 @@ export declare function getMagicContextHistorianDir(harness?: HarnessId): string
|
|
|
47
47
|
/**
|
|
48
48
|
* Project-local magic-context artifact directory.
|
|
49
49
|
*
|
|
50
|
-
* Layout: `<project-directory>/.
|
|
50
|
+
* Layout: `<project-directory>/.magic-context/`
|
|
51
51
|
*
|
|
52
52
|
* Used for artifacts that the historian/recomp pipeline writes during a run
|
|
53
53
|
* and that the model is asked to read via its native Read tool. OpenCode's
|
|
54
54
|
* `external_directory` permission system asks the user before reading any
|
|
55
55
|
* file outside the project directory or its worktree, which interrupts every
|
|
56
56
|
* historian run when artifacts live under `os.tmpdir()`. Writing under the
|
|
57
|
-
* project's own `.
|
|
58
|
-
* never triggers a permission prompt.
|
|
57
|
+
* project's own `.magic-context/` subtree falls inside the project boundary
|
|
58
|
+
* and never triggers a permission prompt.
|
|
59
59
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* magic-context artifacts under `.opencode/magic-context/` keeps them
|
|
63
|
-
* co-located with related OpenCode metadata and makes them easy for users to
|
|
64
|
-
* locate when debugging.
|
|
60
|
+
* Using a harness-agnostic name (`/.magic-context/` rather than
|
|
61
|
+
* `/.opencode/`) ensures the same path works for both OpenCode and Pi.
|
|
65
62
|
*
|
|
66
63
|
* Logger does NOT use this — log files stay in the per-harness tmp subtree
|
|
67
64
|
* because they are written by the plugin process itself (no model-side Read
|
|
@@ -71,7 +68,7 @@ export declare function getProjectMagicContextDir(directory: string): string;
|
|
|
71
68
|
/**
|
|
72
69
|
* Project-local historian artifact directory.
|
|
73
70
|
*
|
|
74
|
-
* Layout: `<project-directory>/.
|
|
71
|
+
* Layout: `<project-directory>/.magic-context/historian/`
|
|
75
72
|
*
|
|
76
73
|
* Used for:
|
|
77
74
|
* - existing-state offload XMLs that long historian/recomp passes write
|
|
@@ -79,8 +76,9 @@ export declare function getProjectMagicContextDir(directory: string): string;
|
|
|
79
76
|
* - validation-failure dump XMLs preserved for debugging
|
|
80
77
|
*
|
|
81
78
|
* Callers must `mkdirSync(dir, { recursive: true })` before writing — the
|
|
82
|
-
* `.
|
|
83
|
-
* here must degrade gracefully (e.g. historian falls back to inline
|
|
79
|
+
* `.magic-context/` parent may not exist on a fresh project, and write
|
|
80
|
+
* failures here must degrade gracefully (e.g. historian falls back to inline
|
|
81
|
+
* state).
|
|
84
82
|
*/
|
|
85
83
|
export declare function getProjectMagicContextHistorianDir(directory: string): string;
|
|
86
84
|
export declare function getOpenCodeStorageDir(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-path.d.ts","sourceRoot":"","sources":["../../src/shared/data-path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAErF;AAED
|
|
1
|
+
{"version":3,"file":"data-path.d.ts","sourceRoot":"","sources":["../../src/shared/data-path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAErF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,uCAAuC,IAAI,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
|
package/package.json
CHANGED
|
@@ -121,20 +121,19 @@ describe("data-path", () => {
|
|
|
121
121
|
expect(shared).toContain("cortexkit");
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
test("getProjectMagicContextDir composes <project>/.
|
|
125
|
-
// Project-local artifacts
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
// under os.tmpdir().
|
|
124
|
+
test("getProjectMagicContextDir composes <project>/.magic-context", () => {
|
|
125
|
+
// Project-local artifacts live inside the project so OpenCode's
|
|
126
|
+
// external_directory permission system treats them as project-internal.
|
|
127
|
+
// Without this, historian's Read tool would trigger a permission prompt
|
|
128
|
+
// on every run when artifacts lived under os.tmpdir().
|
|
130
129
|
expect(getProjectMagicContextDir("/Users/me/Work/proj")).toBe(
|
|
131
|
-
path.join("/Users/me/Work/proj", ".
|
|
130
|
+
path.join("/Users/me/Work/proj", ".magic-context"),
|
|
132
131
|
);
|
|
133
132
|
});
|
|
134
133
|
|
|
135
134
|
test("getProjectMagicContextHistorianDir appends historian/", () => {
|
|
136
135
|
expect(getProjectMagicContextHistorianDir("/Users/me/Work/proj")).toBe(
|
|
137
|
-
path.join("/Users/me/Work/proj", ".
|
|
136
|
+
path.join("/Users/me/Work/proj", ".magic-context", "historian"),
|
|
138
137
|
);
|
|
139
138
|
});
|
|
140
139
|
|
|
@@ -145,7 +144,7 @@ describe("data-path", () => {
|
|
|
145
144
|
// project-local historian dir.
|
|
146
145
|
process.env.XDG_DATA_HOME = "/tmp/custom-data";
|
|
147
146
|
expect(getProjectMagicContextDir("/some/project")).toBe(
|
|
148
|
-
path.join("/some/project", ".
|
|
147
|
+
path.join("/some/project", ".magic-context"),
|
|
149
148
|
);
|
|
150
149
|
});
|
|
151
150
|
|
|
@@ -153,7 +152,7 @@ describe("data-path", () => {
|
|
|
153
152
|
// path.join normalizes redundant separators so callers don't need to
|
|
154
153
|
// worry about how the project directory was constructed.
|
|
155
154
|
expect(getProjectMagicContextDir("/some/project/")).toBe(
|
|
156
|
-
path.join("/some/project/", ".
|
|
155
|
+
path.join("/some/project/", ".magic-context"),
|
|
157
156
|
);
|
|
158
157
|
});
|
|
159
158
|
});
|
package/src/shared/data-path.ts
CHANGED
|
@@ -62,34 +62,31 @@ export function getMagicContextHistorianDir(harness: HarnessId = getHarness()):
|
|
|
62
62
|
/**
|
|
63
63
|
* Project-local magic-context artifact directory.
|
|
64
64
|
*
|
|
65
|
-
* Layout: `<project-directory>/.
|
|
65
|
+
* Layout: `<project-directory>/.magic-context/`
|
|
66
66
|
*
|
|
67
67
|
* Used for artifacts that the historian/recomp pipeline writes during a run
|
|
68
68
|
* and that the model is asked to read via its native Read tool. OpenCode's
|
|
69
69
|
* `external_directory` permission system asks the user before reading any
|
|
70
70
|
* file outside the project directory or its worktree, which interrupts every
|
|
71
71
|
* historian run when artifacts live under `os.tmpdir()`. Writing under the
|
|
72
|
-
* project's own `.
|
|
73
|
-
* never triggers a permission prompt.
|
|
72
|
+
* project's own `.magic-context/` subtree falls inside the project boundary
|
|
73
|
+
* and never triggers a permission prompt.
|
|
74
74
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* magic-context artifacts under `.opencode/magic-context/` keeps them
|
|
78
|
-
* co-located with related OpenCode metadata and makes them easy for users to
|
|
79
|
-
* locate when debugging.
|
|
75
|
+
* Using a harness-agnostic name (`/.magic-context/` rather than
|
|
76
|
+
* `/.opencode/`) ensures the same path works for both OpenCode and Pi.
|
|
80
77
|
*
|
|
81
78
|
* Logger does NOT use this — log files stay in the per-harness tmp subtree
|
|
82
79
|
* because they are written by the plugin process itself (no model-side Read
|
|
83
80
|
* tool call, no permission prompt) and span sessions/projects.
|
|
84
81
|
*/
|
|
85
82
|
export function getProjectMagicContextDir(directory: string): string {
|
|
86
|
-
return path.join(directory, ".
|
|
83
|
+
return path.join(directory, ".magic-context");
|
|
87
84
|
}
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
87
|
* Project-local historian artifact directory.
|
|
91
88
|
*
|
|
92
|
-
* Layout: `<project-directory>/.
|
|
89
|
+
* Layout: `<project-directory>/.magic-context/historian/`
|
|
93
90
|
*
|
|
94
91
|
* Used for:
|
|
95
92
|
* - existing-state offload XMLs that long historian/recomp passes write
|
|
@@ -97,8 +94,9 @@ export function getProjectMagicContextDir(directory: string): string {
|
|
|
97
94
|
* - validation-failure dump XMLs preserved for debugging
|
|
98
95
|
*
|
|
99
96
|
* Callers must `mkdirSync(dir, { recursive: true })` before writing — the
|
|
100
|
-
* `.
|
|
101
|
-
* here must degrade gracefully (e.g. historian falls back to inline
|
|
97
|
+
* `.magic-context/` parent may not exist on a fresh project, and write
|
|
98
|
+
* failures here must degrade gracefully (e.g. historian falls back to inline
|
|
99
|
+
* state).
|
|
102
100
|
*/
|
|
103
101
|
export function getProjectMagicContextHistorianDir(directory: string): string {
|
|
104
102
|
return path.join(getProjectMagicContextDir(directory), "historian");
|
|
@@ -465,7 +465,7 @@ const SidebarContent = (props: {
|
|
|
465
465
|
|
|
466
466
|
export function createSidebarContentSlot(api: TuiPluginApi): TuiSlotPlugin {
|
|
467
467
|
return {
|
|
468
|
-
order:
|
|
468
|
+
order: 153,
|
|
469
469
|
slots: {
|
|
470
470
|
sidebar_content: (ctx, value) => {
|
|
471
471
|
const theme = createMemo(() => ctx.theme.current)
|