@dotdotgod/opencode 0.0.0-stage → 0.6.6

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 (52) hide show
  1. package/LICENSE +94 -0
  2. package/README.md +84 -2
  3. package/commands/impact.md +26 -0
  4. package/commands/init.md +38 -0
  5. package/commands/load.md +28 -0
  6. package/index.js +1 -0
  7. package/mcp/cli.mjs +7017 -0
  8. package/mcp/impact-state.mjs +133 -0
  9. package/mcp/parsers/IGNORE_LICENSE +21 -0
  10. package/mcp/parsers/LICENSE +21 -0
  11. package/mcp/parsers/TYPESCRIPT_LICENSE +21 -0
  12. package/mcp/parsers/tree-sitter-bash.wasm +0 -0
  13. package/mcp/parsers/tree-sitter-c-sharp.wasm +0 -0
  14. package/mcp/parsers/tree-sitter-cpp.wasm +0 -0
  15. package/mcp/parsers/tree-sitter-css.wasm +0 -0
  16. package/mcp/parsers/tree-sitter-go.wasm +0 -0
  17. package/mcp/parsers/tree-sitter-ini.wasm +0 -0
  18. package/mcp/parsers/tree-sitter-java.wasm +0 -0
  19. package/mcp/parsers/tree-sitter-javascript.wasm +0 -0
  20. package/mcp/parsers/tree-sitter-php.wasm +0 -0
  21. package/mcp/parsers/tree-sitter-powershell.wasm +0 -0
  22. package/mcp/parsers/tree-sitter-python.wasm +0 -0
  23. package/mcp/parsers/tree-sitter-regex.wasm +0 -0
  24. package/mcp/parsers/tree-sitter-ruby.wasm +0 -0
  25. package/mcp/parsers/tree-sitter-rust.wasm +0 -0
  26. package/mcp/parsers/tree-sitter-tsx.wasm +0 -0
  27. package/mcp/parsers/tree-sitter-typescript.wasm +0 -0
  28. package/mcp/parsers/tree-sitter.cjs +4075 -0
  29. package/mcp/parsers/tree-sitter.wasm +0 -0
  30. package/mcp/server.mjs +23716 -0
  31. package/package.json +41 -3
  32. package/server.js +1 -0
  33. package/skills/doc-first-planning/SKILL.md +30 -0
  34. package/skills/document-clarify/SKILL.md +41 -0
  35. package/skills/impact-review/SKILL.md +25 -0
  36. package/skills/project-initializer/SKILL.md +37 -0
  37. package/skills/project-initializer/references/agent-docs.md +42 -0
  38. package/skills/project-initializer/scripts/init_project.sh +525 -0
  39. package/skills/project-initializer/templates/case-and-evidence.json +219 -0
  40. package/skills/project-initializer/templates/dotdotgod.config.json +234 -0
  41. package/skills/project-initializer/templates/policy.json +241 -0
  42. package/skills/project-initializer/templates/portfolio.json +255 -0
  43. package/skills/project-initializer/templates/publication.json +265 -0
  44. package/skills/project-initializer/templates/research.json +287 -0
  45. package/skills/project-initializer/templates/software.json +234 -0
  46. package/skills/project-load/SKILL.md +27 -0
  47. package/src/impact.mjs +25 -0
  48. package/src/index.mjs +17 -0
  49. package/src/location.mjs +7 -0
  50. package/src/mcp.mjs +37 -0
  51. package/src/plan.mjs +65 -0
  52. package/src/resources.mjs +28 -0
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@dotdotgod/opencode",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.6.6",
4
+ "description": "OpenCode V2 project memory, automatic project plans and advisory impact tracking.",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "license": "Elastic-2.0",
8
+ "exports": {
9
+ ".": "./src/index.mjs",
10
+ "./server": "./server.js"
11
+ },
12
+ "engines": {
13
+ "node": ">=22.5.0"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "server.js",
21
+ "src",
22
+ "skills",
23
+ "commands",
24
+ "mcp",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "devDependencies": {
29
+ "esbuild": "0.27.3",
30
+ "@dotdotgod/context": "0.6.6"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/dotdotgod/dotdotgod-kit.git",
35
+ "directory": "packages/opencode"
36
+ },
37
+ "scripts": {
38
+ "syntax": "node --check index.js && node --check server.js && node --check src/index.mjs && node --check src/plan.mjs && node --check src/impact.mjs && node --check src/location.mjs && node --check src/resources.mjs && node --check src/mcp.mjs && node --check scripts/smoke.mjs",
39
+ "test": "node --test test/*.test.mjs",
40
+ "smoke": "node scripts/smoke.mjs",
41
+ "verify": "pnpm run syntax && pnpm run test && node ../../scripts/build-adapter-runtime.mjs opencode --check",
42
+ "pack:dry-run": "pnpm pack --dry-run --json"
43
+ }
6
44
  }
package/server.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './src/index.mjs';
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: doc-first-planning
3
+ description: Plan implementation from maintained docs with the native plan agent.
4
+ ---
5
+
6
+ <!-- Generated from packages/shared resources by scripts/generate-adapters.mjs. Do not edit this file directly; edit the shared source and run `pnpm run generate`. -->
7
+
8
+ # Doc-First Planning
9
+
10
+ Use the dotdotgod_context MCP server for project load, initialization, graph impact, execution and indexed retrieval. Discover its exact tool names in OpenCode Code Mode; inspect MCP isError and structuredContent and every execution results entry. For unknown output size use execute with a commands array and outputMode auto; search indexed.id with bounded source-scoped search. Run ancillary CLI checks through MCP execute rather than a duplicate native service. Keep direct read for short located source and images. Pending impact is advisory, never an execution gate. Preserve host permissions. Use the native plan agent, not dd:plan; concrete plans are automatically maintained in docs/plan/<task-slug>/README.md without a separate save request.
11
+
12
+ ## Goal
13
+
14
+ Create an implementation plan from maintained repository documentation before substantial source or configuration changes.
15
+
16
+ Use the native plan agent and automatically create or revise `docs/plan/<task-slug>/README.md` once a concrete implementation plan exists, without a separate save request. Initial clarification and explanation-only exchanges need no file. Use MCP project Load for focused documentation/code query.
17
+
18
+ ## Workflow
19
+
20
+ 1. Check for a matching active plan.
21
+ 2. Reuse loaded memory and the documentation map, then use focused query and README indexes to select maintained docs and verify conclusions in them.
22
+ 3. Inspect the source needed to confirm targets and constraints.
23
+ 4. Run impact review on likely changed files and refine targets, risks, and verification.
24
+ 5. Write and present the task README with scope, targets, executable steps, verification, and required completion gates.
25
+ 6. Resolve blocking decisions; stay in the native plan agent until the user switches agents. Saving is not execution approval.
26
+
27
+ ## Quality Rules
28
+
29
+ - Prefer documented facts over inference; label inference explicitly.
30
+ - Keep plans concise, executable, and maintainable.
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: document-clarify
3
+ description: Clarify documentation while preserving requirements and traceability.
4
+ ---
5
+
6
+ <!-- Generated from packages/shared resources by scripts/generate-adapters.mjs. Do not edit this file directly; edit the shared source and run `pnpm run generate`. -->
7
+
8
+ # Document Clarify
9
+
10
+ Use the dotdotgod_context MCP server for project load, initialization, graph impact, execution and indexed retrieval. Discover its exact tool names in OpenCode Code Mode; inspect MCP isError and structuredContent and every execution results entry. For unknown output size use execute with a commands array and outputMode auto; search indexed.id with bounded source-scoped search. Run ancillary CLI checks through MCP execute rather than a duplicate native service. Keep direct read for short located source and images. Pending impact is advisory, never an execution gate. Preserve host permissions. Use the native plan agent, not dd:plan; concrete plans are automatically maintained in docs/plan/<task-slug>/README.md without a separate save request.
11
+
12
+ ## Memory-Area Context
13
+
14
+ Use `dotdotgod config <root> --json` (or the source-checkout CLI equivalent) to obtain resolved `config.areas`; reuse current resolved settings already in context when the project/config has not changed. Normalize the target to a repository-relative path. Check areas in order, applying each area's `excludePaths` before selecting the first matching `paths` entry. Keep the matched area's relevant guidance in context rather than repeatedly injecting the entire configuration. If no area matches, use the document's purpose and repository conventions without inventing metadata.
15
+
16
+ ## Goal
17
+
18
+ Make project documentation easier to understand and act on while preserving established behavior, decisions, task state, historical meaning, and traceability.
19
+
20
+ ## Editing Checklist
21
+
22
+ Adapted from [Google Technical Writing One](https://developers.google.com/tech-writing/one); these principles supplement repository policy. Apply them directly without requiring runtime web access.
23
+
24
+ - **Audience:** distinguish what readers already know from what they need to learn or do. Add only evidence-backed context that closes that gap.
25
+ - **Terminology:** use one consistent name per concept; explain unfamiliar terms and abbreviations when readers need them. Preserve exact API names and identifiers.
26
+ - **Sentences:** use specific verbs and make responsibility clear. Prefer active voice when it helps; retain passive voice when appropriate and never invent an unknown actor. Keep one main idea per sentence while preserving conditions, exceptions, and logical relationships.
27
+ - **Paragraphs:** focus each paragraph on one topic and make its main point clear near the beginning. Remove sentences that do not support that topic or relocate them within the approved scope.
28
+ - **Lists and tables:** use numbered lists when order matters, bullets otherwise, and parallel phrasing for comparable items. Use tables when readers need to compare the same attributes across items, not merely to decorate prose.
29
+ - **Language:** apply these principles idiomatically in the document's language. Do not impose English word order, a passive-voice ban, or sentence-length quotas on Korean or other languages.
30
+
31
+ ## Workflow
32
+
33
+ 1. Confirm the target, audience, requested outcome, and edit scope. Diagnose ambiguity, repetition, or missing information before editing; small changes need no separate diagnostic report. Use matched memory-area metadata when available: `clarify` guidance first, then `description`, `label`, and `role`.
34
+ 2. Read only the context needed to preserve meaning: the nearest README, directly linked documents, relevant query results, and targeted history when a past decision matters.
35
+ 3. Remove obsolete historical behavior and superseded conditions from current specs when maintained source, tests, or confirmed decisions establish that they no longer apply. Describe current behavior directly rather than narrating how it changed. Do not mistake currently supported compatibility behavior for obsolete history. Preserve current requirements, meaningful limitations, and unresolved uncertainty; when retirement is unverified, ask rather than delete. Preserve historical meaning in archives and reports; do not rewrite past records to look current. Apply criteria suited to the document: README navigation and starting points; spec conditions, behavior, and exceptions; test procedures and pass criteria; architecture boundaries, rationale, and constraints; plan ordering, dependencies, and completion criteria; archive decisions and outcomes in their historical context. Repository-specific guidance takes priority. Clarify terms, ownership, headings, links, and runnable examples. Preserve commands, paths, package/API names, requirement strength, conditions, exceptions, unresolved questions, limitations, and evidence unless verified sources support a change. Do not invent missing facts.
36
+ 4. Prefer direct affirmative statements. Remove repeated framing, indirect wording, mixed responsibilities, and irrelevant background. Remove negative or absence statements only when deleting them leaves the reader's understanding, actions, and decisions unchanged. Rewrite redundant contrasts affirmatively: “It is not automatic; the user starts it” becomes “The user starts it.” Preserve meaningful prohibitions, unsupported cases, exceptions, security constraints, and unverified status. Use “X is not Y; it is Z” when the contrast resolves a likely ambiguity. Accuracy takes priority over brevity.
37
+ 5. Keep edits within the agreed scope. Confirm scope before splitting or moving files, changing meaning, or editing additional documents outside that scope. Update the nearest README when approved structural changes affect navigation. Follow generated markers and canonical-source instructions. For dotdotgod traceability, edit the fenced `json dotdotgod` block as the canonical mapping. Inspect `dotdotgod traceability links <root> --check --json` before using `--write`; the root-wide write can change unrelated documents, so obtain approval if its affected files exceed the agreed scope. Apply ordinary reference policy: shared documents must not depend on concrete local file paths in inline code or Markdown links; inline-code directory, glob, and placeholder usage examples remain allowed. Preserve traceability's separate stricter local-target prohibition.
38
+ 6. Ask for a decision when the requested clarification would change established meaning or when current sources conflict.
39
+ 7. Run verification that matches the changed surface. Use documentation and traceability checks for ordinary docs; add generation checks, focused package tests, dry-runs, or workspace verification when shared resources or product behavior are affected. Report briefly: what became clearer; important meaning preserved and unresolved questions; checks run and checks not run. Do not equate shorter text with improved accuracy.
40
+
41
+ When CLI-backed routing is unavailable, continue from the target document, nearest README, direct links, and repository conventions.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: impact-review
3
+ description: Review changed files and related docs/tests using graph impact.
4
+ ---
5
+
6
+ <!-- Generated from packages/shared resources by scripts/generate-adapters.mjs. Do not edit this file directly; edit the shared source and run `pnpm run generate`. -->
7
+
8
+ # Impact Review
9
+
10
+ Use the dotdotgod_context MCP server for project load, initialization, graph impact, execution and indexed retrieval. Discover its exact tool names in OpenCode Code Mode; inspect MCP isError and structuredContent and every execution results entry. For unknown output size use execute with a commands array and outputMode auto; search indexed.id with bounded source-scoped search. Run ancillary CLI checks through MCP execute rather than a duplicate native service. Keep direct read for short located source and images. Pending impact is advisory, never an execution gate. Preserve host permissions. Use the native plan agent, not dd:plan; concrete plans are automatically maintained in docs/plan/<task-slug>/README.md without a separate save request.
11
+
12
+ ## Goal
13
+
14
+ Review task-relevant source, config, and documentation changes with dotdotgod impact evidence before broad verification, commits, pushes, publishing, or final handoff. OpenCode tracks observed edits per session; pending impact is advisory and never blocks tools.
15
+
16
+ ## Workflow
17
+
18
+ 1. Build the changed-file set from Git status. Preserve unrelated user work and exclude dependencies, caches, build output, secrets, and unrelated local memory.
19
+ 2. Call the shared MCP project_impact tool with up to twenty unique paths in first-seen order. Split larger sets into ordered batches of twenty. Inspect isError and structuredContent; only successful reviews of covered unchanged revisions clear pending state. Failures, cancellation and concurrent re-edits retain pending. When MCP is unavailable, follow README indexes, traceability, package metadata and focused search without claiming pending was cleared.
20
+ 3. Review the combined ranking and each seed's non-seed top results. Prioritize high-signal specs, tests, architecture, and source links, especially `implemented_by`, `verified_by`, and `related_doc` relationships.
21
+ 4. Resolve stale or contradictory related docs and tests that belong to the current task.
22
+ 5. Select focused tests, documentation validation, generated-resource checks, and package dry-runs from the evidence. For dotdotgod documentation changes, run `dotdotgod validate . --include-local-memory` and add `--check-index` when index freshness matters.
23
+ 6. Report the changed files reviewed, the strongest related findings and follow-up actions, and verification completed or skipped.
24
+
25
+ Keep raw impact payloads out of normal summaries. Optional hooks may remind agents about this workflow; default package resources leave full verification, index rebuilds, initialization, archive moves, and write blocking under explicit workflow control.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: project-initializer
3
+ description: Initialize shared project memory, documentation indexes and configuration.
4
+ ---
5
+
6
+ <!-- Generated from packages/shared resources by scripts/generate-adapters.mjs. Do not edit this file directly; edit the shared source and run `pnpm run generate`. -->
7
+
8
+ # Project Initializer
9
+
10
+ Use the dotdotgod_context MCP server for project load, initialization, graph impact, execution and indexed retrieval. Discover its exact tool names in OpenCode Code Mode; inspect MCP isError and structuredContent and every execution results entry. For unknown output size use execute with a commands array and outputMode auto; search indexed.id with bounded source-scoped search. Run ancillary CLI checks through MCP execute rather than a duplicate native service. Keep direct read for short located source and images. Pending impact is advisory, never an execution gate. Preserve host permissions. Use the native plan agent, not dd:plan; concrete plans are automatically maintained in docs/plan/<task-slug>/README.md without a separate save request.
11
+
12
+ ## Goal
13
+
14
+ Create a non-destructive dotdotgod baseline with canonical agent instructions, thin agent entrypoints, documentation indexes, a project config selected from an appropriate initialization template, and local-memory ignore rules.
15
+
16
+ ## Template Selection
17
+
18
+ 1. Inspect existing agent instructions, the root README, docs indexes, major top-level directories, config, and ignore rules.
19
+ 2. Discover custom templates as individual JSON files under `~/.dotdotgod/templates/`. Built-in templates are `software`, `research`, `case-and-evidence`, `publication`, `portfolio`, and `policy`.
20
+ 3. Choose from project evidence:
21
+ - `software`: application, library, or infrastructure projects organized around specs, architecture, source, and tests.
22
+ - `research`: research diaries, dated records, reports, artifacts, and evaluation evidence.
23
+ - `case-and-evidence`: canonical case records, evidence or legal grounds, and case outputs.
24
+ - `publication`: briefs, outlines, chapters, claims, manuscripts, and research sources.
25
+ - `portfolio`: strategy, positions, ledgers, journals, and market research.
26
+ - `policy`: policy sections, integrated proposals, evidence, and submission outputs.
27
+ 4. Consider custom templates by filename and config contents. A same-name custom template replaces the built-in template completely.
28
+ 5. Ask the user when multiple choices are plausible and materially change memory areas or traceability. With insufficient evidence, use `~/.dotdotgod/config.json` `defaultTemplate`, then `software`.
29
+ 6. Report the selected template and a concise reason.
30
+
31
+ ## Workflow
32
+
33
+ 1. Preserve existing files and unrelated user work.
34
+ 2. Call the shared MCP project_initialize tool with the selected template. Keep dryRun true initially; after explicit write approval call with dryRun false and confirmWrite true. Existing files are skipped, never replaced. Switch out of the native plan agent before initialization.
35
+ 3. Use bundled scripts only as an explicit fallback when MCP is unavailable. Custom templates require the CLI; do not silently substitute a bundled template.
36
+ 4. Validate the initialized project with `dotdotgod validate <project-root>` when available.
37
+ 5. Report created and skipped files, the selected template, validation failures, and unresolved instruction conflicts.
@@ -0,0 +1,42 @@
1
+ # Shared Agent Docs
2
+
3
+ Use `AGENTS.md` as the canonical shared instruction file.
4
+
5
+ ## Naming
6
+
7
+ - `AGENTS.md`: preferred shared file name. OpenAI Codex recognizes this convention, and the community `agents.md` convention uses the plural form.
8
+ - `CLAUDE.md`: Claude Code's project memory file. Keep it thin and import `AGENTS.md` with `@AGENTS.md`.
9
+ - `CODEX.md`: project-local Codex pointer. Keep it thin and link to `AGENTS.md`.
10
+ - OpenCode reads `AGENTS.md` natively; do not create an `OPENCODE.md` copy.
11
+ - `.github/copilot-instructions.md`: optional Copilot surface. If present, route to `AGENTS.md`, `docs/README.md`, and project commands instead of copying the full rules body.
12
+ - `.cursor/rules/*.md`: optional Cursor path-scoped rules. If present, keep Cursor-specific scoping there and route durable project rules to shared docs.
13
+ - `llms.txt`: optional documentation discovery surface. If present, point to README indexes and bounded docs entrypoints instead of embedding large docs bodies.
14
+ - `AGENT.md`: avoid for new projects unless an existing tool in the repo requires it.
15
+
16
+ ## Content Model
17
+
18
+ Put durable, project-wide instructions in `AGENTS.md`:
19
+
20
+ - project purpose and stack
21
+ - install, test, run, and lint commands
22
+ - architecture and ownership notes
23
+ - documentation map
24
+ - coding and review expectations
25
+ - environment constraints
26
+
27
+ For projects using the dotdotgod CLI, `dotdotgod validate` is the enforcement point for machine-readable docs rules such as fenced `json dotdotgod` traceability blocks in behavior specs. Keep the detailed schema in the CLI and its validation errors.
28
+
29
+ Do not duplicate the same body in `CLAUDE.md`, `CODEX.md`, Copilot instructions, Cursor rules, or llms discovery surfaces; duplication causes drift.
30
+
31
+ ## Focused Behavior Contracts
32
+
33
+ Use focused behavior contracts for user-visible rules that need clear implementation and verification links.
34
+
35
+ Good focused contracts:
36
+
37
+ - describe current behavior, not change history
38
+ - stay small enough for agents to load and reason about directly
39
+ - connect to implementation files, tests, related docs, and verification commands with a final fenced `json dotdotgod` traceability block when the project uses dotdotgod validation
40
+ - split large product areas into `docs/spec/<domain>/README.md` plus focused UPPER_SNAKE_CASE spec files
41
+
42
+ Traceability helps agents find related code and checks. It is not a semantic proof that tests cover every edge case.