flavor-code 1.2.1
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/LICENSE +21 -0
- package/README.md +1081 -0
- package/dist/agent/loop.d.ts +31 -0
- package/dist/agent/message-queue.d.ts +19 -0
- package/dist/agent/planner.d.ts +28 -0
- package/dist/agent/subagents.d.ts +50 -0
- package/dist/agent/task-plan.d.ts +60 -0
- package/dist/agent/task-tools.d.ts +11 -0
- package/dist/agent/types.d.ts +117 -0
- package/dist/app-WC2XXGLM.js +3185 -0
- package/dist/app-WC2XXGLM.js.map +1 -0
- package/dist/auth/oauth-config.d.ts +4 -0
- package/dist/auth/oauth.d.ts +21 -0
- package/dist/auth/store.d.ts +15 -0
- package/dist/auth/types.d.ts +33 -0
- package/dist/chunk-BU64GNXE.js +15771 -0
- package/dist/chunk-BU64GNXE.js.map +1 -0
- package/dist/chunk-DM64TM4Z.js +124 -0
- package/dist/chunk-DM64TM4Z.js.map +1 -0
- package/dist/chunk-JZ322RCJ.js +40 -0
- package/dist/chunk-JZ322RCJ.js.map +1 -0
- package/dist/chunk-M744K7MK.js +246 -0
- package/dist/chunk-M744K7MK.js.map +1 -0
- package/dist/chunk-MVIMQEQT.js +692 -0
- package/dist/chunk-MVIMQEQT.js.map +1 -0
- package/dist/chunk-VOCZVFP7.js +153 -0
- package/dist/chunk-VOCZVFP7.js.map +1 -0
- package/dist/chunk-XS2JU6S3.js +35557 -0
- package/dist/chunk-XS2JU6S3.js.map +1 -0
- package/dist/claude-ink-ZL4UZMFY.js +27 -0
- package/dist/claude-ink-ZL4UZMFY.js.map +1 -0
- package/dist/cli.js +915 -0
- package/dist/cli.js.map +1 -0
- package/dist/codeisland/activate.mjs +74 -0
- package/dist/codeisland/bridge.mjs +97 -0
- package/dist/codeisland/flavor-plugin.json +27 -0
- package/dist/config/load.d.ts +19 -0
- package/dist/config/protected-file.d.ts +15 -0
- package/dist/config/schema.d.ts +176 -0
- package/dist/config/secret-envelope.d.ts +8 -0
- package/dist/context/compaction.d.ts +44 -0
- package/dist/context/manager.d.ts +65 -0
- package/dist/context/summarizer.d.ts +15 -0
- package/dist/desktop/main.js +17778 -0
- package/dist/desktop/main.js.map +1 -0
- package/dist/desktop/preload.cjs +90 -0
- package/dist/desktop/preload.cjs.map +1 -0
- package/dist/desktop-renderer/assets/index-C66pDvHs.js +144 -0
- package/dist/desktop-renderer/assets/index-C66pDvHs.js.map +1 -0
- package/dist/desktop-renderer/assets/index-Cm_ktmXm.css +1 -0
- package/dist/desktop-renderer/index.html +16 -0
- package/dist/devtools-SXJBSV2N.js +3 -0
- package/dist/devtools-SXJBSV2N.js.map +1 -0
- package/dist/execution/docker.d.ts +29 -0
- package/dist/execution/factory.d.ts +3 -0
- package/dist/execution/types.d.ts +18 -0
- package/dist/goal/classifier.d.ts +12 -0
- package/dist/goal/orchestrator.d.ts +34 -0
- package/dist/goal/planner.d.ts +9 -0
- package/dist/goal/store.d.ts +9 -0
- package/dist/goal/types.d.ts +190 -0
- package/dist/hallucination/confidence.d.ts +12 -0
- package/dist/hallucination/evidence-ledger.d.ts +29 -0
- package/dist/hallucination/guard.d.ts +27 -0
- package/dist/hallucination/messages.d.ts +10 -0
- package/dist/hallucination/retry-monitor.d.ts +19 -0
- package/dist/hallucination/sliding-window.d.ts +13 -0
- package/dist/hallucination/types.d.ts +49 -0
- package/dist/harness/local.d.ts +54 -0
- package/dist/hooks/bus.d.ts +9 -0
- package/dist/hooks/types.d.ts +105 -0
- package/dist/ide/client.d.ts +35 -0
- package/dist/incidents/reporter.d.ts +38 -0
- package/dist/init/project.d.ts +25 -0
- package/dist/load-WQGNTCHC.js +20 -0
- package/dist/load-WQGNTCHC.js.map +1 -0
- package/dist/loop/budget.d.ts +11 -0
- package/dist/loop/isolation.d.ts +21 -0
- package/dist/loop/orchestrator.d.ts +82 -0
- package/dist/loop/store.d.ts +13 -0
- package/dist/loop/types.d.ts +142 -0
- package/dist/loop/verifier.d.ts +13 -0
- package/dist/mcp/client.d.ts +66 -0
- package/dist/mcp/sdk.d.ts +27 -0
- package/dist/memory/coordinator.d.ts +32 -0
- package/dist/memory/extractor.d.ts +15 -0
- package/dist/memory/intent.d.ts +2 -0
- package/dist/memory/retrieval.d.ts +13 -0
- package/dist/memory/review.d.ts +36 -0
- package/dist/memory/similarity.d.ts +5 -0
- package/dist/memory/store.d.ts +58 -0
- package/dist/memory/types.d.ts +37 -0
- package/dist/models/anthropic.d.ts +24 -0
- package/dist/models/cache-profile.d.ts +23 -0
- package/dist/models/openai.d.ts +24 -0
- package/dist/models/registry.d.ts +16 -0
- package/dist/models/structured.d.ts +75 -0
- package/dist/models/types.d.ts +93 -0
- package/dist/permissions/classifier.d.ts +9 -0
- package/dist/permissions/engine.d.ts +28 -0
- package/dist/plugins/host.d.ts +15 -0
- package/dist/plugins/types.d.ts +136 -0
- package/dist/production.d.ts +59 -0
- package/dist/prompts/system.d.ts +28 -0
- package/dist/rpc/schema.d.ts +61 -0
- package/dist/rpc/server.d.ts +54 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +53 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/session/checkpoint.d.ts +25 -0
- package/dist/session/store.d.ts +154 -0
- package/dist/session/tree.d.ts +31 -0
- package/dist/skills/builtin-loop.d.ts +12 -0
- package/dist/skills/registry.d.ts +47 -0
- package/dist/skills/tool.d.ts +9 -0
- package/dist/sleep/organizer.d.ts +37 -0
- package/dist/tools/ask-user-question.d.ts +49 -0
- package/dist/tools/file-diff.d.ts +9 -0
- package/dist/tools/files.d.ts +49 -0
- package/dist/tools/lsp.d.ts +77 -0
- package/dist/tools/managed.d.ts +59 -0
- package/dist/tools/runtime.d.ts +58 -0
- package/dist/tools/search.d.ts +76 -0
- package/dist/tools/shell.d.ts +37 -0
- package/dist/tools/task-output.d.ts +53 -0
- package/dist/tools/todo-write.d.ts +35 -0
- package/dist/tools/types.d.ts +56 -0
- package/dist/trace/recorder.d.ts +14 -0
- package/dist/trace/replay.d.ts +3 -0
- package/dist/trace/schema.d.ts +26 -0
- package/dist/ui/commands.d.ts +67 -0
- package/dist/ui/session.d.ts +126 -0
- package/dist/ui/transcript.d.ts +89 -0
- package/dist/utils/async.d.ts +5 -0
- package/dist/utils/envUtils.d.ts +1 -0
- package/dist/utils/error.d.ts +2 -0
- package/dist/utils/execFileNoThrow.d.ts +13 -0
- package/dist/utils/intl.d.ts +18 -0
- package/dist/utils/json.d.ts +44 -0
- package/dist/utils/log.d.ts +28 -0
- package/dist/utils/redact.d.ts +10 -0
- package/dist/utils/usage-summary.d.ts +34 -0
- package/dist/utils/version.d.ts +6 -0
- package/package.json +124 -0
- package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +4797 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TraceKindSchema: z.ZodEnum<{
|
|
3
|
+
command: "command";
|
|
4
|
+
history: "history";
|
|
5
|
+
output: "output";
|
|
6
|
+
queue: "queue";
|
|
7
|
+
response: "response";
|
|
8
|
+
verification: "verification";
|
|
9
|
+
}>;
|
|
10
|
+
export type TraceKind = z.infer<typeof TraceKindSchema>;
|
|
11
|
+
export declare const TraceRecordSchema: z.ZodObject<{
|
|
12
|
+
version: z.ZodLiteral<1>;
|
|
13
|
+
sequence: z.ZodNumber;
|
|
14
|
+
timestamp: z.ZodString;
|
|
15
|
+
sessionId: z.ZodString;
|
|
16
|
+
kind: z.ZodEnum<{
|
|
17
|
+
command: "command";
|
|
18
|
+
history: "history";
|
|
19
|
+
output: "output";
|
|
20
|
+
queue: "queue";
|
|
21
|
+
response: "response";
|
|
22
|
+
verification: "verification";
|
|
23
|
+
}>;
|
|
24
|
+
payload: z.ZodUnknown;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type TraceRecord = z.infer<typeof TraceRecordSchema>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "mcp", "ide", "memory", "remember", "forget", "checkpoint", "tree", "rewind", "unrevert", "fork"];
|
|
2
|
+
export declare const COMMAND_DESCRIPTIONS: Record<(typeof MVP_COMMANDS)[number], string>;
|
|
3
|
+
export type PermissionCommandMode = PermissionMode;
|
|
4
|
+
export type ModelRole = "main" | "subagent";
|
|
5
|
+
export type McpSlashCommand = {
|
|
6
|
+
name: "mcp";
|
|
7
|
+
action: "status";
|
|
8
|
+
} | {
|
|
9
|
+
name: "mcp";
|
|
10
|
+
action: "tools" | "reconnect";
|
|
11
|
+
target: string;
|
|
12
|
+
} | {
|
|
13
|
+
name: "mcp";
|
|
14
|
+
action: "enable" | "disable";
|
|
15
|
+
target: string;
|
|
16
|
+
};
|
|
17
|
+
export type SlashCommand = {
|
|
18
|
+
name: "model";
|
|
19
|
+
role: ModelRole;
|
|
20
|
+
modelId: string;
|
|
21
|
+
} | {
|
|
22
|
+
name: "permissions";
|
|
23
|
+
mode: PermissionCommandMode;
|
|
24
|
+
} | {
|
|
25
|
+
name: "plugin";
|
|
26
|
+
command: string;
|
|
27
|
+
args: string[];
|
|
28
|
+
} | {
|
|
29
|
+
name: "skill";
|
|
30
|
+
skill: string;
|
|
31
|
+
prompt: string;
|
|
32
|
+
} | {
|
|
33
|
+
name: "loop";
|
|
34
|
+
goal: string;
|
|
35
|
+
} | {
|
|
36
|
+
name: "goal";
|
|
37
|
+
goal: string;
|
|
38
|
+
} | {
|
|
39
|
+
name: "remember";
|
|
40
|
+
type: MemoryType;
|
|
41
|
+
text: string;
|
|
42
|
+
} | {
|
|
43
|
+
name: "forget";
|
|
44
|
+
query: string;
|
|
45
|
+
} | {
|
|
46
|
+
name: "checkpoint";
|
|
47
|
+
label?: string;
|
|
48
|
+
} | {
|
|
49
|
+
name: "rewind" | "fork";
|
|
50
|
+
nodeId: string;
|
|
51
|
+
} | McpSlashCommand | {
|
|
52
|
+
name: Exclude<(typeof MVP_COMMANDS)[number], "model" | "permissions" | "audit" | "loop" | "goal" | "mcp" | "remember" | "forget" | "checkpoint" | "rewind" | "fork">;
|
|
53
|
+
} | {
|
|
54
|
+
name: "audit";
|
|
55
|
+
toolFilter?: string | undefined;
|
|
56
|
+
} | {
|
|
57
|
+
name: "unknown";
|
|
58
|
+
input: string;
|
|
59
|
+
suggestions: string[];
|
|
60
|
+
} | {
|
|
61
|
+
name: "invalid";
|
|
62
|
+
command: string;
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
export declare function parseSlashCommand(input: string, dynamicCommands?: readonly string[], skillCommands?: readonly string[]): SlashCommand | null;
|
|
66
|
+
import { type PermissionMode } from "../config/schema.js";
|
|
67
|
+
import { type MemoryType } from "../memory/types.js";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { AgentEvent } from "../agent/types.js";
|
|
2
|
+
import type { HookBus } from "../hooks/bus.js";
|
|
3
|
+
import type { PermissionMode } from "../permissions/engine.js";
|
|
4
|
+
import type { SkillMetadata } from "../skills/registry.js";
|
|
5
|
+
import { type McpSlashCommand, type ModelRole } from "./commands.js";
|
|
6
|
+
import type { QuestionBridge } from "../tools/ask-user-question.js";
|
|
7
|
+
import type { MemoryType } from "../memory/types.js";
|
|
8
|
+
import { type AgentQueueSnapshot } from "../agent/message-queue.js";
|
|
9
|
+
import type { SessionTreeNode } from "../session/tree.js";
|
|
10
|
+
import { type ModelContentBlock, type ModelMessage } from "../models/types.js";
|
|
11
|
+
import type { IdeEditorContext } from "../ide/client.js";
|
|
12
|
+
export interface SessionApprovalRequest {
|
|
13
|
+
id: string;
|
|
14
|
+
agent: "main" | "subagent";
|
|
15
|
+
tool: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
paths?: readonly string[];
|
|
18
|
+
command?: string;
|
|
19
|
+
args?: readonly string[];
|
|
20
|
+
cwd?: string;
|
|
21
|
+
}
|
|
22
|
+
export type SessionOutput = AgentEvent | {
|
|
23
|
+
type: "notice";
|
|
24
|
+
message: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "queued-prompt";
|
|
27
|
+
prompt: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "write-start";
|
|
30
|
+
id: string;
|
|
31
|
+
path: string;
|
|
32
|
+
before: string;
|
|
33
|
+
totalBytes: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: "write-delta";
|
|
36
|
+
id: string;
|
|
37
|
+
delta: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "write-ready";
|
|
40
|
+
id: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "write-cancelled";
|
|
43
|
+
id: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "approval-request";
|
|
46
|
+
request: SessionApprovalRequest;
|
|
47
|
+
} | {
|
|
48
|
+
type: "approval-cleared";
|
|
49
|
+
id?: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "clear";
|
|
52
|
+
} | {
|
|
53
|
+
type: "exit";
|
|
54
|
+
};
|
|
55
|
+
export interface SessionServices {
|
|
56
|
+
hooks: HookBus;
|
|
57
|
+
workspace: string;
|
|
58
|
+
mainModel(): string;
|
|
59
|
+
subagentModel(): string;
|
|
60
|
+
llmServiceName?(): string | undefined;
|
|
61
|
+
permissionMode(): PermissionMode;
|
|
62
|
+
run(prompt: string, signal: AbortSignal, options?: {
|
|
63
|
+
getSteeringMessages(): readonly string[];
|
|
64
|
+
initialUserMessage?: Extract<ModelMessage, {
|
|
65
|
+
role: "user";
|
|
66
|
+
}>;
|
|
67
|
+
additionalContext?: string;
|
|
68
|
+
}): AsyncIterable<AgentEvent>;
|
|
69
|
+
runSkill(skill: string, prompt: string, signal: AbortSignal): AsyncIterable<AgentEvent>;
|
|
70
|
+
runLoop(goal: string, signal: AbortSignal): AsyncIterable<AgentEvent>;
|
|
71
|
+
runGoal(goal: string, signal: AbortSignal): AsyncIterable<AgentEvent>;
|
|
72
|
+
mcp(command: McpSlashCommand, signal: AbortSignal): Promise<string>;
|
|
73
|
+
ide?(): Promise<string>;
|
|
74
|
+
ideContext?(): Promise<IdeEditorContext | undefined>;
|
|
75
|
+
setModel(role: ModelRole, modelId: string): void | Promise<void>;
|
|
76
|
+
setPermissionMode(mode: PermissionMode): void | Promise<void>;
|
|
77
|
+
compact(signal?: AbortSignal): Promise<boolean>;
|
|
78
|
+
initialize(): Promise<{
|
|
79
|
+
path: string;
|
|
80
|
+
created: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
config(): unknown;
|
|
83
|
+
skills(): Promise<readonly SkillMetadata[]>;
|
|
84
|
+
reloadSkills?(): Promise<void>;
|
|
85
|
+
plugins(): readonly unknown[];
|
|
86
|
+
hooksStatus(): readonly unknown[];
|
|
87
|
+
tasks(): unknown;
|
|
88
|
+
audit(toolFilter?: string): string | Promise<string>;
|
|
89
|
+
usage(): string | Promise<string>;
|
|
90
|
+
cancelActiveTask(): void | Promise<void>;
|
|
91
|
+
clearContext(): void | Promise<void>;
|
|
92
|
+
checkpoint?(label?: string): Promise<SessionTreeNode>;
|
|
93
|
+
tree?(): readonly SessionTreeNode[];
|
|
94
|
+
rewind?(nodeId: string): Promise<void>;
|
|
95
|
+
unrevert?(): Promise<void>;
|
|
96
|
+
fork?(nodeId: string): Promise<void>;
|
|
97
|
+
memory(): Promise<string>;
|
|
98
|
+
refreshMemory?(): Promise<void>;
|
|
99
|
+
remember(type: MemoryType, text: string): Promise<string>;
|
|
100
|
+
forget(query: string): Promise<string>;
|
|
101
|
+
finishTask(): Promise<string>;
|
|
102
|
+
pluginCommands(): readonly string[];
|
|
103
|
+
runPluginCommand(name: string, args: readonly string[], signal: AbortSignal): Promise<unknown>;
|
|
104
|
+
output(event: SessionOutput): void;
|
|
105
|
+
questions: QuestionBridge;
|
|
106
|
+
login(): Promise<string>;
|
|
107
|
+
}
|
|
108
|
+
export interface MultimodalSessionInput {
|
|
109
|
+
text: string;
|
|
110
|
+
content: ModelContentBlock[];
|
|
111
|
+
}
|
|
112
|
+
export declare class FlavorSession {
|
|
113
|
+
#private;
|
|
114
|
+
constructor(services: SessionServices);
|
|
115
|
+
get active(): boolean;
|
|
116
|
+
queueSnapshot(): AgentQueueSnapshot;
|
|
117
|
+
clearQueue(): AgentQueueSnapshot;
|
|
118
|
+
whenIdle(): Promise<void>;
|
|
119
|
+
steer(input: string): void;
|
|
120
|
+
followUp(input: string): void;
|
|
121
|
+
start(): Promise<void>;
|
|
122
|
+
submit(input: string): Promise<void>;
|
|
123
|
+
submit(input: MultimodalSessionInput): Promise<void>;
|
|
124
|
+
interrupt(): "cancelled" | "exit";
|
|
125
|
+
close(): Promise<void>;
|
|
126
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { SessionOutput } from "./session.js";
|
|
2
|
+
import type { TaskSnapshot } from "../agent/types.js";
|
|
3
|
+
import type { ToolPresentation } from "../tools/types.js";
|
|
4
|
+
import { type ModelContent } from "../models/types.js";
|
|
5
|
+
export interface TranscriptTurn {
|
|
6
|
+
id: number;
|
|
7
|
+
kind?: "compaction";
|
|
8
|
+
submittedAt?: string;
|
|
9
|
+
completedAt?: string;
|
|
10
|
+
prompt: string;
|
|
11
|
+
assistantText: string;
|
|
12
|
+
statusLines: string[];
|
|
13
|
+
blocks: TranscriptBlock[];
|
|
14
|
+
taskSnapshot?: TaskSnapshot;
|
|
15
|
+
suppressedTaskIds?: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface TranscriptHistoryMessage {
|
|
18
|
+
readonly role: "user" | "assistant" | "tool";
|
|
19
|
+
readonly content: ModelContent;
|
|
20
|
+
readonly toolCallId?: string | undefined;
|
|
21
|
+
readonly toolCalls?: readonly {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
input: unknown;
|
|
25
|
+
}[] | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface TranscriptCompactBoundary {
|
|
28
|
+
readonly summary: string;
|
|
29
|
+
readonly compactedAt: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TranscriptToolDetails {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly input: unknown;
|
|
34
|
+
readonly result?: import("../tools/types.js").ToolResult;
|
|
35
|
+
}
|
|
36
|
+
export type TranscriptBlock = {
|
|
37
|
+
kind: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "status";
|
|
41
|
+
id: string;
|
|
42
|
+
state: "running" | "completed" | "failed" | "cancelled" | "info";
|
|
43
|
+
tone?: "retry" | "warning";
|
|
44
|
+
text: string;
|
|
45
|
+
hint?: string;
|
|
46
|
+
task?: {
|
|
47
|
+
subject: string;
|
|
48
|
+
activeForm: string;
|
|
49
|
+
role: "main" | "subagent";
|
|
50
|
+
};
|
|
51
|
+
activity?: "model";
|
|
52
|
+
presentation?: ToolPresentation;
|
|
53
|
+
tool?: TranscriptToolDetails;
|
|
54
|
+
details?: string;
|
|
55
|
+
progress?: number;
|
|
56
|
+
startedAt?: number;
|
|
57
|
+
elapsedMs?: number;
|
|
58
|
+
};
|
|
59
|
+
export interface TranscriptState {
|
|
60
|
+
completed: TranscriptTurn[];
|
|
61
|
+
active?: TranscriptTurn;
|
|
62
|
+
nextId: number;
|
|
63
|
+
taskSnapshot?: TaskSnapshot;
|
|
64
|
+
}
|
|
65
|
+
export type TranscriptAction = {
|
|
66
|
+
type: "hydrate";
|
|
67
|
+
messages: readonly TranscriptHistoryMessage[];
|
|
68
|
+
compact?: TranscriptCompactBoundary;
|
|
69
|
+
} | {
|
|
70
|
+
type: "restore";
|
|
71
|
+
state: TranscriptState;
|
|
72
|
+
} | {
|
|
73
|
+
type: "submit";
|
|
74
|
+
prompt: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: "session";
|
|
77
|
+
event: SessionOutput;
|
|
78
|
+
} | {
|
|
79
|
+
type: "submit-error";
|
|
80
|
+
message: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: "finish";
|
|
83
|
+
} | {
|
|
84
|
+
type: "clear";
|
|
85
|
+
};
|
|
86
|
+
export declare function createTranscriptState(): TranscriptState;
|
|
87
|
+
export declare function transcriptReducer(state: TranscriptState, action: TranscriptAction): TranscriptState;
|
|
88
|
+
export declare function transcriptFromLegacyConversation(messages: readonly TranscriptHistoryMessage[], compact?: TranscriptCompactBoundary): TranscriptState;
|
|
89
|
+
export declare function restoreTranscriptState(state: TranscriptState): TranscriptState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEnvTruthy(value: string | boolean | undefined): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ExecFileNoThrowOptions {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
useCwd?: boolean;
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
stdin?: "ignore" | "inherit" | "pipe";
|
|
6
|
+
input?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function execFileNoThrow(file: string, args: string[], options?: ExecFileNoThrowOptions): Promise<{
|
|
9
|
+
stdout: string;
|
|
10
|
+
stderr: string;
|
|
11
|
+
code: number;
|
|
12
|
+
error?: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function getGraphemeSegmenter(): Intl.Segmenter;
|
|
2
|
+
/**
|
|
3
|
+
* Detect the system locale as a BCP47 language tag (e.g. "zh-CN", "en-US").
|
|
4
|
+
* Uses Intl (available since Node 13) and falls back to POSIX locale
|
|
5
|
+
* environment variables on Unix systems.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectSystemLocale(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the effective language tag: explicit config wins, then system
|
|
10
|
+
* detection, and finally "en-US" as the ultimate default.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveLanguage(explicit: string | undefined): string;
|
|
13
|
+
/**
|
|
14
|
+
* Build a short instruction suffix that tells the agent which language to
|
|
15
|
+
* reply in. When the tag is English we still emit it so the model knows
|
|
16
|
+
* the preference is explicit.
|
|
17
|
+
*/
|
|
18
|
+
export declare function languageInstruction(language: string): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a string as JSON.
|
|
3
|
+
*
|
|
4
|
+
* Returns the parsed value on success, or `null` when the string is not valid
|
|
5
|
+
* JSON. Unlike the previous implementation this never returns the raw string,
|
|
6
|
+
* so callers can safely treat a null return as "not JSON" without risking a
|
|
7
|
+
* string masquerading as a parsed object downstream.
|
|
8
|
+
*
|
|
9
|
+
* DeepSeek and other third-party Anthropic-compatible providers have been
|
|
10
|
+
* observed returning tool-call arguments as double-encoded JSON strings
|
|
11
|
+
* (e.g. `"{\"path\": ...}"`) instead of a proper JSON object. Callers
|
|
12
|
+
* should handle that at a higher level (see normalizeToolCallInput).
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseJson(input: string): unknown;
|
|
15
|
+
/** Result of a safe JSON parse that never throws. */
|
|
16
|
+
export interface SafeJsonResult {
|
|
17
|
+
ok: true;
|
|
18
|
+
value: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface SafeJsonError {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: string;
|
|
23
|
+
}
|
|
24
|
+
export type SafeJson = SafeJsonResult | SafeJsonError;
|
|
25
|
+
/** Parse a string as JSON, returning a discriminated union on failure. */
|
|
26
|
+
export declare function safeParseJson(input: string): SafeJson;
|
|
27
|
+
/**
|
|
28
|
+
* Normalize tool-call input that arrived from a model API stream.
|
|
29
|
+
*
|
|
30
|
+
* Model providers (especially third-party Anthropic-compatible ones like
|
|
31
|
+
* DeepSeek) may return tool-call arguments in one of these forms:
|
|
32
|
+
*
|
|
33
|
+
* 1. **Object** — non-streaming / fallback paths (pass through).
|
|
34
|
+
* 2. **JSON string** (`'{"path":"x","content":"y"}'`) — normal streaming.
|
|
35
|
+
* 3. **Double-encoded JSON string** (`'"{\\"path\\":...}"'`) — some providers
|
|
36
|
+
* nest the JSON inside an extra string layer.
|
|
37
|
+
* 4. **Empty string** — treated as `{}` for no-argument tools.
|
|
38
|
+
* 5. **Malformed JSON** — rejected with the parse failure preserved.
|
|
39
|
+
*
|
|
40
|
+
* This function recursively unwraps nested strings until it reaches an object
|
|
41
|
+
* or exhausts the unwrapping depth. Invalid input throws instead of silently
|
|
42
|
+
* becoming `{}`, because that destroys the provider-side failure evidence.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeToolCallInput(input: unknown, maxDepth?: number): Record<string, unknown>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function logError(error: unknown): void;
|
|
2
|
+
export declare function usageLogPath(): string;
|
|
3
|
+
export declare function setUsageSession(sessionId: string): void;
|
|
4
|
+
export declare function currentUsageSession(): string;
|
|
5
|
+
export declare function appendUsageLog(line: string): Promise<void>;
|
|
6
|
+
export interface AuditEntry {
|
|
7
|
+
timestamp: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
event: string;
|
|
10
|
+
tool?: string | undefined;
|
|
11
|
+
model?: string | undefined;
|
|
12
|
+
agent?: string | undefined;
|
|
13
|
+
errorCode?: string | undefined;
|
|
14
|
+
errorMessage?: string | undefined;
|
|
15
|
+
attempt?: number | undefined;
|
|
16
|
+
maxAttempts?: number | undefined;
|
|
17
|
+
purpose?: string | undefined;
|
|
18
|
+
repairAttempt?: number | undefined;
|
|
19
|
+
repairMaxAttempts?: number | undefined;
|
|
20
|
+
input?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare class AuditLogger {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(workspace: string);
|
|
25
|
+
get path(): string;
|
|
26
|
+
append(entry: AuditEntry): Promise<void>;
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip well-known API key patterns from an arbitrary error string so it is
|
|
3
|
+
* safe to display to the user or write to logs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function redactErrorText(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Replace every occurrence of each secret string inside `input` with
|
|
8
|
+
* `[redacted]`. Used for diagnostics that may contain configured API keys.
|
|
9
|
+
*/
|
|
10
|
+
export declare function redactSecrets(input: string, secrets: readonly string[]): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface UsageEntry {
|
|
2
|
+
event: "flavor-usage";
|
|
3
|
+
sessionId?: string | undefined;
|
|
4
|
+
provider: string;
|
|
5
|
+
model: string;
|
|
6
|
+
inputTokens: number;
|
|
7
|
+
cacheReadTokens: number;
|
|
8
|
+
cacheCreationTokens: number;
|
|
9
|
+
totalInputTokens: number;
|
|
10
|
+
cacheHitRatio: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UsageModelStats {
|
|
13
|
+
provider: string;
|
|
14
|
+
model: string;
|
|
15
|
+
requests: number;
|
|
16
|
+
inputTokens: number;
|
|
17
|
+
cacheReadTokens: number;
|
|
18
|
+
cacheCreationTokens: number;
|
|
19
|
+
totalInputTokens: number;
|
|
20
|
+
minHitRatio: number;
|
|
21
|
+
averageHitRatio: number;
|
|
22
|
+
}
|
|
23
|
+
export interface UsageSummary {
|
|
24
|
+
requests: number;
|
|
25
|
+
sessionId: string | undefined;
|
|
26
|
+
byModel: UsageModelStats[];
|
|
27
|
+
totalInputTokens: number;
|
|
28
|
+
totalCacheReadTokens: number;
|
|
29
|
+
/** Share of total input tokens served from cache (0 when nothing was sent). */
|
|
30
|
+
cacheShare: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function parseUsageEntries(raw: string): UsageEntry[];
|
|
33
|
+
export declare function summarizeUsage(entries: readonly UsageEntry[]): UsageSummary;
|
|
34
|
+
export declare function formatUsageSummary(summary: UsageSummary): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "flavor-code",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"author": "YachuanWzh",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/desktop/main.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"flavor": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/desktop/main.js",
|
|
12
|
+
"./sdk": {
|
|
13
|
+
"types": "./dist/sdk/index.d.ts",
|
|
14
|
+
"import": "./dist/sdk/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/",
|
|
19
|
+
"README.md",
|
|
20
|
+
"技术方案报告.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm run build:icons && npm run build:cli && npm run build:desktop",
|
|
28
|
+
"build:icons": "node scripts/build-icons.mjs",
|
|
29
|
+
"build:cli": "tsup && tsc -p tsconfig.sdk.json && node -e \"require('fs').cpSync('src/init/codeisland','dist/codeisland',{recursive:true})\"",
|
|
30
|
+
"build:desktop": "npm run build:desktop:main && npm run build:desktop:renderer",
|
|
31
|
+
"build:desktop:main": "tsup --config tsup.desktop.config.ts",
|
|
32
|
+
"build:desktop:renderer": "vite build --config vite.desktop.config.ts",
|
|
33
|
+
"vscode:build": "tsup --config tsup.vscode.config.ts",
|
|
34
|
+
"vscode:typecheck": "tsc --noEmit -p tsconfig.vscode.json",
|
|
35
|
+
"ide:install": "node scripts/install-vscode-extension.mjs --ide auto",
|
|
36
|
+
"qoder:install": "node scripts/install-vscode-extension.mjs --ide qoder",
|
|
37
|
+
"vscode:install": "node scripts/install-vscode-extension.mjs --ide code",
|
|
38
|
+
"desktop:dev": "npm run build:desktop:main && node scripts/desktop-dev.mjs",
|
|
39
|
+
"desktop:start": "npm run build && electron .",
|
|
40
|
+
"desktop:pack": "npm run build && electron-builder --win --dir",
|
|
41
|
+
"desktop:dist": "npm run build && electron-builder --win nsis",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"smoke:install": "node scripts/smoke-install.mjs",
|
|
46
|
+
"prepack": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"build": {
|
|
49
|
+
"appId": "dev.flavorcode.desktop",
|
|
50
|
+
"productName": "Flavor Code",
|
|
51
|
+
"asar": true,
|
|
52
|
+
"icon": "assets/icon",
|
|
53
|
+
"directories": {
|
|
54
|
+
"output": "release"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist/**/*",
|
|
58
|
+
"assets/icon.png",
|
|
59
|
+
"package.json",
|
|
60
|
+
"README.md",
|
|
61
|
+
"LICENSE"
|
|
62
|
+
],
|
|
63
|
+
"win": {
|
|
64
|
+
"target": [
|
|
65
|
+
{
|
|
66
|
+
"target": "nsis",
|
|
67
|
+
"arch": [
|
|
68
|
+
"x64"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"artifactName": "Flavor-Code-${version}-${arch}.${ext}"
|
|
73
|
+
},
|
|
74
|
+
"nsis": {
|
|
75
|
+
"oneClick": false,
|
|
76
|
+
"allowToChangeInstallationDirectory": true,
|
|
77
|
+
"createDesktopShortcut": true,
|
|
78
|
+
"createStartMenuShortcut": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"@anthropic-ai/sdk": "^0.111.0",
|
|
83
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
84
|
+
"@vscode/ripgrep": "^1.18.0",
|
|
85
|
+
"bidi-js": "^1.0.3",
|
|
86
|
+
"chalk": "^5.6.2",
|
|
87
|
+
"commander": "^15.0.0",
|
|
88
|
+
"dotenv": "^17.4.2",
|
|
89
|
+
"emoji-regex": "^10.6.0",
|
|
90
|
+
"flavor-code": "file:flavor-code-1.2.1.tgz",
|
|
91
|
+
"ignore": "^7.0.6",
|
|
92
|
+
"ink": "^7.1.0",
|
|
93
|
+
"lodash-es": "^4.17.23",
|
|
94
|
+
"marked": "^16.4.2",
|
|
95
|
+
"openai": "^6.46.0",
|
|
96
|
+
"react": "^19.2.7",
|
|
97
|
+
"react-dom": "^19.2.7",
|
|
98
|
+
"semver": "^7.7.4",
|
|
99
|
+
"signal-exit": "4.1.0",
|
|
100
|
+
"supports-hyperlinks": "^4.4.0",
|
|
101
|
+
"typescript": "^7.0.2",
|
|
102
|
+
"usehooks-ts": "^3.1.1",
|
|
103
|
+
"yaml": "^2.9.0",
|
|
104
|
+
"zod": "^4.4.3"
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@types/node": "^26.1.1",
|
|
108
|
+
"@types/react": "^19.2.17",
|
|
109
|
+
"@types/react-dom": "^19.2.3",
|
|
110
|
+
"@types/vscode": "1.95.0",
|
|
111
|
+
"@vscode/vsce": "3.9.2",
|
|
112
|
+
"electron": "^42.7.0",
|
|
113
|
+
"electron-builder": "^26.15.3",
|
|
114
|
+
"sharp": "^0.35.3",
|
|
115
|
+
"tsup": "^8.5.1",
|
|
116
|
+
"vite": "^8.1.5",
|
|
117
|
+
"vitest": "^4.1.10"
|
|
118
|
+
},
|
|
119
|
+
"allowScripts": {
|
|
120
|
+
"electron-winstaller@5.4.0": true,
|
|
121
|
+
"esbuild@0.27.7": true,
|
|
122
|
+
"electron@42.7.0": true
|
|
123
|
+
}
|
|
124
|
+
}
|