toolcraft 0.0.128 → 0.0.129
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/composition.json +2 -2
- package/dist/composition.json +2 -2
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +21 -2
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +9 -6
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +2 -2
package/composition.json
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"name": "toolcraft",
|
|
111
|
-
"version": "0.0.
|
|
111
|
+
"version": "0.0.129",
|
|
112
112
|
"license": "MIT"
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
120
|
"name": "toolcraft-schema",
|
|
121
|
-
"version": "0.0.
|
|
121
|
+
"version": "0.0.129",
|
|
122
122
|
"license": "MIT"
|
|
123
123
|
},
|
|
124
124
|
{
|
package/dist/composition.json
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"name": "toolcraft",
|
|
111
|
-
"version": "0.0.
|
|
111
|
+
"version": "0.0.129",
|
|
112
112
|
"license": "MIT"
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
120
|
"name": "toolcraft-schema",
|
|
121
|
-
"version": "0.0.
|
|
121
|
+
"version": "0.0.129",
|
|
122
122
|
"license": "MIT"
|
|
123
123
|
},
|
|
124
124
|
{
|
|
@@ -6,6 +6,7 @@ type ExplorerKeypressEvent = Extract<ExplorerEvent, {
|
|
|
6
6
|
}>["key"];
|
|
7
7
|
export type ActionRuntimeHandles = {
|
|
8
8
|
refresh: () => Promise<void>;
|
|
9
|
+
reloadDetail: (rowId?: string) => void;
|
|
9
10
|
suspendAnd: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
10
11
|
openModal: (content: {
|
|
11
12
|
title: string;
|
|
@@ -19,6 +19,7 @@ export function buildActionContext(state, _action, source, runtimeHandles, rowsO
|
|
|
19
19
|
item: source === "detail" ? currentDetailItem(state) : undefined,
|
|
20
20
|
filter: state.filter,
|
|
21
21
|
refresh: runtimeHandles.refresh,
|
|
22
|
+
reloadDetail: runtimeHandles.reloadDetail,
|
|
22
23
|
suspendAnd: runtimeHandles.suspendAnd,
|
|
23
24
|
openModal: runtimeHandles.openModal,
|
|
24
25
|
toast: runtimeHandles.toast,
|
|
@@ -4,6 +4,7 @@ import { REGION_ALL, REGION_DETAIL, REGION_FOOTER, REGION_HEADER, REGION_LIST, R
|
|
|
4
4
|
const NO_EFFECTS = [];
|
|
5
5
|
const DEFAULT_ACTION_HANDLES = {
|
|
6
6
|
refresh: async () => undefined,
|
|
7
|
+
reloadDetail: () => undefined,
|
|
7
8
|
suspendAnd: async (fn) => fn(),
|
|
8
9
|
openModal: () => undefined,
|
|
9
10
|
toast: () => undefined,
|
|
@@ -44,6 +44,9 @@ class ExplorerRuntime {
|
|
|
44
44
|
refresh: async () => {
|
|
45
45
|
await this.refreshRowsFromSource();
|
|
46
46
|
},
|
|
47
|
+
reloadDetail: (rowId) => {
|
|
48
|
+
this.reloadFocusedDetail(rowId);
|
|
49
|
+
},
|
|
47
50
|
suspendAnd: async (fn) => this.suspendAnd(fn),
|
|
48
51
|
openModal: (content) => {
|
|
49
52
|
this.dispatch({ type: "modalOpened", title: content.title, content: content.content });
|
|
@@ -62,6 +65,10 @@ class ExplorerRuntime {
|
|
|
62
65
|
this.settle = { resolve, reject };
|
|
63
66
|
try {
|
|
64
67
|
this.startTerminal();
|
|
68
|
+
if (this.config.initialRows !== undefined && this.config.initialRows.length > 0) {
|
|
69
|
+
// Seed list/detail before first paint so callers with known rows avoid an empty flash.
|
|
70
|
+
this.dispatch({ type: "rowsLoaded", rows: this.config.initialRows });
|
|
71
|
+
}
|
|
65
72
|
this.render();
|
|
66
73
|
this.loadRows().catch((error) => {
|
|
67
74
|
this.fail(error);
|
|
@@ -145,13 +152,25 @@ class ExplorerRuntime {
|
|
|
145
152
|
rows: this.state.size.rows,
|
|
146
153
|
detailHidden: this.state.layout === "narrow-list-only" || this.state.layout === "too-narrow"
|
|
147
154
|
});
|
|
148
|
-
|
|
155
|
+
const reloadDetail = () => this.reloadFocusedDetail(rowId);
|
|
156
|
+
void this.detailJobs.schedule(rowId, (ctx) => this.config.detail.items(row, { ...ctx, reloadDetail }), {
|
|
149
157
|
width: layout.detail.width,
|
|
150
158
|
height: layout.detail.height,
|
|
151
159
|
row,
|
|
152
|
-
signal: new AbortController().signal
|
|
160
|
+
signal: new AbortController().signal,
|
|
161
|
+
reloadDetail
|
|
153
162
|
});
|
|
154
163
|
}
|
|
164
|
+
reloadFocusedDetail(rowId) {
|
|
165
|
+
const focusedId = this.state.detail.rowId;
|
|
166
|
+
if (focusedId === null) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (rowId !== undefined && rowId !== focusedId) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.renderDetail(focusedId);
|
|
173
|
+
}
|
|
155
174
|
loadDetailContent(rowId, token, items) {
|
|
156
175
|
const row = this.state.rows.find((candidate) => candidate.id === rowId);
|
|
157
176
|
if (row === undefined) {
|
|
@@ -30,6 +30,8 @@ export interface DetailCtx {
|
|
|
30
30
|
height: number;
|
|
31
31
|
signal: AbortSignal;
|
|
32
32
|
row: Row;
|
|
33
|
+
/** Re-run detail.items for the focused row and repaint the preview pane. */
|
|
34
|
+
reloadDetail?: () => void;
|
|
33
35
|
}
|
|
34
36
|
export interface Action<R> {
|
|
35
37
|
id: string;
|
|
@@ -47,6 +49,8 @@ export interface ActionContext<R> {
|
|
|
47
49
|
item?: DetailItem;
|
|
48
50
|
filter: string;
|
|
49
51
|
refresh: () => Promise<void>;
|
|
52
|
+
/** Re-run detail.items for the focused row and repaint the preview pane. */
|
|
53
|
+
reloadDetail: () => void;
|
|
50
54
|
suspendAnd: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
51
55
|
openModal: (content: {
|
|
52
56
|
title: string;
|
|
@@ -73,6 +77,8 @@ export interface ExplorerConfig<R> {
|
|
|
73
77
|
keybindOverrides?: Record<string, string | string[]>;
|
|
74
78
|
emptyHint?: string;
|
|
75
79
|
initialFilter?: string;
|
|
80
|
+
/** Synchronous first paint rows; still refreshed via `rows()` after start. */
|
|
81
|
+
initialRows?: Row[];
|
|
76
82
|
}
|
|
77
83
|
export declare const REGION_HEADER: number;
|
|
78
84
|
export declare const REGION_LIST: number;
|
|
@@ -17,23 +17,26 @@ export function createInitialState(config, size) {
|
|
|
17
17
|
rows: normalizeSize(size.rows)
|
|
18
18
|
};
|
|
19
19
|
const multiSelect = config.multiSelect ?? true;
|
|
20
|
+
const initialRows = config.initialRows ?? [];
|
|
21
|
+
const initialFilter = config.initialFilter ?? "";
|
|
22
|
+
// Defer filtering to first rowsLoaded when empty; seed list immediately when provided.
|
|
20
23
|
return {
|
|
21
24
|
title: config.title,
|
|
22
25
|
emptyHint: config.emptyHint ?? "No detail",
|
|
23
|
-
rows:
|
|
24
|
-
filtered:
|
|
26
|
+
rows: initialRows,
|
|
27
|
+
filtered: initialRows.map((_, index) => index),
|
|
25
28
|
matchPositions: new Map(),
|
|
26
29
|
cursor: 0,
|
|
27
|
-
filter:
|
|
30
|
+
filter: initialFilter,
|
|
28
31
|
filterFocused: false,
|
|
29
32
|
focused: "list",
|
|
30
33
|
detail: {
|
|
31
|
-
rowId: null,
|
|
34
|
+
rowId: initialRows[0]?.id ?? null,
|
|
32
35
|
items: null,
|
|
33
36
|
cursor: 0,
|
|
34
37
|
scroll: 0,
|
|
35
|
-
token: 0,
|
|
36
|
-
loading:
|
|
38
|
+
token: initialRows.length > 0 ? 1 : 0,
|
|
39
|
+
loading: initialRows.length > 0
|
|
37
40
|
},
|
|
38
41
|
selected: new Set(),
|
|
39
42
|
multiSelect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.129",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"yaml"
|
|
154
154
|
],
|
|
155
155
|
"optionalDependencies": {
|
|
156
|
-
"toolcraft-schema": "0.0.
|
|
156
|
+
"toolcraft-schema": "0.0.129",
|
|
157
157
|
"toolcraft-design": "*",
|
|
158
158
|
"@poe-code/frontmatter": "*",
|
|
159
159
|
"@poe-code/agent-mcp-config": "*",
|