notesoup 0.61.0 → 0.62.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/.agents/plugins/marketplace.json +15 -0
- package/README.md +14 -11
- package/dist/plugins/antigravity/src/cli.d.ts +1 -0
- package/dist/plugins/antigravity/src/cli.js +23 -0
- package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
- package/dist/plugins/antigravity/src/hooks.js +53 -0
- package/dist/plugins/antigravity/src/identity.d.ts +26 -0
- package/dist/plugins/antigravity/src/identity.js +129 -0
- package/dist/plugins/claude/src/helper.js +2 -1
- package/dist/plugins/codex/src/hooks.js +1 -0
- package/dist/plugins/codex/src/identity.d.ts +6 -1
- package/dist/plugins/codex/src/identity.js +13 -1
- package/dist/plugins/codex/src/mcp.d.ts +35 -7
- package/dist/plugins/codex/src/mcp.js +26 -88
- package/dist/plugins/codex/src/text.js +3 -3
- package/dist/plugins/dsh/tools.js +8 -4
- package/dist/plugins/mcp/operations.d.ts +15 -0
- package/dist/plugins/mcp/operations.js +43 -0
- package/dist/plugins/mcp/server.d.ts +14 -0
- package/dist/plugins/mcp/server.js +13 -0
- package/dist/plugins/pi/budget.d.ts +1 -1
- package/dist/plugins/pi/budget.js +3 -2
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -0
- package/dist/plugins/pi/history-tools.js +2 -1
- package/dist/plugins/pi/history.js +18 -1
- package/dist/plugins/pi/notes/tools.js +7 -3
- package/dist/plugins/pi/render.d.ts +7 -1
- package/dist/plugins/pi/render.js +2 -2
- package/dist/plugins/pi/reset/lifecycle.d.ts +1 -1
- package/dist/plugins/pi/reset/lifecycle.js +8 -9
- package/dist/plugins/pi/runtime.js +102 -61
- package/dist/plugins/pi/tool-result.js +7 -7
- package/dist/plugins/pi/window.d.ts +33 -3
- package/dist/plugins/pi/window.js +209 -9
- package/dist/src/boot/render.js +18 -15
- package/dist/src/boot/text.d.ts +3 -1
- package/dist/src/boot/text.js +22 -20
- package/dist/src/budget/text.d.ts +2 -2
- package/dist/src/budget/text.js +13 -13
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +46 -0
- package/dist/src/history/codex-transcript.js +7 -5
- package/dist/src/history/codex.js +3 -0
- package/dist/src/history/corpus.d.ts +28 -1
- package/dist/src/history/corpus.js +40 -0
- package/dist/src/history/history.d.ts +37 -46
- package/dist/src/history/history.js +21 -40
- package/dist/src/history/local.js +67 -32
- package/dist/src/history/pi.d.ts +2 -1
- package/dist/src/history/pi.js +122 -48
- package/dist/src/history/prefilter.js +76 -19
- package/dist/src/history/query.d.ts +28 -49
- package/dist/src/history/query.js +83 -68
- package/dist/src/history/summary-cache.d.ts +8 -1
- package/dist/src/history/summary-cache.js +138 -12
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/errors.d.ts +1 -1
- package/dist/src/notes/frontmatter.d.ts +0 -2
- package/dist/src/notes/frontmatter.js +0 -2
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/policy.d.ts +15 -1
- package/dist/src/notes/policy.js +46 -5
- package/dist/src/notes/store.d.ts +12 -0
- package/dist/src/notes/store.js +16 -20
- package/dist/src/text-match.d.ts +10 -1
- package/dist/src/text-match.js +42 -3
- package/dist/src/tools/dream.d.ts +22 -93
- package/dist/src/tools/dream.js +30 -27
- package/dist/src/tools/history.d.ts +33 -26
- package/dist/src/tools/history.js +257 -163
- package/dist/src/tools/notes.d.ts +51 -163
- package/dist/src/tools/notes.js +146 -100
- package/dist/src/tools/output.d.ts +2 -1
- package/dist/src/tools/output.js +2 -1
- package/dist/src/tools/result.d.ts +4 -7
- package/dist/src/tools/result.js +8 -9
- package/dist/src/tools/schema.d.ts +4 -1
- package/dist/src/tools/schema.js +25 -1
- package/dist/test/agent-loop.test.js +198 -16
- package/dist/test/antigravity-live.test.d.ts +1 -0
- package/dist/test/antigravity-live.test.js +142 -0
- package/dist/test/antigravity-plugin.test.d.ts +1 -0
- package/dist/test/antigravity-plugin.test.js +101 -0
- package/dist/test/boot.integration.test.js +133 -14
- package/dist/test/claude-history.test.js +14 -13
- package/dist/test/claude-mod.test.js +9 -6
- package/dist/test/codex-history.test.js +15 -3
- package/dist/test/codex-plugin.test.js +76 -38
- package/dist/test/dependencies.test.js +7 -3
- package/dist/test/dream-skill.test.js +3 -3
- package/dist/test/dream-tools.test.js +101 -56
- package/dist/test/dsh.test.js +34 -19
- package/dist/test/helpers/dependency-graph.js +2 -2
- package/dist/test/helpers/extension.d.ts +65 -2
- package/dist/test/helpers/extension.js +72 -3
- package/dist/test/history-corpus.test.js +79 -77
- package/dist/test/history-summary-cache.test.js +97 -9
- package/dist/test/history.integration.test.js +234 -168
- package/dist/test/host-neutral.test.js +69 -19
- package/dist/test/marker.test.js +1 -1
- package/dist/test/note-policy.test.js +96 -77
- package/dist/test/notes.integration.test.js +212 -94
- package/dist/test/notes.test.js +184 -113
- package/dist/test/pi-render.test.js +20 -12
- package/dist/test/project-namespace.test.js +3 -2
- package/dist/test/reset-lifecycle.test.js +2 -2
- package/docs/antigravity.md +44 -0
- package/docs/architecture.md +6 -4
- package/docs/claude-code-mod.md +2 -2
- package/docs/codex.md +36 -38
- package/docs/dsh.md +3 -3
- package/docs/history-sessions.md +28 -50
- package/docs/notes-library.md +4 -4
- package/docs/skills.md +3 -3
- package/docs/tool-results.md +47 -28
- package/package.json +3 -2
- package/playbook.md +1 -1
- package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
- package/plugins/antigravity/hooks.json +7 -0
- package/plugins/antigravity/mcp_config.json +8 -0
- package/plugins/antigravity/plugin.json +6 -0
- package/plugins/antigravity/src/cli.ts +22 -0
- package/plugins/antigravity/src/hooks.ts +51 -0
- package/plugins/antigravity/src/identity.ts +127 -0
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +1059 -534
- package/plugins/claude/hooks/register.ts +2 -2
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/notesoup/SKILL.md +92 -0
- package/plugins/claude/src/helper.ts +2 -1
- package/plugins/codex/.codex-plugin/plugin.json +8 -0
- package/plugins/codex/.mcp.json +11 -0
- package/plugins/codex/README.md +5 -21
- package/plugins/codex/dist/codex/notesoup.js +18480 -17946
- package/plugins/codex/src/hooks.ts +1 -0
- package/plugins/codex/src/identity.ts +14 -1
- package/plugins/codex/src/mcp.ts +28 -98
- package/plugins/codex/src/text.ts +3 -3
- package/plugins/dsh/tools.ts +8 -4
- package/plugins/mcp/operations.ts +50 -0
- package/plugins/mcp/server.ts +23 -0
- package/plugins/paseo/README.md +5 -10
- package/plugins/paseo/client/brain-empty-card.tsx +3 -3
- package/plugins/paseo/client/markdown.tsx +50 -38
- package/plugins/paseo/client/notes-op-card.tsx +12 -9
- package/plugins/paseo/client/paper-card.tsx +6 -5
- package/plugins/paseo/client/paper-palette.ts +2 -9
- package/plugins/paseo/client/sticky-card.tsx +2 -2
- package/plugins/paseo/client/tool-result.ts +7 -14
- package/plugins/paseo/package-lock.json +3406 -0
- package/plugins/paseo/package.json +1 -0
- package/plugins/paseo/test/markdown-core.test.ts +73 -66
- package/plugins/pi/budget.ts +3 -3
- package/plugins/pi/entries.ts +1 -0
- package/plugins/pi/history-tools.ts +2 -1
- package/plugins/pi/history.ts +30 -1
- package/plugins/pi/notes/tools.ts +7 -3
- package/plugins/pi/render.ts +6 -6
- package/plugins/pi/reset/lifecycle.ts +9 -10
- package/plugins/pi/runtime.ts +96 -60
- package/plugins/pi/tool-result.ts +8 -8
- package/plugins/pi/window.ts +198 -9
- package/skills/dream/SKILL.md +1 -1
- package/skills/notesoup/SKILL.md +92 -0
- package/src/boot/render.ts +18 -15
- package/src/boot/text.ts +23 -19
- package/src/budget/text.ts +13 -13
- package/src/history/claude.ts +41 -0
- package/src/history/codex-transcript.ts +6 -4
- package/src/history/codex.ts +2 -0
- package/src/history/corpus.ts +51 -2
- package/src/history/history.ts +35 -44
- package/src/history/local.ts +67 -27
- package/src/history/pi.ts +113 -35
- package/src/history/prefilter.ts +73 -15
- package/src/history/query.ts +93 -73
- package/src/history/summary-cache.ts +142 -17
- package/src/index.ts +1 -1
- package/src/notes/errors.ts +1 -1
- package/src/notes/frontmatter.ts +0 -3
- package/src/notes/index.ts +1 -1
- package/src/notes/policy.ts +44 -5
- package/src/notes/store.ts +17 -20
- package/src/text-match.ts +46 -4
- package/src/tools/dream.ts +29 -31
- package/src/tools/history.ts +249 -142
- package/src/tools/notes.ts +145 -113
- package/src/tools/output.ts +2 -1
- package/src/tools/result.ts +12 -11
- package/src/tools/schema.ts +24 -1
- package/plugins/claude/skills/memory/SKILL.md +0 -69
- package/plugins/codex/mcp.json +0 -10
- package/plugins/codex/plugin.json +0 -6
- package/plugins/paseo/client/markdown-core.tsx +0 -189
- package/plugins/paseo/client/typography.ts +0 -24
- package/skills/memory/SKILL.md +0 -69
|
@@ -121,6 +121,7 @@ async function startHook(event: "SessionStart" | "SubagentStart", payload: HookP
|
|
|
121
121
|
home: notesHome(env),
|
|
122
122
|
transcriptPath,
|
|
123
123
|
windowId: native.state.currentWindowId,
|
|
124
|
+
windowNumber: native.state.currentWindowNumber,
|
|
124
125
|
...(target.agentType === undefined ? {} : { agentType: target.agentType }),
|
|
125
126
|
boundAt: new Date().toISOString(),
|
|
126
127
|
};
|
|
@@ -27,6 +27,8 @@ export type ThreadBinding = Readonly<{
|
|
|
27
27
|
transcriptPath: string;
|
|
28
28
|
/** Native window at bind time; a later MCP call must name this same window. */
|
|
29
29
|
windowId: string;
|
|
30
|
+
/** The same native window's monotonic number, used in newer MCP metadata. */
|
|
31
|
+
windowNumber?: number;
|
|
30
32
|
agentType?: string;
|
|
31
33
|
boundAt: string;
|
|
32
34
|
}>;
|
|
@@ -38,7 +40,7 @@ export function safeThreadId(value: unknown, field = "threadId"): string {
|
|
|
38
40
|
return value;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
/** The
|
|
43
|
+
/** The hook receives the native plugin's data directory directly from Codex. */
|
|
42
44
|
export function pluginDataRoot(env: NodeJS.ProcessEnv = process.env): string {
|
|
43
45
|
const value = env.PLUGIN_DATA;
|
|
44
46
|
if (typeof value !== "string" || value.trim() === "" || !isAbsolute(value)) {
|
|
@@ -47,6 +49,14 @@ export function pluginDataRoot(env: NodeJS.ProcessEnv = process.env): string {
|
|
|
47
49
|
return resolve(value);
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
/** Native Codex MCP launches don't inject PLUGIN_DATA (0.171.0). The installed
|
|
53
|
+
* notesoup@notesoup package has a fixed native data path under CODEX_HOME. */
|
|
54
|
+
export function mcpPluginDataRoot(env: NodeJS.ProcessEnv = process.env): string {
|
|
55
|
+
if (env.PLUGIN_DATA !== undefined) return pluginDataRoot(env);
|
|
56
|
+
const home = env.CODEX_HOME?.trim() || join(homedir(), ".codex");
|
|
57
|
+
return resolve(home, "plugins", "data", "notesoup-notesoup");
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
export function notesHome(env: NodeJS.ProcessEnv = process.env): string {
|
|
51
61
|
const value = env.NOTESOUP_HOME;
|
|
52
62
|
return value !== undefined && value.trim() !== "" ? resolve(value) : join(homedir(), ".agents", "notes");
|
|
@@ -95,6 +105,8 @@ export async function readBinding(root: string, threadId: string): Promise<Threa
|
|
|
95
105
|
const cwd = required(row.cwd, "cwd");
|
|
96
106
|
const transcriptPath = required(row.transcriptPath, "transcriptPath");
|
|
97
107
|
const windowId = required(row.windowId, "windowId");
|
|
108
|
+
const windowNumber = row.windowNumber;
|
|
109
|
+
if (windowNumber !== undefined && (typeof windowNumber !== "number" || !Number.isSafeInteger(windowNumber) || windowNumber < 0)) throw new CodexIdentityError("invalid_binding", "Stored notesoup binding has an invalid native window number.");
|
|
98
110
|
if (!isAbsolute(home) || !isAbsolute(cwd) || !isAbsolute(transcriptPath)) throw new CodexIdentityError("invalid_binding", "The stored notesoup binding contains a non-absolute path.");
|
|
99
111
|
return {
|
|
100
112
|
version: 1,
|
|
@@ -106,6 +118,7 @@ export async function readBinding(root: string, threadId: string): Promise<Threa
|
|
|
106
118
|
home,
|
|
107
119
|
transcriptPath,
|
|
108
120
|
windowId,
|
|
121
|
+
...(windowNumber === undefined ? {} : { windowNumber }),
|
|
109
122
|
...(typeof row.agentType === "string" && row.agentType.length > 0 ? { agentType: row.agentType } : {}),
|
|
110
123
|
boundAt: required(row.boundAt, "boundAt"),
|
|
111
124
|
};
|
package/plugins/codex/src/mcp.ts
CHANGED
|
@@ -1,58 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import type
|
|
8
|
-
import { notesList, notesRead, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
9
|
-
import { historyList, historyRead } from "../../../src/tools/history.js";
|
|
10
|
-
import type { Outcome } from "../../../src/result.js";
|
|
11
|
-
import { wireResult, type Operation } from "../../../src/tools/result.js";
|
|
12
|
-
import { CodexIdentityError, notesIdentityFor, pluginDataRoot, readBinding, rootSessionIdOf, safeThreadId, turnModel, type ThreadBinding } from "./identity.js";
|
|
1
|
+
/** Codex alone owns its hook bindings, window validation and native history. */
|
|
2
|
+
import { bindOperation, createNoteTools } from "../../mcp/operations.js";
|
|
3
|
+
import { createToolServer, runToolServer } from "../../mcp/server.js";
|
|
4
|
+
import type { Meta } from "../../mcp/server.js";
|
|
5
|
+
import type { HistoryContext } from "../../../src/history/corpus.js";
|
|
6
|
+
import { historyList, historySearch, historyRead } from "../../../src/tools/history.js";
|
|
7
|
+
import { CodexIdentityError, notesIdentityFor, mcpPluginDataRoot, readBinding, rootSessionIdOf, safeThreadId, turnModel, type ThreadBinding } from "./identity.js";
|
|
13
8
|
import { readCodexHistory } from "../../../src/history/codex.js";
|
|
14
9
|
import { localHistoryCorpus } from "../../../src/history/local.js";
|
|
15
10
|
import { readStartState } from "./state.js";
|
|
16
11
|
import { notesToolContext } from "../../../src/tools/notes-context.js";
|
|
17
12
|
|
|
18
|
-
type
|
|
19
|
-
readonly operation: Operation<TSchema, unknown, readonly unknown[]>;
|
|
20
|
-
readonly history: boolean;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const OPERATIONS: Record<string, Bound> = {
|
|
24
|
-
notes_write: { operation: notesWrite as unknown as Bound["operation"], history: false },
|
|
25
|
-
notes_update: { operation: notesUpdate as unknown as Bound["operation"], history: false },
|
|
26
|
-
notes_read: { operation: notesRead as unknown as Bound["operation"], history: false },
|
|
27
|
-
notes_list: { operation: notesList as unknown as Bound["operation"], history: false },
|
|
28
|
-
history_list: { operation: historyList as unknown as Bound["operation"], history: true },
|
|
29
|
-
history_read: { operation: historyRead as unknown as Bound["operation"], history: true },
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function shellFree(reason: unknown): string {
|
|
33
|
-
const value = reason instanceof Error ? reason.message : String(reason);
|
|
34
|
-
return value.replace(/[\r\n]+/g, " ").slice(0, 500);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function failure(code: string, message: string): CallToolResult {
|
|
38
|
-
return {
|
|
39
|
-
content: [{ type: "text", text: `error: ${code}: ${message}` }],
|
|
40
|
-
structuredContent: { error: message, code },
|
|
41
|
-
isError: true,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function successFor(bound: Bound, outcome: Outcome<unknown>): CallToolResult {
|
|
46
|
-
const wire = wireResult(outcome);
|
|
47
|
-
return {
|
|
48
|
-
content: [{ type: "text", text: bound.operation.render(outcome) }],
|
|
49
|
-
structuredContent: wire as Record<string, unknown>,
|
|
50
|
-
// A refusal stays a tool-level error so the model does not mistake it for data.
|
|
51
|
-
...(outcome.ok ? {} : { isError: true }),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type NativeFacts = { threadId: string; rootSessionId: string; currentWindowId?: string };
|
|
13
|
+
type NativeFacts = { threadId: string; rootSessionId: string; currentWindowId?: string; currentWindowNumber?: number };
|
|
56
14
|
|
|
57
15
|
/** MCP metadata is the caller's claim; it must agree with the hook binding before any read. */
|
|
58
16
|
function metaFacts(meta: Record<string, unknown>, binding: ThreadBinding): { rootSessionId: string } {
|
|
@@ -62,13 +20,14 @@ function metaFacts(meta: Record<string, unknown>, binding: ThreadBinding): { roo
|
|
|
62
20
|
}
|
|
63
21
|
const windowId = typeof meta.windowId === "string" && meta.windowId !== "" ? meta.windowId : undefined;
|
|
64
22
|
if (windowId === undefined) throw new CodexIdentityError("missing_window", "Codex did not supply the current native window in MCP metadata; refusing to use a possibly stale binding.");
|
|
65
|
-
|
|
23
|
+
const numberedId = binding.windowNumber === undefined ? undefined : `${binding.threadId}:${binding.windowNumber}`;
|
|
24
|
+
if (binding.windowId !== windowId && numberedId !== windowId) throw new CodexIdentityError("stale_thread_binding", "This thread's hook binding belongs to a different native window. Resume or compact once so the SessionStart hook rebinds it; notesoup will not read or write through stale identity.");
|
|
66
25
|
return { rootSessionId };
|
|
67
26
|
}
|
|
68
27
|
|
|
69
28
|
async function identityFor(meta: Record<string, unknown>, env: NodeJS.ProcessEnv): Promise<{ binding: ThreadBinding; rootSessionId: string; model: string }> {
|
|
70
29
|
const threadId = safeThreadId(meta.threadId, "MCP threadId");
|
|
71
|
-
const binding = await readBinding(
|
|
30
|
+
const binding = await readBinding(mcpPluginDataRoot(env), threadId);
|
|
72
31
|
const { rootSessionId } = metaFacts(meta, binding);
|
|
73
32
|
return { binding, rootSessionId, model: turnModel(meta) };
|
|
74
33
|
}
|
|
@@ -80,7 +39,7 @@ function verifyNativeFacts(binding: ThreadBinding, rootSessionId: string, native
|
|
|
80
39
|
throw new CodexIdentityError("stale_native_state", "The native transcript no longer matches this thread's root session; refusing to read or write mixed or stale identity.");
|
|
81
40
|
}
|
|
82
41
|
if (native.currentWindowId === undefined) throw new CodexIdentityError("missing_window", "The native transcript has no materialized current window; refusing to guess one.");
|
|
83
|
-
if (native.currentWindowId !== binding.windowId) {
|
|
42
|
+
if (native.currentWindowId !== binding.windowId || (binding.windowNumber !== undefined && native.currentWindowNumber !== binding.windowNumber)) {
|
|
84
43
|
throw new CodexIdentityError("stale_native_state", "The native transcript advanced to a different window. Resume or compact once so the SessionStart hook rebinds it; notesoup will not read or write through stale identity.");
|
|
85
44
|
}
|
|
86
45
|
}
|
|
@@ -94,6 +53,7 @@ function sameBinding(left: ThreadBinding, right: ThreadBinding): boolean {
|
|
|
94
53
|
&& left.home === right.home
|
|
95
54
|
&& left.transcriptPath === right.transcriptPath
|
|
96
55
|
&& left.windowId === right.windowId
|
|
56
|
+
&& left.windowNumber === right.windowNumber
|
|
97
57
|
&& left.agentType === right.agentType;
|
|
98
58
|
}
|
|
99
59
|
|
|
@@ -104,7 +64,7 @@ async function readNative(binding: ThreadBinding, rootSessionId: string, history
|
|
|
104
64
|
verifyNativeFacts(binding, rootSessionId, native);
|
|
105
65
|
// Native reads are asynchronous: a hook may have rebound this thread while we were
|
|
106
66
|
// reading. Compare again before trusting either the cached binding or a mutation.
|
|
107
|
-
const reread = await readBinding(
|
|
67
|
+
const reread = await readBinding(mcpPluginDataRoot(env), binding.threadId);
|
|
108
68
|
if (!sameBinding(binding, reread)) {
|
|
109
69
|
throw new CodexIdentityError("stale_thread_binding", "This thread's hook binding changed while notesoup was reading native facts; retry once the new native window is settled.");
|
|
110
70
|
}
|
|
@@ -114,51 +74,21 @@ async function readNative(binding: ThreadBinding, rootSessionId: string, history
|
|
|
114
74
|
return native;
|
|
115
75
|
}
|
|
116
76
|
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
if (bound === undefined) return failure("unknown_tool", `No notesoup operation named ${JSON.stringify(name)}.`);
|
|
120
|
-
const params = args ?? {};
|
|
121
|
-
if (!Check(bound.operation.parameters, params)) return failure("invalid_params", `invalid ${name} parameters: ${paramProblem(bound.operation.parameters, params)}`);
|
|
122
|
-
try {
|
|
77
|
+
function toolSet(env: NodeJS.ProcessEnv) {
|
|
78
|
+
const notes = async (meta: Meta) => {
|
|
123
79
|
const { binding, rootSessionId, model } = await identityFor(meta, env);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
80
|
+
await readNative(binding, rootSessionId, false, meta, env);
|
|
81
|
+
return notesToolContext(notesIdentityFor(binding, model), binding.cwd);
|
|
82
|
+
};
|
|
83
|
+
const history = async (meta: Meta, params: Record<string, unknown>): Promise<HistoryContext> => {
|
|
84
|
+
const { binding, rootSessionId } = await identityFor(meta, env);
|
|
130
85
|
const current = async () => (await readNative(binding, rootSessionId, true, meta, env) as Awaited<ReturnType<typeof readCodexHistory>>).projection;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return failure("codex_error", shellFree(error));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function tools(): Tool[] {
|
|
141
|
-
return Object.entries(OPERATIONS).map(([name, bound]) => ({
|
|
142
|
-
name,
|
|
143
|
-
description: bound.operation.description,
|
|
144
|
-
inputSchema: JSON.parse(JSON.stringify(bound.operation.parameters)) as Tool["inputSchema"],
|
|
145
|
-
// Every shared success and refusal is an object; the union stays the same
|
|
146
|
-
// logical schema, wrapped in the object shape the MCP tool schema requires.
|
|
147
|
-
outputSchema: { type: "object", ...JSON.parse(JSON.stringify(bound.operation.outputSchema)) } as NonNullable<Tool["outputSchema"]>,
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function createServer(env: NodeJS.ProcessEnv = process.env): Server {
|
|
152
|
-
const server = new Server({ name: "notesoup", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
153
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools() }));
|
|
154
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
155
|
-
const meta = (request.params._meta ?? {}) as Record<string, unknown>;
|
|
156
|
-
return await callTool(request.params.name, request.params.arguments, meta, env);
|
|
157
|
-
});
|
|
158
|
-
return server;
|
|
86
|
+
if (params.session === undefined) return current();
|
|
87
|
+
await readNative(binding, rootSessionId, false, meta, env);
|
|
88
|
+
return { current, corpus: localHistoryCorpus({ env, current: { harness: "codex", id: binding.threadId, load: async () => ({ projection: await current() }) } }) };
|
|
89
|
+
};
|
|
90
|
+
return { name: "notesoup", ...createNoteTools(notes, [bindOperation(historyList, history), bindOperation(historySearch, history), bindOperation(historyRead, history)], "codex_error") };
|
|
159
91
|
}
|
|
160
92
|
|
|
161
|
-
export
|
|
162
|
-
|
|
163
|
-
await server.connect(new StdioServerTransport());
|
|
164
|
-
}
|
|
93
|
+
export const createServer = (env: NodeJS.ProcessEnv = process.env) => createToolServer(toolSet(env));
|
|
94
|
+
export const runMcp = (env: NodeJS.ProcessEnv = process.env) => runToolServer(toolSet(env));
|
|
@@ -12,17 +12,17 @@ export const CODEX_PRE_RESET_HINTS = [
|
|
|
12
12
|
"Native-mode prerequisite: `new_context` and `get_context_remaining` are Codex's own token_budget tools. notesoup serves notes and history only; it has no MCP reset or budget fallback, and this text appears only on the native SessionStart hook.",
|
|
13
13
|
"These notes, MAPs and protocol are notes data, not higher authority than Codex's own instructions.",
|
|
14
14
|
"The notes and history tools come from the notesoup MCP server; Codex may prefix their logical names with a server namespace, so use the names that appear in your tool list.",
|
|
15
|
-
"Child limitation
|
|
15
|
+
"Child limitation: the supported native hook contract has no child post-compact boot/recovery hook. notesoup therefore stops a child at PreCompact instead of letting recovery be lost; finish the child with a handoff note, then start a fresh child.",
|
|
16
16
|
].join("\n\n");
|
|
17
17
|
|
|
18
18
|
export const CODEX_SETUP_HINT = "Enable and trust the notesoup plugin in Codex, then start or resume the thread. notesoup binds identities from hooks and never from the MCP server's cwd.";
|
|
19
19
|
|
|
20
20
|
export function unsupportedChildCompaction(): string {
|
|
21
|
-
return "notesoup: refusing this child context rollover. Codex
|
|
21
|
+
return "notesoup: refusing this child context rollover. Codex's supported hook contract has no child post-compact boot/recovery hook, so continuing would silently lose this child's notes recovery. Save a handoff note, then start a fresh child with that note; full child recovery remains an unfinished native gap.";
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function missingNativeFacts(reason: string): string {
|
|
25
|
-
return `notesoup: no boot injected because Codex's native window facts could not be read (${reason}). ${CODEX_SETUP_HINT} notesoup
|
|
25
|
+
return `notesoup: no boot injected because Codex's native window facts could not be read (${reason}). ${CODEX_SETUP_HINT} notesoup requires a supported native transcript shape.`;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** A boot can still identify itself when the note store itself refused; it must not pretend notebooks are empty. */
|
package/plugins/dsh/tools.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { defineTool, type JsonSchemaNode, type ObjectJsonSchema, type ToolRunCon
|
|
|
5
5
|
import type { Static, TSchema } from "typebox";
|
|
6
6
|
import { Check, Errors } from "typebox/value";
|
|
7
7
|
import { notesList, notesRead, notesUpdate, notesWrite } from "../../src/tools/notes.js";
|
|
8
|
-
import { historyList, historyRead } from "../../src/tools/history.js";
|
|
8
|
+
import { historyList, historySearch, historyRead } from "../../src/tools/history.js";
|
|
9
9
|
import { success } from "../../src/result.js";
|
|
10
10
|
import type { Operation } from "../../src/tools/result.js";
|
|
11
11
|
import { historyContext } from "./history.js";
|
|
@@ -35,9 +35,12 @@ function register<P extends TSchema, D, R extends readonly unknown[]>(ctx: Conte
|
|
|
35
35
|
name: operation.name,
|
|
36
36
|
description: operation.description,
|
|
37
37
|
parameters: hostSchema(operation.parameters) as ObjectJsonSchema & Record<string, unknown>,
|
|
38
|
-
output: {
|
|
38
|
+
output: operation.outputSchema !== undefined ? {
|
|
39
39
|
schema: hostSchema(operation.outputSchema),
|
|
40
40
|
render: (_args, value) => [{ type: "text", text: operation.render(success(value as D)) }],
|
|
41
|
+
} : {
|
|
42
|
+
schema: { type: "string" },
|
|
43
|
+
render: (_args, value) => [{ type: "text", text: value as string }],
|
|
41
44
|
},
|
|
42
45
|
async execute(args, exec) {
|
|
43
46
|
const agent = requireAgent(exec);
|
|
@@ -50,7 +53,7 @@ function register<P extends TSchema, D, R extends readonly unknown[]>(ctx: Conte
|
|
|
50
53
|
exec.signal.throwIfAborted();
|
|
51
54
|
const result = await operation.execute(args as Static<P>, ...rest);
|
|
52
55
|
if (!result.ok) throw new HarnessError(operation.render(result), result.error.code);
|
|
53
|
-
return result.data;
|
|
56
|
+
return operation.outputSchema !== undefined ? result.data : operation.render(result);
|
|
54
57
|
},
|
|
55
58
|
});
|
|
56
59
|
}
|
|
@@ -76,10 +79,11 @@ export function registerTools(ctx: Context, engine: NotesoupCompactionEngine): v
|
|
|
76
79
|
register(ctx, notesRead, (agent) => [toolContext(agent)] as const);
|
|
77
80
|
register(ctx, notesList, (agent) => [toolContext(agent)] as const);
|
|
78
81
|
register(ctx, historyList, (agent) => [historyContext(ctx, agent.session.id)] as const);
|
|
82
|
+
register(ctx, historySearch, (agent) => [historyContext(ctx, agent.session.id)] as const);
|
|
79
83
|
register(ctx, historyRead, (agent) => [historyContext(ctx, agent.session.id)] as const);
|
|
80
84
|
ctx.tools.register(defineTool({
|
|
81
85
|
name: "empty_brain",
|
|
82
|
-
description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history
|
|
86
|
+
description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history survive.",
|
|
83
87
|
parameters: {},
|
|
84
88
|
output: { schema: { type: "object", properties: { window_id: { type: "string", required: true }, reset_requested: { type: "boolean", required: true } }, additionalProperties: false }, render: (_args, value) => [{ type: "text", text: `notesoup: reset requested for ${value.window_id}; finish this tool batch, then recover from your notes.` }] },
|
|
85
89
|
async execute(_args, exec) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Bind each core operation to host context, resolved only after validating this request. */
|
|
2
|
+
import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { Static, TSchema } from "typebox";
|
|
4
|
+
import { Check } from "typebox/value";
|
|
5
|
+
import { notesList, notesRead, notesUpdate, notesWrite } from "../../src/tools/notes.js";
|
|
6
|
+
import type { NotesToolContext } from "../../src/tools/notes-context.js";
|
|
7
|
+
import { wireResult, type Operation } from "../../src/tools/result.js";
|
|
8
|
+
import { paramProblem } from "../../src/tools/schema.js";
|
|
9
|
+
import type { Meta, ToolSet } from "./server.js";
|
|
10
|
+
|
|
11
|
+
type Bound = { tool: Tool; structured: boolean; call(args: unknown, meta: Meta): Promise<CallToolResult> };
|
|
12
|
+
type Resolve<C> = (meta: Meta, params: Record<string, unknown>) => Promise<C>;
|
|
13
|
+
|
|
14
|
+
function refusal(code: string, message: string, structured = false): CallToolResult {
|
|
15
|
+
return { content: [{ type: "text", text: `error: ${code}: ${message}` }], ...(structured ? { structuredContent: { error: message, code } } : {}), isError: true };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function bindOperation<P extends TSchema, D, C>(op: Operation<P, D, [C]>, resolve: Resolve<C>): Bound {
|
|
19
|
+
const structured = op.outputSchema !== undefined;
|
|
20
|
+
return {
|
|
21
|
+
structured,
|
|
22
|
+
tool: { name: op.name, description: op.description, inputSchema: JSON.parse(JSON.stringify(op.parameters)),
|
|
23
|
+
...(structured ? { outputSchema: { type: "object", ...JSON.parse(JSON.stringify(op.outputSchema)) } } : {}) },
|
|
24
|
+
async call(args, meta) {
|
|
25
|
+
const params = args ?? {};
|
|
26
|
+
if (!Check(op.parameters, params)) return refusal("invalid_params", `invalid ${op.name} parameters: ${paramProblem(op.parameters, params)}`, structured);
|
|
27
|
+
const ctx = await resolve(meta, params as Record<string, unknown>);
|
|
28
|
+
const outcome = await op.execute(params as Static<P>, ctx);
|
|
29
|
+
return { content: [{ type: "text", text: op.render(outcome) }], ...(structured ? { structuredContent: wireResult(outcome) as Record<string, unknown> } : {}),
|
|
30
|
+
...(outcome.ok ? {} : { isError: true }) };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createNoteTools(resolve: Resolve<NotesToolContext>, additional: Bound[] = [], fallbackCode = "notesoup_error"): ToolSet {
|
|
36
|
+
const entries = [bindOperation(notesWrite, resolve), bindOperation(notesUpdate, resolve), bindOperation(notesRead, resolve), bindOperation(notesList, resolve), ...additional];
|
|
37
|
+
const byName = new Map(entries.map(entry => [entry.tool.name, entry]));
|
|
38
|
+
return {
|
|
39
|
+
tools: () => entries.map(entry => entry.tool),
|
|
40
|
+
async callTool(name, args, meta) {
|
|
41
|
+
const entry = byName.get(name);
|
|
42
|
+
if (!entry) return refusal("unknown_tool", `No notesoup operation named ${JSON.stringify(name)}.`);
|
|
43
|
+
try { return await entry.call(args, meta); }
|
|
44
|
+
catch (e) {
|
|
45
|
+
const code = e instanceof Error && "code" in e && typeof e.code === "string" ? e.code : fallbackCode;
|
|
46
|
+
return refusal(code, (e instanceof Error ? e.message : String(e)).replace(/[\r\n]+/g, " ").slice(0, 500), entry.structured);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** MCP framing only. Host facts belong to the tool call, not to the server process. */
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, type CallToolResult, type Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
|
|
6
|
+
export type Meta = Record<string, unknown>;
|
|
7
|
+
export type ToolSet = {
|
|
8
|
+
tools(): Tool[];
|
|
9
|
+
callTool(name: string, args: unknown, meta: Meta): Promise<CallToolResult>;
|
|
10
|
+
};
|
|
11
|
+
type ServerOptions = ToolSet & { name: string };
|
|
12
|
+
|
|
13
|
+
export function createToolServer(options: ServerOptions): Server {
|
|
14
|
+
const server = new Server({ name: options.name, version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
15
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: options.tools() }));
|
|
16
|
+
server.setRequestHandler(CallToolRequestSchema, async ({ params }) =>
|
|
17
|
+
options.callTool(params.name, params.arguments, params._meta ?? {}));
|
|
18
|
+
return server;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function runToolServer(options: ServerOptions): Promise<void> {
|
|
22
|
+
await createToolServer(options).connect(new StdioServerTransport());
|
|
23
|
+
}
|
package/plugins/paseo/README.md
CHANGED
|
@@ -13,16 +13,11 @@ Install this directory with `paseo plugin install /absolute/path/to/plugins/pase
|
|
|
13
13
|
|
|
14
14
|
## Markdown maintenance
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
When changing rendering behavior, copy both files to the other plugin and run
|
|
20
|
-
`npm test && npm run typecheck` in both plugin directories. Compare the files
|
|
21
|
-
with `diff -u` before delivery. Each `client/markdown.tsx` owns its palette and
|
|
22
|
-
wrapper; do not copy those adapters.
|
|
16
|
+
Markdown parsing and block/inline rendering come from `@astrosheep/paseo-ui/markdown`,
|
|
17
|
+
shared across Paseo plugins. `client/markdown.tsx` owns only Notesoup's warm paper palette
|
|
18
|
+
tokens and `<NoteMarkdown />` / `<NoteInline />` wrappers.
|
|
23
19
|
|
|
24
|
-
The
|
|
20
|
+
The shared renderer handles inline nesting, block structure, selectable text, safe `http(s)`/`mailto`
|
|
25
21
|
link presses, and horizontal code/table scrolling. Images render as alt text or `[image]`;
|
|
26
|
-
this is not the full Paseo assistant renderer.
|
|
27
|
-
primitives, not native layout. Verify wrapping, selection and scrolling on iOS
|
|
22
|
+
this is not the full Paseo assistant renderer. Verify wrapping, selection and scrolling on iOS
|
|
28
23
|
before claiming visual or gesture correctness.
|
|
@@ -3,7 +3,7 @@ import { Modal } from "@getpaseo/plugin/client/react-native";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Pressable, Text, View } from "react-native";
|
|
5
5
|
import type { BrainEmpty } from "../shared/brain-empty.ts";
|
|
6
|
-
import { typography } from "
|
|
6
|
+
import { typography } from "@astrosheep/paseo-ui/theme";
|
|
7
7
|
|
|
8
8
|
function label(data: BrainEmpty): string {
|
|
9
9
|
if (data.status === "running") return "✂ emptying brain …";
|
|
@@ -25,10 +25,10 @@ function CutLine({ color }: { color: string }) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function BrainEmptyDivider({ item, theme }: PluginTimelineItemProps<BrainEmpty>) {
|
|
28
|
+
export function BrainEmptyDivider({ item, layout, theme }: PluginTimelineItemProps<BrainEmpty>) {
|
|
29
29
|
const [lastWordOpen, setLastWordOpen] = useState(false);
|
|
30
30
|
const data = item.data;
|
|
31
|
-
const type = typography(theme);
|
|
31
|
+
const type = typography(theme, layout.platform);
|
|
32
32
|
const refused = data.error !== undefined || data.status === "failed";
|
|
33
33
|
const color = refused ? theme.colors.statusDanger : theme.colors.foregroundMuted;
|
|
34
34
|
const hasLastWord = data.outcome === "rollover_requested" && data.lastWord !== undefined;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
MarkdownBlock,
|
|
4
|
+
MarkdownInline,
|
|
5
|
+
type MarkdownStyles,
|
|
6
|
+
type MarkdownTokens,
|
|
7
|
+
} from "@astrosheep/paseo-ui/markdown";
|
|
8
|
+
import { hairlineWidth, type Typography } from "@astrosheep/paseo-ui/theme";
|
|
5
9
|
import type { PaperPalette } from "./paper-palette.ts";
|
|
6
|
-
import type { Typography } from "./typography.ts";
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Omit `strong`, `em`, and `code` colors so inline Markdown runs inherit their parent
|
|
13
|
+
* text color (e.g. green `paper.added` inside `NoteInline` diff previews).
|
|
14
|
+
*/
|
|
15
|
+
function paperTokens(paper: PaperPalette): MarkdownTokens {
|
|
16
|
+
return {
|
|
17
|
+
text: paper.ink,
|
|
18
|
+
muted: paper.inkMuted,
|
|
19
|
+
heading: paper.ink,
|
|
20
|
+
link: paper.added,
|
|
21
|
+
inlineCodeBg: `${paper.ink}10`,
|
|
22
|
+
codeBg: paper.crumpled,
|
|
23
|
+
border: paper.edge,
|
|
24
|
+
quoteBg: "transparent",
|
|
25
|
+
quoteBorder: paper.edge,
|
|
26
|
+
tableHeadBg: paper.crumpled,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
9
29
|
|
|
10
|
-
function
|
|
11
|
-
const hairline = { borderWidth:
|
|
30
|
+
function paperOverrides(paper: PaperPalette): Partial<MarkdownStyles> {
|
|
31
|
+
const hairline = { borderWidth: hairlineWidth, borderColor: paper.edge };
|
|
12
32
|
return {
|
|
13
|
-
block: { gap: 8 },
|
|
14
|
-
text: { ...type.body, color: paper.ink },
|
|
15
|
-
muted: { ...type.body, color: paper.inkMuted },
|
|
16
|
-
strong: { fontWeight: "600" },
|
|
17
|
-
em: { fontStyle: "italic" },
|
|
18
|
-
del: { color: paper.inkMuted, textDecorationLine: "line-through" },
|
|
19
|
-
// No borderRadius here: nested rounded Text backgrounds paint a wrapped slab on iOS Fabric.
|
|
20
|
-
// A faint ink wash keeps flush glyph edges gentle and stays visible on crumpled paper too.
|
|
21
|
-
inlineCode: { ...type.inlineCode, backgroundColor: `${paper.ink}10` },
|
|
22
|
-
link: { color: paper.added, textDecorationLine: "underline" },
|
|
23
|
-
heading: { ...type.base, fontWeight: "600", color: paper.ink, letterSpacing: -0.1 },
|
|
24
33
|
quote: { borderLeftWidth: 2, borderLeftColor: paper.edge, paddingLeft: 10, gap: 4 },
|
|
25
|
-
quoteText: { color: paper.inkMuted },
|
|
26
34
|
codeBlock: { ...hairline, backgroundColor: paper.crumpled, borderRadius: 4 },
|
|
27
35
|
codeContent: { paddingVertical: 6, paddingHorizontal: 8 },
|
|
28
|
-
|
|
29
|
-
separator: { height: StyleSheet.hairlineWidth, backgroundColor: paper.edge, marginVertical: 2 },
|
|
30
|
-
list: { gap: 4 },
|
|
31
|
-
listRow: { flexDirection: "row" },
|
|
32
|
-
listItem: { flex: 1, gap: 4 },
|
|
33
|
-
bullet: { ...type.body, color: paper.inkMuted, minWidth: 18, paddingRight: 6,
|
|
34
|
-
textAlign: "right", fontVariant: ["tabular-nums"] },
|
|
36
|
+
separator: { height: hairlineWidth, backgroundColor: paper.edge, marginVertical: 2 },
|
|
35
37
|
table: { ...hairline, borderRadius: 4, overflow: "hidden" },
|
|
36
|
-
|
|
37
|
-
tableRow: { flexDirection: "row", borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: paper.edge },
|
|
38
|
-
tableCell: { paddingVertical: 4, paddingHorizontal: 8 },
|
|
38
|
+
tableRow: { flexDirection: "row", borderTopWidth: hairlineWidth, borderTopColor: paper.edge },
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -46,18 +46,30 @@ export function NoteInline({ text, paper, type, color, numberOfLines }: {
|
|
|
46
46
|
color?: string;
|
|
47
47
|
numberOfLines?: number;
|
|
48
48
|
}) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const tokens = useMemo(() => paperTokens(paper), [paper]);
|
|
50
|
+
const overrides = useMemo(() => paperOverrides(paper), [paper]);
|
|
51
51
|
return (
|
|
52
|
-
<
|
|
53
|
-
{
|
|
54
|
-
|
|
52
|
+
<MarkdownInline
|
|
53
|
+
text={text}
|
|
54
|
+
tokens={tokens}
|
|
55
|
+
type={type}
|
|
56
|
+
color={color ?? paper.ink}
|
|
57
|
+
numberOfLines={numberOfLines}
|
|
58
|
+
overrides={overrides}
|
|
59
|
+
/>
|
|
55
60
|
);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export function NoteMarkdown({ text, paper, type, muted = false }: { text: string; paper: PaperPalette; type: Typography; muted?: boolean }) {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const tokens = useMemo(() => paperTokens(paper), [paper]);
|
|
65
|
+
const overrides = useMemo(() => paperOverrides(paper), [paper]);
|
|
66
|
+
return (
|
|
67
|
+
<MarkdownBlock
|
|
68
|
+
text={text}
|
|
69
|
+
tokens={tokens}
|
|
70
|
+
type={type}
|
|
71
|
+
overrides={overrides}
|
|
72
|
+
textStyle={muted ? { color: paper.inkMuted } : undefined}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
63
75
|
}
|
|
@@ -6,7 +6,7 @@ import { COLLAPSED_PREVIEW_MAX_CHARS, outputPreview, type NotesOp } from "../sha
|
|
|
6
6
|
import { NoteInline, NoteMarkdown } from "./markdown.tsx";
|
|
7
7
|
import { PaperCard } from "./paper-card.tsx";
|
|
8
8
|
import { paperPalette, type PaperPalette } from "./paper-palette.ts";
|
|
9
|
-
import { typography, type Typography } from "
|
|
9
|
+
import { hairlineWidth, hitSlop, typography, type Typography } from "@astrosheep/paseo-ui/theme";
|
|
10
10
|
|
|
11
11
|
const OP_LABEL: Record<NotesOp["op"], string> = { read: "read", write: "wrote", update: "edited" };
|
|
12
12
|
const OP_LABEL_RUNNING: Record<NotesOp["op"], string> = { read: "reading", write: "writing", update: "editing" };
|
|
@@ -34,7 +34,7 @@ function DiffBody({ diff, paper, style }: { diff: string; paper: PaperPalette; s
|
|
|
34
34
|
export function NotesOpCard({ item, layout, theme }: PluginTimelineItemProps<NotesOp>) {
|
|
35
35
|
const [expanded, setExpanded] = useState(false);
|
|
36
36
|
const paper = paperPalette(theme);
|
|
37
|
-
const type = useMemo(() => typography(theme), [theme]);
|
|
37
|
+
const type = useMemo(() => typography(theme, layout.platform), [theme, layout.platform]);
|
|
38
38
|
const data = item.data;
|
|
39
39
|
const title = data.status === "running" ? OP_LABEL_RUNNING[data.op] : OP_LABEL[data.op];
|
|
40
40
|
const hasBody = Boolean(data.text || data.preview || data.diff);
|
|
@@ -48,17 +48,20 @@ export function NotesOpCard({ item, layout, theme }: PluginTimelineItemProps<Not
|
|
|
48
48
|
accessibilityRole="button"
|
|
49
49
|
accessibilityLabel={`${expanded ? "收起" : "展开"} ${data.address}`}
|
|
50
50
|
aria-expanded={expanded}
|
|
51
|
+
hitSlop={hasBody ? hitSlop : undefined}
|
|
51
52
|
onPress={hasBody ? () => setExpanded(value => !value) : undefined}
|
|
52
53
|
disabled={!hasBody}
|
|
53
54
|
style={({ pressed }) => ({ gap: 4, opacity: pressed && hasBody ? 0.7 : 1 })}
|
|
54
55
|
>
|
|
55
56
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
56
|
-
<
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{data.
|
|
61
|
-
|
|
57
|
+
<View style={{ flexDirection: "row", alignItems: "baseline", gap: 8, flex: 1, minWidth: 0 }}>
|
|
58
|
+
<Text style={{ ...type.sm, color: paper.inkMuted, flexShrink: 0 }}>
|
|
59
|
+
{data.crumpled ? "crumpled" : title}{data.status === "running" ? " …" : ""}
|
|
60
|
+
</Text>
|
|
61
|
+
<Text numberOfLines={1} style={{ ...type.base, color: data.crumpled ? paper.inkMuted : paper.ink, flex: 1, minWidth: 0, textDecorationLine: data.crumpled ? "line-through" : "none" }}>
|
|
62
|
+
{data.address}
|
|
63
|
+
</Text>
|
|
64
|
+
</View>
|
|
62
65
|
{hasBody && <Icon name={expanded ? "ChevronUp" : "ChevronDown"} size={12} color={paper.inkMuted} />}
|
|
63
66
|
</View>
|
|
64
67
|
{peek !== undefined && (
|
|
@@ -73,7 +76,7 @@ export function NotesOpCard({ item, layout, theme }: PluginTimelineItemProps<Not
|
|
|
73
76
|
{data.error !== undefined && <Text selectable style={{ ...type.sm, color: paper.removed }}>{data.error}</Text>}
|
|
74
77
|
</Pressable>
|
|
75
78
|
{expanded && hasBody && (
|
|
76
|
-
<ScrollView style={{ maxHeight: layout.compact ? 280 : 400, marginTop: 2, borderTopWidth:
|
|
79
|
+
<ScrollView style={{ maxHeight: layout.compact ? 280 : 400, marginTop: 2, borderTopWidth: hairlineWidth, borderTopColor: paper.edge }} contentContainerStyle={{ gap: 5, paddingTop: 8 }} nestedScrollEnabled>
|
|
77
80
|
{data.text !== undefined && <NoteMarkdown text={outputPreview(data.text)} paper={paper} type={type} />}
|
|
78
81
|
{data.preview !== undefined && <NoteMarkdown text={outputPreview(data.preview)} paper={paper} type={type} />}
|
|
79
82
|
{data.diff !== undefined && <DiffBody diff={outputPreview(data.diff)} paper={paper} style={type.code} />}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { cardSpacing, hairlineWidth } from "@astrosheep/paseo-ui/theme";
|
|
3
4
|
import type { PaperPalette } from "./paper-palette.ts";
|
|
4
5
|
|
|
5
6
|
function Tape({ paper }: { paper: PaperPalette }) {
|
|
@@ -22,12 +23,12 @@ export function PaperCard({ paper, compact, crumpled = false, children }: {
|
|
|
22
23
|
<View style={{ paddingTop: 7 }}>
|
|
23
24
|
<Tape paper={paper} />
|
|
24
25
|
<View style={{
|
|
25
|
-
paddingVertical: compact ?
|
|
26
|
-
paddingHorizontal:
|
|
27
|
-
gap:
|
|
26
|
+
paddingVertical: compact ? cardSpacing.compactPaddingVertical : cardSpacing.paddingVertical,
|
|
27
|
+
paddingHorizontal: cardSpacing.paddingHorizontal,
|
|
28
|
+
gap: cardSpacing.gap,
|
|
28
29
|
minWidth: 0,
|
|
29
30
|
borderRadius: 4,
|
|
30
|
-
borderWidth:
|
|
31
|
+
borderWidth: hairlineWidth,
|
|
31
32
|
borderColor: paper.edge,
|
|
32
33
|
backgroundColor: crumpled ? paper.crumpled : paper.background,
|
|
33
34
|
position: "relative",
|