@jslee124/forge 0.3.0 → 0.3.1

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 (35) hide show
  1. package/dist/index.js +1177 -90
  2. package/package.json +2 -1
  3. package/resources/docs/en/ARCHITECTURE.md +519 -0
  4. package/resources/docs/en/AUTHENTICATION.md +224 -0
  5. package/resources/docs/en/CLI_UI.md +266 -0
  6. package/resources/docs/en/CONFIGURATION.md +263 -0
  7. package/resources/docs/en/CONTEXT_MANAGEMENT.md +692 -0
  8. package/resources/docs/en/GETTING_STARTED.md +241 -0
  9. package/resources/docs/en/PLUGINS.md +622 -0
  10. package/resources/docs/en/PRODUCT.md +157 -0
  11. package/resources/docs/en/PROJECT_CONTEXT.md +225 -0
  12. package/resources/docs/en/RELEASING.md +94 -0
  13. package/resources/docs/en/SECURITY.md +272 -0
  14. package/resources/docs/en/SESSIONS.md +134 -0
  15. package/resources/docs/en/TROUBLESHOOTING.md +256 -0
  16. package/resources/docs/index.json +24334 -0
  17. package/resources/docs/zh-CN/ARCHITECTURE.md +174 -0
  18. package/resources/docs/zh-CN/AUTHENTICATION.md +96 -0
  19. package/resources/docs/zh-CN/CLI_UI.md +112 -0
  20. package/resources/docs/zh-CN/CONFIGURATION.md +221 -0
  21. package/resources/docs/zh-CN/CONTEXT_MANAGEMENT.md +200 -0
  22. package/resources/docs/zh-CN/GETTING_STARTED.md +193 -0
  23. package/resources/docs/zh-CN/PLUGINS.md +286 -0
  24. package/resources/docs/zh-CN/PRODUCT.md +86 -0
  25. package/resources/docs/zh-CN/PROJECT_CONTEXT.md +130 -0
  26. package/resources/docs/zh-CN/RELEASING.md +86 -0
  27. package/resources/docs/zh-CN/SECURITY.md +92 -0
  28. package/resources/docs/zh-CN/SESSIONS.md +69 -0
  29. package/resources/docs/zh-CN/TROUBLESHOOTING.md +185 -0
  30. package/resources/skills/forge-plugin-creator/SKILL.md +70 -0
  31. package/resources/skills/forge-plugin-creator/references/plugin-api.md +36 -0
  32. package/resources/skills/forge-plugin-creator/templates/index.mjs +30 -0
  33. package/resources/skills/forge-plugin-creator/templates/plugin.json +8 -0
  34. package/resources/skills/forge-plugin-creator/templates/plugin.test-template.ts +14 -0
  35. package/resources/skills/forge-product-help/SKILL.md +16 -0
@@ -0,0 +1,157 @@
1
+ # Product Definition
2
+
3
+ 简体中文 · Documentation index
4
+
5
+ ## Summary
6
+
7
+ Forge is a lightweight, safe-by-default terminal coding agent that can inspect a
8
+ local codebase, use tools, modify files, run commands, and adapt its next action
9
+ to the observed result. Trusted plugins can extend its capabilities without
10
+ replacing mandatory runtime safeguards.
11
+
12
+ Its distinguishing feature is transparency. A developer should be able to see
13
+ model-provided reasoning when available, what Forge did, why execution stopped,
14
+ how much it cost, and whether the result passed an objective evaluation.
15
+
16
+ ## Target users
17
+
18
+ ### Primary user
19
+
20
+ A developer who wants to understand and experiment with the internal behavior
21
+ of a coding agent.
22
+
23
+ ### Secondary user
24
+
25
+ A developer who wants a small, inspectable coding assistant for local tasks and
26
+ prefers explicit behavior over a large, opaque feature set.
27
+
28
+ ## Core use case
29
+
30
+ ```bash
31
+ forge run "Add input validation and update the tests"
32
+ ```
33
+
34
+ The expected user journey is:
35
+
36
+ 1. Forge validates its configuration and workspace.
37
+ 2. Forge merges user settings from `~/.forge/` with applicable project settings
38
+ and instructions, recording their source paths.
39
+ 3. Forge asks the model to choose the next action.
40
+ 4. The model uses tools to inspect relevant files.
41
+ 5. Forge checks each proposed action against its safety policy.
42
+ 6. Forge asks for approval when an action crosses a configured boundary.
43
+ 7. Forge executes approved actions and records their results.
44
+ 8. The model uses those results to decide what to do next.
45
+ 9. Forge modifies the code and runs an appropriate verification command.
46
+ 10. Forge stops with a truthful summary, or explains why it could not finish.
47
+
48
+ ## Product principles
49
+
50
+ ### Transparent
51
+
52
+ The terminal should show meaningful model and tool activity. Reasoning or
53
+ thinking content returned by the model provider should be visible to the user by
54
+ default and represented honestly as provider-supplied content. If a model does
55
+ not return reasoning content, Forge must not fabricate or imply access to it. A
56
+ structured trace should preserve the observable execution trajectory for later
57
+ inspection.
58
+
59
+ ### Safe by default
60
+
61
+ Forge should restrict filesystem access to the selected workspace, limit
62
+ commands and execution time, and require approval for risky operations.
63
+
64
+ Read-only operations inside the workspace may run automatically. The first
65
+ workspace write requires approval by default, every process command requires
66
+ approval by default, and built-in file tools deny operations outside the
67
+ workspace in v0.1. In non-interactive operation, an action that requires
68
+ approval is denied unless a matching narrow approval was supplied in advance.
69
+
70
+ ### Verifiable
71
+
72
+ Forge should not treat a plausible final message as proof of completion. When a
73
+ task can be verified with tests, type checking, linting, or another deterministic
74
+ check, Forge should run that check and report its real result.
75
+
76
+ ### Framework-aware, not framework-owned
77
+
78
+ Forge will use established libraries where they remove incidental complexity,
79
+ but its central runtime concepts should remain visible and independently
80
+ testable.
81
+
82
+ ### Extensible without weakening safeguards
83
+
84
+ Plugins may add tools, commands, prompt contributions, and controlled lifecycle
85
+ hooks. They must not turn a core `deny` into `allow`, bypass approval, or replace
86
+ the policy kernel. Trusted in-process plugins still execute as local code and
87
+ therefore require an explicit trust decision.
88
+
89
+ ### Small before broad
90
+
91
+ A narrow, reliable workflow is more valuable than many incomplete features.
92
+
93
+ ## Initial feature set
94
+
95
+ The first useful version will include:
96
+
97
+ - A TypeScript command-line interface
98
+ - A multi-line interactive terminal UI with slash-command discovery,
99
+ workspace-file mentions, and readable diff review
100
+ - DeepSeek as the first provider, authenticated with `DEEPSEEK_API_KEY`
101
+ - Streaming model responses through Vercel AI SDK and `@ai-sdk/deepseek`
102
+ - A multi-step agent loop with explicit stop conditions
103
+ - User-wide configuration through `~/.forge/config.json`
104
+ - Hierarchical repository instructions through `AGENTS.md`
105
+ - Inspectable configuration provenance through `forge config show`
106
+ - Tools for listing, reading, searching, patching, and running commands
107
+ - Workspace path validation
108
+ - Command timeout and cancellation
109
+ - Approval decisions for sensitive actions
110
+ - Visible provider-supplied reasoning when available
111
+ - Structured terminal events and JSONL traces
112
+ - Persistent local sessions that can be resumed after restarting Forge
113
+ - Automated tests for the runtime and tools
114
+ - A canonical fixture task, deterministic recovery scenario, and reproducible
115
+ release evaluation
116
+
117
+ ## Success criteria for v0.1
118
+
119
+ Forge v0.1 is successful when it meets the concrete release gates in
120
+ v0.1 Acceptance and Evaluation, including a small repository
121
+ task from end to end:
122
+
123
+ 1. Inspect more than one relevant file.
124
+ 2. Make a targeted code change.
125
+ 3. Run an automated verification command.
126
+ 4. Demonstrate recovery from a failed verification in a deterministic runtime
127
+ scenario.
128
+ 5. Stop after success or a configured limit.
129
+ 6. Deny built-in file operations outside the selected workspace.
130
+ 7. Produce a trace consistent with its real actions.
131
+ 8. Produce a final summary consistent with the actual file changes and command
132
+ results.
133
+
134
+ ## Out of scope for v0.1
135
+
136
+ - Multiple cooperating agents
137
+ - Graphical or IDE interfaces
138
+ - Remote execution
139
+ - Persistent semantic memory
140
+ - Retrieval-augmented generation
141
+ - MCP server discovery
142
+ - Third-party plugin package installation
143
+ - Automatic commits, pushes, or pull requests
144
+ - Production-grade operating-system sandboxing
145
+
146
+ ## Future portfolio direction
147
+
148
+ After the native runtime is reliable, Forge may add:
149
+
150
+ - A broader evaluation suite with more tasks, trials, graders, and reports
151
+ - OpenAI API-key authentication and, when supported by an appropriate public
152
+ integration, Codex-compatible Sign in with ChatGPT
153
+ - A LangChain or LangGraph runtime adapter evaluated on the same tasks
154
+ - An HTTP API with Server-Sent Events, cancellation, and human approval
155
+ - SQLite-backed indexing, session branching, and cross-machine synchronization
156
+
157
+ These are future extensions, not requirements for beginning implementation.
@@ -0,0 +1,225 @@
1
+ # Project Context and Local Customization
2
+
3
+ 简体中文 · Documentation index
4
+
5
+ ## Goal
6
+
7
+ Forge understands repository-specific instructions and reusable Agent
8
+ resources without turning repository contents into an implicit permission grant.
9
+ It uses three deliberately separate conventions:
10
+
11
+ | Location | Purpose | Executable by itself |
12
+ | --- | --- | --- |
13
+ | `AGENTS.md` | Portable, human-readable project instructions | No |
14
+ | `.agents/` | Agent-agnostic reusable resources such as skills | No |
15
+ | `~/.forge/` | User-wide Forge settings, instructions, state, and plugins | Plugins are code |
16
+ | `<workspace-root>/.forge/` | Forge-specific project settings and plugins | Plugins are code |
17
+
18
+ Repository instructions may shape how the model approaches a task. They cannot
19
+ weaken the policy kernel, approve an action, select `full-access`, or bypass a
20
+ tool's normal approval and trace pipeline.
21
+
22
+ The implemented system includes schema-versioned user/project configuration,
23
+ instruction discovery and provenance, persistent sessions and traces,
24
+ model-invocable portable Skills, trusted plugins, and strictness-merged
25
+ context budgets.
26
+
27
+ ## `AGENTS.md`
28
+
29
+ Forge follows the established uppercase filename `AGENTS.md`. On
30
+ case-sensitive filesystems, `agents.md` is a different file and is not an alias.
31
+ It also supports `AGENTS.override.md` for a more specific replacement at a
32
+ directory level.
33
+
34
+ For a run whose working directory is inside a Git repository, Forge will:
35
+
36
+ 1. Resolve the canonical repository root.
37
+ 2. Walk from that root to the run's working directory.
38
+ 3. In each directory, load at most one non-empty instruction file, preferring
39
+ `AGENTS.override.md` over `AGENTS.md`.
40
+ 4. Merge instructions from root to leaf so that the nearest file has the
41
+ highest instruction precedence.
42
+ 5. Record every loaded path in the run trace.
43
+
44
+ Discovery happens once at the beginning of a run. Forge will impose per-file
45
+ and total byte limits and report ignored or truncated instruction files rather
46
+ than silently changing the effective prompt.
47
+
48
+ These files are prompt input, not trusted policy. A statement such as "run all
49
+ commands without asking" has no effect on the approval policy.
50
+
51
+ ## `.agents/`
52
+
53
+ `.agents/` is the portable resource namespace. The first supported layout is:
54
+
55
+ ```text
56
+ .agents/
57
+ `-- skills/
58
+ `-- <skill-name>/
59
+ `-- SKILL.md
60
+ ```
61
+
62
+ A skill is discovered metadata and instructions; it is never executed merely
63
+ because it exists. If a skill references a script or proposes a tool action,
64
+ that action still uses the normal policy and approval flow. Forge should show
65
+ the source path when a project skill is selected and include the selection in
66
+ the trace.
67
+
68
+ Forge parses bounded YAML frontmatter (`name`, task-oriented `description`, and
69
+ optional `disable-model-invocation`) and initially sends only escaped catalog
70
+ metadata to the model. Matching Skills are loaded on demand by opaque ID;
71
+ `$skill-name` remains a deterministic override. Project Skills are
72
+ model-invocable by default and require no plugin trust because they are never
73
+ imported or executed. `disable-model-invocation: true` makes one Skill available
74
+ only through an explicit user mention.
75
+
76
+ The same convention is available for built-in Skills shipped with Forge and
77
+ user Skills under `$FORGE_HOME/skills/`. Collisions resolve as
78
+ `project > user > builtin`, with shadowed sources recorded as diagnostics. New
79
+ portable subdirectories should only be added when there is a clear cross-agent
80
+ convention instead of placing Forge-specific data here.
81
+
82
+ ## User-level `~/.forge/`
83
+
84
+ Forge uses `~/.forge/` as its default user home. `~` is resolved through the
85
+ operating system rather than relative to the current working directory. A
86
+ `FORGE_HOME` environment variable may override the location for portable
87
+ installations, testing, or managed environments.
88
+
89
+ The user layout is:
90
+
91
+ ```text
92
+ ~/.forge/
93
+ |-- config.json
94
+ |-- AGENTS.md
95
+ |-- skills/
96
+ |-- plugin-trust.json
97
+ |-- plugins/
98
+ |-- state/
99
+ |-- sessions/
100
+ `-- runs/
101
+ ```
102
+
103
+ - `config.json` contains user-wide defaults such as provider, model, limits,
104
+ context behavior, trace behavior, and the default permission profile.
105
+ - `AGENTS.md` contains optional user-wide instructions loaded before project
106
+ instructions.
107
+ - `skills/` contains user-wide non-executable Skills discovered as bounded
108
+ metadata and loaded lazily.
109
+ - `plugins/` contains explicitly installed or enabled user plugins.
110
+ - `state/` contains non-secret Forge state such as project-trust decisions.
111
+ - `sessions/` contains versioned completed conversation snapshots.
112
+ - `runs/` contains local traces when trace persistence is enabled.
113
+
114
+ Forge may create missing runtime subdirectories, but it must not overwrite an
115
+ existing configuration file. API keys and OAuth tokens do not belong in
116
+ `config.json`; Forge uses environment variables or the credential store defined
117
+ in the authentication model.
118
+
119
+ ### Configuration schema
120
+
121
+ The Zod schema in `@forge/config` is the executable source of truth. See the
122
+ Configuration reference for every field, default, accepted
123
+ value, environment override, provider-route example, and merge rule.
124
+
125
+ The security-relevant summary is:
126
+
127
+ | Scope | May configure | Must not configure |
128
+ | --- | --- | --- |
129
+ | User `$FORGE_HOME/config.json` | Model, engine, provider routes, permission profile, limits, traces, plugins, context | API keys or OAuth credentials |
130
+ | Project `.forge/config.json` | Stricter `limits` and `context` values | Model/provider, permissions, traces, plugin enablement, routes, secrets |
131
+ | Environment | `FORGE_PROVIDER`, `FORGE_MODEL`, `FORGE_REASONING_EFFORT`, `FORGE_THINKING`, and credential variables | Permission widening |
132
+ | Explicit CLI | Supported command-scoped model, permission, limit, and context overrides | Repository trust or secret persistence through arguments |
133
+
134
+ Unknown fields are errors rather than silently ignored. `FORGE_HOME` changes
135
+ discovery location before configuration is loaded. There is intentionally no
136
+ environment variable that widens the permission profile.
137
+
138
+ User configuration is loaded before repository configuration. Forge should
139
+ provide `forge config show` to display the effective value and source of every
140
+ setting, and `forge config validate` to report invalid keys and values without
141
+ starting an Agent run.
142
+
143
+ ## Project-level `.forge/`
144
+
145
+ The selected workspace root's `.forge/` is reserved for Forge-specific project
146
+ customization. The current 0.3.1 layout is:
147
+
148
+ ```text
149
+ .forge/
150
+ |-- config.json
151
+ `-- plugins/
152
+ `-- <plugin-name>/
153
+ |-- plugin.json
154
+ `-- index.mjs
155
+ ```
156
+
157
+ The phrase "project-local" means the selected workspace root's canonical
158
+ `.forge/` directory. Forge will not search arbitrary parent directories or
159
+ nested directories for additional `.forge/plugins/` trees. This keeps plugin
160
+ discovery stable when Forge starts from a repository subdirectory.
161
+
162
+ Repository configuration may choose model-independent project behavior,
163
+ formatting, and stricter execution limits, but it cannot
164
+ relax the user's permission profile or core safety policy. Security-sensitive
165
+ keys such as the default permission profile, plugin enablement, and project
166
+ trust are user-only.
167
+ Unknown keys and unsupported schema versions must produce actionable
168
+ diagnostics.
169
+
170
+ Project plugins are trusted executable code. Forge must discover and summarize
171
+ them before loading, then require an explicit trust decision for the canonical
172
+ workspace path. Trust state is stored outside the repository so repository code
173
+ cannot mark itself trusted. In non-interactive mode, untrusted project plugins
174
+ are skipped. An explicit `forge plugins trust --yes` records trust outside the
175
+ project before later runs.
176
+
177
+ Forge will not automatically install plugin dependencies or run package-manager
178
+ lifecycle scripts during discovery.
179
+
180
+ ## Precedence
181
+
182
+ For ordinary settings, later sources override earlier sources:
183
+
184
+ ```text
185
+ built-in defaults < ~/.forge/config.json < project .forge/config.json
186
+ < environment variables < explicit CLI flags
187
+ ```
188
+
189
+ Every configuration value keeps its source metadata so `forge config show` and
190
+ run traces can explain the effective result. Configuration discovery and merge
191
+ happen once at startup; Forge does not silently change settings during a run.
192
+ The schema classifies keys by scope: user-only security settings reject project
193
+ values, while safety limits use the stricter value instead of ordinary
194
+ last-writer-wins merging.
195
+
196
+ Security and instruction precedence are intentionally different:
197
+
198
+ ```text
199
+ Security decisions: deny > confirm > allow (strictest contribution wins)
200
+ Instructions: user request > loaded skill > nearest project AGENTS.md
201
+ > project-root AGENTS.md > ~/.forge/AGENTS.md
202
+ ```
203
+
204
+ Skill name collisions use a separate resource rule:
205
+
206
+ ```text
207
+ explicit $skill-name selection > project > user > builtin
208
+ ```
209
+
210
+ Core policy defines a mandatory safety floor. Explicit CLI choices and user
211
+ configuration may select a supported permission profile, while project content
212
+ and plugins may only make an action stricter. They can never make a mandatory
213
+ decision less strict. The instruction ordering applies only when instructions
214
+ do not conflict with the security boundary or higher-level runtime constraints.
215
+ User-level `~/.forge/AGENTS.md` is loaded before the project hierarchy.
216
+ Forge-specific plugins may contribute prompt instructions only through typed
217
+ hooks, and their source must remain visible in the trace.
218
+
219
+ ## Deferred decisions
220
+
221
+ - Configuration migrations beyond `schemaVersion: 1`
222
+ - Additional environment-variable mappings beyond the v0.1 model settings
223
+ - Additional Skill manifest and compatibility rules beyond the current
224
+ `SKILL.md` convention
225
+ - Whether restricted plugins run in a child process or an OS sandbox
@@ -0,0 +1,94 @@
1
+ # npm Release Guide
2
+
3
+ 简体中文 · Documentation index
4
+
5
+ Forge keeps its implementation packages private and publishes one user-facing
6
+ package: `@jslee124/forge`. The generated package contains the CLI, bundled
7
+ `@forge/*` workspace code, and reviewed version-matched built-in Skill assets.
8
+ Third-party libraries remain ordinary npm runtime dependencies. The plugin SDK
9
+ is not a separately published package.
10
+
11
+ ## Distribution contract
12
+
13
+ - Install: `npm install --global @jslee124/forge`
14
+ - Command: `forge`
15
+ - Stable npm tag: `latest`
16
+ - Prerelease npm tag: `next`
17
+ - Runtime baseline: Node.js 24 or newer
18
+ - Generated package directory: `dist/npm/forge`
19
+
20
+ The source package at `apps/cli` remains private. `pnpm build:package` creates
21
+ the public manifest and bundle in the ignored `dist/npm/forge` directory, so
22
+ development-only files cannot enter the registry by accident.
23
+
24
+ ## Prepare a release
25
+
26
+ Start from a clean checkout and choose a semantic version:
27
+
28
+ ```bash
29
+ pnpm version:set 0.3.0
30
+ pnpm install --frozen-lockfile
31
+ pnpm check
32
+ pnpm check:docs
33
+ pnpm test
34
+ pnpm eval:deterministic
35
+ pnpm package:verify
36
+ pnpm release:verify-tag v0.3.0
37
+ ```
38
+
39
+ `package:verify` builds the public artifact, inspects the tarball, installs it
40
+ into a fresh temporary prefix with lifecycle scripts disabled, verifies the
41
+ exact built-in Skill/reference/template allowlist and API version, and checks
42
+ `forge --version`, `forge --help`, and `forge config validate`.
43
+
44
+ Review `npm pack --dry-run` output and release notes before tagging. Never
45
+ include API keys, auth files, local traces, `.env` files, or evaluation
46
+ artifacts that were not explicitly reviewed for publication.
47
+
48
+ ## First npm publication
49
+
50
+ The npm account or organization must control the `@jslee124` scope and have 2FA
51
+ enabled. npm requires a package to exist before a trusted publisher can be
52
+ attached. Bootstrap the package with a reviewed prerelease such as
53
+ `0.3.0-bootstrap.0` under a non-stable dist-tag, then configure the repository's
54
+ `publish.yml` as the package's GitHub Actions trusted publisher. Do not assign
55
+ the bootstrap build to `latest`.
56
+
57
+ After trusted publishing is configured, stable releases should come only from
58
+ the tag workflow. It uses OIDC instead of a long-lived npm token and publishes
59
+ the generated package after all release gates pass.
60
+
61
+ ## Publish a stable release
62
+
63
+ Commit the version, release notes, and generated-input changes, then create an
64
+ annotated immutable tag:
65
+
66
+ ```bash
67
+ git tag -a v0.3.0 -m "Forge v0.3.0"
68
+ git push origin v0.3.0
69
+ ```
70
+
71
+ The `Publish npm package` workflow verifies that the Git tag, root version,
72
+ private workspace versions, runtime version, and generated npm package all
73
+ match before it runs `npm publish --access public`.
74
+
75
+ Use `npm publish --tag next` only for deliberate prereleases. Do not move a
76
+ published Git tag or reuse an npm version. Fix a bad release with a new patch
77
+ version and leave the prior artifact available for rollback.
78
+
79
+ ## User updates
80
+
81
+ Installed users can check or update explicitly:
82
+
83
+ ```bash
84
+ forge update check
85
+ forge update
86
+ forge update 0.3.1
87
+ ```
88
+
89
+ Interactive startup refreshes an advisory npm check in the background at most
90
+ once per 24 hours and displays cached results on a later launch. It never
91
+ installs an update automatically. Set
92
+ `FORGE_DISABLE_UPDATE_CHECK=1` to disable startup checks. The explicit update
93
+ command resolves npm metadata to an exact semantic version before invoking
94
+ `npm install --global --ignore-scripts`.