Skip to content

feat: Research Environments — shared knowledge, code, and config substrate (#880) - #891

Merged
jeonghun-jj-lee merged 23 commits into
mainfrom
amico/issue-880-research-environments
Sep 8, 2026
Merged

feat: Research Environments — shared knowledge, code, and config substrate (#880)#891
jeonghun-jj-lee merged 23 commits into
mainfrom
amico/issue-880-research-environments

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Closes #880

Research Environments

Implements the research environments architecture — shared knowledge, code, config, and results across research projects.

Sub-issues (dependency order)

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1f302260-2876-419a-ad66-6c5885653bfd


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- EnvironmentToml schema (validation, rendering, round-trip)
- ENV_SCAFFOLD_DIRS (9 prescribed directories)
- environments.toml registry (parse, render, upsert)
- amico env create (scaffold + git init + register)
- amico env register (validate manifest + upsert registry)
- ProjectToml: add optional [environment] section
- renderProjectToml: emit [environment] when present
- 37 new tests (28 pure logic + 9 integration), all green

Part of #880 Research Environments. Closes #881.
- detectProjectType: add 'environment' type (research-environment.toml)
- environment takes priority over research when both manifests present
- resolveEnvironment: four-strategy resolution (walk-up, explicit path,
  workspace scan, registry) with per-project-path caching
- walk-up stops at workspace folder root (AC-53)
- malformed TOML / future schema_version → null + console.warn
- sidebar_bridge: TreeRoot.projectType accepts 'environment'
- sidebar_tree_service: filter out environment folders from roots (AC-49)
- workspace_projects: filter out environment folders (AC-49)
- sidebar_view: watcher tracks research-environment.toml changes +
  invalidates environment cache on manifest changes
- 18 new tests (12 resolution + 4 detection + 2 filtering), all green

Part of #880 Research Environments. Closes #882.
- buildResearchEnvironmentSection() in stack_state.ts: emits '## Active
  Research Environment' block with name, path, directory summary counts,
  language detection from lib/, and skills listing
- Absent directories omitted (AC-28), researcher-added dirs auto-discovered
  (AC-29), 500+ entries reported as ~500+
- AMICODE_RESOLVED_ENVIRONMENT env var threaded through buildServerSpawnEnv
- AMICODE_WORKSPACE_FOLDERS also added to spawn env (was test-only)
- SEAM_KEYS updated with AMICODE_RESOLVED_ENVIRONMENT
- 6 new tests (environment section, absent dirs, extra dirs, skills,
  malformed TOML, no env), all green

Part of #880 Research Environments. Closes #883.
- SkillIndexEntry.source: add 'environment' to the union
- resolveEnvironmentSkills(): scan workspace folders with
  research-environment.toml for skills/
- mergeSkillEntries: 5-arg signature (project > environment > custom >
  workspace > shipped) — AC-31
- buildSkillIndexSection: render environment skills with (environment)
  label, between project and custom
- opencode_config.ts: wire environment skill discovery + new merge
- Environment skills shadow armonissima (shipped) at same name — AC-45
- 7 new tests (3 resolution + 4 merge), all green; existing tests updated
  to new 5-arg signature

Part of #880 Research Environments. Closes #888.
…889)

- envPromote(): promote files with frontmatter-based routing
  (type: insight → insights/, type: method → methods/, etc.)
- Provenance stamps on copies (promoted_from_project, promoted_date) — AC-37
- Source stamps (promoted, promoted_to with env slug) to prevent
  re-promotion — AC-38
- --dry-run lists without writing — AC-40
- Already-promoted files skipped (same env slug check) — AC-48
- --target-dir override for files without type frontmatter
- Git stages only the promoted files, never git add .
- Verb registered as 'amico env promote'
- 7 new integration tests, all green

Part of #880 Research Environments. Closes #889.
- Color palette utility: hashCode, envColorIndex (slug → 0-7),
  truncateWithEllipsis (for pill label)
- TreeRoot.environment field: name, slug, path, colorIndex
- SidebarTreeService.getRoots: resolveEnvironment dep, attaches env
  data to research project roots
- sidebar_view.ts: wires resolveEnvironment into the tree service
- Resolution failure → graceful degradation (no pill, no crash)
- AC-6 (deterministic slug hash), AC-10 (no pill without binding)
- 14 new tests (color palette, hash, truncation, tree service wiring)
- Webview pill rendering deferred to the fork's sidebar_webview.ts

Part of #880 Research Environments. Closes #884.
- WorkspaceProjectEntry: add optional environment field
- WorkspaceProjectDeps: add resolveEnvironment dep
- getWorkspaceProjects: populate environment name for bound research
  projects; absent for unbound and dev projects
- AC-19 (subtitle for bound), AC-20 (no subtitle for unbound/dev)
- 3 new tests, all green
- Fork-side rendering (prompt-project-selector.tsx) is a follow-up

Part of #880 Research Environments. Closes #886.
- Register 3 command palette entries: Amicode: New Environment,
  Amicode: Bind to Environment, Amicode: Promote to Environment
- sidebar_bridge: add BindToEnvironmentMessage and
  PromoteToEnvironmentMessage to SidebarUpMessage union
- Command handlers and webview context menu items are fork-side follow-ups

Part of #880 Research Environments. Closes #887.
…890)

- Environment digest assembly at campaign kickoff (filtered by domain +
  tags + objective, updated at loop boundaries)
- Subagent brief fields: env_digest_path for all three roles;
  env_lib_path, env_templates_path, env_config_path, env_context_path
  for the experimenter
- Per-iteration staging: project card updates + insight proposals to
  ledger/environment-proposals/
- Promotion suggestion at campaign boundaries
- All directory paths respect [paths] overrides from the manifest
- Prose-only deliverable (skill SKILL.md update), no TypeScript tests

Part of #880 Research Environments. Closes #890.
- TreeEntry: add entryKind ('environment-root') and environmentSlug
  fields for the environment row
- SidebarTreeService: track root→environment map from getRoots(),
  append environment as last child of bound project roots in getChildren()
- Environment row carries name, path, slug, and directory type
- AC-11 (last child), AC-14 (lazy-loaded on getChildren call)
- 3 new tests (environment child, no env, sort order), all green
- Webview rendering (icon, italic, muted children) deferred to fork

Part of #880 Research Environments. Closes #885.
Walk-up resolution removed: projects and environments are always separate
git repos linked by [environment].slug (or .path). Resolution is now a
three-strategy cascade: explicit path → workspace scan → registry.

- Delete walkUp() and its three tests (parent, ws-root stop, ws-root find)
- Delete walk-up-vs-explicit-conflict test
- Add explicit-path-wins-over-workspace-scan priority test
- Update cache test to use explicit path fixture (was walk-up)
- Update detect.ts comment (remove monorepo root rationale)
- Update file header (four-strategy → three-strategy)
- Remove unused dirname import

Net: -33 lines implementation, -3 tests (4 removed, 1 added).
2925 extension tests pass, 0 failures.
…nup (#880)

Environments hold shared knowledge, not project-level work. Projects are
always separate repos.

- Drop experiments/ and results/ from ENV_SCAFFOLD_DIRS (9 → 7 dirs)
- Drop experiment and result from TYPE_ROUTE (promote rejects them)
- Add checkNestingViolation(): walks ancestors for research-project.toml
  or research-environment.toml, refuses if found
- Wire guard into envCreate — env init inside a project or another env
  is a hard error with a clear message
- Export checkNestingViolation for direct testing
- 5 new tests (2 envCreate guard, 3 checkNestingViolation), all green
- Update scaffold test: 7 dirs, explicitly assert no experiments/results

50 env tests pass, 0 failures.
…ewEnvironment, bindToEnvironment, promoteToEnvironment) (#892)
…skill-to-skill chaining

The amicode_session tool previously sent prompts via promptAsync, which
delivers plain text. When a skill chains into another skill via a spawned
session (e.g. migrate → create-research-environment), the child LLM had to
independently recognize the /skill-name prefix and load the target skill —
unreliable.

Now amicode_session accepts an optional `command` parameter that uses the
opencode engine's dedicated POST /session/{id}/command endpoint (the same
mechanism bug_report.ts uses) to invoke a registered skill directly in the
child session. The `prompt` text becomes the command's `arguments` field.

Changes:
- session_spawn.ts: add `command` to SpawnArgs + parseSpawnArgs
- amicode_tools_core.ts: widen EngineClientShape with session.command,
  add command arg to tool schema, dispatch via command API when set
- amicode_tools.ts (plugin twin): mirror all changes
- migrate-research-project SKILL.md: Phase 6 uses command parameter
- create-research-project SKILL.md: Stage 8 uses command parameter
- Tests: 5 new tests (3 parseSpawnArgs, 2 command dispatch e2e)

Fixes the issue where migrate-research-project's 'Create new' environment
option did not trigger a new session.
#884)

The data pipeline was fully wired (resolveEnvironment → TreeService →
bridge types) but the sidebar webview never read root.environment to
render anything. Now:

- sidebar_view.ts: env-pill CSS — 8-color palette (env-pill-0..7),
  compact rounded badge, 10px text, 120px max-width with ellipsis
- sidebar_webview.ts: TreeRoot/TreeEntry interfaces widened to include
  environment fields; renderRootNode appends an env-pill span after the
  label when root.environment is present, with tooltip showing slug + path
- 3 new tests: CSS presence, interface field, rendering code check
@jeonghun-jj-lee
jeonghun-jj-lee marked this pull request as ready for review September 8, 2026 03:23
@jeonghun-jj-lee
jeonghun-jj-lee merged commit 6ac2ff8 into main Sep 8, 2026
10 checks passed
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.

Research Environments — shared knowledge, code, and config substrate for research projects

1 participant