@maidang1/hataraku 0.0.3
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/.claude/CLAUDE.md +21 -0
- package/.codex/skills/beautiful-mermaid/SKILL.md +171 -0
- package/.codex/skills/beautiful-mermaid/references/mermaid-syntax.md +235 -0
- package/.codex/skills/beautiful-mermaid/scripts/create-html.ts +177 -0
- package/.codex/skills/beautiful-mermaid/scripts/render.ts +221 -0
- package/.codex/skills/find-skills/SKILL.md +133 -0
- package/.github/workflows/publish-github-packages.yml +58 -0
- package/.github/workflows/publish-npm.yml +46 -0
- package/.vscode/settings.json +2 -0
- package/AGENTS.md +41 -0
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/bun.lock +327 -0
- package/docs/agent/architecture.md +28 -0
- package/docs/agent/development_commands.md +6 -0
- package/docs/plan/agent-plan-2026-02-05.md +136 -0
- package/docs/plan/core-agent-sdk-structure-2026-02-07.md +156 -0
- package/docs/plan/implementation-summary.md +303 -0
- package/docs/plan/mcp-2026-02-05.md +700 -0
- package/docs/plan/op.md +478 -0
- package/docs/plan/skills-2026-02-05.md +352 -0
- package/docs/plan/skills-flow.svg +120 -0
- package/docs/plan/tui-readability-2026-02-06.md +67 -0
- package/package.json +34 -0
- package/src/cli/index.tsx +4 -0
- package/src/cli/main.tsx +98 -0
- package/src/core/README.md +19 -0
- package/src/core/api/agent.ts +1 -0
- package/src/core/api/config.ts +1 -0
- package/src/core/api/index.ts +10 -0
- package/src/core/api/integrations.ts +1 -0
- package/src/core/api/observability.ts +1 -0
- package/src/core/api/policy.ts +1 -0
- package/src/core/api/providers.ts +1 -0
- package/src/core/api/runtime.ts +1 -0
- package/src/core/api/shared.ts +1 -0
- package/src/core/api/tools.ts +1 -0
- package/src/core/api/types.ts +1 -0
- package/src/core/index.ts +1 -0
- package/src/core/internal/config/defaults.ts +8 -0
- package/src/core/internal/config/index.ts +3 -0
- package/src/core/internal/config/loader.ts +97 -0
- package/src/core/internal/config/schema.ts +47 -0
- package/src/core/internal/integrations/index.ts +2 -0
- package/src/core/internal/integrations/mcp/connection-manager.ts +231 -0
- package/src/core/internal/integrations/mcp/health-checker.ts +91 -0
- package/src/core/internal/integrations/mcp/index.ts +197 -0
- package/src/core/internal/integrations/mcp/retry-strategy.ts +111 -0
- package/src/core/internal/integrations/mcp/tool-cache.ts +103 -0
- package/src/core/internal/integrations/mcp/transport.ts +58 -0
- package/src/core/internal/integrations/mcp/types.ts +95 -0
- package/src/core/internal/integrations/mcp/utils.ts +44 -0
- package/src/core/internal/integrations/skills/cache/index.ts +38 -0
- package/src/core/internal/integrations/skills/cache/interface.ts +9 -0
- package/src/core/internal/integrations/skills/cache/memory-cache.ts +118 -0
- package/src/core/internal/integrations/skills/config/defaults.ts +35 -0
- package/src/core/internal/integrations/skills/config/index.ts +71 -0
- package/src/core/internal/integrations/skills/config/schema.ts +31 -0
- package/src/core/internal/integrations/skills/core/errors.ts +36 -0
- package/src/core/internal/integrations/skills/core/events.ts +143 -0
- package/src/core/internal/integrations/skills/core/types.ts +83 -0
- package/src/core/internal/integrations/skills/dependency/conflict-detector.ts +126 -0
- package/src/core/internal/integrations/skills/dependency/graph.ts +91 -0
- package/src/core/internal/integrations/skills/dependency/resolver.ts +128 -0
- package/src/core/internal/integrations/skills/dependency/types.ts +51 -0
- package/src/core/internal/integrations/skills/discovery/index.ts +98 -0
- package/src/core/internal/integrations/skills/discovery/resolver.ts +39 -0
- package/src/core/internal/integrations/skills/discovery/scanner.ts +116 -0
- package/src/core/internal/integrations/skills/discovery/strategies/file-system.ts +16 -0
- package/src/core/internal/integrations/skills/index.ts +3 -0
- package/src/core/internal/integrations/skills/integration/lifecycle.ts +124 -0
- package/src/core/internal/integrations/skills/integration/mcp-loader.ts +100 -0
- package/src/core/internal/integrations/skills/integration/tool-mapper.ts +56 -0
- package/src/core/internal/integrations/skills/loaders/index.ts +5 -0
- package/src/core/internal/integrations/skills/loaders/skill-loader.ts +97 -0
- package/src/core/internal/integrations/skills/manager.ts +200 -0
- package/src/core/internal/integrations/skills/parsers/base.ts +134 -0
- package/src/core/internal/integrations/skills/parsers/factory.ts +42 -0
- package/src/core/internal/integrations/skills/parsers/index.ts +71 -0
- package/src/core/internal/integrations/skills/parsers/markdown.ts +111 -0
- package/src/core/internal/integrations/skills/parsers/yaml-metadata.ts +49 -0
- package/src/core/internal/integrations/skills/types.ts +15 -0
- package/src/core/internal/integrations/skills/utils/fs.ts +59 -0
- package/src/core/internal/integrations/skills/utils/logger.ts +109 -0
- package/src/core/internal/integrations/skills/utils/path.ts +27 -0
- package/src/core/internal/integrations/skills/validation/index.ts +43 -0
- package/src/core/internal/integrations/skills/validation/schema.ts +37 -0
- package/src/core/internal/integrations/skills/validation/skill-validator.ts +56 -0
- package/src/core/internal/observability/index.ts +2 -0
- package/src/core/internal/observability/logging/env.ts +32 -0
- package/src/core/internal/observability/logging/export.ts +55 -0
- package/src/core/internal/observability/logging/index.ts +4 -0
- package/src/core/internal/observability/logging/session-logger.ts +54 -0
- package/src/core/internal/observability/logging/types.ts +53 -0
- package/src/core/internal/policy/index.ts +1 -0
- package/src/core/internal/policy/safety/index.ts +2 -0
- package/src/core/internal/policy/safety/policy.ts +96 -0
- package/src/core/internal/policy/safety/types.ts +24 -0
- package/src/core/internal/providers/anthropic/client.ts +20 -0
- package/src/core/internal/providers/anthropic/index.ts +1 -0
- package/src/core/internal/providers/index.ts +1 -0
- package/src/core/internal/sdk/agent/agent.ts +691 -0
- package/src/core/internal/sdk/agent/index.ts +3 -0
- package/src/core/internal/sdk/agent/session.ts +9 -0
- package/src/core/internal/sdk/agent/tool-loop.ts +10 -0
- package/src/core/internal/sdk/index.ts +3 -0
- package/src/core/internal/sdk/runtime/context.ts +1 -0
- package/src/core/internal/sdk/runtime/errors.ts +9 -0
- package/src/core/internal/sdk/runtime/execution.ts +12 -0
- package/src/core/internal/sdk/runtime/index.ts +3 -0
- package/src/core/internal/sdk/types/api.ts +4 -0
- package/src/core/internal/sdk/types/index.ts +1 -0
- package/src/core/internal/sdk/types/internal.ts +1 -0
- package/src/core/internal/shared/fs.ts +10 -0
- package/src/core/internal/shared/index.ts +3 -0
- package/src/core/internal/shared/message.ts +12 -0
- package/src/core/internal/shared/path.ts +10 -0
- package/src/core/internal/tools/base/errors.ts +6 -0
- package/src/core/internal/tools/base/index.ts +3 -0
- package/src/core/internal/tools/base/schema.ts +1 -0
- package/src/core/internal/tools/base/tool.ts +42 -0
- package/src/core/internal/tools/builtins/architect.ts +45 -0
- package/src/core/internal/tools/builtins/bash.ts +135 -0
- package/src/core/internal/tools/builtins/fetch.ts +62 -0
- package/src/core/internal/tools/builtins/file-edit.ts +134 -0
- package/src/core/internal/tools/builtins/file-read.ts +75 -0
- package/src/core/internal/tools/builtins/fs.ts +254 -0
- package/src/core/internal/tools/builtins/glob.ts +75 -0
- package/src/core/internal/tools/builtins/grep.ts +104 -0
- package/src/core/internal/tools/builtins/index.ts +26 -0
- package/src/core/internal/tools/builtins/list-files.ts +64 -0
- package/src/core/internal/tools/builtins/search.ts +50 -0
- package/src/core/internal/tools/builtins/skills.ts +127 -0
- package/src/core/internal/tools/builtins/todo.ts +121 -0
- package/src/core/internal/tools/guards/file-edit-cache.ts +21 -0
- package/src/core/internal/tools/guards/limits.ts +43 -0
- package/src/core/internal/tools/index.ts +39 -0
- package/src/core/internal/tools/registry/index.ts +2 -0
- package/src/core/internal/tools/registry/presets.ts +28 -0
- package/src/core/internal/tools/registry/registry.ts +21 -0
- package/src/index.ts +3 -0
- package/src/render/commands/index.ts +113 -0
- package/src/render/commands/init.ts +45 -0
- package/src/render/components/ActivityPane.tsx +67 -0
- package/src/render/components/ChatBubble.tsx +58 -0
- package/src/render/components/ConfirmCard.tsx +100 -0
- package/src/render/components/ConfirmSelectMenu.tsx +56 -0
- package/src/render/components/ConversationPane.tsx +65 -0
- package/src/render/components/EventTimeline.tsx +30 -0
- package/src/render/components/MarkdownText.tsx +139 -0
- package/src/render/components/SlashCommandMenu.tsx +68 -0
- package/src/render/components/Spinner.tsx +18 -0
- package/src/render/components/StatusBar.tsx +72 -0
- package/src/render/components/Timeline.tsx +57 -0
- package/src/render/components/TimelineEvent.tsx +313 -0
- package/src/render/components/ToolCard.tsx +126 -0
- package/src/render/components/formatters/confirm.test.ts +34 -0
- package/src/render/components/formatters/confirm.ts +32 -0
- package/src/render/index.tsx +466 -0
- package/src/render/state/events.ts +301 -0
- package/src/render/state/history.ts +5 -0
- package/src/render/state/loading.ts +18 -0
- package/src/render/state/message.tsx +35 -0
- package/src/render/state/store.ts +7 -0
- package/src/render/theme.ts +52 -0
- package/test-e2e.ts +250 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type SessionEvent =
|
|
2
|
+
| { type: "session_start"; ts: string; sessionId: string; projectRoot: string }
|
|
3
|
+
| { type: "user_message"; ts: string; content: string }
|
|
4
|
+
| { type: "assistant_start"; ts: string; content: string }
|
|
5
|
+
| { type: "assistant_delta"; ts: string; delta: string }
|
|
6
|
+
| { type: "assistant_thinking_start"; ts: string; content: string; redacted?: boolean }
|
|
7
|
+
| { type: "assistant_thinking_delta"; ts: string; delta: string }
|
|
8
|
+
| { type: "assistant_thinking_end"; ts: string }
|
|
9
|
+
| { type: "assistant_end"; ts: string }
|
|
10
|
+
| { type: "tool_use"; ts: string; toolName: string; input: unknown; preview?: string }
|
|
11
|
+
| {
|
|
12
|
+
type: "tool_result";
|
|
13
|
+
ts: string;
|
|
14
|
+
toolName: string;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
content: string;
|
|
17
|
+
filesChanged?: string[];
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
type: "confirm_request";
|
|
21
|
+
ts: string;
|
|
22
|
+
confirmId: string;
|
|
23
|
+
toolName: string;
|
|
24
|
+
reason: string;
|
|
25
|
+
preview?: string;
|
|
26
|
+
}
|
|
27
|
+
| { type: "confirm_response"; ts: string; confirmId: string; allowed: boolean }
|
|
28
|
+
| { type: "error"; ts: string; message: string; stack?: string };
|
|
29
|
+
|
|
30
|
+
export type EnvSnapshot = {
|
|
31
|
+
ts: string;
|
|
32
|
+
os: {
|
|
33
|
+
platform: string;
|
|
34
|
+
release: string;
|
|
35
|
+
arch: string;
|
|
36
|
+
cpus: number;
|
|
37
|
+
};
|
|
38
|
+
runtime: {
|
|
39
|
+
bunVersion?: string;
|
|
40
|
+
nodeVersion: string;
|
|
41
|
+
};
|
|
42
|
+
shell?: string;
|
|
43
|
+
cwd: string;
|
|
44
|
+
git?: {
|
|
45
|
+
branch?: string;
|
|
46
|
+
status?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type ExportOptions = {
|
|
51
|
+
sessionDir: string;
|
|
52
|
+
outPath: string;
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as safetyPolicy from "./safety";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import type { SafetyAction, SafetyDecision, SafetyPolicyConfig } from "./types";
|
|
3
|
+
|
|
4
|
+
function isWithinRoots(targetPath: string, roots: string[]): boolean {
|
|
5
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
6
|
+
return roots.some((root) => {
|
|
7
|
+
const resolvedRoot = path.resolve(root);
|
|
8
|
+
const rel = path.relative(resolvedRoot, resolvedTarget);
|
|
9
|
+
return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getBashPrefix(command: string): string {
|
|
14
|
+
return command.trim().split(/\s+/).slice(0, 2).join(" ");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class SafetyPolicy {
|
|
18
|
+
private config: SafetyPolicyConfig;
|
|
19
|
+
|
|
20
|
+
constructor(config: SafetyPolicyConfig) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
decide(action: SafetyAction): SafetyDecision {
|
|
25
|
+
const projectRoot = this.config.projectRoot;
|
|
26
|
+
const allowedWriteRoots = this.config.allowedWriteRoots?.length
|
|
27
|
+
? this.config.allowedWriteRoots
|
|
28
|
+
: [projectRoot];
|
|
29
|
+
|
|
30
|
+
if (action.type === "bash") {
|
|
31
|
+
const prefix = getBashPrefix(action.command);
|
|
32
|
+
const autoPrefixes = this.config.autoAllowedBashPrefixes ?? [
|
|
33
|
+
"rg",
|
|
34
|
+
"cat",
|
|
35
|
+
"ls",
|
|
36
|
+
"pwd",
|
|
37
|
+
"git status",
|
|
38
|
+
"git diff",
|
|
39
|
+
"git log",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
if (autoPrefixes.some((p) => prefix === p || action.command.trim().startsWith(p + " "))) {
|
|
43
|
+
return { allowed: true, requiresConfirm: false, reason: `Auto-allowed command: ${prefix}` };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { allowed: true, requiresConfirm: true, reason: "Command execution requires confirmation" };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (action.type === "tool") {
|
|
50
|
+
const toolName = action.toolName;
|
|
51
|
+
if (
|
|
52
|
+
toolName === "fileRead" ||
|
|
53
|
+
toolName === "listFiles" ||
|
|
54
|
+
toolName === "grep" ||
|
|
55
|
+
toolName === "glob" ||
|
|
56
|
+
toolName === "architect" ||
|
|
57
|
+
toolName === "todo_read" ||
|
|
58
|
+
toolName === "skills"
|
|
59
|
+
) {
|
|
60
|
+
return { allowed: true, requiresConfirm: false, reason: "Read-only tool" };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (toolName === "fileEdit" || toolName === "todo_write") {
|
|
64
|
+
const input = action.input as any;
|
|
65
|
+
const filePath =
|
|
66
|
+
typeof input?.path === "string"
|
|
67
|
+
? input.path
|
|
68
|
+
: typeof input?.filePath === "string"
|
|
69
|
+
? input.filePath
|
|
70
|
+
: "";
|
|
71
|
+
if (filePath && !isWithinRoots(path.resolve(projectRoot, filePath), allowedWriteRoots)) {
|
|
72
|
+
return {
|
|
73
|
+
allowed: false,
|
|
74
|
+
requiresConfirm: false,
|
|
75
|
+
reason: `Write path is outside allowed roots: ${filePath}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return { allowed: true, requiresConfirm: true, reason: "File write requires confirmation" };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (toolName === "fetch") {
|
|
82
|
+
return { allowed: true, requiresConfirm: true, reason: "Network access requires confirmation" };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (toolName === "bash") {
|
|
86
|
+
const input = action.input as any;
|
|
87
|
+
const command = typeof input?.command === "string" ? input.command : "";
|
|
88
|
+
return this.decide({ type: "bash", command, preview: action.preview });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { allowed: true, requiresConfirm: true, reason: `Tool requires confirmation: ${toolName}` };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { allowed: true, requiresConfirm: true, reason: "Unknown action requires confirmation" };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SafetyAction =
|
|
2
|
+
| {
|
|
3
|
+
type: "tool";
|
|
4
|
+
toolName: string;
|
|
5
|
+
input: unknown;
|
|
6
|
+
preview?: string;
|
|
7
|
+
}
|
|
8
|
+
| {
|
|
9
|
+
type: "bash";
|
|
10
|
+
command: string;
|
|
11
|
+
preview?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SafetyDecision = {
|
|
15
|
+
allowed: boolean;
|
|
16
|
+
requiresConfirm: boolean;
|
|
17
|
+
reason: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type SafetyPolicyConfig = {
|
|
21
|
+
projectRoot: string;
|
|
22
|
+
allowedWriteRoots?: string[];
|
|
23
|
+
autoAllowedBashPrefixes?: string[];
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import { getEffectiveConfig } from "../../config";
|
|
3
|
+
|
|
4
|
+
export function createAnthropicClient(): Anthropic {
|
|
5
|
+
const config = getEffectiveConfig();
|
|
6
|
+
return new Anthropic({
|
|
7
|
+
baseURL: config.baseURL || process.env.ANTHROPIC_BASE_URL,
|
|
8
|
+
authToken: config.authToken || process.env.ANTHROPIC_AUTH_TOKEN,
|
|
9
|
+
apiKey: config.apiKey,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let cachedClient: Anthropic | null = null;
|
|
14
|
+
|
|
15
|
+
export function getAnthropicClient(): Anthropic {
|
|
16
|
+
if (!cachedClient) {
|
|
17
|
+
cachedClient = createAnthropicClient();
|
|
18
|
+
}
|
|
19
|
+
return cachedClient;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./anthropic";
|