@intend-it/core 3.0.0 → 3.0.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 (2) hide show
  1. package/dist/index.js +158 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -168885,6 +168885,26 @@ class TypeScriptGenerator {
168885
168885
  content: `return ${lastStep.resultVariable};`,
168886
168886
  indent: 1
168887
168887
  });
168888
+ } else {
168889
+ const returnBase = intent.returnType.base.toLowerCase();
168890
+ if (returnBase !== "void" && returnBase !== "undefined") {
168891
+ blocks.push({ type: "comment", content: "", indent: 0 });
168892
+ blocks.push({
168893
+ type: "statement",
168894
+ content: `return null as any; // PLACEHOLDER - AI will replace`,
168895
+ indent: 1
168896
+ });
168897
+ }
168898
+ }
168899
+ } else {
168900
+ const returnBase = intent.returnType.base.toLowerCase();
168901
+ if (returnBase !== "void" && returnBase !== "undefined") {
168902
+ blocks.push({ type: "comment", content: "", indent: 0 });
168903
+ blocks.push({
168904
+ type: "statement",
168905
+ content: `return null as any; // PLACEHOLDER - AI will replace`,
168906
+ indent: 1
168907
+ });
168888
168908
  }
168889
168909
  }
168890
168910
  return blocks;
@@ -169327,6 +169347,86 @@ Respond with APPROVED or ISSUES + FIX as specified.`);
169327
169347
  `);
169328
169348
  }
169329
169349
  }
169350
+ // src/utils/debug.ts
169351
+ var COLORS = {
169352
+ reset: "\x1B[0m",
169353
+ dim: "\x1B[2m",
169354
+ cyan: "\x1B[36m",
169355
+ yellow: "\x1B[33m",
169356
+ magenta: "\x1B[35m",
169357
+ green: "\x1B[32m",
169358
+ blue: "\x1B[34m",
169359
+ gray: "\x1B[90m"
169360
+ };
169361
+
169362
+ class DebugLogger {
169363
+ enabled;
169364
+ constructor(enabled = false) {
169365
+ this.enabled = enabled;
169366
+ }
169367
+ isEnabled() {
169368
+ return this.enabled;
169369
+ }
169370
+ setEnabled(enabled) {
169371
+ this.enabled = enabled;
169372
+ }
169373
+ header(title) {
169374
+ if (!this.enabled)
169375
+ return;
169376
+ console.log();
169377
+ console.log(`${COLORS.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLORS.reset}`);
169378
+ console.log(`${COLORS.cyan}┃${COLORS.reset} ${COLORS.yellow}\uD83D\uDD0D DEBUG:${COLORS.reset} ${title}`);
169379
+ console.log(`${COLORS.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLORS.reset}`);
169380
+ }
169381
+ prompt(label, content) {
169382
+ if (!this.enabled)
169383
+ return;
169384
+ console.log();
169385
+ console.log(`${COLORS.magenta}┌─ ${label} ─────────────────────────────────────────────────────────────────${COLORS.reset}`);
169386
+ this.dimmedBlock(content);
169387
+ console.log(`${COLORS.magenta}└──────────────────────────────────────────────────────────────────────────────${COLORS.reset}`);
169388
+ }
169389
+ thinking(content) {
169390
+ if (!this.enabled || !content)
169391
+ return;
169392
+ console.log();
169393
+ console.log(`${COLORS.blue}┌─ \uD83E\uDDE0 Model Thinking ──────────────────────────────────────────────────────────${COLORS.reset}`);
169394
+ this.dimmedBlock(content);
169395
+ console.log(`${COLORS.blue}└──────────────────────────────────────────────────────────────────────────────${COLORS.reset}`);
169396
+ }
169397
+ response(label, content) {
169398
+ if (!this.enabled)
169399
+ return;
169400
+ console.log();
169401
+ console.log(`${COLORS.green}┌─ ${label} ─────────────────────────────────────────────────────────────────${COLORS.reset}`);
169402
+ this.dimmedBlock(content);
169403
+ console.log(`${COLORS.green}└──────────────────────────────────────────────────────────────────────────────${COLORS.reset}`);
169404
+ }
169405
+ log(message) {
169406
+ if (!this.enabled)
169407
+ return;
169408
+ console.log(`${COLORS.dim} [debug] ${message}${COLORS.reset}`);
169409
+ }
169410
+ info(key, value) {
169411
+ if (!this.enabled)
169412
+ return;
169413
+ console.log(`${COLORS.dim} ${key}: ${COLORS.reset}${value}`);
169414
+ }
169415
+ dimmedBlock(content) {
169416
+ const lines = content.split(`
169417
+ `);
169418
+ const maxLines = 100;
169419
+ const showLines = lines.slice(0, maxLines);
169420
+ for (const line of showLines) {
169421
+ console.log(`${COLORS.dim}│ ${line}${COLORS.reset}`);
169422
+ }
169423
+ if (lines.length > maxLines) {
169424
+ console.log(`${COLORS.dim}│ ... (${lines.length - maxLines} more lines truncated)${COLORS.reset}`);
169425
+ }
169426
+ }
169427
+ }
169428
+ var debugLogger = new DebugLogger(false);
169429
+
169330
169430
  // src/ai/providers/gemini.ts
169331
169431
  var DEFAULT_MODEL2 = "gemini-flash-latest";
169332
169432
  var DEFAULT_TEMPERATURE2 = 0.2;
@@ -169350,12 +169450,28 @@ class GeminiProvider {
169350
169450
  }
169351
169451
  async generateCode(request) {
169352
169452
  try {
169453
+ if (request.debug) {
169454
+ debugLogger.setEnabled(true);
169455
+ debugLogger.header(`Gemini API Call (${this.model})`);
169456
+ debugLogger.prompt("System Prompt", request.systemPrompt || "(none)");
169457
+ debugLogger.prompt("User Prompt", request.prompt);
169458
+ }
169353
169459
  const response = await this.makeRequest(request);
169460
+ const code = this.extractCode(response);
169461
+ let thinking;
169462
+ if (request.debug) {
169463
+ const fullText = response?.candidates?.[0]?.content?.parts?.[0]?.text || "";
169464
+ debugLogger.response("Gemini Response", fullText);
169465
+ }
169354
169466
  return {
169355
- code: this.extractCode(response),
169356
- success: true
169467
+ code,
169468
+ success: true,
169469
+ thinking
169357
169470
  };
169358
169471
  } catch (error) {
169472
+ if (request.debug) {
169473
+ debugLogger.log(`Error: ${error.message}`);
169474
+ }
169359
169475
  return {
169360
169476
  code: "",
169361
169477
  success: false,
@@ -169461,12 +169577,39 @@ class OllamaProvider {
169461
169577
  }
169462
169578
  async generateCode(request) {
169463
169579
  try {
169580
+ if (request.debug) {
169581
+ debugLogger.setEnabled(true);
169582
+ debugLogger.header(`Ollama API Call (${this.model})`);
169583
+ debugLogger.prompt("System Prompt", request.systemPrompt || "(none)");
169584
+ debugLogger.prompt("User Prompt", request.prompt);
169585
+ }
169464
169586
  const response = await this.makeRequest(request);
169587
+ const code = this.extractCode(response);
169588
+ let thinking;
169589
+ const fullText = response?.response || "";
169590
+ if (response?.thinking) {
169591
+ thinking = response.thinking;
169592
+ } else {
169593
+ const thinkMatch = fullText.match(/<think>([\s\S]*?)<\/think>/);
169594
+ if (thinkMatch) {
169595
+ thinking = thinkMatch[1].trim();
169596
+ }
169597
+ }
169598
+ if (request.debug) {
169599
+ if (thinking) {
169600
+ debugLogger.thinking(thinking);
169601
+ }
169602
+ debugLogger.response("Ollama Response", fullText);
169603
+ }
169465
169604
  return {
169466
- code: this.extractCode(response),
169467
- success: true
169605
+ code,
169606
+ success: true,
169607
+ thinking
169468
169608
  };
169469
169609
  } catch (error) {
169610
+ if (request.debug) {
169611
+ debugLogger.log(`Error: ${error.message}`);
169612
+ }
169470
169613
  return {
169471
169614
  code: "",
169472
169615
  success: false,
@@ -169489,6 +169632,7 @@ ${request.prompt}`;
169489
169632
  num_thread: this.num_thread
169490
169633
  }
169491
169634
  };
169635
+ body.think = true;
169492
169636
  try {
169493
169637
  const response = await fetch(url, {
169494
169638
  method: "POST",
@@ -169631,12 +169775,14 @@ class AICodeGenerator {
169631
169775
  validator;
169632
169776
  maxAttempts;
169633
169777
  projectContext;
169778
+ debug;
169634
169779
  constructor(options) {
169635
169780
  this.promptBuilder = new PromptBuilder;
169636
169781
  this.validator = new TypeScriptValidator;
169637
169782
  this.mode = options.mode || "full";
169638
169783
  this.maxAttempts = options.maxAttempts ?? 5;
169639
169784
  this.projectContext = options.projectContext;
169785
+ this.debug = options.debug ?? false;
169640
169786
  const providerName = options.provider || "gemini";
169641
169787
  if (providerName === "ollama") {
169642
169788
  if (!options.ollamaConfig) {
@@ -169704,7 +169850,8 @@ class AICodeGenerator {
169704
169850
  while (attempts < limit) {
169705
169851
  const response = await this.provider.generateCode({
169706
169852
  systemPrompt,
169707
- prompt
169853
+ prompt,
169854
+ debug: this.debug
169708
169855
  });
169709
169856
  if (!response.success) {
169710
169857
  throw new Error(`AI generation failed: ${response.error}`);
@@ -169788,7 +169935,8 @@ ${logicIssues.issues.join(`
169788
169935
  const prompt = this.promptBuilder.buildReviewerPrompt(context, code);
169789
169936
  const response = await this.provider.generateCode({
169790
169937
  systemPrompt,
169791
- prompt
169938
+ prompt,
169939
+ debug: this.debug
169792
169940
  });
169793
169941
  if (!response.success) {
169794
169942
  console.warn(` ⚠️ Logic verification skipped (AI error)`);
@@ -169839,7 +169987,8 @@ Focus on the root cause. Keep it concise.
169839
169987
  console.log(` \uD83E\uDD16 Analyzing failure...`);
169840
169988
  const response = await this.provider.generateCode({
169841
169989
  systemPrompt: "You are a helpful coding assistant explaining compile errors.",
169842
- prompt
169990
+ prompt,
169991
+ debug: this.debug
169843
169992
  });
169844
169993
  if (response.success) {
169845
169994
  console.log(`
@@ -169959,6 +170108,7 @@ function computeHash(content, config) {
169959
170108
  }
169960
170109
  export {
169961
170110
  generateTypeScript,
170111
+ debugLogger,
169962
170112
  computeHash,
169963
170113
  TypeScriptValidator,
169964
170114
  TypeScriptGenerator,
@@ -169967,5 +170117,6 @@ export {
169967
170117
  GeminiProvider,
169968
170118
  GeminiClient,
169969
170119
  FileSystemCAS,
170120
+ DebugLogger,
169970
170121
  AICodeGenerator
169971
170122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intend-it/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
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.0",
38
+ "@intend-it/parser": "^1.2.1",
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.0"
46
+ "@intend-it/parser": ">=1.2.1"
47
47
  }
48
48
  }