@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.
Files changed (167) hide show
  1. package/.claude/CLAUDE.md +21 -0
  2. package/.codex/skills/beautiful-mermaid/SKILL.md +171 -0
  3. package/.codex/skills/beautiful-mermaid/references/mermaid-syntax.md +235 -0
  4. package/.codex/skills/beautiful-mermaid/scripts/create-html.ts +177 -0
  5. package/.codex/skills/beautiful-mermaid/scripts/render.ts +221 -0
  6. package/.codex/skills/find-skills/SKILL.md +133 -0
  7. package/.github/workflows/publish-github-packages.yml +58 -0
  8. package/.github/workflows/publish-npm.yml +46 -0
  9. package/.vscode/settings.json +2 -0
  10. package/AGENTS.md +41 -0
  11. package/LICENSE +21 -0
  12. package/README.md +119 -0
  13. package/bun.lock +327 -0
  14. package/docs/agent/architecture.md +28 -0
  15. package/docs/agent/development_commands.md +6 -0
  16. package/docs/plan/agent-plan-2026-02-05.md +136 -0
  17. package/docs/plan/core-agent-sdk-structure-2026-02-07.md +156 -0
  18. package/docs/plan/implementation-summary.md +303 -0
  19. package/docs/plan/mcp-2026-02-05.md +700 -0
  20. package/docs/plan/op.md +478 -0
  21. package/docs/plan/skills-2026-02-05.md +352 -0
  22. package/docs/plan/skills-flow.svg +120 -0
  23. package/docs/plan/tui-readability-2026-02-06.md +67 -0
  24. package/package.json +34 -0
  25. package/src/cli/index.tsx +4 -0
  26. package/src/cli/main.tsx +98 -0
  27. package/src/core/README.md +19 -0
  28. package/src/core/api/agent.ts +1 -0
  29. package/src/core/api/config.ts +1 -0
  30. package/src/core/api/index.ts +10 -0
  31. package/src/core/api/integrations.ts +1 -0
  32. package/src/core/api/observability.ts +1 -0
  33. package/src/core/api/policy.ts +1 -0
  34. package/src/core/api/providers.ts +1 -0
  35. package/src/core/api/runtime.ts +1 -0
  36. package/src/core/api/shared.ts +1 -0
  37. package/src/core/api/tools.ts +1 -0
  38. package/src/core/api/types.ts +1 -0
  39. package/src/core/index.ts +1 -0
  40. package/src/core/internal/config/defaults.ts +8 -0
  41. package/src/core/internal/config/index.ts +3 -0
  42. package/src/core/internal/config/loader.ts +97 -0
  43. package/src/core/internal/config/schema.ts +47 -0
  44. package/src/core/internal/integrations/index.ts +2 -0
  45. package/src/core/internal/integrations/mcp/connection-manager.ts +231 -0
  46. package/src/core/internal/integrations/mcp/health-checker.ts +91 -0
  47. package/src/core/internal/integrations/mcp/index.ts +197 -0
  48. package/src/core/internal/integrations/mcp/retry-strategy.ts +111 -0
  49. package/src/core/internal/integrations/mcp/tool-cache.ts +103 -0
  50. package/src/core/internal/integrations/mcp/transport.ts +58 -0
  51. package/src/core/internal/integrations/mcp/types.ts +95 -0
  52. package/src/core/internal/integrations/mcp/utils.ts +44 -0
  53. package/src/core/internal/integrations/skills/cache/index.ts +38 -0
  54. package/src/core/internal/integrations/skills/cache/interface.ts +9 -0
  55. package/src/core/internal/integrations/skills/cache/memory-cache.ts +118 -0
  56. package/src/core/internal/integrations/skills/config/defaults.ts +35 -0
  57. package/src/core/internal/integrations/skills/config/index.ts +71 -0
  58. package/src/core/internal/integrations/skills/config/schema.ts +31 -0
  59. package/src/core/internal/integrations/skills/core/errors.ts +36 -0
  60. package/src/core/internal/integrations/skills/core/events.ts +143 -0
  61. package/src/core/internal/integrations/skills/core/types.ts +83 -0
  62. package/src/core/internal/integrations/skills/dependency/conflict-detector.ts +126 -0
  63. package/src/core/internal/integrations/skills/dependency/graph.ts +91 -0
  64. package/src/core/internal/integrations/skills/dependency/resolver.ts +128 -0
  65. package/src/core/internal/integrations/skills/dependency/types.ts +51 -0
  66. package/src/core/internal/integrations/skills/discovery/index.ts +98 -0
  67. package/src/core/internal/integrations/skills/discovery/resolver.ts +39 -0
  68. package/src/core/internal/integrations/skills/discovery/scanner.ts +116 -0
  69. package/src/core/internal/integrations/skills/discovery/strategies/file-system.ts +16 -0
  70. package/src/core/internal/integrations/skills/index.ts +3 -0
  71. package/src/core/internal/integrations/skills/integration/lifecycle.ts +124 -0
  72. package/src/core/internal/integrations/skills/integration/mcp-loader.ts +100 -0
  73. package/src/core/internal/integrations/skills/integration/tool-mapper.ts +56 -0
  74. package/src/core/internal/integrations/skills/loaders/index.ts +5 -0
  75. package/src/core/internal/integrations/skills/loaders/skill-loader.ts +97 -0
  76. package/src/core/internal/integrations/skills/manager.ts +200 -0
  77. package/src/core/internal/integrations/skills/parsers/base.ts +134 -0
  78. package/src/core/internal/integrations/skills/parsers/factory.ts +42 -0
  79. package/src/core/internal/integrations/skills/parsers/index.ts +71 -0
  80. package/src/core/internal/integrations/skills/parsers/markdown.ts +111 -0
  81. package/src/core/internal/integrations/skills/parsers/yaml-metadata.ts +49 -0
  82. package/src/core/internal/integrations/skills/types.ts +15 -0
  83. package/src/core/internal/integrations/skills/utils/fs.ts +59 -0
  84. package/src/core/internal/integrations/skills/utils/logger.ts +109 -0
  85. package/src/core/internal/integrations/skills/utils/path.ts +27 -0
  86. package/src/core/internal/integrations/skills/validation/index.ts +43 -0
  87. package/src/core/internal/integrations/skills/validation/schema.ts +37 -0
  88. package/src/core/internal/integrations/skills/validation/skill-validator.ts +56 -0
  89. package/src/core/internal/observability/index.ts +2 -0
  90. package/src/core/internal/observability/logging/env.ts +32 -0
  91. package/src/core/internal/observability/logging/export.ts +55 -0
  92. package/src/core/internal/observability/logging/index.ts +4 -0
  93. package/src/core/internal/observability/logging/session-logger.ts +54 -0
  94. package/src/core/internal/observability/logging/types.ts +53 -0
  95. package/src/core/internal/policy/index.ts +1 -0
  96. package/src/core/internal/policy/safety/index.ts +2 -0
  97. package/src/core/internal/policy/safety/policy.ts +96 -0
  98. package/src/core/internal/policy/safety/types.ts +24 -0
  99. package/src/core/internal/providers/anthropic/client.ts +20 -0
  100. package/src/core/internal/providers/anthropic/index.ts +1 -0
  101. package/src/core/internal/providers/index.ts +1 -0
  102. package/src/core/internal/sdk/agent/agent.ts +691 -0
  103. package/src/core/internal/sdk/agent/index.ts +3 -0
  104. package/src/core/internal/sdk/agent/session.ts +9 -0
  105. package/src/core/internal/sdk/agent/tool-loop.ts +10 -0
  106. package/src/core/internal/sdk/index.ts +3 -0
  107. package/src/core/internal/sdk/runtime/context.ts +1 -0
  108. package/src/core/internal/sdk/runtime/errors.ts +9 -0
  109. package/src/core/internal/sdk/runtime/execution.ts +12 -0
  110. package/src/core/internal/sdk/runtime/index.ts +3 -0
  111. package/src/core/internal/sdk/types/api.ts +4 -0
  112. package/src/core/internal/sdk/types/index.ts +1 -0
  113. package/src/core/internal/sdk/types/internal.ts +1 -0
  114. package/src/core/internal/shared/fs.ts +10 -0
  115. package/src/core/internal/shared/index.ts +3 -0
  116. package/src/core/internal/shared/message.ts +12 -0
  117. package/src/core/internal/shared/path.ts +10 -0
  118. package/src/core/internal/tools/base/errors.ts +6 -0
  119. package/src/core/internal/tools/base/index.ts +3 -0
  120. package/src/core/internal/tools/base/schema.ts +1 -0
  121. package/src/core/internal/tools/base/tool.ts +42 -0
  122. package/src/core/internal/tools/builtins/architect.ts +45 -0
  123. package/src/core/internal/tools/builtins/bash.ts +135 -0
  124. package/src/core/internal/tools/builtins/fetch.ts +62 -0
  125. package/src/core/internal/tools/builtins/file-edit.ts +134 -0
  126. package/src/core/internal/tools/builtins/file-read.ts +75 -0
  127. package/src/core/internal/tools/builtins/fs.ts +254 -0
  128. package/src/core/internal/tools/builtins/glob.ts +75 -0
  129. package/src/core/internal/tools/builtins/grep.ts +104 -0
  130. package/src/core/internal/tools/builtins/index.ts +26 -0
  131. package/src/core/internal/tools/builtins/list-files.ts +64 -0
  132. package/src/core/internal/tools/builtins/search.ts +50 -0
  133. package/src/core/internal/tools/builtins/skills.ts +127 -0
  134. package/src/core/internal/tools/builtins/todo.ts +121 -0
  135. package/src/core/internal/tools/guards/file-edit-cache.ts +21 -0
  136. package/src/core/internal/tools/guards/limits.ts +43 -0
  137. package/src/core/internal/tools/index.ts +39 -0
  138. package/src/core/internal/tools/registry/index.ts +2 -0
  139. package/src/core/internal/tools/registry/presets.ts +28 -0
  140. package/src/core/internal/tools/registry/registry.ts +21 -0
  141. package/src/index.ts +3 -0
  142. package/src/render/commands/index.ts +113 -0
  143. package/src/render/commands/init.ts +45 -0
  144. package/src/render/components/ActivityPane.tsx +67 -0
  145. package/src/render/components/ChatBubble.tsx +58 -0
  146. package/src/render/components/ConfirmCard.tsx +100 -0
  147. package/src/render/components/ConfirmSelectMenu.tsx +56 -0
  148. package/src/render/components/ConversationPane.tsx +65 -0
  149. package/src/render/components/EventTimeline.tsx +30 -0
  150. package/src/render/components/MarkdownText.tsx +139 -0
  151. package/src/render/components/SlashCommandMenu.tsx +68 -0
  152. package/src/render/components/Spinner.tsx +18 -0
  153. package/src/render/components/StatusBar.tsx +72 -0
  154. package/src/render/components/Timeline.tsx +57 -0
  155. package/src/render/components/TimelineEvent.tsx +313 -0
  156. package/src/render/components/ToolCard.tsx +126 -0
  157. package/src/render/components/formatters/confirm.test.ts +34 -0
  158. package/src/render/components/formatters/confirm.ts +32 -0
  159. package/src/render/index.tsx +466 -0
  160. package/src/render/state/events.ts +301 -0
  161. package/src/render/state/history.ts +5 -0
  162. package/src/render/state/loading.ts +18 -0
  163. package/src/render/state/message.tsx +35 -0
  164. package/src/render/state/store.ts +7 -0
  165. package/src/render/theme.ts +52 -0
  166. package/test-e2e.ts +250 -0
  167. 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,2 @@
1
+ export * from "./types";
2
+ export * from "./policy";
@@ -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";