archbyte 0.1.0

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 (142) hide show
  1. package/README.md +282 -0
  2. package/bin/archbyte.js +213 -0
  3. package/dist/agents/core/component-detector.d.ts +2 -0
  4. package/dist/agents/core/component-detector.js +57 -0
  5. package/dist/agents/core/connection-mapper.d.ts +2 -0
  6. package/dist/agents/core/connection-mapper.js +77 -0
  7. package/dist/agents/core/doc-parser.d.ts +2 -0
  8. package/dist/agents/core/doc-parser.js +64 -0
  9. package/dist/agents/core/env-detector.d.ts +2 -0
  10. package/dist/agents/core/env-detector.js +51 -0
  11. package/dist/agents/core/event-detector.d.ts +2 -0
  12. package/dist/agents/core/event-detector.js +59 -0
  13. package/dist/agents/core/infra-analyzer.d.ts +2 -0
  14. package/dist/agents/core/infra-analyzer.js +72 -0
  15. package/dist/agents/core/structure-scanner.d.ts +2 -0
  16. package/dist/agents/core/structure-scanner.js +55 -0
  17. package/dist/agents/core/validator.d.ts +2 -0
  18. package/dist/agents/core/validator.js +74 -0
  19. package/dist/agents/index.d.ts +24 -0
  20. package/dist/agents/index.js +73 -0
  21. package/dist/agents/llm/index.d.ts +8 -0
  22. package/dist/agents/llm/index.js +185 -0
  23. package/dist/agents/llm/prompt-builder.d.ts +3 -0
  24. package/dist/agents/llm/prompt-builder.js +251 -0
  25. package/dist/agents/llm/response-parser.d.ts +6 -0
  26. package/dist/agents/llm/response-parser.js +174 -0
  27. package/dist/agents/llm/types.d.ts +31 -0
  28. package/dist/agents/llm/types.js +2 -0
  29. package/dist/agents/pipeline/agents/component-identifier.d.ts +3 -0
  30. package/dist/agents/pipeline/agents/component-identifier.js +102 -0
  31. package/dist/agents/pipeline/agents/connection-mapper.d.ts +3 -0
  32. package/dist/agents/pipeline/agents/connection-mapper.js +126 -0
  33. package/dist/agents/pipeline/agents/flow-detector.d.ts +3 -0
  34. package/dist/agents/pipeline/agents/flow-detector.js +101 -0
  35. package/dist/agents/pipeline/agents/service-describer.d.ts +3 -0
  36. package/dist/agents/pipeline/agents/service-describer.js +100 -0
  37. package/dist/agents/pipeline/agents/validator.d.ts +3 -0
  38. package/dist/agents/pipeline/agents/validator.js +102 -0
  39. package/dist/agents/pipeline/index.d.ts +13 -0
  40. package/dist/agents/pipeline/index.js +128 -0
  41. package/dist/agents/pipeline/merger.d.ts +7 -0
  42. package/dist/agents/pipeline/merger.js +212 -0
  43. package/dist/agents/pipeline/response-parser.d.ts +5 -0
  44. package/dist/agents/pipeline/response-parser.js +43 -0
  45. package/dist/agents/pipeline/types.d.ts +92 -0
  46. package/dist/agents/pipeline/types.js +3 -0
  47. package/dist/agents/prompt-data.d.ts +1 -0
  48. package/dist/agents/prompt-data.js +15 -0
  49. package/dist/agents/prompts-encode.d.ts +9 -0
  50. package/dist/agents/prompts-encode.js +26 -0
  51. package/dist/agents/prompts.d.ts +12 -0
  52. package/dist/agents/prompts.js +30 -0
  53. package/dist/agents/providers/anthropic.d.ts +10 -0
  54. package/dist/agents/providers/anthropic.js +117 -0
  55. package/dist/agents/providers/google.d.ts +10 -0
  56. package/dist/agents/providers/google.js +136 -0
  57. package/dist/agents/providers/ollama.d.ts +9 -0
  58. package/dist/agents/providers/ollama.js +162 -0
  59. package/dist/agents/providers/openai.d.ts +9 -0
  60. package/dist/agents/providers/openai.js +142 -0
  61. package/dist/agents/providers/router.d.ts +7 -0
  62. package/dist/agents/providers/router.js +55 -0
  63. package/dist/agents/runtime/orchestrator.d.ts +34 -0
  64. package/dist/agents/runtime/orchestrator.js +193 -0
  65. package/dist/agents/runtime/registry.d.ts +23 -0
  66. package/dist/agents/runtime/registry.js +56 -0
  67. package/dist/agents/runtime/types.d.ts +117 -0
  68. package/dist/agents/runtime/types.js +29 -0
  69. package/dist/agents/static/code-sampler.d.ts +3 -0
  70. package/dist/agents/static/code-sampler.js +153 -0
  71. package/dist/agents/static/component-detector.d.ts +3 -0
  72. package/dist/agents/static/component-detector.js +404 -0
  73. package/dist/agents/static/connection-mapper.d.ts +3 -0
  74. package/dist/agents/static/connection-mapper.js +280 -0
  75. package/dist/agents/static/doc-parser.d.ts +3 -0
  76. package/dist/agents/static/doc-parser.js +358 -0
  77. package/dist/agents/static/env-detector.d.ts +3 -0
  78. package/dist/agents/static/env-detector.js +73 -0
  79. package/dist/agents/static/event-detector.d.ts +3 -0
  80. package/dist/agents/static/event-detector.js +70 -0
  81. package/dist/agents/static/file-tree-collector.d.ts +3 -0
  82. package/dist/agents/static/file-tree-collector.js +51 -0
  83. package/dist/agents/static/index.d.ts +19 -0
  84. package/dist/agents/static/index.js +307 -0
  85. package/dist/agents/static/infra-analyzer.d.ts +3 -0
  86. package/dist/agents/static/infra-analyzer.js +208 -0
  87. package/dist/agents/static/structure-scanner.d.ts +3 -0
  88. package/dist/agents/static/structure-scanner.js +195 -0
  89. package/dist/agents/static/types.d.ts +165 -0
  90. package/dist/agents/static/types.js +2 -0
  91. package/dist/agents/static/utils.d.ts +21 -0
  92. package/dist/agents/static/utils.js +146 -0
  93. package/dist/agents/static/validator.d.ts +2 -0
  94. package/dist/agents/static/validator.js +75 -0
  95. package/dist/agents/tools/claude-code.d.ts +38 -0
  96. package/dist/agents/tools/claude-code.js +129 -0
  97. package/dist/agents/tools/local-fs.d.ts +12 -0
  98. package/dist/agents/tools/local-fs.js +112 -0
  99. package/dist/agents/tools/tool-definitions.d.ts +6 -0
  100. package/dist/agents/tools/tool-definitions.js +66 -0
  101. package/dist/cli/analyze.d.ts +27 -0
  102. package/dist/cli/analyze.js +586 -0
  103. package/dist/cli/auth.d.ts +46 -0
  104. package/dist/cli/auth.js +397 -0
  105. package/dist/cli/config.d.ts +11 -0
  106. package/dist/cli/config.js +177 -0
  107. package/dist/cli/diff.d.ts +10 -0
  108. package/dist/cli/diff.js +144 -0
  109. package/dist/cli/export.d.ts +10 -0
  110. package/dist/cli/export.js +321 -0
  111. package/dist/cli/gate.d.ts +13 -0
  112. package/dist/cli/gate.js +131 -0
  113. package/dist/cli/generate.d.ts +10 -0
  114. package/dist/cli/generate.js +213 -0
  115. package/dist/cli/license-gate.d.ts +27 -0
  116. package/dist/cli/license-gate.js +121 -0
  117. package/dist/cli/patrol.d.ts +15 -0
  118. package/dist/cli/patrol.js +212 -0
  119. package/dist/cli/run.d.ts +11 -0
  120. package/dist/cli/run.js +24 -0
  121. package/dist/cli/serve.d.ts +9 -0
  122. package/dist/cli/serve.js +65 -0
  123. package/dist/cli/setup.d.ts +1 -0
  124. package/dist/cli/setup.js +233 -0
  125. package/dist/cli/shared.d.ts +68 -0
  126. package/dist/cli/shared.js +275 -0
  127. package/dist/cli/stats.d.ts +9 -0
  128. package/dist/cli/stats.js +158 -0
  129. package/dist/cli/ui.d.ts +18 -0
  130. package/dist/cli/ui.js +144 -0
  131. package/dist/cli/validate.d.ts +54 -0
  132. package/dist/cli/validate.js +315 -0
  133. package/dist/cli/workflow.d.ts +10 -0
  134. package/dist/cli/workflow.js +594 -0
  135. package/dist/server/src/generator/index.d.ts +123 -0
  136. package/dist/server/src/generator/index.js +254 -0
  137. package/dist/server/src/index.d.ts +8 -0
  138. package/dist/server/src/index.js +1311 -0
  139. package/package.json +62 -0
  140. package/ui/dist/assets/index-B66Til39.js +70 -0
  141. package/ui/dist/assets/index-BE2OWbzu.css +1 -0
  142. package/ui/dist/index.html +14 -0
@@ -0,0 +1,129 @@
1
+ import { readFile, readdir, stat } from "node:fs/promises";
2
+ import { resolve, join } from "node:path";
3
+ /**
4
+ * ClaudeCodeBackend — uses the same local FS operations as LocalFSBackend
5
+ * but is designed to be instantiated when running inside Claude Code.
6
+ *
7
+ * In practice, when archbyte is invoked via a Claude Code skill,
8
+ * Claude Code's Task agents run the archbyte agent pipeline.
9
+ * The agents use tool_use calls which are executed by the orchestrator
10
+ * against this backend — which reads the local filesystem that
11
+ * Claude Code also has access to.
12
+ *
13
+ * The key difference from LocalFSBackend:
14
+ * - Optimized for the files Claude Code has already discovered
15
+ * - Can accept a pre-scanned file list to avoid redundant discovery
16
+ * - Respects .gitignore and Claude Code's file filtering
17
+ */
18
+ export class ClaudeCodeBackend {
19
+ root;
20
+ preScannedFiles;
21
+ constructor(projectRoot, preScannedFiles) {
22
+ this.root = resolve(projectRoot);
23
+ this.preScannedFiles = preScannedFiles;
24
+ }
25
+ async readFile(filePath) {
26
+ const resolved = this.resolvePath(filePath);
27
+ return readFile(resolved, "utf-8");
28
+ }
29
+ async glob(pattern) {
30
+ // If we have pre-scanned files, filter against the pattern
31
+ if (this.preScannedFiles) {
32
+ const regex = this.globToRegex(pattern);
33
+ return this.preScannedFiles.filter((f) => regex.test(f)).sort();
34
+ }
35
+ // Fallback to filesystem walk
36
+ const matches = [];
37
+ const regex = this.globToRegex(pattern);
38
+ await this.walk(this.root, "", regex, matches);
39
+ return matches.sort();
40
+ }
41
+ async grep(pattern, searchPath) {
42
+ const regex = new RegExp(pattern, "i");
43
+ const results = [];
44
+ const files = await this.glob("**/*");
45
+ for (const file of files.slice(0, 300)) {
46
+ try {
47
+ const content = await readFile(this.resolvePath(file), "utf-8");
48
+ const lines = content.split("\n");
49
+ for (let i = 0; i < lines.length; i++) {
50
+ if (regex.test(lines[i])) {
51
+ results.push({ file, line: i + 1, content: lines[i].trim() });
52
+ }
53
+ }
54
+ }
55
+ catch {
56
+ // Skip
57
+ }
58
+ if (results.length >= 150)
59
+ break;
60
+ }
61
+ return results;
62
+ }
63
+ async listDir(dirPath) {
64
+ const resolved = this.resolvePath(dirPath);
65
+ const entries = await readdir(resolved, { withFileTypes: true });
66
+ const results = [];
67
+ for (const entry of entries) {
68
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
69
+ continue;
70
+ const entryPath = join(resolved, entry.name);
71
+ const s = await stat(entryPath).catch(() => null);
72
+ results.push({
73
+ name: entry.name,
74
+ type: entry.isDirectory() ? "directory" : "file",
75
+ size: s?.size,
76
+ });
77
+ }
78
+ return results.sort((a, b) => {
79
+ if (a.type !== b.type)
80
+ return a.type === "directory" ? -1 : 1;
81
+ return a.name.localeCompare(b.name);
82
+ });
83
+ }
84
+ resolvePath(p) {
85
+ const resolved = resolve(this.root, p);
86
+ if (!resolved.startsWith(this.root)) {
87
+ throw new Error(`Path traversal attempt: ${p}`);
88
+ }
89
+ return resolved;
90
+ }
91
+ async walk(base, prefix, regex, matches) {
92
+ if (matches.length >= 3000)
93
+ return;
94
+ const dir = prefix ? join(base, prefix) : base;
95
+ let entries;
96
+ try {
97
+ entries = await readdir(dir, { withFileTypes: true });
98
+ }
99
+ catch {
100
+ return;
101
+ }
102
+ for (const entry of entries) {
103
+ if (entry.name.startsWith(".") ||
104
+ entry.name === "node_modules" ||
105
+ entry.name === "dist" ||
106
+ entry.name === "__pycache__" ||
107
+ entry.name === ".git" ||
108
+ entry.name === ".archbyte") {
109
+ continue;
110
+ }
111
+ const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
112
+ if (entry.isDirectory()) {
113
+ await this.walk(base, relPath, regex, matches);
114
+ }
115
+ else if (entry.isFile() && regex.test(relPath)) {
116
+ matches.push(relPath);
117
+ }
118
+ }
119
+ }
120
+ globToRegex(pattern) {
121
+ let regex = pattern
122
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&")
123
+ .replace(/\*\*/g, "___DOUBLESTAR___")
124
+ .replace(/\*/g, "[^/]*")
125
+ .replace(/___DOUBLESTAR___/g, ".*")
126
+ .replace(/\?/g, "[^/]");
127
+ return new RegExp(`^${regex}$`);
128
+ }
129
+ }
@@ -0,0 +1,12 @@
1
+ import type { ToolBackend, GrepResult, DirEntry } from "../runtime/types.js";
2
+ export declare class LocalFSBackend implements ToolBackend {
3
+ private root;
4
+ constructor(projectRoot: string);
5
+ readFile(filePath: string): Promise<string>;
6
+ glob(pattern: string, cwd?: string): Promise<string[]>;
7
+ grep(pattern: string, searchPath?: string): Promise<GrepResult[]>;
8
+ listDir(dirPath: string): Promise<DirEntry[]>;
9
+ private resolvePath;
10
+ private walk;
11
+ private globToRegex;
12
+ }
@@ -0,0 +1,112 @@
1
+ import { readFile, readdir, stat } from "node:fs/promises";
2
+ import { resolve, relative, join } from "node:path";
3
+ export class LocalFSBackend {
4
+ root;
5
+ constructor(projectRoot) {
6
+ this.root = resolve(projectRoot);
7
+ }
8
+ async readFile(filePath) {
9
+ const resolved = this.resolvePath(filePath);
10
+ return readFile(resolved, "utf-8");
11
+ }
12
+ async glob(pattern, cwd) {
13
+ const searchDir = cwd ? this.resolvePath(cwd) : this.root;
14
+ // Use Node.js built-in glob (available in Node 22+) or fallback to manual walk
15
+ // For broad compatibility, do a simple recursive walk with pattern matching
16
+ const matches = [];
17
+ const regex = this.globToRegex(pattern);
18
+ await this.walk(searchDir, "", regex, matches);
19
+ return matches.sort();
20
+ }
21
+ async grep(pattern, searchPath) {
22
+ const searchDir = searchPath ? this.resolvePath(searchPath) : this.root;
23
+ const regex = new RegExp(pattern, "i");
24
+ const results = [];
25
+ const files = await this.glob("**/*", searchDir === this.root ? undefined : relative(this.root, searchDir));
26
+ for (const file of files.slice(0, 500)) {
27
+ try {
28
+ const content = await readFile(this.resolvePath(file), "utf-8");
29
+ const lines = content.split("\n");
30
+ for (let i = 0; i < lines.length; i++) {
31
+ if (regex.test(lines[i])) {
32
+ results.push({ file, line: i + 1, content: lines[i].trim() });
33
+ }
34
+ }
35
+ }
36
+ catch {
37
+ // Skip unreadable files
38
+ }
39
+ if (results.length >= 200)
40
+ break;
41
+ }
42
+ return results;
43
+ }
44
+ async listDir(dirPath) {
45
+ const resolved = this.resolvePath(dirPath);
46
+ const entries = await readdir(resolved, { withFileTypes: true });
47
+ const results = [];
48
+ for (const entry of entries) {
49
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
50
+ continue;
51
+ const entryPath = join(resolved, entry.name);
52
+ const s = await stat(entryPath).catch(() => null);
53
+ results.push({
54
+ name: entry.name,
55
+ type: entry.isDirectory() ? "directory" : "file",
56
+ size: s?.size,
57
+ });
58
+ }
59
+ return results.sort((a, b) => {
60
+ if (a.type !== b.type)
61
+ return a.type === "directory" ? -1 : 1;
62
+ return a.name.localeCompare(b.name);
63
+ });
64
+ }
65
+ resolvePath(p) {
66
+ const resolved = resolve(this.root, p);
67
+ // Prevent path traversal outside project root
68
+ if (!resolved.startsWith(this.root)) {
69
+ throw new Error(`Path traversal attempt: ${p}`);
70
+ }
71
+ return resolved;
72
+ }
73
+ async walk(base, prefix, regex, matches) {
74
+ if (matches.length >= 5000)
75
+ return;
76
+ const dir = prefix ? join(base, prefix) : base;
77
+ let entries;
78
+ try {
79
+ entries = await readdir(dir, { withFileTypes: true });
80
+ }
81
+ catch {
82
+ return;
83
+ }
84
+ for (const entry of entries) {
85
+ // Skip hidden dirs, node_modules, dist, .git
86
+ if (entry.name.startsWith(".") ||
87
+ entry.name === "node_modules" ||
88
+ entry.name === "dist" ||
89
+ entry.name === "__pycache__" ||
90
+ entry.name === ".git") {
91
+ continue;
92
+ }
93
+ const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
94
+ if (entry.isDirectory()) {
95
+ await this.walk(base, relPath, regex, matches);
96
+ }
97
+ else if (entry.isFile() && regex.test(relPath)) {
98
+ matches.push(relPath);
99
+ }
100
+ }
101
+ }
102
+ globToRegex(pattern) {
103
+ // Convert glob pattern to regex
104
+ let regex = pattern
105
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&") // Escape special regex chars
106
+ .replace(/\*\*/g, "___DOUBLESTAR___")
107
+ .replace(/\*/g, "[^/]*")
108
+ .replace(/___DOUBLESTAR___/g, ".*")
109
+ .replace(/\?/g, "[^/]");
110
+ return new RegExp(`^${regex}$`);
111
+ }
112
+ }
@@ -0,0 +1,6 @@
1
+ import type { ToolDefinition } from "../runtime/types.js";
2
+ /**
3
+ * Tool definitions exposed to LLM agents.
4
+ * These match the ToolBackend interface methods.
5
+ */
6
+ export declare const AGENT_TOOLS: ToolDefinition[];
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Tool definitions exposed to LLM agents.
3
+ * These match the ToolBackend interface methods.
4
+ */
5
+ export const AGENT_TOOLS = [
6
+ {
7
+ name: "read_file",
8
+ description: "Read the contents of a file. Returns the full text content of the file.",
9
+ input_schema: {
10
+ type: "object",
11
+ properties: {
12
+ path: {
13
+ type: "string",
14
+ description: "Relative path to the file from the project root (e.g. 'src/index.ts', 'package.json')",
15
+ },
16
+ },
17
+ required: ["path"],
18
+ },
19
+ },
20
+ {
21
+ name: "glob",
22
+ description: "Find files matching a glob pattern. Returns a list of matching file paths relative to the project root. Supports ** for recursive matching.",
23
+ input_schema: {
24
+ type: "object",
25
+ properties: {
26
+ pattern: {
27
+ type: "string",
28
+ description: "Glob pattern (e.g. '**/*.ts', 'src/**/*.py', 'Dockerfile*', '*.yaml')",
29
+ },
30
+ },
31
+ required: ["pattern"],
32
+ },
33
+ },
34
+ {
35
+ name: "grep",
36
+ description: "Search file contents for a regex pattern. Returns matching lines with file paths and line numbers. Searches all text files in the project.",
37
+ input_schema: {
38
+ type: "object",
39
+ properties: {
40
+ pattern: {
41
+ type: "string",
42
+ description: "Regular expression pattern to search for (e.g. 'import.*express', 'class\\s+\\w+Controller')",
43
+ },
44
+ path: {
45
+ type: "string",
46
+ description: "Optional: restrict search to this directory (relative to project root)",
47
+ },
48
+ },
49
+ required: ["pattern"],
50
+ },
51
+ },
52
+ {
53
+ name: "list_dir",
54
+ description: "List contents of a directory. Returns file and directory names with types and sizes. Hidden files and node_modules are excluded.",
55
+ input_schema: {
56
+ type: "object",
57
+ properties: {
58
+ path: {
59
+ type: "string",
60
+ description: "Relative path to the directory from the project root (e.g. 'src', 'lib/utils'). Use '.' for root.",
61
+ },
62
+ },
63
+ required: ["path"],
64
+ },
65
+ },
66
+ ];
@@ -0,0 +1,27 @@
1
+ import type { StaticAnalysisResult } from "../agents/static/types.js";
2
+ interface AnalyzeOptions {
3
+ output?: string;
4
+ verbose?: boolean;
5
+ provider?: string;
6
+ apiKey?: string;
7
+ premiumOnly?: boolean;
8
+ static?: boolean;
9
+ skipLlm?: boolean;
10
+ dryRun?: boolean;
11
+ }
12
+ export declare function handleAnalyze(options: AnalyzeOptions): Promise<void>;
13
+ /**
14
+ * Convert a StaticAnalysisResult (from pipeline or static-only) into the
15
+ * flat analysis.json format expected by generate.ts.
16
+ */
17
+ export declare function buildAnalysisFromStatic(result: StaticAnalysisResult, projectRoot: string): Record<string, unknown>;
18
+ /**
19
+ * Aggregate agent results into the analysis.json format expected by the generator.
20
+ * Used by legacy mode (--legacy flag) only.
21
+ */
22
+ export declare function buildAnalysis(agents: Array<{
23
+ agentId: string;
24
+ data: unknown;
25
+ confidence: number;
26
+ }>, projectRoot: string): Record<string, unknown>;
27
+ export {};