autonomous-flow-daemon 1.1.0 → 1.9.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 (75) hide show
  1. package/CHANGELOG.md +85 -46
  2. package/LICENSE +21 -21
  3. package/README-ko.md +282 -0
  4. package/README.md +282 -337
  5. package/mcp-config.json +10 -10
  6. package/package.json +14 -6
  7. package/src/adapters/index.ts +370 -159
  8. package/src/cli.ts +162 -57
  9. package/src/commands/benchmark.ts +187 -0
  10. package/src/commands/correlate.ts +180 -0
  11. package/src/commands/dashboard.ts +404 -0
  12. package/src/commands/diagnose.ts +56 -14
  13. package/src/commands/doctor.ts +243 -0
  14. package/src/commands/evolution.ts +190 -0
  15. package/src/commands/fix.ts +158 -138
  16. package/src/commands/hooks.ts +136 -0
  17. package/src/commands/lang.ts +41 -41
  18. package/src/commands/mcp.ts +129 -0
  19. package/src/commands/plugin.ts +110 -0
  20. package/src/commands/restart.ts +14 -0
  21. package/src/commands/score.ts +276 -208
  22. package/src/commands/start.ts +155 -96
  23. package/src/commands/stats.ts +103 -0
  24. package/src/commands/status.ts +157 -0
  25. package/src/commands/stop.ts +68 -49
  26. package/src/commands/suggest.ts +211 -0
  27. package/src/commands/sync.ts +567 -21
  28. package/src/commands/vaccine.ts +177 -0
  29. package/src/constants.ts +32 -8
  30. package/src/core/boast.ts +280 -265
  31. package/src/core/config.ts +49 -49
  32. package/src/core/correlation-engine.ts +265 -0
  33. package/src/core/db.ts +145 -46
  34. package/src/core/discovery.ts +65 -65
  35. package/src/core/evolution.ts +215 -0
  36. package/src/core/federation.ts +129 -0
  37. package/src/core/hologram/engine.ts +71 -0
  38. package/src/core/hologram/fallback.ts +11 -0
  39. package/src/core/hologram/go-extractor.ts +203 -0
  40. package/src/core/hologram/incremental.ts +227 -0
  41. package/src/core/hologram/py-extractor.ts +132 -0
  42. package/src/core/hologram/rust-extractor.ts +244 -0
  43. package/src/core/hologram/ts-extractor.ts +406 -0
  44. package/src/core/hologram/types.ts +27 -0
  45. package/src/core/hologram.ts +73 -243
  46. package/src/core/hook-manager.ts +259 -0
  47. package/src/core/i18n/messages.ts +309 -266
  48. package/src/core/immune.ts +8 -123
  49. package/src/core/locale.ts +88 -88
  50. package/src/core/log-rotate.ts +33 -0
  51. package/src/core/log-utils.ts +38 -0
  52. package/src/core/lru-map.ts +61 -0
  53. package/src/core/notify.ts +74 -66
  54. package/src/core/plugin-manager.ts +225 -0
  55. package/src/core/rule-engine.ts +287 -0
  56. package/src/core/rule-suggestion.ts +127 -0
  57. package/src/core/semantic-diff.ts +432 -0
  58. package/src/core/telemetry.ts +94 -0
  59. package/src/core/vaccine-registry.ts +212 -0
  60. package/src/core/validator-generator.ts +224 -0
  61. package/src/core/workspace.ts +28 -0
  62. package/src/core/yaml-minimal.ts +176 -0
  63. package/src/daemon/client.ts +78 -37
  64. package/src/daemon/event-batcher.ts +108 -0
  65. package/src/daemon/guards.ts +13 -0
  66. package/src/daemon/http-routes.ts +376 -0
  67. package/src/daemon/mcp-handler.ts +575 -0
  68. package/src/daemon/mcp-subscriptions.ts +81 -0
  69. package/src/daemon/mesh.ts +51 -0
  70. package/src/daemon/server.ts +655 -504
  71. package/src/daemon/types.ts +121 -0
  72. package/src/daemon/workspace-map.ts +104 -0
  73. package/src/platform.ts +60 -39
  74. package/src/version.ts +15 -0
  75. package/README.ko.md +0 -306
@@ -0,0 +1,177 @@
1
+ /**
2
+ * afd vaccine — Vaccine registry CLI
3
+ *
4
+ * Sub-commands:
5
+ * afd vaccine list — list available packages
6
+ * afd vaccine search <query> — search packages
7
+ * afd vaccine install <name> — install a vaccine package
8
+ * afd vaccine publish <file> — publish a vaccine package
9
+ * afd vaccine installed — list installed packages
10
+ */
11
+
12
+ import { readFileSync, existsSync } from "fs";
13
+ import {
14
+ publishPackage,
15
+ searchPackages,
16
+ installPackage,
17
+ listInstalled,
18
+ getPackage,
19
+ } from "../core/vaccine-registry";
20
+ import type { VaccinePackage } from "../core/vaccine-registry";
21
+ import { getSystemLanguage } from "../core/locale";
22
+
23
+ const msgs = {
24
+ en: {
25
+ title: "afd vaccine — Registry",
26
+ list: "Available Packages",
27
+ search: "Search Results",
28
+ install: "Install",
29
+ publish: "Publish",
30
+ installed: "Installed Packages",
31
+ noPackages: "No packages found.",
32
+ noResults: "No matching packages.",
33
+ notFound: "Package not found.",
34
+ usage: `Usage:
35
+ afd vaccine list List available packages
36
+ afd vaccine search <query> Search packages
37
+ afd vaccine install <name> Install a vaccine package
38
+ afd vaccine publish <file> Publish from vaccine.json
39
+ afd vaccine installed List installed packages`,
40
+ },
41
+ ko: {
42
+ title: "afd vaccine — 레지스트리",
43
+ list: "사용 가능한 패키지",
44
+ search: "검색 결과",
45
+ install: "설치",
46
+ publish: "발행",
47
+ installed: "설치된 패키지",
48
+ noPackages: "패키지가 없습니다.",
49
+ noResults: "일치하는 패키지가 없습니다.",
50
+ notFound: "패키지를 찾을 수 없습니다.",
51
+ usage: `사용법:
52
+ afd vaccine list 사용 가능한 패키지 목록
53
+ afd vaccine search <query> 패키지 검색
54
+ afd vaccine install <name> 백신 패키지 설치
55
+ afd vaccine publish <file> vaccine.json에서 발행
56
+ afd vaccine installed 설치된 패키지 목록`,
57
+ },
58
+ };
59
+
60
+ const BOX = { tl: "┌", tr: "┐", bl: "└", br: "┘", h: "─", v: "│", ml: "├", mr: "┤" };
61
+ const W = 54;
62
+ function hline(l: string, r: string) { return `${l}${BOX.h.repeat(W)}${r}`; }
63
+ function row(s: string) {
64
+ const pad = Math.max(0, W - 2 - s.length);
65
+ return `${BOX.v} ${s}${" ".repeat(pad)} ${BOX.v}`;
66
+ }
67
+
68
+ export async function vaccineCommand(subcommand?: string, arg?: string) {
69
+ const lang = getSystemLanguage();
70
+ const m = msgs[lang];
71
+
72
+ if (!subcommand) {
73
+ console.log(m.usage);
74
+ return;
75
+ }
76
+
77
+ switch (subcommand) {
78
+ case "list": {
79
+ const packages = searchPackages();
80
+ console.log(hline(BOX.tl, BOX.tr));
81
+ console.log(row(`💉 ${m.title} — ${m.list}`));
82
+ console.log(hline(BOX.ml, BOX.mr));
83
+ if (packages.length === 0) {
84
+ console.log(row(m.noPackages));
85
+ } else {
86
+ for (const p of packages) {
87
+ console.log(row(`📦 ${p.name}@${p.version} (${p.antibodyCount} rules)`));
88
+ console.log(row(` ${p.description}`));
89
+ console.log(row(` ${p.ecosystem} | by ${p.author}`));
90
+ console.log(row(""));
91
+ }
92
+ }
93
+ console.log(hline(BOX.bl, BOX.br));
94
+ break;
95
+ }
96
+
97
+ case "search": {
98
+ const results = searchPackages(arg);
99
+ console.log(hline(BOX.tl, BOX.tr));
100
+ console.log(row(`🔍 ${m.title} — ${m.search}: "${arg ?? ""}"`));
101
+ console.log(hline(BOX.ml, BOX.mr));
102
+ if (results.length === 0) {
103
+ console.log(row(m.noResults));
104
+ } else {
105
+ for (const p of results) {
106
+ console.log(row(`📦 ${p.name}@${p.version} — ${p.description}`));
107
+ }
108
+ }
109
+ console.log(hline(BOX.bl, BOX.br));
110
+ break;
111
+ }
112
+
113
+ case "install": {
114
+ if (!arg) {
115
+ console.error("Usage: afd vaccine install <name>");
116
+ process.exit(1);
117
+ }
118
+ const result = installPackage(arg);
119
+ if (!result.success) {
120
+ console.error(`[afd vaccine] ${result.message}`);
121
+ process.exit(1);
122
+ }
123
+ console.log(hline(BOX.tl, BOX.tr));
124
+ console.log(row(`✅ ${m.install}: ${arg}`));
125
+ console.log(hline(BOX.ml, BOX.mr));
126
+ console.log(row(result.message));
127
+ console.log(hline(BOX.bl, BOX.br));
128
+ break;
129
+ }
130
+
131
+ case "publish": {
132
+ const filePath = arg ?? "vaccine.json";
133
+ if (!existsSync(filePath)) {
134
+ console.error(`[afd vaccine] File not found: ${filePath}`);
135
+ process.exit(1);
136
+ }
137
+ let pkg: VaccinePackage;
138
+ try {
139
+ pkg = JSON.parse(readFileSync(filePath, "utf-8"));
140
+ } catch {
141
+ console.error("[afd vaccine] Invalid JSON in vaccine file.");
142
+ process.exit(1);
143
+ }
144
+ const result = publishPackage(pkg);
145
+ console.log(hline(BOX.tl, BOX.tr));
146
+ console.log(row(`📤 ${m.publish}`));
147
+ console.log(hline(BOX.ml, BOX.mr));
148
+ console.log(row(result.message));
149
+ console.log(hline(BOX.bl, BOX.br));
150
+ break;
151
+ }
152
+
153
+ case "installed": {
154
+ const pkgs = listInstalled();
155
+ console.log(hline(BOX.tl, BOX.tr));
156
+ console.log(row(`📋 ${m.title} — ${m.installed}`));
157
+ console.log(hline(BOX.ml, BOX.mr));
158
+ if (pkgs.length === 0) {
159
+ console.log(row(m.noPackages));
160
+ } else {
161
+ for (const name of pkgs) {
162
+ const pkg = getPackage(name);
163
+ if (pkg) {
164
+ console.log(row(`📦 ${pkg.name}@${pkg.version} (${pkg.antibodies.length} rules)`));
165
+ } else {
166
+ console.log(row(`📦 ${name}`));
167
+ }
168
+ }
169
+ }
170
+ console.log(hline(BOX.bl, BOX.br));
171
+ break;
172
+ }
173
+
174
+ default:
175
+ console.log(m.usage);
176
+ }
177
+ }
package/src/constants.ts CHANGED
@@ -1,8 +1,32 @@
1
- import { join } from "path";
2
-
3
- export const AFD_DIR = ".afd";
4
- export const PID_FILE = join(AFD_DIR, "daemon.pid");
5
- export const PORT_FILE = join(AFD_DIR, "daemon.port");
6
- export const DB_FILE = join(AFD_DIR, "antibodies.sqlite");
7
- export const LOG_FILE = join(AFD_DIR, "daemon.log");
8
- export const WATCH_TARGETS = [".claude/", "CLAUDE.md", ".cursorrules", ".claudeignore", ".gitignore"];
1
+ import { join } from "path";
2
+ import { findWorkspaceRoot } from "./core/workspace";
3
+
4
+ // Relative paths (used when cwd is already the workspace root)
5
+ export const AFD_DIR = ".afd";
6
+ export const PID_FILE = join(AFD_DIR, "daemon.pid");
7
+ export const PORT_FILE = join(AFD_DIR, "daemon.port");
8
+ export const DB_FILE = join(AFD_DIR, "antibodies.sqlite");
9
+ export const LOG_FILE = join(AFD_DIR, "daemon.log");
10
+ export const QUARANTINE_DIR = join(AFD_DIR, "quarantine");
11
+ export const WATCH_TARGETS = [
12
+ ".claude/", "CLAUDE.md", ".cursorrules", ".claudeignore", ".gitignore",
13
+ ".windsurfrules", ".windsurf/", "codex.md", ".codex/",
14
+ ".cursorignore", ".windsurfignore", ".codexignore",
15
+ ];
16
+
17
+ /**
18
+ * Resolve all `.afd/` paths against the workspace root.
19
+ * Works correctly even when CLI is invoked from a subdirectory.
20
+ */
21
+ export function resolveWorkspacePaths(from?: string) {
22
+ const root = findWorkspaceRoot(from);
23
+ return {
24
+ root,
25
+ afdDir: join(root, AFD_DIR),
26
+ pidFile: join(root, PID_FILE),
27
+ portFile: join(root, PORT_FILE),
28
+ dbFile: join(root, DB_FILE),
29
+ logFile: join(root, LOG_FILE),
30
+ quarantineDir: join(root, QUARANTINE_DIR),
31
+ };
32
+ }