meto-cli 0.10.0 → 0.11.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.
Files changed (39) hide show
  1. package/README.md +66 -0
  2. package/dist/cli/audit/blueprint.d.ts +53 -0
  3. package/dist/cli/audit/blueprint.d.ts.map +1 -0
  4. package/dist/cli/audit/blueprint.js +386 -0
  5. package/dist/cli/audit/blueprint.js.map +1 -0
  6. package/dist/cli/audit/detect-stack.d.ts +31 -0
  7. package/dist/cli/audit/detect-stack.d.ts.map +1 -0
  8. package/dist/cli/audit/detect-stack.js +154 -0
  9. package/dist/cli/audit/detect-stack.js.map +1 -0
  10. package/dist/cli/audit/fixer.d.ts +75 -0
  11. package/dist/cli/audit/fixer.d.ts.map +1 -0
  12. package/dist/cli/audit/fixer.js +802 -0
  13. package/dist/cli/audit/fixer.js.map +1 -0
  14. package/dist/cli/audit/index.d.ts +24 -0
  15. package/dist/cli/audit/index.d.ts.map +1 -0
  16. package/dist/cli/audit/index.js +216 -0
  17. package/dist/cli/audit/index.js.map +1 -0
  18. package/dist/cli/audit/reporter.d.ts +42 -0
  19. package/dist/cli/audit/reporter.d.ts.map +1 -0
  20. package/dist/cli/audit/reporter.js +101 -0
  21. package/dist/cli/audit/reporter.js.map +1 -0
  22. package/dist/cli/audit/scanner.d.ts +48 -0
  23. package/dist/cli/audit/scanner.d.ts.map +1 -0
  24. package/dist/cli/audit/scanner.js +202 -0
  25. package/dist/cli/audit/scanner.js.map +1 -0
  26. package/dist/cli/index.js +6 -0
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/cli/renderer.d.ts.map +1 -1
  29. package/dist/cli/renderer.js +3 -1
  30. package/dist/cli/renderer.js.map +1 -1
  31. package/dist/cli/stacks.d.ts +11 -0
  32. package/dist/cli/stacks.d.ts.map +1 -1
  33. package/dist/cli/stacks.js +82 -0
  34. package/dist/cli/stacks.js.map +1 -1
  35. package/package.json +1 -1
  36. package/templates/.claude/agents/developer-agent.md +4 -1
  37. package/templates/.claude/agents/tester-agent.md +4 -1
  38. package/templates/CLAUDE.md +3 -0
  39. package/templates/ai/workflows/code-guidelines.md +46 -0
@@ -0,0 +1,154 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Checks whether a file exists at the given path.
5
+ */
6
+ async function fileExists(filePath) {
7
+ try {
8
+ const stats = await stat(filePath);
9
+ return stats.isFile();
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ /**
16
+ * Reads and parses a package.json file. Returns null if the file
17
+ * does not exist or cannot be parsed.
18
+ */
19
+ async function readPackageJson(projectDir) {
20
+ const pkgPath = join(projectDir, "package.json");
21
+ try {
22
+ const content = await readFile(pkgPath, "utf-8");
23
+ return JSON.parse(content);
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ /**
30
+ * Checks whether a dependency exists in package.json dependencies
31
+ * or devDependencies.
32
+ */
33
+ function hasDependency(pkg, depName) {
34
+ const deps = pkg["dependencies"];
35
+ const devDeps = pkg["devDependencies"];
36
+ if (deps !== null && deps !== undefined && typeof deps === "object") {
37
+ if (depName in deps) {
38
+ return true;
39
+ }
40
+ }
41
+ if (devDeps !== null && devDeps !== undefined && typeof devDeps === "object") {
42
+ if (depName in devDeps) {
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ /**
49
+ * Determines the most specific Node.js stack from package.json contents.
50
+ * Checks for framework-specific dependencies to distinguish between
51
+ * Next.js, React Native, Vite+React, and generic Node.js CLI.
52
+ */
53
+ function detectNodeStack(pkg) {
54
+ // Next.js detection (maps to nextjs-supabase preset)
55
+ if (hasDependency(pkg, "next")) {
56
+ return {
57
+ stack: "nextjs-supabase",
58
+ detectedVia: "package.json",
59
+ label: "Next.js",
60
+ };
61
+ }
62
+ // React Native detection
63
+ if (hasDependency(pkg, "react-native")) {
64
+ return {
65
+ stack: "react-native",
66
+ detectedVia: "package.json",
67
+ label: "React Native",
68
+ };
69
+ }
70
+ // Vite + React detection (check vite first, then confirm React)
71
+ if (hasDependency(pkg, "vite") && hasDependency(pkg, "react")) {
72
+ return {
73
+ stack: "vite-react",
74
+ detectedVia: "package.json",
75
+ label: "Vite + React",
76
+ };
77
+ }
78
+ // Generic Node.js CLI fallback for package.json projects
79
+ return {
80
+ stack: "nodejs-cli",
81
+ detectedVia: "package.json",
82
+ label: "Node.js",
83
+ };
84
+ }
85
+ /**
86
+ * Auto-detects the tech stack of a project by examining manifest files
87
+ * in the project root directory.
88
+ *
89
+ * Detection order:
90
+ * 1. package.json — inspects dependencies for Next.js, React Native,
91
+ * Vite+React, or falls back to Node.js CLI
92
+ * 2. go.mod — Go
93
+ * 3. pyproject.toml or requirements.txt — Python (FastAPI preset)
94
+ * 4. pubspec.yaml — Flutter
95
+ * 5. Cargo.toml — Rust (returns "custom" since no Rust preset exists)
96
+ *
97
+ * Root-level manifests only. Does not recurse into subdirectories.
98
+ *
99
+ * @param projectDir - Absolute path to the project root directory
100
+ * @returns The detected stack result, or a "custom" fallback if no manifest is found
101
+ */
102
+ export async function detectStack(projectDir) {
103
+ // 1. Check package.json first (most common, and allows sub-detection)
104
+ const pkg = await readPackageJson(projectDir);
105
+ if (pkg !== null) {
106
+ return detectNodeStack(pkg);
107
+ }
108
+ // 2. Check go.mod
109
+ if (await fileExists(join(projectDir, "go.mod"))) {
110
+ return {
111
+ stack: "go",
112
+ detectedVia: "go.mod",
113
+ label: "Go",
114
+ };
115
+ }
116
+ // 3. Check Python manifests
117
+ if (await fileExists(join(projectDir, "pyproject.toml"))) {
118
+ return {
119
+ stack: "python-fastapi",
120
+ detectedVia: "pyproject.toml",
121
+ label: "Python",
122
+ };
123
+ }
124
+ if (await fileExists(join(projectDir, "requirements.txt"))) {
125
+ return {
126
+ stack: "python-fastapi",
127
+ detectedVia: "requirements.txt",
128
+ label: "Python",
129
+ };
130
+ }
131
+ // 4. Check Flutter
132
+ if (await fileExists(join(projectDir, "pubspec.yaml"))) {
133
+ return {
134
+ stack: "flutter",
135
+ detectedVia: "pubspec.yaml",
136
+ label: "Flutter",
137
+ };
138
+ }
139
+ // 5. Check Rust (no preset — returns "custom")
140
+ if (await fileExists(join(projectDir, "Cargo.toml"))) {
141
+ return {
142
+ stack: "custom",
143
+ detectedVia: "Cargo.toml",
144
+ label: "Rust",
145
+ };
146
+ }
147
+ // No manifest detected
148
+ return {
149
+ stack: "custom",
150
+ detectedVia: "none",
151
+ label: "Unknown",
152
+ };
153
+ }
154
+ //# sourceMappingURL=detect-stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-stack.js","sourceRoot":"","sources":["../../../src/cli/audit/detect-stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAejC;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,eAAe,CAC5B,UAAkB;IAElB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CACpB,GAA4B,EAC5B,OAAe;IAEf,MAAM,IAAI,GAAG,GAAG,CAAC,cAAc,CAA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AAY;YACzB,KAAK,EAAE,MAAM;SACd,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,MAAM;QACnB,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { TokenMap } from "../renderer.js";
2
+ import type { ScanResult, LayerScanResult } from "./scanner.js";
3
+ /** Outcome of a single fix attempt. */
4
+ export type FixOutcome = "created" | "declined" | "skipped" | "error";
5
+ /**
6
+ * Result of attempting to fix a single failed expectation.
7
+ */
8
+ export interface FixResult {
9
+ /** The scan result that triggered this fix */
10
+ scanResult: ScanResult;
11
+ /** What happened during the fix attempt */
12
+ outcome: FixOutcome;
13
+ /** Human-readable message about the fix */
14
+ message: string;
15
+ }
16
+ /**
17
+ * Result of running the fixer on an entire layer.
18
+ */
19
+ export interface LayerFixResult {
20
+ /** Layer ID that was fixed */
21
+ layerId: number;
22
+ /** Individual fix results */
23
+ fixes: FixResult[];
24
+ }
25
+ /**
26
+ * Runs the interactive fixer for all failed expectations in a layer scan result.
27
+ * Prompts the user for each missing file/directory and creates it from templates.
28
+ *
29
+ * This function is layer-agnostic -- it works with any LayerScanResult.
30
+ * The fixer never overwrites existing files -- only creates missing ones.
31
+ *
32
+ * @param projectDir - Absolute path to the project root
33
+ * @param layerResult - The scan result containing failures to fix
34
+ * @param tokens - Token map for template rendering
35
+ * @returns Fix results for each failed expectation
36
+ */
37
+ export declare function fixLayer(projectDir: string, layerResult: LayerScanResult, tokens: TokenMap): Promise<LayerFixResult>;
38
+ /**
39
+ * Runs the interactive fixer for Layer 2 (Agents).
40
+ *
41
+ * Layer 2 differs from other layers because:
42
+ * - When creating agent files from scratch, the user is asked to choose
43
+ * Sprint vs Swarm workflow mode.
44
+ * - The workflow choice affects the WORKFLOW_AGENTS_SECTION token in CLAUDE.md
45
+ * (CLAUDE.md is Layer 1, but the token content depends on the Layer 2 choice).
46
+ * - Agent memory directories are created with a MEMORY.md file from templates.
47
+ *
48
+ * The fixer never overwrites existing agent definitions or settings.
49
+ *
50
+ * @param projectDir - Absolute path to the project root
51
+ * @param layerResult - The Layer 2 scan result containing failures to fix
52
+ * @param tokens - Token map for template rendering
53
+ * @returns Fix results for each failed expectation
54
+ */
55
+ export declare function fixLayerTwo(projectDir: string, layerResult: LayerScanResult, tokens: TokenMap): Promise<LayerFixResult>;
56
+ /**
57
+ * Runs the interactive fixer for Layer 3 (Governance).
58
+ *
59
+ * Layer 3 differs from other layers because it has three fix strategies:
60
+ * 1. Missing governance files (definition-of-done, session-checkpoint):
61
+ * created from templates, same as Layer 1.
62
+ * 2. CLAUDE.md missing commit conventions section:
63
+ * appends a commit format section to the existing file.
64
+ * 3. Agent definitions missing governance references:
65
+ * appends reference sections to existing agent files.
66
+ *
67
+ * All fixes are additive -- existing content is never modified or removed.
68
+ *
69
+ * @param projectDir - Absolute path to the project root
70
+ * @param layerResult - The Layer 3 scan result containing failures to fix
71
+ * @param tokens - Token map for template rendering
72
+ * @returns Fix results for each failed expectation
73
+ */
74
+ export declare function fixLayerThree(projectDir: string, layerResult: LayerScanResult, tokens: TokenMap): Promise<LayerFixResult>;
75
+ //# sourceMappingURL=fixer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixer.d.ts","sourceRoot":"","sources":["../../../src/cli/audit/fixer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMhE,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,UAAU,EAAE,UAAU,CAAC;IACvB,2CAA2C;IAC3C,OAAO,EAAE,UAAU,CAAC;IACpB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AA8LD;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,cAAc,CAAC,CAwCzB;AAiED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,cAAc,CAAC,CA0LzB;AA6GD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,cAAc,CAAC,CA6PzB"}