@intend-it/core 3.0.1 → 4.0.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 (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +70 -10
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -17,6 +17,7 @@
17
17
  ### ✨ Key Features
18
18
 
19
19
  - **🧠 AI Code Generation** - Transforms natural language steps into actual code
20
+ - **🔀 Hybrid Orchestration** - Mix AI steps with deterministic function calls
20
21
  - **🔄 Self-Correction Loop** - Validates output and auto-fixes errors
21
22
  - **⚡ Smart Caching (CAS)** - Content-addressable storage for instant rebuilds
22
23
  - **🔌 Multi-Provider** - Supports Gemini and Ollama (local)
package/dist/index.js CHANGED
@@ -168911,6 +168911,9 @@ class TypeScriptGenerator {
168911
168911
  }
168912
168912
  generateStep(step, index) {
168913
168913
  const blocks = [];
168914
+ if (step.type === "Call") {
168915
+ return this.generateCall(step);
168916
+ }
168914
168917
  if (this.options.includeTodos) {
168915
168918
  blocks.push({
168916
168919
  type: "comment",
@@ -168934,6 +168937,33 @@ class TypeScriptGenerator {
168934
168937
  blocks.push({ type: "comment", content: "", indent: 0 });
168935
168938
  return blocks;
168936
168939
  }
168940
+ generateCall(call) {
168941
+ const blocks = [];
168942
+ const args = call.args.map((arg) => this.generateValue(arg)).join(", ");
168943
+ const callExpr = `await ${call.intent}(${args})`;
168944
+ if (call.resultVariable) {
168945
+ const decl = call.variableKind || "const";
168946
+ blocks.push({
168947
+ type: "statement",
168948
+ content: `${decl} ${call.resultVariable} = ${callExpr};`,
168949
+ indent: 1
168950
+ });
168951
+ } else {
168952
+ blocks.push({
168953
+ type: "statement",
168954
+ content: `${callExpr};`,
168955
+ indent: 1
168956
+ });
168957
+ }
168958
+ blocks.push({ type: "comment", content: "", indent: 0 });
168959
+ return blocks;
168960
+ }
168961
+ generateValue(v) {
168962
+ if (v.type === "String") {
168963
+ return JSON.stringify(v.value);
168964
+ }
168965
+ return v.value;
168966
+ }
168937
168967
  generateEnsure(ensure) {
168938
168968
  const blocks = [];
168939
168969
  const expr = ensure.expression.trim();
@@ -169185,7 +169215,12 @@ Rules:
169185
169215
  lines.push("");
169186
169216
  }
169187
169217
  lines.push(`Step ${stepIndex + 1} of ${context.steps.length}:`);
169188
- lines.push(`"${step.instruction}"`);
169218
+ if (step.type === "Call") {
169219
+ const args = step.args.map((a) => a.type === "String" ? JSON.stringify(a.value) : a.value).join(", ");
169220
+ lines.push(`Execute Call: ${step.intent}(${args})`);
169221
+ } else {
169222
+ lines.push(`"${step.instruction}"`);
169223
+ }
169189
169224
  if (step.resultVariable) {
169190
169225
  lines.push(`
169191
169226
  This step must store its result in a variable named: ${step.resultVariable}`);
@@ -169195,10 +169230,17 @@ This step must store its result in a variable named: ${step.resultVariable}`);
169195
169230
  Previous steps:`);
169196
169231
  for (let i = 0;i < stepIndex; i++) {
169197
169232
  const prevStep = context.steps[i];
169233
+ let desc = "";
169234
+ if (prevStep.type === "Call") {
169235
+ const args = prevStep.args.map((a) => a.type === "String" ? JSON.stringify(a.value) : a.value).join(", ");
169236
+ desc = `Call: ${prevStep.intent}(${args})`;
169237
+ } else {
169238
+ desc = `"${prevStep.instruction}"`;
169239
+ }
169198
169240
  if (prevStep.resultVariable) {
169199
- lines.push(`- Step ${i + 1}: ${prevStep.instruction} => const ${prevStep.resultVariable}`);
169241
+ lines.push(`- Step ${i + 1}: ${desc} => const ${prevStep.resultVariable}`);
169200
169242
  } else {
169201
- lines.push(`- Step ${i + 1}: ${prevStep.instruction}`);
169243
+ lines.push(`- Step ${i + 1}: ${desc}`);
169202
169244
  }
169203
169245
  }
169204
169246
  }
@@ -169247,10 +169289,16 @@ Generate ONLY the TypeScript code for this step (no explanations, no markdown).`
169247
169289
  }
169248
169290
  lines.push(`Implementation Steps (in order):`);
169249
169291
  context.steps.forEach((step, i) => {
169250
- let line = `${i + 1}. "${step.instruction}"`;
169292
+ let line = `${i + 1}. `;
169293
+ if (step.type === "Call") {
169294
+ const args = step.args.map((a) => a.type === "String" ? JSON.stringify(a.value) : a.value).join(", ");
169295
+ line += `Call: ${step.intent}(${args})`;
169296
+ } else {
169297
+ line += `"${step.instruction}"`;
169298
+ }
169251
169299
  if (step.resultVariable) {
169252
169300
  line += ` => const ${step.resultVariable}`;
169253
- if (step.resultType) {
169301
+ if (step.type === "Step" && step.resultType) {
169254
169302
  line += `: ${step.resultType}`;
169255
169303
  }
169256
169304
  }
@@ -169321,10 +169369,16 @@ Response Format:
169321
169369
  `);
169322
169370
  lines.push(`Required Steps:`);
169323
169371
  context.steps.forEach((step, i) => {
169324
- let line = `${i + 1}. "${step.instruction}"`;
169372
+ let line = `${i + 1}. `;
169373
+ if (step.type === "Call") {
169374
+ const args = step.args.map((a) => a.type === "String" ? JSON.stringify(a.value) : a.value).join(", ");
169375
+ line += `Call: ${step.intent}(${args})`;
169376
+ } else {
169377
+ line += `"${step.instruction}"`;
169378
+ }
169325
169379
  if (step.resultVariable) {
169326
169380
  line += ` => ${step.resultVariable}`;
169327
- if (step.resultType)
169381
+ if (step.type === "Step" && step.resultType)
169328
169382
  line += `: ${step.resultType}`;
169329
169383
  }
169330
169384
  lines.push(line);
@@ -169562,6 +169616,7 @@ ${request.prompt}`;
169562
169616
  var DEFAULT_MODEL3 = "llama3";
169563
169617
  var DEFAULT_BASE_URL = "http://localhost:11434";
169564
169618
  var DEFAULT_TEMPERATURE3 = 0.2;
169619
+ var DEFAULT_TIMEOUT = 90 * 60 * 1000;
169565
169620
 
169566
169621
  class OllamaProvider {
169567
169622
  name = "ollama";
@@ -169569,11 +169624,13 @@ class OllamaProvider {
169569
169624
  baseUrl;
169570
169625
  temperature;
169571
169626
  num_thread;
169627
+ timeout;
169572
169628
  constructor(config) {
169573
169629
  this.model = config.model || DEFAULT_MODEL3;
169574
169630
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
169575
169631
  this.temperature = config.temperature ?? DEFAULT_TEMPERATURE3;
169576
169632
  this.num_thread = config.num_thread;
169633
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
169577
169634
  }
169578
169635
  async generateCode(request) {
169579
169636
  try {
@@ -169632,15 +169689,18 @@ ${request.prompt}`;
169632
169689
  num_thread: this.num_thread
169633
169690
  }
169634
169691
  };
169635
- body.think = true;
169636
169692
  try {
169693
+ const controller = new AbortController;
169694
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
169637
169695
  const response = await fetch(url, {
169638
169696
  method: "POST",
169639
169697
  headers: {
169640
169698
  "Content-Type": "application/json"
169641
169699
  },
169642
- body: JSON.stringify(body)
169700
+ body: JSON.stringify(body),
169701
+ signal: controller.signal
169643
169702
  });
169703
+ clearTimeout(timeoutId);
169644
169704
  if (!response.ok) {
169645
169705
  throw new Error(`Ollama API error: ${response.status} - ${response.statusText}`);
169646
169706
  }
@@ -169780,7 +169840,7 @@ class AICodeGenerator {
169780
169840
  this.promptBuilder = new PromptBuilder;
169781
169841
  this.validator = new TypeScriptValidator;
169782
169842
  this.mode = options.mode || "full";
169783
- this.maxAttempts = options.maxAttempts ?? 5;
169843
+ this.maxAttempts = options.maxAttempts ?? 3;
169784
169844
  this.projectContext = options.projectContext;
169785
169845
  this.debug = options.debug ?? false;
169786
169846
  const providerName = options.provider || "gemini";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intend-it/core",
3
- "version": "3.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Core compiler and AI integration for the Intend programming language",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@intend-it/parser": "^1.2.1",
38
+ "@intend-it/parser": "^1.3.0",
39
39
  "@google/generative-ai": "^0.21.0"
40
40
  },
41
41
  "devDependencies": {
@@ -43,6 +43,6 @@
43
43
  "typescript": "^5.0.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "@intend-it/parser": ">=1.2.1"
46
+ "@intend-it/parser": ">=1.3.0"
47
47
  }
48
48
  }