@shahmarasy/prodo 0.1.4 → 0.1.6
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/README.md +201 -97
- package/bin/prodo.cjs +6 -6
- package/dist/agents/agent-registry.d.ts +13 -0
- package/dist/agents/agent-registry.js +79 -0
- package/dist/agents/anthropic/index.d.ts +9 -0
- package/dist/agents/anthropic/index.js +55 -0
- package/dist/agents/base.d.ts +25 -0
- package/dist/agents/base.js +71 -0
- package/dist/agents/google/index.d.ts +9 -0
- package/dist/agents/google/index.js +53 -0
- package/dist/agents/mock/index.d.ts +11 -0
- package/dist/agents/mock/index.js +26 -0
- package/dist/agents/openai/index.d.ts +9 -0
- package/dist/agents/openai/index.js +57 -0
- package/dist/agents/system-prompts.d.ts +3 -0
- package/dist/agents/system-prompts.js +32 -0
- package/dist/cli/agent-command-installer.d.ts +4 -0
- package/dist/cli/agent-command-installer.js +148 -0
- package/dist/cli/agent-ids.d.ts +15 -0
- package/dist/cli/agent-ids.js +49 -0
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/doctor.js +144 -0
- package/dist/cli/fix-tui.d.ts +4 -0
- package/dist/cli/fix-tui.js +79 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +467 -0
- package/dist/cli/init-tui.d.ts +23 -0
- package/dist/cli/init-tui.js +183 -0
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.js +335 -0
- package/dist/cli/normalize-interactive.d.ts +8 -0
- package/dist/cli/normalize-interactive.js +167 -0
- package/dist/cli/preset-loader.d.ts +4 -0
- package/dist/cli/preset-loader.js +210 -0
- package/dist/core/artifact-registry.d.ts +11 -0
- package/dist/core/artifact-registry.js +49 -0
- package/dist/core/artifacts.d.ts +10 -0
- package/dist/core/artifacts.js +892 -0
- package/dist/core/clean.d.ts +10 -0
- package/dist/core/clean.js +74 -0
- package/dist/core/consistency.d.ts +8 -0
- package/dist/core/consistency.js +328 -0
- package/dist/core/constants.d.ts +7 -0
- package/dist/core/constants.js +64 -0
- package/dist/core/errors.d.ts +3 -0
- package/dist/core/errors.js +10 -0
- package/dist/core/fix.d.ts +31 -0
- package/dist/core/fix.js +188 -0
- package/dist/core/hook-executor.d.ts +1 -0
- package/dist/core/hook-executor.js +175 -0
- package/dist/core/markdown.d.ts +16 -0
- package/dist/core/markdown.js +81 -0
- package/dist/core/normalize.d.ts +8 -0
- package/dist/core/normalize.js +125 -0
- package/dist/core/normalized-brief.d.ts +48 -0
- package/dist/core/normalized-brief.js +182 -0
- package/dist/core/output-index.d.ts +13 -0
- package/dist/core/output-index.js +55 -0
- package/dist/core/paths.d.ts +17 -0
- package/dist/core/paths.js +80 -0
- package/dist/core/project-config.d.ts +14 -0
- package/dist/core/project-config.js +69 -0
- package/dist/core/registry.d.ts +13 -0
- package/dist/core/registry.js +115 -0
- package/dist/core/settings.d.ts +8 -0
- package/dist/core/settings.js +43 -0
- package/dist/core/template-engine.d.ts +3 -0
- package/dist/core/template-engine.js +43 -0
- package/dist/core/template-resolver.d.ts +15 -0
- package/dist/core/template-resolver.js +46 -0
- package/dist/core/templates.d.ts +33 -0
- package/dist/core/templates.js +440 -0
- package/dist/core/terminology.d.ts +21 -0
- package/dist/core/terminology.js +143 -0
- package/dist/core/tracing.d.ts +21 -0
- package/dist/core/tracing.js +74 -0
- package/dist/core/types.d.ts +35 -0
- package/dist/core/types.js +5 -0
- package/dist/core/utils.d.ts +7 -0
- package/dist/core/utils.js +66 -0
- package/dist/core/validate.d.ts +10 -0
- package/dist/core/validate.js +226 -0
- package/dist/core/validator.d.ts +5 -0
- package/dist/core/validator.js +76 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +30 -0
- package/dist/core/workflow-commands.d.ts +7 -0
- package/dist/core/workflow-commands.js +29 -0
- package/dist/i18n/en.json +45 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.js +63 -0
- package/dist/i18n/tr.json +45 -0
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.js +20 -6
- package/dist/providers/mock-provider.d.ts +1 -1
- package/dist/providers/mock-provider.js +12 -11
- package/dist/providers/openai-provider.d.ts +1 -1
- package/dist/providers/openai-provider.js +13 -13
- package/dist/skill-engine/context.d.ts +7 -0
- package/dist/skill-engine/context.js +76 -0
- package/dist/skill-engine/discovery.d.ts +2 -0
- package/dist/skill-engine/discovery.js +52 -0
- package/dist/skill-engine/graph.d.ts +4 -0
- package/dist/skill-engine/graph.js +114 -0
- package/dist/skill-engine/index.d.ts +11 -0
- package/dist/skill-engine/index.js +49 -0
- package/dist/skill-engine/pipeline.d.ts +9 -0
- package/dist/skill-engine/pipeline.js +84 -0
- package/dist/skill-engine/registry.d.ts +12 -0
- package/dist/skill-engine/registry.js +74 -0
- package/dist/skill-engine/types.d.ts +66 -0
- package/dist/skill-engine/types.js +2 -0
- package/dist/skill-engine/validator.d.ts +4 -0
- package/dist/skill-engine/validator.js +90 -0
- package/dist/skills/engine.d.ts +10 -0
- package/dist/skills/engine.js +75 -0
- package/dist/skills/fix-skill.d.ts +2 -0
- package/dist/skills/fix-skill.js +38 -0
- package/dist/skills/fix.d.ts +2 -0
- package/dist/skills/fix.js +41 -0
- package/dist/skills/generate-artifact-skill.d.ts +2 -0
- package/dist/skills/generate-artifact-skill.js +32 -0
- package/dist/skills/generate-artifact.d.ts +2 -0
- package/dist/skills/generate-artifact.js +42 -0
- package/dist/skills/generate-pipeline-skill.d.ts +2 -0
- package/dist/skills/generate-pipeline-skill.js +45 -0
- package/dist/skills/normalize-skill.d.ts +2 -0
- package/dist/skills/normalize-skill.js +29 -0
- package/dist/skills/normalize.d.ts +2 -0
- package/dist/skills/normalize.js +29 -0
- package/dist/skills/register-core.d.ts +2 -0
- package/dist/skills/register-core.js +21 -0
- package/dist/skills/types.d.ts +28 -0
- package/dist/skills/types.js +2 -0
- package/dist/skills/validate-skill.d.ts +2 -0
- package/dist/skills/validate-skill.js +29 -0
- package/dist/skills/validate.d.ts +2 -0
- package/dist/skills/validate.js +37 -0
- package/package.json +72 -45
- package/src/agents/agent-registry.ts +93 -0
- package/src/agents/anthropic/index.ts +86 -0
- package/src/agents/anthropic/manifest.json +7 -0
- package/src/agents/base.ts +77 -0
- package/src/agents/google/index.ts +79 -0
- package/src/agents/google/manifest.json +7 -0
- package/src/agents/mock/index.ts +32 -0
- package/src/agents/mock/manifest.json +7 -0
- package/src/agents/openai/index.ts +83 -0
- package/src/agents/openai/manifest.json +7 -0
- package/src/agents/system-prompts.ts +35 -0
- package/src/{agent-command-installer.ts → cli/agent-command-installer.ts} +164 -164
- package/src/{agents.ts → cli/agent-ids.ts} +58 -58
- package/src/{doctor.ts → cli/doctor.ts} +157 -137
- package/src/cli/fix-tui.ts +111 -0
- package/src/{cli.ts → cli/index.ts} +463 -410
- package/src/{init-tui.ts → cli/init-tui.ts} +49 -37
- package/src/{init.ts → cli/init.ts} +399 -398
- package/src/cli/normalize-interactive.ts +241 -0
- package/src/{preset-loader.ts → cli/preset-loader.ts} +237 -237
- package/src/{artifact-registry.ts → core/artifact-registry.ts} +69 -69
- package/src/{artifacts.ts → core/artifacts.ts} +1081 -1072
- package/src/core/clean.ts +88 -0
- package/src/{consistency.ts → core/consistency.ts} +374 -303
- package/src/{constants.ts → core/constants.ts} +72 -72
- package/src/{errors.ts → core/errors.ts} +7 -7
- package/src/core/fix.ts +253 -0
- package/src/{hook-executor.ts → core/hook-executor.ts} +196 -196
- package/src/{markdown.ts → core/markdown.ts} +93 -73
- package/src/{normalize.ts → core/normalize.ts} +145 -137
- package/src/{normalized-brief.ts → core/normalized-brief.ts} +227 -206
- package/src/{output-index.ts → core/output-index.ts} +59 -59
- package/src/{paths.ts → core/paths.ts} +75 -71
- package/src/{project-config.ts → core/project-config.ts} +78 -78
- package/src/{registry.ts → core/registry.ts} +119 -119
- package/src/{settings.ts → core/settings.ts} +8 -2
- package/src/core/template-engine.ts +45 -0
- package/src/{template-resolver.ts → core/template-resolver.ts} +54 -54
- package/src/{templates.ts → core/templates.ts} +452 -452
- package/src/core/terminology.ts +177 -0
- package/src/core/tracing.ts +110 -0
- package/src/{types.ts → core/types.ts} +46 -46
- package/src/{utils.ts → core/utils.ts} +64 -64
- package/src/{validate.ts → core/validate.ts} +252 -246
- package/src/{validator.ts → core/validator.ts} +92 -92
- package/src/{version.ts → core/version.ts} +24 -24
- package/src/{workflow-commands.ts → core/workflow-commands.ts} +32 -32
- package/src/i18n/en.json +45 -0
- package/src/i18n/index.ts +58 -0
- package/src/i18n/tr.json +45 -0
- package/src/providers/index.ts +29 -12
- package/src/providers/mock-provider.ts +200 -199
- package/src/providers/openai-provider.ts +88 -88
- package/src/skill-engine/context.ts +90 -0
- package/src/skill-engine/discovery.ts +57 -0
- package/src/skill-engine/graph.ts +136 -0
- package/src/skill-engine/index.ts +55 -0
- package/src/skill-engine/pipeline.ts +112 -0
- package/src/skill-engine/registry.ts +75 -0
- package/src/skill-engine/types.ts +81 -0
- package/src/skill-engine/validator.ts +135 -0
- package/src/skills/fix.ts +45 -0
- package/src/skills/generate-artifact.ts +48 -0
- package/src/skills/normalize.ts +32 -0
- package/src/skills/register-core.ts +27 -0
- package/src/skills/validate.ts +40 -0
|
@@ -1,137 +1,145 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { UserError } from "./errors";
|
|
4
|
-
import {
|
|
5
|
-
buildContractsFromArrays,
|
|
6
|
-
parseNormalizedBriefOrThrow,
|
|
7
|
-
requireConfidenceOrThrow
|
|
8
|
-
} from "./normalized-brief";
|
|
9
|
-
import { briefPath, normalizedBriefPath, prodoPath } from "./paths";
|
|
10
|
-
import { createProvider } from "
|
|
11
|
-
import { readSettings } from "./settings";
|
|
12
|
-
import { fileExists, isPathInside } from "./utils";
|
|
13
|
-
|
|
14
|
-
type NormalizeOptions = {
|
|
15
|
-
cwd: string;
|
|
16
|
-
brief?: string;
|
|
17
|
-
out?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
.replace(
|
|
25
|
-
.replace(
|
|
26
|
-
.
|
|
27
|
-
.
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
headingKey === "
|
|
40
|
-
headingKey === "
|
|
41
|
-
headingKey === "urun
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { UserError } from "./errors";
|
|
4
|
+
import {
|
|
5
|
+
buildContractsFromArrays,
|
|
6
|
+
parseNormalizedBriefOrThrow,
|
|
7
|
+
requireConfidenceOrThrow
|
|
8
|
+
} from "./normalized-brief";
|
|
9
|
+
import { briefPath, normalizedBriefPath, prodoPath } from "./paths";
|
|
10
|
+
import { createProvider } from "../providers";
|
|
11
|
+
import { readSettings } from "./settings";
|
|
12
|
+
import { fileExists, isPathInside } from "./utils";
|
|
13
|
+
|
|
14
|
+
type NormalizeOptions = {
|
|
15
|
+
cwd: string;
|
|
16
|
+
brief?: string;
|
|
17
|
+
out?: string;
|
|
18
|
+
additionalContext?: Record<string, string>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function normalizedKey(value: string): string {
|
|
22
|
+
return value
|
|
23
|
+
.normalize("NFD")
|
|
24
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
25
|
+
.replace(/ı/g, "i")
|
|
26
|
+
.replace(/İ/g, "I")
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.replace(/[^a-z0-9]+/g, " ")
|
|
29
|
+
.trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function extractBriefProductName(rawBrief: string): string | undefined {
|
|
33
|
+
const lines = rawBrief.split(/\r?\n/);
|
|
34
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
35
|
+
const headingMatch = lines[index].match(/^\s*#{1,6}\s+(.+?)\s*$/);
|
|
36
|
+
if (!headingMatch) continue;
|
|
37
|
+
const headingKey = normalizedKey(headingMatch[1]);
|
|
38
|
+
const isProductHeading =
|
|
39
|
+
headingKey === "product name" ||
|
|
40
|
+
headingKey === "project name" ||
|
|
41
|
+
headingKey === "urun adi" ||
|
|
42
|
+
headingKey === "urun ismi";
|
|
43
|
+
if (!isProductHeading) continue;
|
|
44
|
+
|
|
45
|
+
for (let cursor = index + 1; cursor < lines.length; cursor += 1) {
|
|
46
|
+
const rawLine = lines[cursor].trim();
|
|
47
|
+
if (!rawLine) continue;
|
|
48
|
+
if (/^\s*#{1,6}\s+/.test(rawLine)) break;
|
|
49
|
+
const cleaned = rawLine.replace(/^\s*[-*]\s*/, "").trim();
|
|
50
|
+
if (cleaned.length > 0) return cleaned;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function preserveOriginalProductName(
|
|
57
|
+
parsed: Record<string, unknown>,
|
|
58
|
+
rawBrief: string
|
|
59
|
+
): Record<string, unknown> {
|
|
60
|
+
const briefProductName = extractBriefProductName(rawBrief);
|
|
61
|
+
if (!briefProductName) return parsed;
|
|
62
|
+
const generated = typeof parsed.product_name === "string" ? parsed.product_name : "";
|
|
63
|
+
if (!generated.trim()) return { ...parsed, product_name: briefProductName };
|
|
64
|
+
if (normalizedKey(generated) !== normalizedKey(briefProductName)) return parsed;
|
|
65
|
+
return { ...parsed, product_name: briefProductName };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function extractJsonObject(raw: string): Record<string, unknown> {
|
|
69
|
+
const trimmed = raw.trim();
|
|
70
|
+
const fenced = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
71
|
+
const candidate = fenced ? fenced[1] : trimmed;
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(candidate) as Record<string, unknown>;
|
|
74
|
+
} catch {
|
|
75
|
+
throw new UserError("Normalizer provider did not return valid JSON.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function runNormalize(options: NormalizeOptions): Promise<string> {
|
|
80
|
+
const { cwd } = options;
|
|
81
|
+
const root = prodoPath(cwd);
|
|
82
|
+
if (!(await fileExists(root))) {
|
|
83
|
+
throw new UserError("Missing .prodo directory. Run `prodo init .` first.");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const inPath = options.brief ? path.resolve(cwd, options.brief) : briefPath(cwd);
|
|
87
|
+
if (!(await fileExists(inPath))) {
|
|
88
|
+
throw new UserError(`Brief file not found: ${inPath}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const rawBrief = await fs.readFile(inPath, "utf8");
|
|
92
|
+
const normalizePromptPath = path.join(root, "prompts", "normalize.md");
|
|
93
|
+
const normalizePrompt = await fs.readFile(normalizePromptPath, "utf8");
|
|
94
|
+
const settings = await readSettings(cwd);
|
|
95
|
+
const provider = createProvider();
|
|
96
|
+
|
|
97
|
+
const inputContext: Record<string, unknown> = {
|
|
98
|
+
briefMarkdown: rawBrief,
|
|
99
|
+
sourceBriefPath: inPath,
|
|
100
|
+
outputLanguage: settings.lang
|
|
101
|
+
};
|
|
102
|
+
if (options.additionalContext && Object.keys(options.additionalContext).length > 0) {
|
|
103
|
+
inputContext.userClarifications = options.additionalContext;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const generated = await provider.generate(
|
|
107
|
+
normalizePrompt,
|
|
108
|
+
inputContext,
|
|
109
|
+
{
|
|
110
|
+
artifactType: "normalize",
|
|
111
|
+
requiredHeadings: [],
|
|
112
|
+
requiredContracts: []
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const parsed = extractJsonObject(generated.body);
|
|
117
|
+
const preserved = preserveOriginalProductName(parsed, rawBrief);
|
|
118
|
+
const withContracts = {
|
|
119
|
+
...preserved,
|
|
120
|
+
contracts:
|
|
121
|
+
preserved.contracts ??
|
|
122
|
+
buildContractsFromArrays({
|
|
123
|
+
goals: Array.isArray(preserved.goals) ? preserved.goals.filter((x): x is string => typeof x === "string") : [],
|
|
124
|
+
core_features: Array.isArray(preserved.core_features)
|
|
125
|
+
? preserved.core_features.filter((x): x is string => typeof x === "string")
|
|
126
|
+
: [],
|
|
127
|
+
constraints: Array.isArray(preserved.constraints)
|
|
128
|
+
? preserved.constraints.filter((x): x is string => typeof x === "string")
|
|
129
|
+
: []
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const normalized = parseNormalizedBriefOrThrow(withContracts);
|
|
134
|
+
|
|
135
|
+
const outPath = options.out ? path.resolve(cwd, options.out) : normalizedBriefPath(cwd);
|
|
136
|
+
if (!isPathInside(prodoPath(cwd), outPath)) {
|
|
137
|
+
throw new UserError("Normalize output must be inside `.prodo/`.");
|
|
138
|
+
}
|
|
139
|
+
await fs.mkdir(path.dirname(outPath), { recursive: true });
|
|
140
|
+
await fs.writeFile(outPath, `${JSON.stringify(normalized, null, 2)}\n`, "utf8");
|
|
141
|
+
|
|
142
|
+
requireConfidenceOrThrow(normalized, ["product_name", "problem", "audience", "goals", "core_features"], 0.7);
|
|
143
|
+
|
|
144
|
+
return outPath;
|
|
145
|
+
}
|