Skip to content

refactor(registry/coder-labs/modules/auggie)!: remove agentapi, tasks and start logic - #1177

Open
35C4n0r wants to merge 7 commits into
mainfrom
35C4n0r/migrate-auggie
Open

35C4n0r wants to merge 7 commits into
mainfrom
35C4n0r/migrate-auggie

Conversation

@35C4n0r

@35C4n0r 35C4n0r commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Closes REG-82

Refactor coder-labs/auggie to install and configure Auggie CLI only, matching the claude-code, codex, copilot, cursor-cli, opencode, and kiro-cli migrations. Changes beyond the AgentAPI removal are limited to what the current Auggie docs require.

  • Replace the agentapi module with coder-utils; drop Tasks/web-app inputs (order, group, install_agentapi, agentapi_version, ai_prompt, report_tasks, cli_app, web_app_display_name, cli_app_display_name, continue_previous_conversation, interaction_mode), the task_app_id output, the start script, and the task-reporting coder MCP server.
  • folder is renamed to workdir, optional, and created if missing.
  • Install stays on the documented npm install -g @augmentcode/auggie (into ~/.npm-global, as before), now on every start when install_auggie = true; with false, auggie must be on PATH. Removed the auggie_version validation; it is base64-encoded into the script.
  • mcp and mcp_files are added to ~/.augment/settings.json with auggie mcp add-json at install time instead of --mcp-config flags at launch. Existing names are kept with a per-name warning, matching the CLI without --replace.
  • rules are written to the user rules folder (~/.augment/rules/coder-module.md) instead of a --rules flag. auggie_model sets the model key in ~/.augment/settings.json instead of --model.
  • augment_session_token is now sensitive and AUGMENT_SESSION_AUTH is only created when set; it was previously also rendered into the start script.
  • Add scripts output; README reduced to examples and doc links; rewrite tests. Bump to 1.0.0.

Important

Model calls and MCP connections were not verified: they need an Augment account, which was not available.

Decision log
Topic Auggie CLI reality (docs, verified on 0.36.0) Decision
Install Only documented method is npm install -g @augmentcode/auggie, Node 20+ Keep npm with the existing ~/.npm-global prefix (keeps auggie upgrade writable); keep the node/npm check and .bashrc sourcing
Version npm tags; interactive mode auto-updates unless disabled Pass straight to npm; README links the auto-update docs instead of adding a new input
Auth AUGMENT_SESSION_AUTH env var with the auggie token print JSON coder_env only, gated on non-empty, never in scripts or logs
MCP ~/.augment/settings.json mcpServers; auggie mcp add-json works without login, preserves JSONC, and non-interactively exits 3 with "already exists" unless --replace Use auggie mcp add-json; existing servers win with a warning; no jq edit of MCP
Rules --rules flag, or auto-loaded ~/.augment/rules/*.md (always applied) Write rules to ~/.augment/rules/coder-module.md; auggie rules list shows it
Model Docs show --model//model; settings schema has model, and with it set auggie logs Ignoring --model=<value> when no models are available Keep auggie_model by writing model with jq; a JSONC settings file is left unchanged with a warning
Workdir No trust file; indexing confirmation is a launch flag (--allow-indexing) Create only
Validations auggie_version and interaction_mode had them Removed

Testing

  • terraform test (6 passed), bun test main.test.ts (12 passed, container-based), terraform fmt, terraform validate, prettier, shellcheck on the rendered script (all severities)
  • Real Auggie in codercom/enterprise-node:latest via the module's rendered pre_install and install scripts:
    • pinned 0.35.0 installed, CODER_SCRIPT_BIN_DIR symlink and profile PATH entries created
    • pre_install seeded settings kept (theme, user shared server wins with a warning); everything and mcp_files server added; auggie mcp list shows all three
    • auggie rules list shows ~/.augment/rules/coder-module.md; the model key is picked up (Ignoring --model=test-model because no model options are available without login)
    • rerun is idempotent (no duplicate profile lines, settings unchanged); switching to latest installs 0.36.0
    • token only in AUGMENT_SESSION_AUTH (dummy token gets a 401 from Augment), absent from scripts, logs, and ~/.augment; rotated value applied
  • Dogfood workspace from a test template: Auggie 0.36.0 installed and linked into CODER_SCRIPT_BIN_DIR, downstream coder exp sync script ran after pre_install, install, post_install; seeded settings kept, user shared server kept with a warning, everything and mcp_files servers added, model set, rules written, AUGMENT_SESSION_AUTH set
  • Verified auggie --help, auggie mcp --help, and duplicate auggie mcp add-json behavior (exit 3, existing entry and JSONC kept) on 0.36.0

Generated with Coder Agents.

@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

REG-82

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Module Scorecard Check

coder-labs/auggie: first scorecard, 60 / 100

No specific score is required to contribute, but modules with higher scores are more likely to be approved by the Coder team and widely used.

Full scorecard for this PR
Presentation & Onboarding Agent Integration Credential Hygiene Restricted-Environment Readiness Engineering Quality Overall
6 / 17 15 / 25 20 / 20 7 / 20 7 / 10 60 / 100
Drilldown

Presentation & Onboarding — 6 / 17

Criterion Max Score Notes
Configuration-mode examples 12 half README shows launcher/coder_app, MCP+rules, pinned version, and downstream-sync examples with sensible defaults, but the key "bring-your-own binary" mode (install_auggie=false) is never shown as a README example — only described in the variable description/main.tf.
Visual preview 5 0 No image, GIF, or video anywhere in the README.

Credential Hygiene — 20 / 20

Criterion Max Score Notes
Secrets marked sensitive 16 full augment_session_token is sensitive = true; README examples reference var.augment_session_token with no inline literal/placeholder secret values.
Non-hardcoded auth path 4 full README's "Authentication" section documents auggie login as the non-hardcoded path and auggie token print to populate the sensitive variable, avoiding pasted keys.

Restricted-Environment Readiness — 7 / 20

Criterion Max Score Notes
Mirrorable artifact source 5 0 Install uses npm install -g @augmentcode/auggie[@version]; no variable overrides the npm registry/download URL — auggie_version only pins a version string, not a source URL.
Bring-your-own binary 10 half install_auggie = false skips install and validates a pre-existing auggie on PATH (enforced in scripts/install.sh.tftpl), but this mode is only documented in the main.tf variable description, not demonstrated or called out in the README itself.
Egress transparency 3 0 No dedicated README section enumerating install/runtime endpoints (e.g., npm registry, Augment API); endpoints are not documented anywhere.
Runs without sudo 2 full scripts/install.sh.tftpl never invokes sudo; npm install uses a user-writable $HOME/.npm-global prefix, confirmed by code inspection.

Engineering Quality — 7 / 10

Criterion Max Score Notes
Input quality 6 half All variables have clear descriptions and sensible defaults (e.g., install_auggie=true, auggie_version=""), but no validation blocks are present anywhere in main.tf.
Test coverage 4 full main.tftest.hcl covers defaults, workdir trimming, secret non-leakage, encoding of inputs, and scripts output ordering; main.test.ts provides extensive end-to-end container tests (install paths, MCP merging, rules, model settings, secret handling).

Agent Integration — 15 / 25

Criterion Max Score Notes
AI governance 10 0 No mention of Coder AI Gateway or Agent Firewall anywhere in the README; v1 changelog explicitly removes prior AgentAPI integration without replacement governance story.
Dashboard entry point 5 full README's "Standalone mode with a launcher app" example shows a full coder_app resource with open_in, icon, and launch command.
Session continuity 5 full The launcher example explicitly runs auggie --continue to resume the previous conversation, documenting session continuity across relaunches.
Managed configuration 5 full README documents managed MCP servers (mcp, mcp_files), rules (rules → ~/.augment/rules/coder-module.md), and model config (auggie_model → ~/.augment/settings.json).

Overall — 60 / 100

Raw 55 / 92 → round(55 / 92 × 100) = 60

Tip

You can run this locally by telling your agent: "review this module against .github/scorecard/SCORECARD.md".


Scored against SCORECARD.md with solstice-1. Language-model scores are advisory.

@coder

coder Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Automated review requested by @matifali. Please sanity-check before acting on it.

Summary

The agentapi module is replaced with coder-utils@0.0.1. The start script, task_app_id, the coder MCP server (coder_mcp.json with CODER_MCP_APP_STATUS_SLUG/CODER_MCP_AI_AGENTAPI_URL), and the Tasks/launch inputs are removed. folder is renamed to workdir and made optional. MCP servers now go through auggie mcp add-json into ~/.augment/settings.json, rules into ~/.augment/rules/coder-module.md, and the model into the settings.json model key. augment_session_token is now sensitive and AUGMENT_SESSION_AUTH is only set when non-empty; v0 also rendered it into the start script. Version goes 0.3.1 → 1.0.0 in all README examples, and the migration note is thorough.

Correctness

  • main.tf (121 lines) is self-consistent: all 7 template args are used, and there are no dangling references.
  • Install is npm into ~/.npm-global, same as v0 (v0 also reinstalled on every start). It validates the binary, symlinks into CODER_SCRIPT_BIN_DIR, and adds PATH entries to shell profiles.
  • Note in the PR body: not verified in a dogfood workspace (provisioner out of disk). coder exp sync ordering, coder_env delivery, and restart behavior on a real agent are untested. That should happen before this leaves draft.

Leftovers

  • None in module code. Grep hits are only the README migration note and the agentapi/test-util import.

Findings

should-fix S1 (blocking for me): changes to module-managed MCP servers never apply after the first start. scripts/install.sh.tftpl:140-155, test at main.test.ts:280
add_mcp_servers keeps any existing name. Since ~/.augment/settings.json persists in the home volume, a server the module itself added on start 1 counts as "existing" on start 2. If a template admin changes the filesystem server's args or URL in mcp/mcp_files, workspaces keep the old definition forever and only log a warning. Removing a server from mcp doesn't remove it either.
This regresses v0, where user_mcp.json was rewritten every start and passed with --mcp-config, so it always reflected the current template. (claude-code's add_mcp_servers uses claude mcp add-json without replace and, as far as I know, behaves the same; I didn't verify that here, but it may be worth a series-level decision.)
Fix: record the module-owned server names under $HOME/.coder-modules/coder-labs/auggie/ and run auggie mcp add-json --replace for those names, while user-added names still win. At minimum, document that updates require manual auggie mcp remove. Add a test that runs install twice with a changed mcp.

should-fix S2: rules can't be cleared. scripts/install.sh.tftpl:184-187
When rules is unset, write_rules returns without touching ~/.augment/rules/coder-module.md, so removed rules keep applying to every session. The module owns this filename, so rm -f "$RULES_FILE" when ARG_RULES is empty is safe.

nit N1: v0 leftovers on persistent homes. ~/.augment/coder_mcp.json holds a CODER_AGENT_TOKEN plus the CODER_MCP_APP_STATUS_SLUG and CODER_MCP_AI_AGENTAPI_URL=http://localhost:3284 entries. ~/.augment/user_mcp.json, ~/.augment/rules.md, and ~/.auggie-module/ also remain. They're inert because v1 doesn't pass --mcp-config, but deleting coder_mcp.json (it holds a credential) during install, or mentioning it in the migration note, would be tidy.

nit N2: jq is now required but not documented. scripts/install.sh.tftpl:35-40,163,201: mcp, mcp_files, and auggie_model now hard-fail without jq. The README (line 11) only lists Node/npm. Add jq to the prerequisite sentence.

nit N3: variable attribute order. main.tf:74-75: augment_session_token puts sensitive before default. AGENTS.md specifies description → type → default → validation → sensitive.

nit N4: constraints are inconsistent with the series. main.tf:2 keeps required_version = ">= 1.0"; kiro-cli and claude-code use >= 1.9. main.tf:7 says coder >= 2.12, but coder-utils needs >= 2.13.

nit N5: tests still import from the agentapi module. main.test.ts:18-21 imports from ../../../coder/modules/agentapi/test-util. This is the same series-wide issue as kiro N4.

nit N6: MCP names with newlines break pairing. scripts/install.sh.tftpl:146,154: the read name && read server pairing breaks if a server name contains a newline. This is an edge case; jq -c '... | [.key, .value]' with a single read would be more robust.

nit N7: the PR body says the npm install happens "now on every start", but v0 also reinstalled every start. Not a regression; just a wording fix.

Tests

  • auggie.tftest.hcl is replaced by main.tftest.hcl with 6 runs: defaults, workdir trim and encoding, session token env var not in the script, encoded inputs, and scripts ordering.
  • main.test.ts was rewritten with 12 container tests covering bring-your-own binary, pinned/latest npm, npm failure, workdir, MCP keep-existing merge plus a missing file, rules, model preserving settings, JSONC left unchanged, token not leaking, and pre/post scripts. The mock (testdata/auggie-mock.sh) faithfully emulates add-json exit 3.
  • Gaps: a second run with changed mcp (S1); clearing rules (S2); missing jq; dropping the interaction_mode validation tests is correct.

CI and reviews

  • Passing: Validate Terraform output (TS and terraform tests, validate, shellcheck), lint, typos/format, Validate README files. Compare module scores against main was still in progress; the scorecard bot gave 72/100.
  • No human reviews or review comments; nothing unresolved.

Series consistency

It follows the same layout as kiro-cli and claude-code (coder-utils, .coder-modules/coder-labs/auggie, optional workdir, scripts output, launcher coder_app example, migration WARNING). The MCP keep-existing semantics likely match claude-code (unverified; see S1). The required_version mismatch is noted in N4.

@35C4n0r

35C4n0r commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Re S1 (module-managed MCP servers never update after the first start): not changing this here.

"Existing name wins" is intentional and matches the rest of the series and claude-code on main:

Auggie does the same via a non-interactive auggie mcp add-json, so servers users add or edit in ~/.augment/settings.json are never overwritten. The trade-off (template edits to an already-added name don't reach existing workspaces) applies to every module. If we want module-owned servers to be refreshed, it should be one series-wide change (including claude-code), not an auggie-only divergence.

Generated with Coder Agents.

@35C4n0r
35C4n0r marked this pull request as ready for review October 16, 2026 18:01

write_rules() {
if [ -z "$${ARG_RULES}" ]; then
return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove ~/.augment/rules/coder-module.md when rules is empty? Auggie automatically loads this file, so clearing the template input leaves the previous rules active after a restart. Previously, clearing the input stopped passing --rules to the CLI.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e95795a. When rules is empty, the module now removes ~/.augment/rules/coder-module.md (a file the module owns), so clearing the input stops applying the previous rules on the next start. Added stale-rules-are-removed-when-rules-is-empty, which fails without the fix.

Generated with Coder Agents.


mkdir -p "$(dirname "$${SETTINGS_FILE}")"
echo "$${existing}" | jq --arg model "$${ARG_AUGGIE_MODEL}" '.model = $model' > "$${SETTINGS_FILE}.tmp"
mv "$${SETTINGS_FILE}.tmp" "$${SETTINGS_FILE}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@35C4n0r I think we could preserve the existing file permissions when updating the model here. Replacing settings.json with the temporary file makes a previously owner-only file readable by other users who can access its directory. I reproduced this with another user in the same group, who could then read the dummy MCP credentials used in the test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 795ddb4. setup_model now rewrites settings.json in place instead of replacing it with a temp file, so the existing mode and owner are kept (and a symlinked file is written through). Added model-keeps-settings-permissions, which seeds a 0600 file and checks it is still 0600; it fails without the fix.

Generated with Coder Agents.

…n rules is empty

Auggie auto-loads ~/.augment/rules/*.md, so a cleared rules input kept
applying the previous rules after restart.
…ns when setting the model

Replacing the file with a temp file reset an owner-only settings.json to
the default mode, exposing MCP credentials to other users.
@DevelopmentCats

Copy link
Copy Markdown
Collaborator

/review

@DevelopmentCats DevelopmentCats left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full review of 795ddb4 with the repo's AGENTS.md conventions and the sibling coder-utils based modules as context.

Verified locally

  • terraform validate and terraform fmt -check pass on the module
  • prettier --check passes on all changed files
  • shellcheck on the rendered install script (through style severity): only the expected SC2016 infos from the ${ARG_*} template placeholders
  • The new main.tftest.hcl expectations match the coder-utils contract: scripts output order is pre_install, install, post_install, and the coder-labs-auggie-* naming falls out of module_directory
  • Module data moved to ~/.coder-modules/coder-labs/auggie per the AGENTS.md layout, #!/usr/bin/env bash shebangs everywhere (including the mock), and set -u ordering is compliant (.bashrc is sourced before set -euo pipefail)
  • augment_session_token is sensitive, gated on non-empty via count, and never rendered into scripts; the test suite asserts the no-leak property including the base64 encoding
  • Version bumped to 1.0.0 in all README examples; breaking changes documented in the WARNING block; coder-utils pinned to 0.0.1 like coder/claude-code

Not verified here

  • terraform test fails in this environment with template ID is missing: CODER_WORKSPACE_TEMPLATE_ID is required from the coder provider data source, but coder/claude-code on main fails identically, so this is environmental and not caused by this PR
  • bun test main.test.ts needs Docker, which this workspace lacks, so the container tests the PR reports are unverified by me

Findings

Nothing blocking. Three suggestions and one nit inline. Two smaller observations:

  • require_jq exits 1 when jq is missing and mcp or auggie_model is set. A loud failure is defensible since the alternative is silently dropping config, but it is a new hard dependency compared to v0, which wrote JSON with plain bash. Fine if intended.
  • The PR description reports 12 passing bun tests but the suite now contains 14; consider refreshing the testing section.
  • Upgraded workspaces keep the stale v0 files ~/.augment/coder_mcp.json and ~/.augment/user_mcp.json. Nothing reads them anymore, so this is harmless, but a cleanup rm -f next to the write_rules logic would keep things tidy. Not worth blocking on.

The rest of the migration is clean: MCP handling matches the real CLI behavior (existing names win, the exit 3 path is handled), model writing preserves file permissions and leaves JSONC settings alone, and the README examples and launcher app are correct.

Generated by the Coder agent in response to /review.

Comment on lines 53 to 57
variable "mcp" {
type = string
description = "MCP configuration as a JSON string for the auggie cli, check https://docs.augmentcode.com/cli/integrations#mcp-integrations"
description = "MCP servers as a JSON string ({\"mcpServers\": {...}}), added to ~/.augment/settings.json with `auggie mcp add-json`. Servers already configured win on duplicate names. See https://docs.augmentcode.com/cli/integrations#mcp-integrations"
default = ""
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An invalid mcp string is only caught at runtime today: it is skipped with a warning after the workspace has already started. A plan-time validation surfaces the typo when the template is applied instead:

Suggested change
variable "mcp" {
type = string
description = "MCP configuration as a JSON string for the auggie cli, check https://docs.augmentcode.com/cli/integrations#mcp-integrations"
description = "MCP servers as a JSON string ({\"mcpServers\": {...}}), added to ~/.augment/settings.json with `auggie mcp add-json`. Servers already configured win on duplicate names. See https://docs.augmentcode.com/cli/integrations#mcp-integrations"
default = ""
}
variable "mcp" {
type = string
description = "MCP servers as a JSON string ({\"mcpServers\": {...}}), added to ~/.augment/settings.json with `auggie mcp add-json`. Servers already configured win on duplicate names. See https://docs.augmentcode.com/cli/integrations#mcp-integrations"
default = ""
validation {
condition = var.mcp == "" || can(jsondecode(var.mcp))
error_message = "mcp must be a valid JSON string, e.g. {\"mcpServers\": {...}}."
}
}

Optional, since the runtime warning already prevents a broken install; this just moves the failure earlier.

for profile in "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.bashrc" "$HOME/.zprofile" "$HOME/.zshrc"; do
if [ -f "$${profile}" ]; then
if ! grep -q "$${path_dir}" "$${profile}" 2> /dev/null; then
echo "export PATH=\"\$PATH:$${path_dir}\"" >> "$${profile}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appends the npm-global bin dir after $PATH, but v0's install.sh prepended it (export PATH="$HOME/.npm-global/bin:$PATH"). With appending, an image that ships an older auggie earlier on PATH keeps shadowing the npm-installed one in login shells, which also undercuts the writability rationale for the user prefix in the decision log. fish_add_path below already prepends by default, so this would also make the two consistent:

Suggested change
echo "export PATH=\"\$PATH:$${path_dir}\"" >> "$${profile}"
echo "export PATH=\"$${path_dir}:\$PATH\"" >> "$${profile}"

printf "Auggie CLI version: %s\n" "$${AUGGIE_VERSION}"

if [ -n "$${CODER_SCRIPT_BIN_DIR:-}" ] && [ ! -e "$${CODER_SCRIPT_BIN_DIR}/auggie" ]; then
ln -s "$${AUGGIE_BIN}" "$${CODER_SCRIPT_BIN_DIR}/auggie"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny edge case: if a dangling symlink already exists at this path, [ ! -e ] is true but ln -s fails with File exists and no symlink gets created (the failure does not abort because the function runs inside an if). ln -sfn covers both the fresh and dangling cases:

Suggested change
ln -s "$${AUGGIE_BIN}" "$${CODER_SCRIPT_BIN_DIR}/auggie"
ln -sfn "$${AUGGIE_BIN}" "$${CODER_SCRIPT_BIN_DIR}/auggie"

else
echo "Warning: Failed to add MCP server '$${name}' ($${source_desc}): $${output}"
fi
done < <(echo "$${mcp_json}" | jq -r '.mcpServers // {} | to_entries[] | .key, (.value | @json)')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small footgun: if someone passes a bare server map without the mcpServers wrapper (a shape some other CLIs accept), this silently adds zero servers. jq -r '(.mcpServers // .) | to_entries[] | ...' would also accept that shape; the trade-off is that a non-server object would then produce add-json warnings instead of a silent no-op. Fine to keep as is since the README documents the mcpServers format, but worth a thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants