poe-code 3.0.222 → 3.0.224
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/cli/commands/configure-payload.js +72 -15
- package/dist/cli/commands/configure-payload.js.map +1 -1
- package/dist/cli/commands/configure.d.ts +2 -0
- package/dist/cli/commands/configure.js +55 -15
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/commands/ensure-isolated-config.js +24 -3
- package/dist/cli/commands/ensure-isolated-config.js.map +1 -1
- package/dist/cli/commands/harness.js +45 -2
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/cli/commands/login.js +11 -2
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/plan.js +52 -20
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/provider.d.ts +2 -0
- package/dist/cli/commands/provider.js +126 -3
- package/dist/cli/commands/provider.js.map +1 -1
- package/dist/cli/commands/shared.d.ts +16 -1
- package/dist/cli/commands/shared.js +141 -18
- package/dist/cli/commands/shared.js.map +1 -1
- package/dist/cli/commands/spawn.js +24 -3
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/commands/tasks-options.d.ts +9 -1
- package/dist/cli/commands/tasks-options.js +88 -5
- package/dist/cli/commands/tasks-options.js.map +1 -1
- package/dist/cli/commands/tasks.js +250 -7
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/constants.d.ts +1 -2
- package/dist/cli/constants.js +1 -13
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/container.js +22 -9
- package/dist/cli/container.js.map +1 -1
- package/dist/cli/environment.d.ts +1 -0
- package/dist/cli/environment.js +3 -1
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/options.d.ts +1 -1
- package/dist/cli/options.js +10 -1
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/program.js +127 -13
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/prompt-runner.js +4 -2
- package/dist/cli/prompt-runner.js.map +1 -1
- package/dist/cli/prompts.d.ts +3 -1
- package/dist/cli/prompts.js +13 -0
- package/dist/cli/prompts.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +47146 -26676
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +4547 -1202
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +4558 -1210
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/goose.js +4652 -1137
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +4548 -1203
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +4543 -1198
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +12879 -11508
- package/dist/providers/poe-agent.js.map +4 -4
- package/dist/providers/spawn-options.d.ts +1 -0
- package/dist/sdk/container.js +22 -9
- package/dist/sdk/container.js.map +1 -1
- package/dist/sdk/pipeline.js +1 -0
- package/dist/sdk/pipeline.js.map +1 -1
- package/dist/sdk/spawn-core.d.ts +2 -0
- package/dist/sdk/spawn-core.js +2 -1
- package/dist/sdk/spawn-core.js.map +1 -1
- package/dist/sdk/spawn.d.ts +6 -1
- package/dist/sdk/spawn.js +192 -4
- package/dist/sdk/spawn.js.map +1 -1
- package/dist/sdk/types.d.ts +10 -1
- package/dist/services/config.d.ts +4 -14
- package/dist/services/config.js +12 -54
- package/dist/services/config.js.map +1 -1
- package/dist/workflow-templates/maestro-turn.yml +159 -0
- package/package.json +6 -2
- package/packages/agent-skill-config/dist/bridge-active-skills.d.ts +23 -0
- package/packages/agent-skill-config/dist/bridge-active-skills.js +194 -0
- package/packages/agent-skill-config/dist/configs.d.ts +1 -1
- package/packages/agent-skill-config/dist/configs.js +5 -5
- package/packages/agent-skill-config/dist/git-exclude.d.ts +4 -0
- package/packages/agent-skill-config/dist/git-exclude.js +93 -0
- package/packages/agent-skill-config/dist/index.d.ts +5 -0
- package/packages/agent-skill-config/dist/index.js +3 -0
- package/packages/agent-skill-config/dist/resolve-skill-reference.d.ts +22 -0
- package/packages/agent-skill-config/dist/resolve-skill-reference.js +82 -0
- package/packages/design-system/dist/components/browser.d.ts +15 -0
- package/packages/design-system/dist/components/browser.js +26 -0
- package/packages/design-system/dist/explorer/index.d.ts +1 -1
- package/packages/design-system/dist/explorer/keymap.js +6 -3
- package/packages/design-system/dist/explorer/render/footer.js +14 -0
- package/packages/design-system/dist/explorer/runtime.js +11 -4
- package/packages/design-system/dist/explorer/state.d.ts +6 -1
- package/packages/design-system/dist/index.d.ts +2 -1
- package/packages/design-system/dist/index.js +1 -0
- package/packages/memory/dist/index.js +2564 -568
- package/packages/memory/dist/index.js.map +4 -4
- package/scripts/postinstall-sync-skills.mjs +15 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const markerPrefix = "# poe-code-spawn-skills:";
|
|
5
|
+
function defaultGitDirRunner(cwd) {
|
|
6
|
+
try {
|
|
7
|
+
return execFileSync("git", ["rev-parse", "--git-dir"], {
|
|
8
|
+
cwd,
|
|
9
|
+
encoding: "utf8",
|
|
10
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
11
|
+
}).trim();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let gitDirRunner = defaultGitDirRunner;
|
|
18
|
+
export function setGitDirRunnerForTest(runner) {
|
|
19
|
+
const previous = gitDirRunner;
|
|
20
|
+
gitDirRunner = runner;
|
|
21
|
+
return () => {
|
|
22
|
+
gitDirRunner = previous;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolveExcludePath(cwd) {
|
|
26
|
+
const gitDir = gitDirRunner(cwd);
|
|
27
|
+
if (gitDir === undefined || gitDir.length === 0) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return path.join(path.isAbsolute(gitDir) ? gitDir : path.resolve(cwd, gitDir), "info/exclude");
|
|
31
|
+
}
|
|
32
|
+
function markers(runId) {
|
|
33
|
+
return {
|
|
34
|
+
begin: `${markerPrefix}${runId} begin`,
|
|
35
|
+
end: `${markerPrefix}${runId} end`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function readExcludeFile(excludePath) {
|
|
39
|
+
try {
|
|
40
|
+
return fs.readFileSync(excludePath, "utf8");
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function isNodeError(error) {
|
|
50
|
+
return error instanceof Error && "code" in error;
|
|
51
|
+
}
|
|
52
|
+
function removeBlock(content, runId) {
|
|
53
|
+
const { begin, end } = markers(runId);
|
|
54
|
+
const lines = content.split("\n");
|
|
55
|
+
const result = [];
|
|
56
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
57
|
+
if (lines[index] === begin) {
|
|
58
|
+
const endIndex = lines.indexOf(end, index + 1);
|
|
59
|
+
if (endIndex !== -1) {
|
|
60
|
+
index = endIndex;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
result.push(lines[index]);
|
|
65
|
+
}
|
|
66
|
+
return result.join("\n");
|
|
67
|
+
}
|
|
68
|
+
function appendBlock(content, runId, entries) {
|
|
69
|
+
const { begin, end } = markers(runId);
|
|
70
|
+
const existing = content ?? "";
|
|
71
|
+
const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}\n`;
|
|
72
|
+
return `${prefix}${[begin, ...entries, end, ""].join("\n")}`;
|
|
73
|
+
}
|
|
74
|
+
export function appendExcludeBlock(cwd, runId, entries) {
|
|
75
|
+
const excludePath = resolveExcludePath(cwd);
|
|
76
|
+
if (excludePath === undefined) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
fs.mkdirSync(path.dirname(excludePath), { recursive: true });
|
|
80
|
+
const content = readExcludeFile(excludePath);
|
|
81
|
+
fs.writeFileSync(excludePath, appendBlock(content, runId, entries), "utf8");
|
|
82
|
+
}
|
|
83
|
+
export function removeExcludeBlock(cwd, runId) {
|
|
84
|
+
const excludePath = resolveExcludePath(cwd);
|
|
85
|
+
if (excludePath === undefined) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const content = readExcludeFile(excludePath);
|
|
89
|
+
if (content === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
fs.writeFileSync(excludePath, removeBlock(content, runId), "utf8");
|
|
93
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export type { AgentSkillConfig, AgentSupportResult, AgentSupportStatus, SkillScope } from "./configs.js";
|
|
2
2
|
export type { ApplyOptions, SkillFile } from "./types.js";
|
|
3
|
+
export type { SkillResolution, SkillResolutionFailure, SkillSource } from "./resolve-skill-reference.js";
|
|
4
|
+
export type { BridgeEntry, BridgeManifest, BridgeWarning, BridgeWarningKind } from "./bridge-active-skills.js";
|
|
3
5
|
export { supportedAgents, resolveAgentSupport, getAgentConfig, resolveSkillDir } from "./configs.js";
|
|
4
6
|
export { configure, unconfigure, installSkill, UnsupportedAgentError } from "./apply.js";
|
|
5
7
|
export type { InstallSkillOptions, InstallSkillResult } from "./apply.js";
|
|
8
|
+
export { resolveSkillReference } from "./resolve-skill-reference.js";
|
|
9
|
+
export { appendExcludeBlock, removeExcludeBlock } from "./git-exclude.js";
|
|
10
|
+
export { bridgeActiveSkills, cleanupBridgedSkills } from "./bridge-active-skills.js";
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { supportedAgents, resolveAgentSupport, getAgentConfig, resolveSkillDir } from "./configs.js";
|
|
2
2
|
export { configure, unconfigure, installSkill, UnsupportedAgentError } from "./apply.js";
|
|
3
|
+
export { resolveSkillReference } from "./resolve-skill-reference.js";
|
|
4
|
+
export { appendExcludeBlock, removeExcludeBlock } from "./git-exclude.js";
|
|
5
|
+
export { bridgeActiveSkills, cleanupBridgedSkills } from "./bridge-active-skills.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SkillSource {
|
|
2
|
+
kind: "resolved";
|
|
3
|
+
ref: string;
|
|
4
|
+
name: string;
|
|
5
|
+
sourceAgentId?: string;
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
scope: "project" | "user";
|
|
8
|
+
}
|
|
9
|
+
export type SkillResolutionFailure = {
|
|
10
|
+
kind: "malformed";
|
|
11
|
+
ref: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "unknown-agent";
|
|
14
|
+
ref: string;
|
|
15
|
+
agentInput: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "not-found";
|
|
18
|
+
ref: string;
|
|
19
|
+
searchedPaths: string[];
|
|
20
|
+
};
|
|
21
|
+
export type SkillResolution = SkillSource | SkillResolutionFailure;
|
|
22
|
+
export declare function resolveSkillReference(ref: string, cwd: string, homeDir: string): SkillResolution;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getAgentConfig, resolveAgentSupport, resolveSkillDir } from "./configs.js";
|
|
4
|
+
function isMalformedSegment(segment) {
|
|
5
|
+
return segment.length === 0 || segment !== segment.trim();
|
|
6
|
+
}
|
|
7
|
+
function isDirectory(targetPath) {
|
|
8
|
+
try {
|
|
9
|
+
return statSync(targetPath).isDirectory();
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function findSkill(ref, name, tiers, sourceAgentId) {
|
|
16
|
+
for (const tier of tiers) {
|
|
17
|
+
if (isDirectory(tier.sourcePath)) {
|
|
18
|
+
return {
|
|
19
|
+
kind: "resolved",
|
|
20
|
+
ref,
|
|
21
|
+
name,
|
|
22
|
+
...(sourceAgentId ? { sourceAgentId } : {}),
|
|
23
|
+
sourcePath: tier.sourcePath,
|
|
24
|
+
scope: tier.scope
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
kind: "not-found",
|
|
30
|
+
ref,
|
|
31
|
+
searchedPaths: tiers.map((tier) => tier.sourcePath)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function resolveSkillReference(ref, cwd, homeDir) {
|
|
35
|
+
const slashIndex = ref.indexOf("/");
|
|
36
|
+
const hasPrefix = slashIndex !== -1;
|
|
37
|
+
if (ref.length === 0 ||
|
|
38
|
+
ref !== ref.trim() ||
|
|
39
|
+
(hasPrefix && ref.indexOf("/", slashIndex + 1) !== -1)) {
|
|
40
|
+
return { kind: "malformed", ref };
|
|
41
|
+
}
|
|
42
|
+
if (!hasPrefix) {
|
|
43
|
+
if (isMalformedSegment(ref)) {
|
|
44
|
+
return { kind: "malformed", ref };
|
|
45
|
+
}
|
|
46
|
+
const tiers = [
|
|
47
|
+
{
|
|
48
|
+
scope: "project",
|
|
49
|
+
sourcePath: path.resolve(cwd, ".poe-code/skills", ref)
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
scope: "user",
|
|
53
|
+
sourcePath: path.resolve(homeDir, ".poe-code/skills", ref)
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
return findSkill(ref, ref, tiers);
|
|
57
|
+
}
|
|
58
|
+
const agentInput = ref.slice(0, slashIndex);
|
|
59
|
+
const name = ref.slice(slashIndex + 1);
|
|
60
|
+
if (isMalformedSegment(agentInput) || isMalformedSegment(name)) {
|
|
61
|
+
return { kind: "malformed", ref };
|
|
62
|
+
}
|
|
63
|
+
const support = resolveAgentSupport(agentInput);
|
|
64
|
+
if (support.status !== "supported" || !support.id) {
|
|
65
|
+
return { kind: "unknown-agent", ref, agentInput };
|
|
66
|
+
}
|
|
67
|
+
const config = getAgentConfig(support.id);
|
|
68
|
+
if (!config) {
|
|
69
|
+
return { kind: "unknown-agent", ref, agentInput };
|
|
70
|
+
}
|
|
71
|
+
const tiers = [
|
|
72
|
+
{
|
|
73
|
+
scope: "project",
|
|
74
|
+
sourcePath: path.resolve(resolveSkillDir(config, "local", cwd), name)
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
scope: "user",
|
|
78
|
+
sourcePath: path.resolve(resolveSkillDir(config, "global", cwd, homeDir), name)
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
return findSkill(ref, name, tiers, support.id);
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface BrowserProcess {
|
|
2
|
+
once(event: "error", listener: (error: Error) => void): this;
|
|
3
|
+
once(event: "spawn", listener: () => void): this;
|
|
4
|
+
unref(): void;
|
|
5
|
+
}
|
|
6
|
+
type SpawnBrowserProcess = (command: string, args: string[], options: {
|
|
7
|
+
detached: true;
|
|
8
|
+
stdio: "ignore";
|
|
9
|
+
}) => BrowserProcess;
|
|
10
|
+
export interface OpenExternalOptions {
|
|
11
|
+
platform?: NodeJS.Platform;
|
|
12
|
+
spawnProcess?: SpawnBrowserProcess;
|
|
13
|
+
}
|
|
14
|
+
export declare function openExternal(url: string, options?: OpenExternalOptions): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
export async function openExternal(url, options = {}) {
|
|
4
|
+
const parsed = new URL(url);
|
|
5
|
+
const { command, args } = browserCommand(parsed.href, options.platform ?? process.platform);
|
|
6
|
+
await launchBrowser(command, args, options.spawnProcess ?? spawn);
|
|
7
|
+
}
|
|
8
|
+
function browserCommand(url, platform) {
|
|
9
|
+
if (platform === "darwin") {
|
|
10
|
+
return { command: "open", args: [url] };
|
|
11
|
+
}
|
|
12
|
+
if (platform === "win32") {
|
|
13
|
+
return { command: "cmd", args: ["/c", "start", "", url] };
|
|
14
|
+
}
|
|
15
|
+
return { command: "xdg-open", args: [url] };
|
|
16
|
+
}
|
|
17
|
+
function launchBrowser(command, args, spawnProcess) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const child = spawnProcess(command, args, { detached: true, stdio: "ignore" });
|
|
20
|
+
child.once("error", reject);
|
|
21
|
+
child.once("spawn", () => {
|
|
22
|
+
child.unref();
|
|
23
|
+
resolve();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -4,5 +4,5 @@ export { createInitialState } from "./state.js";
|
|
|
4
4
|
export { resolveBindings } from "./keymap.js";
|
|
5
5
|
export type { Effect, ExplorerEvent } from "./events.js";
|
|
6
6
|
export type { BindingTarget, ExplorerBindingDefaults, ExplorerBuiltinCommand, ResolvedBindings } from "./keymap.js";
|
|
7
|
-
export type { Action, ActionContext, Detail, DetailCtx, DetailItem, Dirty, ExplorerConfig, ExplorerLayoutMode, ExplorerSize, ExplorerState, Row, Tone } from "./state.js";
|
|
7
|
+
export type { Action, ActionContext, Detail, DetailCtx, DetailItem, Dirty, ExplorerConfig, ExplorerLayoutMode, ExplorerSize, ExplorerState, ReorderContext, Row, Tone } from "./state.js";
|
|
8
8
|
export declare function singleDetail<R>(fn: (row: Row, ctx: DetailCtx) => string | Promise<string>): Detail<R>;
|
|
@@ -19,8 +19,8 @@ const builtinBindings = {
|
|
|
19
19
|
detailScrollUp: ["Ctrl+b"],
|
|
20
20
|
extendSelectionUp: ["Shift+up"],
|
|
21
21
|
extendSelectionDown: ["Shift+down"],
|
|
22
|
-
reorderUp: ["
|
|
23
|
-
reorderDown: ["
|
|
22
|
+
reorderUp: ["Shift+up", "K"],
|
|
23
|
+
reorderDown: ["Shift+down", "J"]
|
|
24
24
|
};
|
|
25
25
|
const baseBuiltinCommands = [
|
|
26
26
|
"quit",
|
|
@@ -49,7 +49,10 @@ const reservedActionIds = new Set(["quit"]);
|
|
|
49
49
|
export function resolveBindings(config, defaults = {}) {
|
|
50
50
|
const commands = config.reorder === undefined
|
|
51
51
|
? baseBuiltinCommands
|
|
52
|
-
: [
|
|
52
|
+
: [
|
|
53
|
+
...baseBuiltinCommands.filter((command) => command !== "extendSelectionUp" && command !== "extendSelectionDown"),
|
|
54
|
+
...reorderCommands
|
|
55
|
+
];
|
|
53
56
|
const commandBindings = new Map();
|
|
54
57
|
const flatBindings = new Map();
|
|
55
58
|
const targetKeys = new Map();
|
|
@@ -13,6 +13,12 @@ export function renderFooter(state, screen, layout) {
|
|
|
13
13
|
if (x >= rect.x + rect.width) {
|
|
14
14
|
break;
|
|
15
15
|
}
|
|
16
|
+
if (hint.bracketed === false) {
|
|
17
|
+
const text = `${hint.key} ${hint.label}`;
|
|
18
|
+
screen.put(x, y, text, hint.running ? styles.muted : {});
|
|
19
|
+
x += text.length + 2;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
16
22
|
screen.put(x, y, `[${hint.key}]`, hint.running ? styles.muted : styles.accent);
|
|
17
23
|
x += hint.key.length + 2;
|
|
18
24
|
screen.put(x, y, ` ${hint.label}`, hint.running ? styles.muted : {});
|
|
@@ -37,9 +43,17 @@ function footerHints(state) {
|
|
|
37
43
|
}
|
|
38
44
|
hints.push({ key: "?", label: "help", running: false });
|
|
39
45
|
hints.push({ key: "Ctrl+P", label: "palette", running: false });
|
|
46
|
+
if (hasShiftReorderBindings(state)) {
|
|
47
|
+
hints.push({ key: "⇧↑↓", label: "reorder (within state)", running: false, bracketed: false });
|
|
48
|
+
}
|
|
40
49
|
hints.push({ key: "q", label: "quit", running: false });
|
|
41
50
|
return hints;
|
|
42
51
|
}
|
|
52
|
+
function hasShiftReorderBindings(state) {
|
|
53
|
+
const up = state.bindings.keysByTarget.get("builtin:reorderUp") ?? [];
|
|
54
|
+
const down = state.bindings.keysByTarget.get("builtin:reorderDown") ?? [];
|
|
55
|
+
return up.includes("Shift+up") && down.includes("Shift+down");
|
|
56
|
+
}
|
|
43
57
|
function actionKey(entry, fallback) {
|
|
44
58
|
const key = entry.action?.key;
|
|
45
59
|
if (Array.isArray(key)) {
|
|
@@ -36,7 +36,7 @@ class ExplorerRuntime {
|
|
|
36
36
|
});
|
|
37
37
|
this.runtimeHandles = {
|
|
38
38
|
refresh: async () => {
|
|
39
|
-
await this.
|
|
39
|
+
await this.refreshRowsFromSource();
|
|
40
40
|
},
|
|
41
41
|
suspendAnd: async (fn) => this.suspendAnd(fn),
|
|
42
42
|
toast: (msg, tone) => {
|
|
@@ -54,7 +54,7 @@ class ExplorerRuntime {
|
|
|
54
54
|
try {
|
|
55
55
|
this.startTerminal();
|
|
56
56
|
this.render();
|
|
57
|
-
this.
|
|
57
|
+
this.loadRows().catch((error) => {
|
|
58
58
|
this.fail(error);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
@@ -76,10 +76,14 @@ class ExplorerRuntime {
|
|
|
76
76
|
this.dispatch({ type: "resize", cols: size.cols, rows: size.rows });
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
async
|
|
79
|
+
async loadRows() {
|
|
80
80
|
const rows = await this.config.rows();
|
|
81
81
|
this.dispatch({ type: "rowsLoaded", rows });
|
|
82
82
|
}
|
|
83
|
+
async refreshRowsFromSource() {
|
|
84
|
+
await this.config.refresh?.();
|
|
85
|
+
await this.loadRows();
|
|
86
|
+
}
|
|
83
87
|
dispatch(event) {
|
|
84
88
|
if (this.stopped) {
|
|
85
89
|
return;
|
|
@@ -128,7 +132,10 @@ class ExplorerRuntime {
|
|
|
128
132
|
}
|
|
129
133
|
async persistOrder(orderedIds, previousRows) {
|
|
130
134
|
try {
|
|
131
|
-
await this.config.reorder?.onReorder(orderedIds
|
|
135
|
+
await this.config.reorder?.onReorder(orderedIds, {
|
|
136
|
+
refresh: this.runtimeHandles.refresh,
|
|
137
|
+
toast: this.runtimeHandles.toast
|
|
138
|
+
});
|
|
132
139
|
}
|
|
133
140
|
catch (error) {
|
|
134
141
|
this.showToast(error instanceof Error ? error.message : "Could not persist order", "error");
|
|
@@ -51,13 +51,18 @@ export interface ActionContext<R> {
|
|
|
51
51
|
confirm: (prompt: string) => Promise<boolean>;
|
|
52
52
|
exit: (after?: () => void | Promise<void>) => void;
|
|
53
53
|
}
|
|
54
|
+
export interface ReorderContext {
|
|
55
|
+
refresh: () => Promise<void>;
|
|
56
|
+
toast: (msg: string, tone?: Tone) => void;
|
|
57
|
+
}
|
|
54
58
|
export interface ExplorerConfig<R> {
|
|
55
59
|
title: string;
|
|
56
60
|
rows: () => Promise<Row[]>;
|
|
61
|
+
refresh?: () => Promise<void>;
|
|
57
62
|
detail: Detail<R>;
|
|
58
63
|
actions: Action<R>[];
|
|
59
64
|
reorder?: {
|
|
60
|
-
onReorder: (orderedIds: string[]) => void | Promise<void>;
|
|
65
|
+
onReorder: (orderedIds: string[], ctx?: ReorderContext) => void | Promise<void>;
|
|
61
66
|
};
|
|
62
67
|
multiSelect?: boolean;
|
|
63
68
|
keybindOverrides?: Record<string, string | string[]>;
|
|
@@ -19,13 +19,14 @@ export { renderTable } from "./components/table.js";
|
|
|
19
19
|
export type { TableColumn, RenderTableOptions } from "./components/table.js";
|
|
20
20
|
export { renderTemplate } from "./components/template.js";
|
|
21
21
|
export type { RenderTemplateOptions, TemplateEscape } from "./components/template.js";
|
|
22
|
+
export { openExternal } from "./components/browser.js";
|
|
22
23
|
export * as acp from "./acp/index.js";
|
|
23
24
|
export * as dashboard from "./dashboard/index.js";
|
|
24
25
|
export { createDashboard, shouldUseInteractiveDashboard } from "./dashboard/index.js";
|
|
25
26
|
export type { Dashboard, DashboardOptions } from "./dashboard/index.js";
|
|
26
27
|
export * as explorer from "./explorer/index.js";
|
|
27
28
|
export { runExplorer, singleDetail } from "./explorer/index.js";
|
|
28
|
-
export type { Row, DetailItem, Detail, DetailCtx, Action, ActionContext, ExplorerConfig, Tone, } from "./explorer/index.js";
|
|
29
|
+
export type { Row, DetailItem, Detail, DetailCtx, Action, ActionContext, ExplorerConfig, ReorderContext, Tone, } from "./explorer/index.js";
|
|
29
30
|
export * as prompts from "./prompts/index.js";
|
|
30
31
|
export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
|
|
31
32
|
export type { SelectOptions, MultiselectOptions, TextOptions, ConfirmOptions, PasswordOptions, SpinnerOptions, WithSpinnerOptions } from "./prompts/index.js";
|
|
@@ -15,6 +15,7 @@ export { formatCommandNotFound } from "./components/command-errors.js";
|
|
|
15
15
|
export { formatCommandNotFoundPanel } from "./components/command-errors.js";
|
|
16
16
|
export { renderTable } from "./components/table.js";
|
|
17
17
|
export { renderTemplate } from "./components/template.js";
|
|
18
|
+
export { openExternal } from "./components/browser.js";
|
|
18
19
|
// ACP rendering
|
|
19
20
|
export * as acp from "./acp/index.js";
|
|
20
21
|
// Dashboard
|