Building a Local AI Coding Workbench from Scratch: Installation, Permissions, and Geometry Drawing in Practice

    Local AI coding tools have evolved from simple chat-based code generators into full workbenches that can understand project directories, create files, run commands, and iterate based on feedback. This article walks through the complete process of setting up a local AI coding workbench: preparing the environment, handling native dependency issues during installation, configuring credentials securely, choosing workspaces and permission levels wisely, designing effective prompts for complex tasks, and reviewing generated code. Two hands-on geometry examples—constructing a regular heptagon with a two-marked ruler and demonstrating the Delian problem (cube doubling)—illustrate how to turn mathematical constructions into working, animated web pages.

    1. From “Chat-Style Generation” to “Workspace-Style Coding”

    In recent years, AI coding tools have evolved from simply answering code questions into workbenches that can understand project directories, create files, modify code, run tests, and keep iterating based on results. Compared with an ordinary chat window, the core change is not whether the model “can write code,” but whether it can enter a real engineering environment and form a complete feedback loop around files, commands, execution results, and user feedback.

    From a practical standpoint, a local AI coding workbench typically includes the following components:

    1. Workspace management: You designate a directory as the project root, and the model reads and generates files within it.
    2. Permission control: Determines whether the model can create files, modify existing code, execute commands, or access resources outside the workspace.
    3. Mode selection: Different modes correspond to different task goals, such as general Q&A, code generation, debugging, and automated execution.
    4. Model configuration: Choose a model appropriate for the task’s complexity and configure the required access credentials.
    5. Execution feedback: The tool can run the project and feed compile errors, page screenshots, test results, or console output back to the model.

    So when evaluating such a tool, don’t just look at whether the first version of generated code is complete. Also consider how easy it is to install, whether it has clear permission boundaries, whether it runs reliably, and whether it can continuously fix problems in complex tasks.

    2. Preparing the Environment Before Installation

    Local workbenches are usually built on a runtime environment, a package manager, and native build tools. Before installing, confirm the following:

    • A recent version of a JavaScript runtime is installed;
    • The package manager can access software repositories normally;
    • The system has the compilers, linkers, and development headers needed to build native dependencies;
    • The current user has write access to the global installation directory or the project directory;
    • The terminal can run scripts and subprocesses normally.

    The installation command is usually provided by the tool’s vendor. Since this article isn’t tied to a specific product, always follow the official installation instructions of the project you’re using. After installation, verify that the command can be found by the system, then check the version:

    1. command -v workbench-command
    2. workbench-command --version

    1. Installation Failures Caused by Native Dependencies

    These tools often depend on terminal control, file watching, or process management components, some of which contain native code that must be compiled locally. If the system’s default compiler is outdated, you may hit issues like:

    • The compiler fails to recognize newer syntax;
    • The standard library version doesn’t meet dependency requirements;
    • The linking stage can’t find the required system libraries;
    • The installation stalls at the native module build stage.

    This doesn’t necessarily mean the tool itself is broken. Many enterprise systems have multiple compiler versions installed—it’s just that the newer one isn’t in the current terminal’s default environment. Start troubleshooting by checking which compilers are available:

    1. which g++
    2. g++ --version
    3. ls /opt/

    If the system provides a toolchain environment script, load it first, then retry the installation. For example:

    1. source /path/to/compiler-toolset/enable
    2. g++ --version
    3. package-manager install -g workbench-package

    Note that source only affects the current terminal session. If you want the toolchain available every time you open a terminal, you can add the initialization script to your shell configuration file—but in production environments, avoid blindly changing global configuration. First make sure it won’t affect other projects.

    3. Starting the Local Service and Completing Initial Configuration

    After installation, the workbench typically starts a local service and prints a local access URL in the terminal. You can open that URL in a browser to enter the graphical interface.

    A typical startup looks like:

    1. workbench-command --profile web

    Once started, the terminal usually shows something like:

    1. Web interface available at http://127.0.0.1:port

    The local address only means the service is listening on the current machine—it doesn’t imply remote access capability. To access it over a LAN, you’ll need additional configuration for the listening address, firewall, and authentication. Unless there’s a genuine need, don’t expose a local coding workbench directly to the public internet.

    After entering the page, you’ll generally need to configure access credentials. Store credentials securely—never write them directly into code repositories, screenshots, or log files. Recommendations:

    • Use environment variables or the system key store;
    • Never put credentials into prompts;
    • Never commit configuration files to public repositories;
    • Use sanitized configuration templates when sharing projects;
    • Revoke and regenerate credentials immediately if they leak.

    4. Choosing Workspaces, Modes, and Permissions Wisely

    When you first enter the interface, you’ll usually see options for workspace selection and run mode.

    1. Workspace Selection

    The workspace is the project directory the model can understand and operate on. It’s best to create a separate folder for each experiment, for example:

    1. geometry-demo/
    2. ├── index.html
    3. ├── src/
    4. ├── assets/
    5. ├── scripts/
    6. └── README.md

    An isolated directory offers three benefits:

    • Prevents the model from accidentally modifying other projects;
    • Makes it easy to compare results generated by different prompts;
    • Makes it easy to roll back using version control.

    Never use your entire home directory, system directories, or folders containing sensitive information as the workspace. For real business projects, copy the code into an experimental branch or a temporary directory first, then let the model make large-scale changes.

    2. Mode Selection

    Normal mode suits conceptual questions, code explanations, or small snippets. Code mode is better for:

    • Creating multiple project files;
    • Modifying existing HTML, CSS, and scripts;
    • Running local tests;
    • Iterating based on error messages;
    • Generating fairly complete interactive applications.

    If the task involves running in a browser, animation debugging, or file export, code mode is usually more efficient—but it also demands stronger review from the user.

    3. Permission Settings

    Permissions can be divided into three levels:

    • Read-only: The model can only view files; suitable for code analysis;
    • Restricted write: The model can modify files in the workspace but can’t execute high-risk commands;
    • Full access: The model can read and write files and run more operations; suitable for isolated experimental environments.

    Full access does not mean unconditional trust. Especially when a project involves deleting files, installing dependencies, running scripts, or accessing the network, you should still confirm each action. A safer workflow is to generate the solution with restricted permissions first, review the file changes, then temporarily elevate permissions to complete execution.

    5. Designing Prompts for Complex Tasks

    A geometry drawing task looks like just “generating a page,” but it actually involves mathematical derivation, interaction design, graphics rendering, animation control, and file export. If you only say “implement some geometric construction,” the model will often ignore construction logic, locus constraints, or interaction details.

    A better prompt should include at least the following:

    1. Mathematical goal: State clearly what object to construct and how the result will be verified.
    2. Input constraints: Define the unit length, initial points, segments, and circles.
    3. Operation order: Describe step by step how lines, circles, parallels, intersections, and auxiliary lines are produced.
    4. Interaction requirements: Specify which points can be dragged and which objects should stay fixed.
    5. Animation rules: Clarify which motions need displayed traces, and at which stages traces appear.
    6. Output format: Whether to generate a directly openable HTML file or split it into multiple source files.
    7. Acceptance criteria: For example, whether the construction stays stable, whether the animation can be paused, and whether GIF export works.

    A clearer task template looks like this:

    1. Create a geometry demo page that runs directly in the browser.
    2. Goal:
    3. Implement a compass-and-straightedge-style construction and show all steps.
    4. Mathematical objects:
    5. Define the unit length, initial points, auxiliary circles, and auxiliary lines; explain the geometric relationships of each object.
    6. Interaction:
    7. Allow dragging specified points; other points are computed automatically from geometric constraints.
    8. Provide play, pause, reset, and step buttons.
    9. Visuals:
    10. Use different colors for different object types;
    11. highlight the current step;
    12. show motion traces only at necessary stages.
    13. Output:
    14. Generate complete HTML, styles, and scripts;
    15. do not rely on inaccessible external resources;
    16. include usage instructions and verification steps.

    6. Case 1: Constructing a Regular Heptagon with a Two-Marked Ruler

    A “two-marked ruler” can be understood as a special straightedge with two fixed marks. When using it to construct a regular heptagon, the key isn’t drawing an approximate shape—it’s translating every geometric action into state changes a browser can execute.

    The page implementation can be split into four layers:

    1. Geometric Data Layer

    Represent geometric objects with points, segments, circles, and traces. For example:

    1. const points = {
    2. D: { x: 120, y: 360 },
    3. E: { x: 420, y: 360 }
    4. };
    5. const segments = [];
    6. const circles = [];
    7. const traces = [];

    All coordinates should be produced by unified geometric computation functions—avoid scattering hardcoded numbers throughout the drawing code.

    2. Construction Algorithm Layer

    The construction flow can be abstracted as:

    • Build the initial square;
    • Draw the perpendicular bisector of the base;
    • Draw an auxiliary circle centered at a designated vertex with the diagonal as radius;
    • Simulate the two-marked ruler’s translation and rotation so the two marks satisfy the target constraints;
    • Record the key points when the conditions are met;
    • Continue determining the heptagon’s vertices using perpendiculars, circles, and intersections;
    • Connect all vertices and verify side lengths and central angles.

    The hardest part is “solving the ruler’s position.” A numerical search works well: first enumerate rotation angles, then compute the constraint error between the ruler and the target lines and circles, and pick the position with minimal error. To make the animation more natural, use the search result as the target state and interpolate frame by frame toward it.

    3. Animation Layer

    The animation shouldn’t directly modify the final figure. Instead, maintain an explicit step state:

    1. const steps = [
    2. "draw-square",
    3. "draw-bisector",
    4. "move-ruler",
    5. "mark-intersection",
    6. "complete-polygon"
    7. ];

    Each step is responsible for:

    • Displaying the necessary auxiliary lines;
    • Updating the two-marked ruler’s position;
    • Controlling whether traces are recorded;
    • Marking the current key points;
    • Providing input for the next step.

    This approach is much easier to debug than juggling many timers, and it makes it simple to add “previous step” and “next step” buttons.

    4. Traces and GIF Export

    The user specifically requested that “only the necessary parts produce traces,” so trace recording should be state-controlled:

    1. if (state.recordTrace) {
    2. trace.push({ x: ruler.x, y: ruler.y });
    3. }

    GIF export requires drawing animation frames onto a canvas and passing them to an encoder. Keep in mind:

    • Control the frame rate to avoid oversized files;
    • Fix the canvas size before exporting;
    • Handle transparent backgrounds and line anti-aliasing properly;
    • Disable repeated clicks during export;
    • Show a progress indicator for long animations.

    7. Case 2: Demonstrating Cube Doubling with a Two-Marked Ruler

    The Delian problem (doubling the cube) is essentially constructing the cube root of a length. To make the page both mathematically sound and easy to understand, first convert the textual description into geometric constraints.

    You can organize it as follows:

    1. Set segment (OA=a) as the given length;
    2. Extend it along the same line and construct auxiliary points;
    3. Build perpendiculars and auxiliary lines based on the unit length;
    4. Connect designated points to form a diagonal line;
    5. Position the two-marked ruler so its two marks fall on the target line and the given line respectively;
    6. Obtain the target length through similar-triangle relationships;
    7. Display the ratio and computed result on the page.

    Don’t rely on visual approximation alone. Explicitly store the geometric relationships between points in code and recompute after every drag:

    1. function updateConstruction(input) {
    2. const a = clamp(input, 0.05, 0.95);
    3. const target = Math.cbrt(a);
    4. return {
    5. inputLength: a,
    6. targetLength: target,
    7. points: calculatePoints(a, target)
    8. };
    9. }

    Math.cbrt can serve as numerical validation, but it cannot replace the geometric construction itself. The page should display simultaneously:

    • The constructed segment;
    • The theoretical computed value;
    • The measured geometric value;
    • The error between the two.

    Only then can users judge whether the animation genuinely reflects the construction rather than merely displaying a precomputed answer.

    8. Review Checklist After Code Generation

    After an AI coding tool produces the first version of the code, review it from four angles.

    Functional Correctness

    • Does the page open directly?
    • Do all buttons respond?
    • Do geometric relationships still hold after dragging points?
    • Are pause and reset reliable?
    • Does the GIF generate correctly?

    Mathematical Correctness

    • Are the initial conditions satisfied?
    • Are the auxiliary lines and circles defined accurately?
    • Are intersection choices stable?
    • Do special inputs produce no solution or errors?
    • Does the result match the theoretical value?

    Engineering Quality

    • Is there duplicated code?
    • Is the coordinate system consistent?
    • Is window resizing handled correctly?
    • Are exception branches included?
    • Does it depend on undocumented external resources?

    Security

    • Were unnecessary system commands executed?
    • Were files outside the workspace read?
    • Were credentials written into the page or logs?
    • Were dependencies of unknown origin installed?
    • Was the local service exposed to untrusted networks?

    9. Overall Assessment: The Value Lies in the Loop, Not One-Shot Generation

    The real value of a local AI coding workbench lies mainly in its closed-loop capability: understand the project → modify files → run and verify → fix based on feedback. For simple pages, it can significantly reduce boilerplate coding; for geometric animations, visualizations, and interactive experiments, it helps developers quickly build validation prototypes.

    But these tools cannot replace developer judgment. Whether a mathematical construction holds, whether permissions are reasonable, whether dependencies are safe, and whether the generated code is maintainable still require human review. A mature workflow looks like this:

    1. Break down the problem and acceptance criteria first;
    2. Create the project with minimal permissions;
    3. Let the tool generate the first version of the structure;
    4. Run it and collect concrete errors;
    5. Fix in stages rather than demanding everything at once;
    6. Accept separately for math, interaction, and security;
    7. Finally, clean up dependencies, add documentation, and lock in a version.

    Treat it as a collaborating developer that executes operations—not a “chatbot that auto-generates answers”—and you’ll get far more value out of it while effectively reducing the risks of misoperation and runaway code.