gherkin-ai 1.3.2 β 1.4.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.
- package/README.md +13 -20
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +21 -5
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/create.d.ts +6 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +130 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/lang.d.ts +4 -0
- package/dist/commands/lang.d.ts.map +1 -0
- package/dist/commands/lang.js +38 -0
- package/dist/commands/lang.js.map +1 -0
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/i18n-cli.d.ts +53 -0
- package/dist/utils/i18n-cli.d.ts.map +1 -0
- package/dist/utils/i18n-cli.js +124 -0
- package/dist/utils/i18n-cli.js.map +1 -0
- package/docs/ARCHITECTURE.md +35 -16
- package/docs/USAGE_GUIDE.md +96 -69
- package/package.json +3 -11
package/README.md
CHANGED
|
@@ -16,29 +16,33 @@ While simple AI prompt generators produce generic text instructions, AI agents o
|
|
|
16
16
|
- **`contracts.ts`**: Strict domain interfaces, event schemas, Zod DTOs, CQRS Event Store ports, and Architecture Decision Records (ADRs).
|
|
17
17
|
- **`openapi.json`**: Auto-generated OpenAPI 3.0 specification derived directly from Gherkin AST schemas.
|
|
18
18
|
- **`fixtures.ts` & `seed.sql`**: Concrete database seeds (hashed passwords, bcrypt cost factor 12, pre-conditions) raising AI acceptance test success rates from ~30% to ~85%.
|
|
19
|
-
- **
|
|
19
|
+
- **Interactive Spec Wizard (`ghk create`)**: Create Gherkin specifications step-by-step directly from your terminal.
|
|
20
|
+
- **Brownfield Integration (`ghk detect` & `ghk add`)**: Inject contracts directly into existing project module folders (Laravel, Rails, .NET, Angular, NestJS, etc.).
|
|
20
21
|
- **Bilingual Gherkin Parsing**: Native support for English (`Given/When/Then`) and Spanish (`Dado/Cuando/Entonces`).
|
|
21
|
-
- **Strict Stack Versions**: Enforces explicit package versions (e.g., NestJS v10 + Prisma + Zod + Redis) so agents never diverge.
|
|
22
|
-
- **Runnable Infrastructure**: Includes pre-configured `docker-compose.yml` (PostgreSQL, Redis, RabbitMQ) and native AWS Lambda `serverless.yml` for FaaS architectures.
|
|
23
|
-
- **`ghk validate`**: Deep Architectural Linter checking layer boundary import isolation, step coverage, and circular dependency rules.
|
|
24
22
|
|
|
25
23
|
---
|
|
26
24
|
|
|
27
|
-
## π
|
|
25
|
+
## π Quick Start Commands
|
|
28
26
|
|
|
29
|
-
### 1.
|
|
27
|
+
### 1. Create a Gherkin Spec Interactively (`ghk create`)
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
Don't have a `.feature` file ready? Build one interactively step-by-step in terminal:
|
|
32
30
|
|
|
33
31
|
```bash
|
|
34
|
-
#
|
|
32
|
+
ghk create # (or: ghk new)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Existing Projects (Brownfield Mode)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 1. Auto-detect stack (Laravel, Rails, .NET, NestJS, Angular, Flutter, etc.)
|
|
35
39
|
ghk detect
|
|
36
40
|
|
|
37
41
|
# 2. Inject contract directly into an existing module folder
|
|
38
42
|
ghk add --feature ./specs/payments.feature --target ./src/modules/payments
|
|
39
43
|
```
|
|
40
44
|
|
|
41
|
-
###
|
|
45
|
+
### 3. New Projects (Greenfield Mode)
|
|
42
46
|
|
|
43
47
|
```bash
|
|
44
48
|
# 1. Initialize project configuration interactively
|
|
@@ -53,17 +57,6 @@ ghk validate --feature ./specs/auth.feature
|
|
|
53
57
|
|
|
54
58
|
---
|
|
55
59
|
|
|
56
|
-
## ποΈ Supported Architecture Styles
|
|
57
|
-
|
|
58
|
-
- **Hexagonal Architecture (Ports & Adapters)**
|
|
59
|
-
- **Domain-Driven Design (DDD)**
|
|
60
|
-
- **Clean Architecture**
|
|
61
|
-
- **CQRS + Event Sourcing (Real Event Store & Aggregate Versions)**
|
|
62
|
-
- **Serverless / FaaS (Native AWS Lambda & `serverless.yml`)**
|
|
63
|
-
- **Microservices Architecture**
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
60
|
## π Complete Documentation
|
|
68
61
|
|
|
69
62
|
- [Comprehensive Usage Guide](docs/USAGE_GUIDE.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAeA,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwErH"}
|
package/dist/commands/add.js
CHANGED
|
@@ -8,24 +8,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.handleAddCommand = handleAddCommand;
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
12
|
const config_1 = require("../core/config");
|
|
12
13
|
const stack_detector_1 = require("../core/stack-detector");
|
|
13
14
|
const gherkin_parser_1 = require("../core/gherkin-parser");
|
|
14
15
|
const contracts_1 = require("../generators/contracts");
|
|
15
16
|
const prompts_1 = require("../generators/prompts");
|
|
17
|
+
const create_1 = require("./create");
|
|
16
18
|
const file_system_1 = require("../utils/file-system");
|
|
17
19
|
const logger_1 = require("../utils/logger");
|
|
18
20
|
async function handleAddCommand(options) {
|
|
19
21
|
logger_1.logger.banner();
|
|
20
22
|
if (!options.feature) {
|
|
21
|
-
logger_1.logger.
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
logger_1.logger.info('No --feature file specified. Launching interactive spec wizard...');
|
|
24
|
+
await (0, create_1.handleCreateCommand)({ target: options.target });
|
|
25
|
+
return;
|
|
24
26
|
}
|
|
25
27
|
const featurePath = path_1.default.resolve(process.cwd(), options.feature);
|
|
26
28
|
if (!(0, file_system_1.fileExistsSync)(featurePath)) {
|
|
27
|
-
logger_1.logger.
|
|
28
|
-
|
|
29
|
+
logger_1.logger.warn(`Feature file not found at: ${featurePath}`);
|
|
30
|
+
const answer = await inquirer_1.default.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: 'confirm',
|
|
33
|
+
name: 'createNow',
|
|
34
|
+
message: 'ΒΏDeseas crear la especificaciΓ³n Gherkin paso a paso ahora (wizard interactivo)?',
|
|
35
|
+
default: true
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
if (answer.createNow) {
|
|
39
|
+
await (0, create_1.handleCreateCommand)({ output: options.feature, target: options.target });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
29
45
|
}
|
|
30
46
|
// Load config or auto-detect if config doesn't exist
|
|
31
47
|
let config = (0, config_1.loadConfig)(options.config);
|
package/dist/commands/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;;;;
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;;;;AAahF,4CAwEC;AAnFD,gDAAwB;AACxB,wDAAgC;AAChC,2CAA4C;AAC5C,2DAA6D;AAC7D,2DAA0D;AAC1D,uDAA4D;AAC5D,mDAAwD;AACxD,qCAA+C;AAC/C,sDAAkG;AAClG,4CAAyC;AAElC,KAAK,UAAU,gBAAgB,CAAC,OAA+D;IACpG,eAAM,CAAC,MAAM,EAAE,CAAC;IAE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KAAK,CAAC,CAAC;IACtE,eAAM,CAAC,OAAO,CAAC,0BAA0B,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAEnF,iDAAiD;IACjD,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACnD,IAAA,2BAAa,EAAC,UAAU,CAAC,CAAC;IAE1B,MAAM,OAAO,GAAG,IAAA,yBAAe,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACtC,IAAA,2BAAa,EAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,eAAM,CAAC,OAAO,CAAC,0CAA0C,UAAU,EAAE,CAAC,CAAC;IAEvE,eAAM,CAAC,MAAM,EAAE,CAAC;IAChB,eAAM,CAAC,OAAO,CAAC,4DAA4D,SAAS,GAAG,CAAC,CAAC;IACzF,eAAM,CAAC,IAAI,CAAC,wCAAwC,gBAAgB,+BAA+B,CAAC,CAAC;AACvG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAWA,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiIrH"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ==========================================================================
|
|
3
|
+
gherkin-ai-cli - 'create' Command Handler (Localized Interactive Spec Wizard)
|
|
4
|
+
========================================================================== */
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleCreateCommand = handleCreateCommand;
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
|
+
const add_1 = require("./add");
|
|
13
|
+
const i18n_cli_1 = require("../utils/i18n-cli");
|
|
14
|
+
const file_system_1 = require("../utils/file-system");
|
|
15
|
+
const logger_1 = require("../utils/logger");
|
|
16
|
+
async function handleCreateCommand(options) {
|
|
17
|
+
logger_1.logger.banner();
|
|
18
|
+
const locale = await (0, i18n_cli_1.ensureCliLanguage)(options.lang);
|
|
19
|
+
const isEs = locale === 'es';
|
|
20
|
+
logger_1.logger.info(isEs ? 'Asistente Interactivo Gherkin - CreaciΓ³n paso a paso' : 'Interactive Gherkin Spec Wizard - Step-by-step feature creator');
|
|
21
|
+
const answers = await inquirer_1.default.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: 'input',
|
|
24
|
+
name: 'featureName',
|
|
25
|
+
message: (0, i18n_cli_1.t)('featureNamePrompt', locale),
|
|
26
|
+
default: isEs ? 'AutenticaciΓ³n de Doble Factor 2FA' : 'Two Factor Authentication 2FA',
|
|
27
|
+
validate: (input) => input.trim().length > 0 || 'Name cannot be empty.'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'input',
|
|
31
|
+
name: 'actor',
|
|
32
|
+
message: (0, i18n_cli_1.t)('actorPrompt', locale),
|
|
33
|
+
default: isEs ? 'usuario autenticado del sistema' : 'authenticated system user'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'input',
|
|
37
|
+
name: 'action',
|
|
38
|
+
message: (0, i18n_cli_1.t)('actionPrompt', locale),
|
|
39
|
+
default: isEs ? 'habilitar y verificar un cΓ³digo OTP de dos factores' : 'enable and verify a two-factor OTP code'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'input',
|
|
43
|
+
name: 'outcome',
|
|
44
|
+
message: (0, i18n_cli_1.t)('outcomePrompt', locale),
|
|
45
|
+
default: isEs ? 'proteger mi cuenta contra accesos no autorizados' : 'protect my account against unauthorized access'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'input',
|
|
49
|
+
name: 'scenarioName',
|
|
50
|
+
message: (0, i18n_cli_1.t)('scenarioNamePrompt', locale),
|
|
51
|
+
default: isEs ? 'Habilitar y verificar cΓ³digo 2FA exitosamente' : 'Enable and verify 2FA code successfully'
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
const steps = [];
|
|
55
|
+
console.log(isEs ? '\n--- Asistente de Pasos Gherkin (Dado / Cuando / Entonces) ---' : '\n--- Step-by-step Gherkin Scenario Builder (Given / When / Then) ---');
|
|
56
|
+
let addMore = true;
|
|
57
|
+
let defaultKw = isEs ? 'Dado' : 'Given';
|
|
58
|
+
const choicesEn = ['Given', 'When', 'Then', 'And', 'But'];
|
|
59
|
+
const choicesEs = ['Dado', 'Cuando', 'Entonces', 'Y', 'Pero'];
|
|
60
|
+
while (addMore) {
|
|
61
|
+
const stepAnswers = await inquirer_1.default.prompt([
|
|
62
|
+
{
|
|
63
|
+
type: 'list',
|
|
64
|
+
name: 'keyword',
|
|
65
|
+
message: (0, i18n_cli_1.t)('stepKeywordPrompt', locale),
|
|
66
|
+
choices: isEs ? choicesEs : choicesEn,
|
|
67
|
+
default: defaultKw
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'input',
|
|
71
|
+
name: 'text',
|
|
72
|
+
message: (0, i18n_cli_1.t)('stepDescPrompt', locale),
|
|
73
|
+
validate: (input) => input.trim().length > 0 || 'Description cannot be empty.'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
name: 'next',
|
|
78
|
+
message: (0, i18n_cli_1.t)('addAnotherStepPrompt', locale),
|
|
79
|
+
default: true
|
|
80
|
+
}
|
|
81
|
+
]);
|
|
82
|
+
steps.push({ keyword: stepAnswers.keyword, text: stepAnswers.text });
|
|
83
|
+
if (['Dado', 'Given'].includes(stepAnswers.keyword))
|
|
84
|
+
defaultKw = isEs ? 'Cuando' : 'When';
|
|
85
|
+
else if (['Cuando', 'When'].includes(stepAnswers.keyword))
|
|
86
|
+
defaultKw = isEs ? 'Entonces' : 'Then';
|
|
87
|
+
else
|
|
88
|
+
defaultKw = isEs ? 'Y' : 'And';
|
|
89
|
+
addMore = stepAnswers.next;
|
|
90
|
+
}
|
|
91
|
+
// Construct Gherkin File Content
|
|
92
|
+
const featureKw = isEs ? 'CaracterΓstica:' : 'Feature:';
|
|
93
|
+
const asKw = isEs ? 'Como' : 'As a';
|
|
94
|
+
const wantKw = isEs ? 'Quiero' : 'I want to';
|
|
95
|
+
const soKw = isEs ? 'Para' : 'So that';
|
|
96
|
+
const scKw = isEs ? 'Escenario:' : 'Scenario:';
|
|
97
|
+
let gherkinContent = `${featureKw} ${answers.featureName}\n`;
|
|
98
|
+
gherkinContent += ` ${asKw} ${answers.actor}\n`;
|
|
99
|
+
gherkinContent += ` ${wantKw} ${answers.action}\n`;
|
|
100
|
+
gherkinContent += ` ${soKw} ${answers.outcome}\n\n`;
|
|
101
|
+
gherkinContent += ` ${scKw} ${answers.scenarioName}\n`;
|
|
102
|
+
steps.forEach(st => {
|
|
103
|
+
gherkinContent += ` ${st.keyword} ${st.text}\n`;
|
|
104
|
+
});
|
|
105
|
+
const defaultFileName = answers.featureName.toLowerCase().replace(/[^a-z0-9]/g, '_') + '.feature';
|
|
106
|
+
const targetSpecPath = options.output
|
|
107
|
+
? path_1.default.resolve(process.cwd(), options.output)
|
|
108
|
+
: path_1.default.resolve(process.cwd(), 'specs', defaultFileName);
|
|
109
|
+
(0, file_system_1.writeFileSync)(targetSpecPath, gherkinContent);
|
|
110
|
+
logger_1.logger.success(`${(0, i18n_cli_1.t)('specCreated', locale)} ${targetSpecPath}`);
|
|
111
|
+
console.log('\n------------------------------------------------------------');
|
|
112
|
+
console.log(gherkinContent);
|
|
113
|
+
console.log('------------------------------------------------------------\n');
|
|
114
|
+
// Prompt to immediately inject contracts into project
|
|
115
|
+
const injectAnswer = await inquirer_1.default.prompt([
|
|
116
|
+
{
|
|
117
|
+
type: 'confirm',
|
|
118
|
+
name: 'inject',
|
|
119
|
+
message: (0, i18n_cli_1.t)('injectPrompt', locale),
|
|
120
|
+
default: true
|
|
121
|
+
}
|
|
122
|
+
]);
|
|
123
|
+
if (injectAnswer.inject) {
|
|
124
|
+
await (0, add_1.handleAddCommand)({
|
|
125
|
+
feature: targetSpecPath,
|
|
126
|
+
target: options.target
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;;;;AAShF,kDAiIC;AAxID,gDAAwB;AACxB,wDAAgC;AAChC,+BAAyC;AACzC,gDAAyD;AACzD,sDAAqE;AACrE,4CAAyC;AAElC,KAAK,UAAU,mBAAmB,CAAC,OAA4D;IACpG,eAAM,CAAC,MAAM,EAAE,CAAC;IAEhB,MAAM,MAAM,GAAG,MAAM,IAAA,4BAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,KAAK,IAAI,CAAC;IAE7B,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,gEAAgE,CAAC,CAAC;IAE9I,MAAM,OAAO,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;QACpC;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,IAAA,YAAC,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EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ==========================================================================
|
|
3
|
+
gherkin-ai-cli - 'lang' Command Handler (Language Switcher)
|
|
4
|
+
========================================================================== */
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleLangCommand = handleLangCommand;
|
|
10
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
|
+
const i18n_cli_1 = require("../utils/i18n-cli");
|
|
12
|
+
const logger_1 = require("../utils/logger");
|
|
13
|
+
async function handleLangCommand(options) {
|
|
14
|
+
logger_1.logger.banner();
|
|
15
|
+
if (options.set === 'en' || options.set === 'es') {
|
|
16
|
+
(0, i18n_cli_1.saveGlobalUserLocale)(options.set);
|
|
17
|
+
logger_1.logger.success((0, i18n_cli_1.t)('langUpdated', options.set));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const current = (0, i18n_cli_1.getGlobalUserLocale)() || 'en';
|
|
21
|
+
logger_1.logger.info(`${(0, i18n_cli_1.t)('langCurrent', current)} ${current === 'es' ? 'πͺπΈ EspaΓ±ol' : 'πΊπΈ English'}`);
|
|
22
|
+
const answer = await inquirer_1.default.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: 'list',
|
|
25
|
+
name: 'locale',
|
|
26
|
+
message: (0, i18n_cli_1.t)('selectLanguagePrompt', current),
|
|
27
|
+
choices: [
|
|
28
|
+
{ name: 'πΊπΈ English', value: 'en' },
|
|
29
|
+
{ name: 'πͺπΈ EspaΓ±ol', value: 'es' }
|
|
30
|
+
],
|
|
31
|
+
default: current
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
const selected = answer.locale;
|
|
35
|
+
(0, i18n_cli_1.saveGlobalUserLocale)(selected);
|
|
36
|
+
logger_1.logger.success((0, i18n_cli_1.t)('langUpdated', selected));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/commands/lang.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;;;;AAMhF,8CA4BC;AAhCD,wDAAgC;AAChC,gDAAqH;AACrH,4CAAyC;AAElC,KAAK,UAAU,iBAAiB,CAAC,OAAyB;IAC/D,eAAM,CAAC,MAAM,EAAE,CAAC;IAEhB,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QACjD,IAAA,+BAAoB,EAAC,OAAO,CAAC,GAAsB,CAAC,CAAC;QACrD,eAAM,CAAC,OAAO,CAAC,IAAA,YAAC,EAAC,aAAa,EAAE,OAAO,CAAC,GAAsB,CAAC,CAAC,CAAC;QACjE,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,8BAAmB,GAAE,IAAI,IAAI,CAAC;IAC9C,eAAM,CAAC,IAAI,CAAC,GAAG,IAAA,YAAC,EAAC,aAAa,EAAE,OAAO,CAAC,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;IAElG,MAAM,MAAM,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;QACnC;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAA,YAAC,EAAC,sBAAsB,EAAE,OAAO,CAAC;YAC3C,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE;gBACrC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE;aACtC;YACD,OAAO,EAAE,OAAO;SACjB;KACF,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAyB,CAAC;IAClD,IAAA,+BAAoB,EAAC,QAAQ,CAAC,CAAC;IAC/B,eAAM,CAAC,OAAO,CAAC,IAAA,YAAC,EAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,14 +10,17 @@ const validate_1 = require("./commands/validate");
|
|
|
10
10
|
const export_1 = require("./commands/export");
|
|
11
11
|
const detect_1 = require("./commands/detect");
|
|
12
12
|
const add_1 = require("./commands/add");
|
|
13
|
+
const create_1 = require("./commands/create");
|
|
14
|
+
const lang_1 = require("./commands/lang");
|
|
13
15
|
// Dynamic version from package.json
|
|
14
16
|
const pkg = require('../package.json');
|
|
15
17
|
const program = new commander_1.Command();
|
|
16
18
|
program
|
|
17
19
|
.name('gherkin-ai')
|
|
18
20
|
.description('CLI tool & contract engine translating Gherkin specs into executable prompts, TypeScript contracts, and seed fixtures for AI Agents.')
|
|
19
|
-
.version(pkg.version || '1.
|
|
21
|
+
.version(pkg.version || '1.4.0')
|
|
20
22
|
.option('--init', 'Alias for init command')
|
|
23
|
+
.option('--create', 'Alias for create command')
|
|
21
24
|
.option('--generate', 'Alias for generate command')
|
|
22
25
|
.option('--validate', 'Alias for validate command')
|
|
23
26
|
.option('--detect', 'Alias for detect command');
|
|
@@ -28,6 +31,26 @@ program
|
|
|
28
31
|
.action(async () => {
|
|
29
32
|
await (0, init_1.handleInitCommand)();
|
|
30
33
|
});
|
|
34
|
+
program
|
|
35
|
+
.command('lang')
|
|
36
|
+
.alias('l')
|
|
37
|
+
.alias('language')
|
|
38
|
+
.description('Configure CLI preferred interaction language (English or Spanish)')
|
|
39
|
+
.option('-s, --set <locale>', 'Set language directly (en or es)')
|
|
40
|
+
.action(async (options) => {
|
|
41
|
+
await (0, lang_1.handleLangCommand)(options);
|
|
42
|
+
});
|
|
43
|
+
program
|
|
44
|
+
.command('create')
|
|
45
|
+
.alias('c')
|
|
46
|
+
.alias('new')
|
|
47
|
+
.description('Create a Gherkin feature specification interactively step-by-step from the terminal')
|
|
48
|
+
.option('-o, --output <file>', 'Output destination for .feature file')
|
|
49
|
+
.option('-t, --target <directory>', 'Target directory to inject contracts')
|
|
50
|
+
.option('-l, --lang <locale>', 'Override CLI interaction language for this run (en or es)')
|
|
51
|
+
.action(async (options) => {
|
|
52
|
+
await (0, create_1.handleCreateCommand)(options);
|
|
53
|
+
});
|
|
31
54
|
program
|
|
32
55
|
.command('detect')
|
|
33
56
|
.alias('d')
|
|
@@ -73,11 +96,14 @@ program
|
|
|
73
96
|
.action(async (options) => {
|
|
74
97
|
await (0, export_1.handleExportCommand)(options);
|
|
75
98
|
});
|
|
76
|
-
// Action fallback for root flags (--init, --generate, --validate, --detect)
|
|
99
|
+
// Action fallback for root flags (--init, --create, --generate, --validate, --detect)
|
|
77
100
|
program.action(async (options) => {
|
|
78
101
|
if (options.init) {
|
|
79
102
|
await (0, init_1.handleInitCommand)();
|
|
80
103
|
}
|
|
104
|
+
else if (options.create) {
|
|
105
|
+
await (0, create_1.handleCreateCommand)({});
|
|
106
|
+
}
|
|
81
107
|
else if (options.detect) {
|
|
82
108
|
await (0, detect_1.handleDetectCommand)();
|
|
83
109
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;AAEhF,yCAAoC;AACpC,0CAAoD;AACpD,kDAA4D;AAC5D,kDAA4D;AAC5D,8CAAwD;AACxD,8CAAwD;AACxD,wCAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;AAEhF,yCAAoC;AACpC,0CAAoD;AACpD,kDAA4D;AAC5D,kDAA4D;AAC5D,8CAAwD;AACxD,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H,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type SupportedLocale = 'en' | 'es';
|
|
2
|
+
declare const messages: {
|
|
3
|
+
en: {
|
|
4
|
+
selectLanguagePrompt: string;
|
|
5
|
+
langUpdated: string;
|
|
6
|
+
langCurrent: string;
|
|
7
|
+
featureNamePrompt: string;
|
|
8
|
+
actorPrompt: string;
|
|
9
|
+
actionPrompt: string;
|
|
10
|
+
outcomePrompt: string;
|
|
11
|
+
scenarioNamePrompt: string;
|
|
12
|
+
stepKeywordPrompt: string;
|
|
13
|
+
stepDescPrompt: string;
|
|
14
|
+
addAnotherStepPrompt: string;
|
|
15
|
+
specCreated: string;
|
|
16
|
+
injectPrompt: string;
|
|
17
|
+
featureNotFound: string;
|
|
18
|
+
askCreateInteractive: string;
|
|
19
|
+
detectingStack: string;
|
|
20
|
+
stackDetected: string;
|
|
21
|
+
savedConfig: string;
|
|
22
|
+
injectingContracts: string;
|
|
23
|
+
contractsInjected: string;
|
|
24
|
+
};
|
|
25
|
+
es: {
|
|
26
|
+
selectLanguagePrompt: string;
|
|
27
|
+
langUpdated: string;
|
|
28
|
+
langCurrent: string;
|
|
29
|
+
featureNamePrompt: string;
|
|
30
|
+
actorPrompt: string;
|
|
31
|
+
actionPrompt: string;
|
|
32
|
+
outcomePrompt: string;
|
|
33
|
+
scenarioNamePrompt: string;
|
|
34
|
+
stepKeywordPrompt: string;
|
|
35
|
+
stepDescPrompt: string;
|
|
36
|
+
addAnotherStepPrompt: string;
|
|
37
|
+
specCreated: string;
|
|
38
|
+
injectPrompt: string;
|
|
39
|
+
featureNotFound: string;
|
|
40
|
+
askCreateInteractive: string;
|
|
41
|
+
detectingStack: string;
|
|
42
|
+
stackDetected: string;
|
|
43
|
+
savedConfig: string;
|
|
44
|
+
injectingContracts: string;
|
|
45
|
+
contractsInjected: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare function getGlobalUserLocale(): SupportedLocale | null;
|
|
49
|
+
export declare function saveGlobalUserLocale(locale: SupportedLocale): void;
|
|
50
|
+
export declare function ensureCliLanguage(requestedLang?: string): Promise<SupportedLocale>;
|
|
51
|
+
export declare function t(key: keyof typeof messages['en'], locale?: SupportedLocale): string;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=i18n-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-cli.d.ts","sourceRoot":"","sources":["../../src/utils/i18n-cli.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;AAS1C,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Cb,CAAC;AAIF,wBAAgB,mBAAmB,IAAI,eAAe,GAAG,IAAI,CAgB5D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAMlE;AAED,wBAAsB,iBAAiB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA+BxF;AAED,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAGpF"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ==========================================================================
|
|
3
|
+
gherkin-ai-cli - Interactive i18n Engine for CLI (EN / ES)
|
|
4
|
+
========================================================================== */
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getGlobalUserLocale = getGlobalUserLocale;
|
|
10
|
+
exports.saveGlobalUserLocale = saveGlobalUserLocale;
|
|
11
|
+
exports.ensureCliLanguage = ensureCliLanguage;
|
|
12
|
+
exports.t = t;
|
|
13
|
+
const os_1 = __importDefault(require("os"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
16
|
+
const file_system_1 = require("./file-system");
|
|
17
|
+
const GLOBAL_CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.gherkin-ai');
|
|
18
|
+
const GLOBAL_CONFIG_PATH = path_1.default.join(GLOBAL_CONFIG_DIR, 'config.json');
|
|
19
|
+
const messages = {
|
|
20
|
+
en: {
|
|
21
|
+
selectLanguagePrompt: 'Select preferred CLI interaction language / Selecciona el idioma preferido para la CLI:',
|
|
22
|
+
langUpdated: 'CLI language successfully updated to English (en).',
|
|
23
|
+
langCurrent: 'Current CLI language:',
|
|
24
|
+
featureNamePrompt: 'Feature Name:',
|
|
25
|
+
actorPrompt: 'Actor (As a...):',
|
|
26
|
+
actionPrompt: 'Action (I want to...):',
|
|
27
|
+
outcomePrompt: 'Benefit (So that...):',
|
|
28
|
+
scenarioNamePrompt: 'Scenario Name:',
|
|
29
|
+
stepKeywordPrompt: 'Step Keyword:',
|
|
30
|
+
stepDescPrompt: 'Step Description:',
|
|
31
|
+
addAnotherStepPrompt: 'Add another step?',
|
|
32
|
+
specCreated: 'Created Gherkin feature specification at:',
|
|
33
|
+
injectPrompt: 'Do you want to inject contracts and prompts into your project now (ghk add)?',
|
|
34
|
+
featureNotFound: 'Feature file not found at:',
|
|
35
|
+
askCreateInteractive: 'Would you like to create the Gherkin specification step-by-step interactively now?',
|
|
36
|
+
detectingStack: 'Scanning project directory for existing stack & architecture...',
|
|
37
|
+
stackDetected: 'Existing Project Stack & Architecture Detected:',
|
|
38
|
+
savedConfig: 'Saved project configuration to:',
|
|
39
|
+
injectingContracts: 'Injecting contracts & AI prompts into:',
|
|
40
|
+
contractsInjected: 'Contracts & AI prompts injected into existing project at'
|
|
41
|
+
},
|
|
42
|
+
es: {
|
|
43
|
+
selectLanguagePrompt: 'Selecciona el idioma preferido para la CLI / Select preferred CLI interaction language:',
|
|
44
|
+
langUpdated: 'Idioma de la CLI actualizado exitosamente a EspaΓ±ol (es).',
|
|
45
|
+
langCurrent: 'Idioma actual de la CLI:',
|
|
46
|
+
featureNamePrompt: 'Nombre de la Feature:',
|
|
47
|
+
actorPrompt: 'Actor (Como...):',
|
|
48
|
+
actionPrompt: 'AcciΓ³n (Quiero...):',
|
|
49
|
+
outcomePrompt: 'Beneficio (Para...):',
|
|
50
|
+
scenarioNamePrompt: 'Nombre del Escenario:',
|
|
51
|
+
stepKeywordPrompt: 'Palabra clave del paso:',
|
|
52
|
+
stepDescPrompt: 'DescripciΓ³n del paso:',
|
|
53
|
+
addAnotherStepPrompt: 'ΒΏAΓ±adir otro paso?',
|
|
54
|
+
specCreated: 'EspecificaciΓ³n Gherkin creada exitosamente en:',
|
|
55
|
+
injectPrompt: 'ΒΏDeseas inyectar inmediatamente los contratos y prompts en tu proyecto (ghk add)?',
|
|
56
|
+
featureNotFound: 'Archivo de feature no encontrado en:',
|
|
57
|
+
askCreateInteractive: 'ΒΏDeseas crear la especificaciΓ³n Gherkin paso a paso ahora (wizard interactivo)?',
|
|
58
|
+
detectingStack: 'Escaneando directorio del proyecto en busca de stack y arquitectura...',
|
|
59
|
+
stackDetected: 'Stack y Arquitectura del Proyecto Detectados:',
|
|
60
|
+
savedConfig: 'ConfiguraciΓ³n guardada exitosamente en:',
|
|
61
|
+
injectingContracts: 'Inyectando contratos y prompts para Agentes de IA en:',
|
|
62
|
+
contractsInjected: 'Contratos y prompts inyectados exitosamente en el proyecto en'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
let cachedLocale = null;
|
|
66
|
+
function getGlobalUserLocale() {
|
|
67
|
+
if (cachedLocale)
|
|
68
|
+
return cachedLocale;
|
|
69
|
+
if ((0, file_system_1.fileExistsSync)(GLOBAL_CONFIG_PATH)) {
|
|
70
|
+
try {
|
|
71
|
+
const raw = (0, file_system_1.readFileSync)(GLOBAL_CONFIG_PATH);
|
|
72
|
+
const parsed = JSON.parse(raw);
|
|
73
|
+
if (parsed.locale === 'en' || parsed.locale === 'es') {
|
|
74
|
+
cachedLocale = parsed.locale;
|
|
75
|
+
return parsed.locale;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Ignore JSON parse error
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function saveGlobalUserLocale(locale) {
|
|
85
|
+
(0, file_system_1.ensureDirSync)(GLOBAL_CONFIG_DIR);
|
|
86
|
+
const current = (0, file_system_1.fileExistsSync)(GLOBAL_CONFIG_PATH) ? JSON.parse((0, file_system_1.readFileSync)(GLOBAL_CONFIG_PATH)) : {};
|
|
87
|
+
current.locale = locale;
|
|
88
|
+
(0, file_system_1.writeFileSync)(GLOBAL_CONFIG_PATH, JSON.stringify(current, null, 2));
|
|
89
|
+
cachedLocale = locale;
|
|
90
|
+
}
|
|
91
|
+
async function ensureCliLanguage(requestedLang) {
|
|
92
|
+
if (requestedLang === 'en' || requestedLang === 'es') {
|
|
93
|
+
saveGlobalUserLocale(requestedLang);
|
|
94
|
+
return requestedLang;
|
|
95
|
+
}
|
|
96
|
+
const existing = getGlobalUserLocale();
|
|
97
|
+
if (existing)
|
|
98
|
+
return existing;
|
|
99
|
+
// Default is English if running in non-interactive CI mode
|
|
100
|
+
if (!process.stdout.isTTY) {
|
|
101
|
+
saveGlobalUserLocale('en');
|
|
102
|
+
return 'en';
|
|
103
|
+
}
|
|
104
|
+
const answer = await inquirer_1.default.prompt([
|
|
105
|
+
{
|
|
106
|
+
type: 'list',
|
|
107
|
+
name: 'locale',
|
|
108
|
+
message: 'Select preferred CLI language / Selecciona el idioma para la CLI:',
|
|
109
|
+
choices: [
|
|
110
|
+
{ name: 'πΊπΈ English (Default)', value: 'en' },
|
|
111
|
+
{ name: 'πͺπΈ EspaΓ±ol', value: 'es' }
|
|
112
|
+
],
|
|
113
|
+
default: 'en'
|
|
114
|
+
}
|
|
115
|
+
]);
|
|
116
|
+
const selectedLocale = answer.locale;
|
|
117
|
+
saveGlobalUserLocale(selectedLocale);
|
|
118
|
+
return selectedLocale;
|
|
119
|
+
}
|
|
120
|
+
function t(key, locale) {
|
|
121
|
+
const lang = locale || getGlobalUserLocale() || 'en';
|
|
122
|
+
return messages[lang][key] || messages['en'][key] || key;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=i18n-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-cli.js","sourceRoot":"","sources":["../../src/utils/i18n-cli.ts"],"names":[],"mappings":";AAAA;;gFAEgF;;;;;AAiEhF,kDAgBC;AAED,oDAMC;AAED,8CA+BC;AAED,cAGC;AA7HD,4CAAoB;AACpB,gDAAwB;AACxB,wDAAgC;AAChC,+CAA2F;AAQ3F,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAEvE,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE;QACF,oBAAoB,EAAE,yFAAyF;QAC/G,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE,uBAAuB;QACpC,iBAAiB,EAAE,eAAe;QAClC,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,wBAAwB;QACtC,aAAa,EAAE,uBAAuB;QACtC,kBAAkB,EAAE,gBAAgB;QACpC,iBAAiB,EAAE,eAAe;QAClC,cAAc,EAAE,mBAAmB;QACnC,oBAAoB,EAAE,mBAAmB;QACzC,WAAW,EAAE,2CAA2C;QACxD,YAAY,EAAE,8EAA8E;QAC5F,eAAe,EAAE,4BAA4B;QAC7C,oBAAoB,EAAE,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AE,KAAK,EAAE,IAAI,EAAE;aACtC;YACD,OAAO,EAAE,IAAI;SACd;KACF,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,MAAM,CAAC,MAAyB,CAAC;IACxD,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACrC,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAgB,CAAC,CAAC,GAAgC,EAAE,MAAwB;IAC1E,MAAM,IAAI,GAAG,MAAM,IAAI,mBAAmB,EAAE,IAAI,IAAI,CAAC;IACrD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AAC3D,CAAC"}
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ποΈ `gherkin-ai` CLI Architecture & Agent Pipeline Design
|
|
2
2
|
|
|
3
|
-
This document details the internal design, Abstract Syntax Tree (AST) parsing pipeline, and contract generation mechanisms of `gherkin-ai` CLI.
|
|
3
|
+
This document details the internal design, Abstract Syntax Tree (AST) parsing pipeline, multi-stack detection, and contract generation mechanisms of `gherkin-ai` CLI.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -13,12 +13,17 @@ This document details the internal design, Abstract Syntax Tree (AST) parsing pi
|
|
|
13
13
|
β
|
|
14
14
|
βΌ
|
|
15
15
|
ββββββββββββββββββββββββ βββββββββββββββββββββββββ
|
|
16
|
-
β gherkin-parser.ts βββββββΊβ ParsedFeature (AST) β
|
|
16
|
+
β gherkin-parser.ts βββββββΊβ ParsedFeature (AST) β (Bilingual EN / ES)
|
|
17
17
|
ββββββββββββββββββββββββ ββββββββββββ¬βββββββββββββ
|
|
18
18
|
β
|
|
19
19
|
βΌ
|
|
20
20
|
ββββββββββββββββββββββββ βββββββββββββββββββββββββ
|
|
21
|
-
β
|
|
21
|
+
β stack-detector.ts βββββββΊβ Detected Stack β (Laravel, Rails, .NET, Angular, Nest, etc.)
|
|
22
|
+
ββββββββββββββββββββββββ ββββββββββββ¬βββββββββββββ
|
|
23
|
+
β
|
|
24
|
+
βΌ
|
|
25
|
+
ββββββββββββββββββββββββ βββββββββββββββββββββββββ
|
|
26
|
+
β i18n-cli.ts βββββββΊβ User Locale Context β (English / Spanish)
|
|
22
27
|
ββββββββββββββββββββββββ ββββββββββββ¬βββββββββββββ
|
|
23
28
|
β
|
|
24
29
|
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
|
|
@@ -36,22 +41,36 @@ This document details the internal design, Abstract Syntax Tree (AST) parsing pi
|
|
|
36
41
|
## 2. Core Components
|
|
37
42
|
|
|
38
43
|
### 2.1 AST Parser (`src/core/gherkin-parser.ts`)
|
|
39
|
-
Parses `.feature` text into structured models:
|
|
40
|
-
- **Feature Title & Business Goal**
|
|
41
|
-
- **Scenarios & Given/When/Then Steps**
|
|
42
|
-
- **Domain Analysis**: Automatically classifies step phrases into Actors, Commands
|
|
44
|
+
Parses `.feature` text into structured models with native bilingual support:
|
|
45
|
+
- **Feature Title & Business Goal** (supports `Feature:` / `CaracterΓstica:`)
|
|
46
|
+
- **Scenarios & Given/When/Then Steps** (supports `Scenario:` / `Escenario:`, `Given` / `Dado`, `When` / `Cuando`, `Then` / `Entonces`, `And` / `Y`, `But` / `Pero`).
|
|
47
|
+
- **Domain Analysis**: Automatically classifies step phrases into Actors, Commands, Queries, Events, and Fixtures.
|
|
43
48
|
|
|
44
|
-
### 2.2
|
|
45
|
-
|
|
49
|
+
### 2.2 Stack Auto-Detector (`src/core/stack-detector.ts`)
|
|
50
|
+
Inspects root workspace files to identify the tech stack of existing projects:
|
|
51
|
+
- **PHP / Laravel**: Inspects `artisan` and `composer.json`.
|
|
52
|
+
- **Ruby on Rails**: Inspects `Gemfile` and `Rakefile`.
|
|
53
|
+
- **C# / .NET**: Inspects `Program.cs` and `appsettings.json`.
|
|
54
|
+
- **Java / Spring Boot**: Inspects `pom.xml` and `build.gradle`.
|
|
55
|
+
- **Python (Django / FastAPI)**: Inspects `manage.py`, `pyproject.toml`, `requirements.txt`.
|
|
56
|
+
- **Go**: Inspects `go.mod`.
|
|
57
|
+
- **Frontend & Mobile**: Inspects `angular.json` (Angular / Ionic), `react-native`, `pubspec.yaml` (Flutter/Dart).
|
|
46
58
|
|
|
47
|
-
### 2.3
|
|
48
|
-
|
|
59
|
+
### 2.3 Interactive CLI i18n Engine (`src/utils/i18n-cli.ts`)
|
|
60
|
+
Manages CLI locale preferences (`en` / `es`):
|
|
61
|
+
- Defaults to **English** (`en`).
|
|
62
|
+
- Persists user preferences globally in `~/.gherkin-ai/config.json`.
|
|
63
|
+
- Allows switching preferred CLI language anytime using `ghk lang`.
|
|
64
|
+
|
|
65
|
+
### 2.4 Interactive Spec Wizard (`src/commands/create.ts`)
|
|
66
|
+
Guides users step-by-step through terminal prompts to build Gherkin `.feature` specifications in English or Spanish, saving the resulting file and offering direct contract injection.
|
|
67
|
+
|
|
68
|
+
### 2.5 Contract & DTO Generator (`src/generators/contracts.ts`)
|
|
69
|
+
Transforms parsed AST commands into valid Zod validation schemas, OpenAPI 3.0 JSON specifications, and TypeScript interfaces:
|
|
49
70
|
- `IDomainEvent` & explicit event schemas.
|
|
50
71
|
- Command DTO schemas for input validation.
|
|
51
72
|
- Outbound repository ports (`IRepository`).
|
|
52
|
-
|
|
53
|
-
### 2.4 Test Fixture Engine (`src/generators/fixtures.ts`)
|
|
54
|
-
Generates concrete setup fixtures and SQL seeds (hashed passwords via `bcrypt`, pre-conditions) to resolve the ambiguity of `Given` steps.
|
|
73
|
+
- CQRS Event Store ports (`IEventStore`, `IAggregateRoot<T>`, `ISnapshotStore<T>`).
|
|
55
74
|
|
|
56
75
|
---
|
|
57
76
|
|
|
@@ -59,5 +78,5 @@ Generates concrete setup fixtures and SQL seeds (hashed passwords via `bcrypt`,
|
|
|
59
78
|
|
|
60
79
|
To prevent AI coding agents from diverging or producing uncompilable code:
|
|
61
80
|
1. **Domain Architect Agent** reads `contracts.ts` and implements pure business logic without external dependencies.
|
|
62
|
-
2. **Backend Developer Agent** uses `contracts.ts` and `fixtures.ts` to implement Use Cases, Controllers, and ORM Repositories.
|
|
63
|
-
3. **QA Automation Agent** uses `fixtures.ts` and `.feature` files to write deterministic unit and integration tests.
|
|
81
|
+
2. **Backend Developer Agent** uses `contracts.ts` and `fixtures.ts` to implement Use Cases, Controllers, and ORM Repositories (NestJS, Laravel, Rails, .NET, Spring Boot).
|
|
82
|
+
3. **QA Automation Agent** uses `fixtures.ts` and `.feature` files to write deterministic unit and integration tests (Jest, PHPUnit, RSpec, xUnit, Pytest).
|
package/docs/USAGE_GUIDE.md
CHANGED
|
@@ -6,120 +6,147 @@ This guide provides step-by-step instructions for installing, configuring, and e
|
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
|
-
1. [Installation](#installation)
|
|
10
|
-
2. [
|
|
11
|
-
3. [
|
|
12
|
-
4. [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- [`export`](#export)
|
|
17
|
-
5. [Feeding Generated Prompts into AI Agents](#feeding-prompts-into-ai-agents)
|
|
9
|
+
1. [Installation & Short Alias (`ghk`)](#1-installation--short-alias-ghk)
|
|
10
|
+
2. [Language Configuration (`ghk lang`)](#2-language-configuration-ghk-lang)
|
|
11
|
+
3. [Interactive Gherkin Spec Wizard (`ghk create`)](#3-interactive-gherkin-spec-wizard-ghk-create)
|
|
12
|
+
4. [Existing Projects / Brownfield Mode (`ghk detect` & `ghk add`)](#4-existing-projects--brownfield-mode-ghk-detect--ghk-add)
|
|
13
|
+
5. [New Projects / Greenfield Mode (`ghk init` & `ghk generate`)](#5-new-projects--greenfield-mode-ghk-init--ghk-generate)
|
|
14
|
+
6. [Command Reference](#6-command-reference)
|
|
15
|
+
7. [Feeding Generated Prompts into AI Agents](#7-feeding-generated-prompts-into-ai-agents)
|
|
18
16
|
|
|
19
17
|
---
|
|
20
18
|
|
|
21
|
-
## 1. Installation
|
|
19
|
+
## 1. Installation & Short Alias (`ghk`)
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Run `gherkin-ai` instantly without installation using `npx` and the short alias **`ghk`**:
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
|
-
npx
|
|
24
|
+
npx ghk --version
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
Or install it globally
|
|
27
|
+
Or install it globally:
|
|
30
28
|
|
|
31
29
|
```bash
|
|
32
30
|
npm install -g gherkin-ai
|
|
31
|
+
ghk --help
|
|
33
32
|
```
|
|
34
33
|
|
|
35
34
|
---
|
|
36
35
|
|
|
37
|
-
## 2.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"orm": "prisma",
|
|
49
|
-
"database": "postgresql",
|
|
50
|
-
"validation": "zod",
|
|
51
|
-
"auth": "jwt-bcrypt",
|
|
52
|
-
"messaging": "rabbitmq",
|
|
53
|
-
"testing": "jest"
|
|
54
|
-
},
|
|
55
|
-
"rules": {
|
|
56
|
-
"bcryptCostFactor": 12,
|
|
57
|
-
"jwtTtlSeconds": 3600,
|
|
58
|
-
"strictLayerBoundaries": true,
|
|
59
|
-
"coverageTarget": 85
|
|
60
|
-
},
|
|
61
|
-
"outputDir": "./generated-specs"
|
|
62
|
-
}
|
|
36
|
+
## 2. Language Configuration (`ghk lang`)
|
|
37
|
+
|
|
38
|
+
By default, CLI interactions run in **English**. You can switch CLI interaction language to **Spanish** or **English** at any time.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Interactive language selector
|
|
42
|
+
ghk lang
|
|
43
|
+
|
|
44
|
+
# Or set directly
|
|
45
|
+
ghk lang --set es # Switch to Spanish
|
|
46
|
+
ghk lang --set en # Switch to English
|
|
63
47
|
```
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
The language preference is saved globally under `~/.gherkin-ai/config.json` and automatically applies to all future terminal sessions.
|
|
66
50
|
|
|
67
|
-
|
|
51
|
+
---
|
|
68
52
|
|
|
69
|
-
|
|
53
|
+
## 3. Interactive Gherkin Spec Wizard (`ghk create`)
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
Feature: User Authentication & Token Issuance
|
|
73
|
-
As a registered system user
|
|
74
|
-
I want to authenticate using valid credentials
|
|
75
|
-
So that I obtain a JWT token to access protected APIs
|
|
55
|
+
Build a Gherkin specification step-by-step interactively directly in your terminal without typing raw `.feature` syntax:
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
When sending an authentication request with email "dev@example.com" and password "Pass123!"
|
|
80
|
-
Then the system responds with HTTP status 200 OK
|
|
81
|
-
And returns a short-lived access JWT token
|
|
82
|
-
And emits a "UserAuthenticated" domain event
|
|
57
|
+
```bash
|
|
58
|
+
ghk create # (or alias: ghk new)
|
|
83
59
|
```
|
|
84
60
|
|
|
61
|
+
The wizard prompts you for:
|
|
62
|
+
1. Feature Name (e.g. *Two Factor Authentication 2FA* / *AutenticaciΓ³n de Doble Factor*)
|
|
63
|
+
2. Actor (*As a...* / *Como...*)
|
|
64
|
+
3. Action (*I want to...* / *Quiero...*)
|
|
65
|
+
4. Benefit (*So that...* / *Para...*)
|
|
66
|
+
5. Scenario Name & Step Loop (`Given`/`Dado`, `When`/`Cuando`, `Then`/`Entonces`, `And`/`Y`).
|
|
67
|
+
|
|
68
|
+
After creation, it saves the file to `./specs/` and offers to immediately inject contracts into your project.
|
|
69
|
+
|
|
85
70
|
---
|
|
86
71
|
|
|
87
|
-
## 4.
|
|
72
|
+
## 4. Existing Projects / Brownfield Mode (`ghk detect` & `ghk add`)
|
|
88
73
|
|
|
89
|
-
|
|
74
|
+
If you have an existing codebase (**Laravel, Rails, ASP.NET Core, Angular, Ionic, Spring Boot, NestJS, FastAPI, Django, Flutter**):
|
|
90
75
|
|
|
91
|
-
|
|
76
|
+
### Step 1: Auto-Detect Tech Stack
|
|
92
77
|
|
|
93
78
|
```bash
|
|
94
|
-
|
|
79
|
+
ghk detect
|
|
95
80
|
```
|
|
96
81
|
|
|
97
|
-
|
|
82
|
+
Scans your root directory for manifests (`package.json`, `artisan`, `composer.json`, `pom.xml`, `go.mod`, `requirements.txt`, `Gemfile`, `angular.json`, `pubspec.yaml`) and saves `gherkin-ai.config.json` with `projectMode: "brownfield"`.
|
|
98
83
|
|
|
99
|
-
|
|
84
|
+
### Step 2: Inject Feature Contracts into Existing Modules
|
|
100
85
|
|
|
101
86
|
```bash
|
|
102
|
-
|
|
87
|
+
ghk add --feature ./specs/payments.feature --target ./src/modules/payments
|
|
103
88
|
```
|
|
104
89
|
|
|
105
|
-
|
|
90
|
+
Injects `<feature>.contract.ts`, `<feature>.openapi.json`, `ADR-<feature>.md`, and specialized AI prompts directly inside `./src/modules/payments/` without modifying the rest of your application.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 5. New Projects / Greenfield Mode (`ghk init` & `ghk generate`)
|
|
106
95
|
|
|
107
|
-
|
|
96
|
+
For starting a brand-new service from scratch:
|
|
108
97
|
|
|
109
98
|
```bash
|
|
110
|
-
|
|
99
|
+
# 1. Initialize configuration
|
|
100
|
+
ghk init
|
|
101
|
+
|
|
102
|
+
# 2. Generate complete specification artifacts
|
|
103
|
+
ghk generate --feature ./specs/auth.feature
|
|
104
|
+
|
|
105
|
+
# 3. Perform architectural linting
|
|
106
|
+
ghk validate --feature ./specs/auth.feature
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Generates:
|
|
110
|
+
```text
|
|
111
|
+
generated-specs/
|
|
112
|
+
βββ contracts.ts # Interfaces, Zod schemas, Repository & Event Store ports
|
|
113
|
+
βββ openapi.json # Auto-generated OpenAPI 3.0 specification
|
|
114
|
+
βββ fixtures.ts # Test seed functions (bcrypt, Given setup)
|
|
115
|
+
βββ seed.sql # Raw SQL initialization script
|
|
116
|
+
βββ docker-compose.yml / serverless.yml # Pre-configured infrastructure
|
|
117
|
+
βββ .env.example # Environment variables template
|
|
118
|
+
βββ ADR-001-architecture-decisions.md # Architecture Decision Record
|
|
119
|
+
βββ prompts/
|
|
120
|
+
βββ domain-agent.md # Instructions for Domain Architect Agent
|
|
121
|
+
βββ backend-agent.md # Instructions for Backend Developer Agent
|
|
122
|
+
βββ qa-agent.md # Instructions for QA Automation Agent
|
|
111
123
|
```
|
|
112
124
|
|
|
113
125
|
---
|
|
114
126
|
|
|
115
|
-
##
|
|
127
|
+
## 6. Command Reference
|
|
128
|
+
|
|
129
|
+
| Command | Alias | Description |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `ghk init` | `i` | Initialize interactive project configuration (`gherkin-ai.config.json`). |
|
|
132
|
+
| `ghk lang` | `l`, `language` | Configure preferred CLI interaction language (English or Spanish). |
|
|
133
|
+
| `ghk create` | `c`, `new` | Interactive terminal wizard to build Gherkin `.feature` specs step-by-step. |
|
|
134
|
+
| `ghk detect` | `d` | Auto-detect stack & architecture of an existing codebase (Brownfield mode). |
|
|
135
|
+
| `ghk add` | `a` | Inject contracts and AI prompts into a specific module in an existing project. |
|
|
136
|
+
| `ghk generate` | `g` | Generate complete contracts, OpenAPI, seeds, docker-compose, and prompts. |
|
|
137
|
+
| `ghk validate` | `v` | Perform deep architectural linting and layer boundary checks. |
|
|
138
|
+
| `ghk export` | `e` | Export a single Markdown or JSON context bundle for AI agents. |
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 7. Feeding Generated Prompts into AI Agents
|
|
116
143
|
|
|
117
144
|
### For Claude Code / Terminal Agents:
|
|
118
145
|
```bash
|
|
119
|
-
claude "Read generated-specs/prompts/
|
|
146
|
+
claude "Read generated-specs/prompts/backend-agent.md and contracts.ts. Implement the controllers and services in src/."
|
|
120
147
|
```
|
|
121
148
|
|
|
122
|
-
### For Cursor / Windsurf / IDE Agents:
|
|
123
|
-
1. Open `@
|
|
124
|
-
2. Load `@
|
|
125
|
-
3. Instruct the AI agent: *"Implement the application use cases and controllers following
|
|
149
|
+
### For Cursor / Windsurf / Antigravity / IDE Agents:
|
|
150
|
+
1. Open `@contracts.ts` (or `@<module>.contract.ts`) in your workspace.
|
|
151
|
+
2. Load `@prompts/backend-agent.md` as context.
|
|
152
|
+
3. Instruct the AI agent: *"Implement the application use cases and controllers following the contract interfaces."*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gherkin-ai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "CLI tool & contract engine translating Gherkin specs into production-grade executable prompts, TypeScript contracts, and seed fixtures for AI Coding Agents.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -34,16 +34,8 @@
|
|
|
34
34
|
"ghk",
|
|
35
35
|
"brownfield",
|
|
36
36
|
"detect",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"ruby",
|
|
40
|
-
"rails",
|
|
41
|
-
"dotnet",
|
|
42
|
-
"csharp",
|
|
43
|
-
"angular",
|
|
44
|
-
"ionic",
|
|
45
|
-
"react-native",
|
|
46
|
-
"flutter"
|
|
37
|
+
"create",
|
|
38
|
+
"wizard"
|
|
47
39
|
],
|
|
48
40
|
"author": "Fenner Eduardo <contact@fennereduardo.com> (https://fennereduardo.com)",
|
|
49
41
|
"license": "MIT",
|