editcodewithai 2.0.0 → 2.1.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 CHANGED
@@ -23,7 +23,11 @@ npm install editcodewithai
23
23
  Here's a basic example of how to use `performAiEdit` to update a file:
24
24
 
25
25
  ```typescript
26
- import { performAiEdit, LlmFunction } from "editcodewithai";
26
+ import {
27
+ performAiEdit,
28
+ FORMAT_INSTRUCTIONS,
29
+ LlmFunction,
30
+ } from "editcodewithai";
27
31
  import { VizFiles } from "@vizhub/viz-types";
28
32
 
29
33
  // Your function to call the LLM
@@ -102,6 +106,45 @@ The library handles several file operations automatically:
102
106
  - **Creating new files**: When the AI suggests new files to add
103
107
  - **Deleting files**: When the AI returns empty content for a file
104
108
 
109
+ ## Format Instructions
110
+
111
+ The library exports `FORMAT_INSTRUCTIONS` which contains the exact prompt instructions used for each edit format. This can be useful if you want to:
112
+
113
+ - Use the formatting instructions in your own custom prompts
114
+ - Understand exactly what instructions are sent to the LLM for each format
115
+ - Build your own AI editing tools using the same proven prompt patterns
116
+
117
+ ### Usage
118
+
119
+ ```typescript
120
+ import { FORMAT_INSTRUCTIONS } from "editcodewithai";
121
+
122
+ // Access instructions for a specific format
123
+ console.log(FORMAT_INSTRUCTIONS.diff);
124
+ console.log(FORMAT_INSTRUCTIONS.whole);
125
+ console.log(FORMAT_INSTRUCTIONS["diff-fenced"]);
126
+ console.log(FORMAT_INSTRUCTIONS.udiff);
127
+
128
+ // Use in your own prompts
129
+ const customPrompt = `
130
+ ${FORMAT_INSTRUCTIONS.diff}
131
+
132
+ Please update the following code to add error handling:
133
+ ${yourCodeHere}
134
+ `;
135
+ ```
136
+
137
+ ### Available Formats
138
+
139
+ The `FORMAT_INSTRUCTIONS` object contains instructions for these edit formats:
140
+
141
+ - **`whole`**: Instructions for returning complete file contents
142
+ - **`diff`**: Instructions for search-and-replace blocks
143
+ - **`diff-fenced`**: Instructions for search-and-replace blocks with file paths inside code fences
144
+ - **`udiff`**: Instructions for unified diff format
145
+
146
+ Each instruction set is a string containing detailed formatting guidelines that help ensure the LLM produces properly structured output that can be parsed by the library.
147
+
105
148
  ## Similar Projects
106
149
 
107
150
  - **Aider**: An AI pair programming tool that integrates with your terminal to assist in code editing within your local git repository. [https://aider.chat/](https://aider.chat/)
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { PerformAiEditParams, PerformAiEditResult } from "./types";
2
+ import { FORMAT_INSTRUCTIONS } from "./prompt";
2
3
  export type { LlmFunction, PerformAiEditParams, PerformAiEditResult, EditFormat, } from "./types";
4
+ export { FORMAT_INSTRUCTIONS };
3
5
  /**
4
6
  * Core AI logic for:
5
7
  * - Building the prompt (including context)
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORMAT_INSTRUCTIONS = void 0;
3
4
  exports.performAiEdit = performAiEdit;
4
5
  const llm_code_format_1 = require("llm-code-format");
5
6
  const prompt_1 = require("./prompt");
7
+ Object.defineProperty(exports, "FORMAT_INSTRUCTIONS", { enumerable: true, get: function () { return prompt_1.FORMAT_INSTRUCTIONS; } });
6
8
  const metadata_1 = require("./metadata");
7
9
  const fileUtils_1 = require("./fileUtils");
8
10
  const debug = false;
package/dist/prompt.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { EditFormat } from "./types";
2
2
  export declare const PROMPT_TEMPLATE_VERSION = 1;
3
+ export declare const FORMAT_INSTRUCTIONS: Record<EditFormat, string>;
3
4
  /**
4
5
  * Assembles the full prompt by combining task, files context, and formatting instructions
5
6
  */
package/dist/prompt.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROMPT_TEMPLATE_VERSION = void 0;
3
+ exports.FORMAT_INSTRUCTIONS = exports.PROMPT_TEMPLATE_VERSION = void 0;
4
4
  exports.assembleFullPrompt = assembleFullPrompt;
5
5
  // Versions of the prompt template.
6
6
  exports.PROMPT_TEMPLATE_VERSION = 1;
7
7
  // Template pieces
8
8
  const TASK = (prompt) => `## Your Task\n\n${prompt}`;
9
9
  const FILES = (filesContext) => `## Original Files\n\n${filesContext}`;
10
- const FORMAT_INSTRUCTIONS = {
10
+ exports.FORMAT_INSTRUCTIONS = {
11
11
  whole: [
12
12
  "## Formatting Instructions\n\n",
13
13
  "Suggest changes to the original files using this exact format:\n\n",
@@ -64,6 +64,6 @@ const FORMAT_INSTRUCTIONS = {
64
64
  * Assembles the full prompt by combining task, files context, and formatting instructions
65
65
  */
66
66
  function assembleFullPrompt({ filesContext, prompt, editFormat = "whole", }) {
67
- const FORMAT = FORMAT_INSTRUCTIONS[editFormat];
67
+ const FORMAT = exports.FORMAT_INSTRUCTIONS[editFormat];
68
68
  return [TASK(prompt), FILES(filesContext), FORMAT].join("\n\n");
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editcodewithai",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Edit Code With AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,20 +40,20 @@
40
40
  },
41
41
  "homepage": "https://github.com/vizhub-core/editcodewithai#readme",
42
42
  "dependencies": {
43
- "@vizhub/viz-types": "^0.1.0",
44
- "@vizhub/viz-utils": "^1.1.0",
45
- "dotenv": "^17.0.1",
43
+ "@vizhub/viz-types": "^0.3.0",
44
+ "@vizhub/viz-utils": "^1.3.0",
45
+ "dotenv": "^17.2.0",
46
46
  "llm-code-format": "^2.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@langchain/core": "^0.3.61",
50
- "@langchain/openai": "^0.5.16",
51
- "langchain": "^0.3.29",
49
+ "@langchain/core": "^0.3.66",
50
+ "@langchain/openai": "^0.6.2",
51
+ "langchain": "^0.3.30",
52
52
  "cors": "^2.8.5",
53
53
  "express": "^5.1.0",
54
54
  "npm-check-updates": "^18.0.1",
55
55
  "prettier": "^3.6.2",
56
- "puppeteer": "^24.11.2",
56
+ "puppeteer": "^24.14.0",
57
57
  "ts-node": "^10.9.2",
58
58
  "typescript": "^5.8.3",
59
59
  "vitest": "^3.2.4"