@bamptee/aia-code 0.2.0 → 0.3.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/package.json +1 -1
- package/src/cli.js +2 -0
- package/src/commands/next.js +26 -0
- package/src/commands/run.js +3 -3
- package/src/prompt-builder.js +22 -4
- package/src/services/runner.js +2 -2
- package/src/services/status.js +2 -5
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { registerRunCommand } from './commands/run.js';
|
|
|
5
5
|
import { registerRepoCommand } from './commands/repo.js';
|
|
6
6
|
import { registerStatusCommand } from './commands/status.js';
|
|
7
7
|
import { registerResetCommand } from './commands/reset.js';
|
|
8
|
+
import { registerNextCommand } from './commands/next.js';
|
|
8
9
|
|
|
9
10
|
export function createCli() {
|
|
10
11
|
const program = new Command();
|
|
@@ -17,6 +18,7 @@ export function createCli() {
|
|
|
17
18
|
registerInitCommand(program);
|
|
18
19
|
registerFeatureCommand(program);
|
|
19
20
|
registerRunCommand(program);
|
|
21
|
+
registerNextCommand(program);
|
|
20
22
|
registerRepoCommand(program);
|
|
21
23
|
registerStatusCommand(program);
|
|
22
24
|
registerResetCommand(program);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { loadStatus } from '../services/status.js';
|
|
3
|
+
import { runStep } from '../services/runner.js';
|
|
4
|
+
|
|
5
|
+
export function registerNextCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('next <feature> [description]')
|
|
8
|
+
.description('Run the next pending step for a feature')
|
|
9
|
+
.action(async (feature, description) => {
|
|
10
|
+
try {
|
|
11
|
+
const status = await loadStatus(feature);
|
|
12
|
+
const nextStep = status.current_step;
|
|
13
|
+
|
|
14
|
+
if (!nextStep) {
|
|
15
|
+
console.log(chalk.green(`All steps completed for feature "${feature}".`));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log(chalk.cyan(`[next] Running step: ${nextStep}`));
|
|
20
|
+
await runStep(nextStep, feature, { description });
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error(chalk.red(err.message));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
package/src/commands/run.js
CHANGED
|
@@ -3,11 +3,11 @@ import { runStep } from '../services/runner.js';
|
|
|
3
3
|
|
|
4
4
|
export function registerRunCommand(program) {
|
|
5
5
|
program
|
|
6
|
-
.command('run <step> <feature>')
|
|
6
|
+
.command('run <step> <feature> [description]')
|
|
7
7
|
.description('Execute a step for a feature using the configured AI model')
|
|
8
|
-
.action(async (step, feature) => {
|
|
8
|
+
.action(async (step, feature, description) => {
|
|
9
9
|
try {
|
|
10
|
-
await runStep(step, feature);
|
|
10
|
+
await runStep(step, feature, { description });
|
|
11
11
|
} catch (err) {
|
|
12
12
|
console.error(chalk.red(err.message));
|
|
13
13
|
process.exit(1);
|
package/src/prompt-builder.js
CHANGED
|
@@ -44,9 +44,14 @@ async function loadFeatureFiles(feature, step, root) {
|
|
|
44
44
|
return sections.join('\n\n');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
async function loadPreviousOutput(feature, step, root) {
|
|
48
|
+
const filePath = path.join(root, AIA_DIR, 'features', feature, `${step}.md`);
|
|
49
|
+
return readIfExists(filePath);
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
async function resolveKnowledgeCategories(feature, config, root) {
|
|
48
|
-
const
|
|
49
|
-
const raw = await readIfExists(
|
|
53
|
+
const statusFile = path.join(root, AIA_DIR, 'features', feature, 'status.yaml');
|
|
54
|
+
const raw = await readIfExists(statusFile);
|
|
50
55
|
|
|
51
56
|
if (raw) {
|
|
52
57
|
const status = yaml.parse(raw);
|
|
@@ -67,13 +72,14 @@ async function loadPromptTemplate(step, root) {
|
|
|
67
72
|
return content;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
export async function buildPrompt(feature, step, root = process.cwd()) {
|
|
75
|
+
export async function buildPrompt(feature, step, { description, root = process.cwd() } = {}) {
|
|
71
76
|
const config = await loadConfig(root);
|
|
72
77
|
|
|
73
|
-
const [context, knowledgeCategories, featureContent, task] = await Promise.all([
|
|
78
|
+
const [context, knowledgeCategories, featureContent, previousOutput, task] = await Promise.all([
|
|
74
79
|
loadContextFiles(config, root),
|
|
75
80
|
resolveKnowledgeCategories(feature, config, root),
|
|
76
81
|
loadFeatureFiles(feature, step, root),
|
|
82
|
+
loadPreviousOutput(feature, step, root),
|
|
77
83
|
loadPromptTemplate(step, root),
|
|
78
84
|
]);
|
|
79
85
|
|
|
@@ -81,6 +87,12 @@ export async function buildPrompt(feature, step, root = process.cwd()) {
|
|
|
81
87
|
|
|
82
88
|
const parts = [];
|
|
83
89
|
|
|
90
|
+
if (description) {
|
|
91
|
+
parts.push('=== DESCRIPTION ===\n');
|
|
92
|
+
parts.push(description);
|
|
93
|
+
parts.push('');
|
|
94
|
+
}
|
|
95
|
+
|
|
84
96
|
parts.push('=== CONTEXT ===\n');
|
|
85
97
|
parts.push(context || '(no context files)');
|
|
86
98
|
|
|
@@ -90,6 +102,12 @@ export async function buildPrompt(feature, step, root = process.cwd()) {
|
|
|
90
102
|
parts.push('\n\n=== FEATURE ===\n');
|
|
91
103
|
parts.push(featureContent || '(no prior steps)');
|
|
92
104
|
|
|
105
|
+
if (previousOutput) {
|
|
106
|
+
parts.push('\n\n=== PREVIOUS OUTPUT ===\n');
|
|
107
|
+
parts.push(previousOutput);
|
|
108
|
+
parts.push('\n\nThe above is a previous version of this step. Rewrite it incorporating any new information, answers to questions, and improvements.');
|
|
109
|
+
}
|
|
110
|
+
|
|
93
111
|
parts.push('\n\n=== TASK ===\n');
|
|
94
112
|
parts.push(task);
|
|
95
113
|
|
package/src/services/runner.js
CHANGED
|
@@ -8,7 +8,7 @@ import { callModel } from './model-call.js';
|
|
|
8
8
|
import { loadStatus, updateStepStatus } from './status.js';
|
|
9
9
|
import { logExecution } from '../logger.js';
|
|
10
10
|
|
|
11
|
-
export async function runStep(step, feature, root = process.cwd()) {
|
|
11
|
+
export async function runStep(step, feature, { description, root = process.cwd() } = {}) {
|
|
12
12
|
if (!FEATURE_STEPS.includes(step)) {
|
|
13
13
|
throw new Error(`Unknown step "${step}". Valid steps: ${FEATURE_STEPS.join(', ')}`);
|
|
14
14
|
}
|
|
@@ -25,7 +25,7 @@ export async function runStep(step, feature, root = process.cwd()) {
|
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
27
|
const model = await resolveModel(step, root);
|
|
28
|
-
const prompt = await buildPrompt(feature, step, root);
|
|
28
|
+
const prompt = await buildPrompt(feature, step, { description, root });
|
|
29
29
|
|
|
30
30
|
const start = performance.now();
|
|
31
31
|
const output = await callModel(model, prompt);
|
package/src/services/status.js
CHANGED
|
@@ -38,7 +38,7 @@ export async function updateStepStatus(feature, step, value, root = process.cwd(
|
|
|
38
38
|
|
|
39
39
|
const stepIndex = FEATURE_STEPS.indexOf(step);
|
|
40
40
|
const nextStep = FEATURE_STEPS[stepIndex + 1] ?? null;
|
|
41
|
-
if (value === STEP_STATUS.DONE
|
|
41
|
+
if (value === STEP_STATUS.DONE) {
|
|
42
42
|
status.current_step = nextStep;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -63,8 +63,5 @@ export async function resetStep(feature, step, root = process.cwd()) {
|
|
|
63
63
|
const content = yaml.stringify(status);
|
|
64
64
|
await fs.writeFile(statusPath(feature, root), content, 'utf-8');
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
if (await fs.pathExists(outputPath)) {
|
|
68
|
-
await fs.writeFile(outputPath, '', 'utf-8');
|
|
69
|
-
}
|
|
66
|
+
// Keep the existing output — it will be fed back as context on re-run
|
|
70
67
|
}
|