boxdown 1.0.0

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 (58) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +115 -0
  3. package/assets/devcontainer/README.md +177 -0
  4. package/assets/devcontainer/devcontainer.json +83 -0
  5. package/assets/devcontainer/hooks/initialize.sh +55 -0
  6. package/assets/devcontainer/hooks/post-create.sh +67 -0
  7. package/assets/devcontainer/hooks/post-start.sh +34 -0
  8. package/assets/devcontainer/ssh-config-install.sh +172 -0
  9. package/assets/devcontainer/start.sh +485 -0
  10. package/assets/devcontainer/utils/codex-cli-update.sh +9 -0
  11. package/assets/devcontainer/utils/coding-agent-cli-update.sh +360 -0
  12. package/assets/devcontainer/utils/deps-install.sh +87 -0
  13. package/assets/devcontainer/utils/ssh-bootstrap.sh +200 -0
  14. package/dist/bin/cli.cjs +12 -0
  15. package/dist/bin/cli.d.cts +1 -0
  16. package/dist/bin/cli.d.mts +1 -0
  17. package/dist/bin/cli.mjs +14 -0
  18. package/dist/bin/cli.mjs.map +1 -0
  19. package/dist/main-BuEptwlL.cjs +1707 -0
  20. package/dist/main-ZFTrSVgt.mjs +1685 -0
  21. package/dist/main-ZFTrSVgt.mjs.map +1 -0
  22. package/dist/main.cjs +7 -0
  23. package/dist/main.d.cts +24 -0
  24. package/dist/main.d.cts.map +1 -0
  25. package/dist/main.d.mts +24 -0
  26. package/dist/main.d.mts.map +1 -0
  27. package/dist/main.mjs +3 -0
  28. package/docs/README.md +34 -0
  29. package/docs/architecture.md +75 -0
  30. package/docs/conventions.md +29 -0
  31. package/docs/development.md +59 -0
  32. package/docs/features/README.md +14 -0
  33. package/docs/features/generated-config-and-state.md +64 -0
  34. package/docs/features/github-auth-refresh.md +64 -0
  35. package/docs/features/lifecycle.md +64 -0
  36. package/docs/features/ssh-config-and-proxy.md +60 -0
  37. package/docs/features/start-and-shell.md +83 -0
  38. package/docs/testing.md +63 -0
  39. package/docs/todo.md +170 -0
  40. package/package.json +128 -0
  41. package/src/bin/cli.ts +9 -0
  42. package/src/coding-agents.ts +22 -0
  43. package/src/config.ts +81 -0
  44. package/src/constants.ts +9 -0
  45. package/src/devcontainer-cli.ts +57 -0
  46. package/src/devcontainer.ts +394 -0
  47. package/src/doctor.ts +139 -0
  48. package/src/github-git-auth.ts +143 -0
  49. package/src/jsonc.ts +123 -0
  50. package/src/list.ts +102 -0
  51. package/src/main.ts +362 -0
  52. package/src/metadata.ts +84 -0
  53. package/src/paths.ts +117 -0
  54. package/src/process.ts +94 -0
  55. package/src/shell.ts +60 -0
  56. package/src/ssh-config.ts +113 -0
  57. package/src/ssh-key.ts +52 -0
  58. package/src/status.ts +327 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Liran Tal <liran.tal@gmail.com>.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ https://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ <!-- markdownlint-disable -->
2
+
3
+ <p align="center">
4
+ <h1 align="center">
5
+ boxdown
6
+ </h1>
7
+ </p>
8
+
9
+ <p align="center">
10
+ Start and SSH into a reusable Dev Container environment for any local project.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://www.npmjs.com/package/boxdown"><img src="https://badgen.net/npm/v/boxdown" alt="npm version"/></a>
15
+ <a href="https://www.npmjs.com/package/boxdown"><img src="https://badgen.net/npm/license/boxdown" alt="license"/></a>
16
+ <a href="https://www.npmjs.com/package/boxdown"><img src="https://badgen.net/npm/dt/boxdown" alt="downloads"/></a>
17
+ <a href="https://github.com/lirantal/boxdown/actions/workflows/ci.yml"><img src="https://github.com/lirantal/boxdown/actions/workflows/ci.yml/badge.svg?branch=main" alt="build"/></a>
18
+ <a href="https://app.codecov.io/gh/lirantal/boxdown"><img src="https://badgen.net/codecov/c/github/lirantal/boxdown" alt="codecov"/></a>
19
+ <a href="./SECURITY.md"><img src="https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg" alt="Responsible Disclosure Policy" /></a>
20
+ </p>
21
+
22
+ ## Install
23
+
24
+ ```sh
25
+ npm install -g boxdown
26
+ ```
27
+
28
+ You can also run it without installing:
29
+
30
+ ```sh
31
+ npx boxdown start
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ From any project repository on your host:
37
+
38
+ ```sh
39
+ npx boxdown start
40
+ ```
41
+
42
+ Boxdown builds or reuses a Dev Container for the current directory, then opens a shell inside it. The target repository stays clean; Boxdown writes generated configuration and SSH keys under user cache/data directories instead of copying `.devcontainer/` into the project.
43
+
44
+ Boxdown ships and invokes its own `@devcontainers/cli` dependency. It does not require a host/global Dev Containers CLI install.
45
+
46
+ ### Portless SSH
47
+
48
+ Install an SSH alias for the current project:
49
+
50
+ ```sh
51
+ npx boxdown ssh-config install
52
+ ```
53
+
54
+ By default this creates a `<repo-name>-devcontainer` SSH host. Validate it with:
55
+
56
+ ```sh
57
+ ssh <repo-name>-devcontainer 'whoami && pwd'
58
+ ```
59
+
60
+ Use the same alias in Cursor, Claude, Codex, or any SSH-capable tool.
61
+
62
+ ### Commands
63
+
64
+ ```sh
65
+ boxdown start
66
+ boxdown codex
67
+ boxdown claude
68
+ boxdown cc
69
+ boxdown opencode
70
+ boxdown antigravity
71
+ boxdown list
72
+ boxdown status
73
+ boxdown stop
74
+ boxdown down
75
+ boxdown doctor
76
+ boxdown ssh-config install
77
+ boxdown ssh-proxy
78
+ boxdown refresh-gh-token
79
+ boxdown refresh-gh-token-running
80
+ ```
81
+
82
+ `boxdown shell` remains supported as an alias for `boxdown start`, but
83
+ documentation uses `start` as the canonical command.
84
+
85
+ The coding-agent commands start or reuse the devcontainer, refresh the selected
86
+ CLI, then launch it directly inside the container. Use `--` to pass arguments to
87
+ the agent:
88
+
89
+ ```sh
90
+ boxdown claude -- --continue
91
+ ```
92
+
93
+ List Boxdown-known devcontainer environments from any directory:
94
+
95
+ ```sh
96
+ boxdown list
97
+ boxdown list --json
98
+ ```
99
+
100
+ Shared options:
101
+
102
+ ```sh
103
+ --workspace <path> # target project directory, defaults to cwd
104
+ --alias <name> # SSH alias, defaults to <repo-name>-devcontainer
105
+ --recreate # recreate the devcontainer before starting
106
+ --json # JSON output for status and list
107
+ ```
108
+
109
+ ## Contributing
110
+
111
+ Please consult [CONTRIBUTING](./CONTRIBUTING.md) for guidelines on contributing to this project.
112
+
113
+ ## Author
114
+
115
+ **boxdown** © [Liran Tal](https://github.com/lirantal), Released under the [Apache-2.0](./LICENSE) License.
@@ -0,0 +1,177 @@
1
+ # Dev container
2
+
3
+ Run this project in a **consistent Node.js 24 + TypeScript** environment without installing toolchains on your machine. Dependencies install automatically; your repo is the workspace inside the container.
4
+
5
+ ## Why use it?
6
+
7
+ - **Same stack for everyone** — Node 24, pnpm, and tooling match CI and collaborators.
8
+ - **Fast onboarding** — Open the folder in a container; `pnpm install` and local git tweaks run once after create.
9
+ - **Host secrets, container dev** — `ANTHROPIC_API_KEY` and `SNYK_TOKEN` are passed from your Mac/Linux session into the container when set locally (see below).
10
+ - **Optional CLI workflow** — Use `start.sh` if you prefer a terminal-driven container instead of only the editor.
11
+ - **Portless SSH workflow** — Install a normal SSH host alias that proxies into the devcontainer without publishing an SSH port.
12
+
13
+ ## What’s here
14
+
15
+ | File | Role |
16
+ | ---- | ---- |
17
+ | `devcontainer.json` | Image, mounts (e.g. your `~/.gitconfig`), lifecycle commands, env forwarding. |
18
+ | `start.sh` | Brings the dev container up with the Dev Containers CLI, then opens a shell **inside** the container or acts as an SSH `ProxyCommand`. |
19
+ | `ssh-config-install.sh` | Installs/updates a host SSH config alias for Cursor, Claude, or plain `ssh`. |
20
+ | `hooks/initialize.sh` | Runs on the host before container create/start; prepares the env file and optional secrets. |
21
+ | `hooks/post-create.sh` | Runs once after the container is created — e.g. installs [APM](https://github.com/microsoft/apm) (Agent Package Manager), coding-agent CLIs, and OpenSSH server. |
22
+ | `hooks/post-start.sh` | Runs on each container start; refreshes runtime state such as SSH host keys and authorized keys. |
23
+ | `utils/ssh-bootstrap.sh` | Container-side OpenSSH install/runtime helper used by lifecycle scripts. |
24
+ | `utils/coding-agent-cli-update.sh` | Shared install/update helper for Codex, OpenCode, Claude Code, and Antigravity CLI. |
25
+ | `utils/deps-install.sh` | Dependency installation helper used by `hooks/post-create.sh`. |
26
+
27
+ ## Usage
28
+
29
+ ### Editor (recommended)
30
+
31
+ 1. Install the **Dev Containers** extension (VS Code) or use Cursor’s dev container support.
32
+ 2. **Command Palette** → *Dev Containers: Reopen in Container* (or *Rebuild Container* after config changes).
33
+ 3. Wait for create/start; the editor attaches when ready.
34
+
35
+ ### Terminal only
36
+
37
+ From the **repository root** on your host:
38
+
39
+ ```bash
40
+ bash .devcontainer/start.sh
41
+ ```
42
+
43
+ Requires Docker running. The script resolves Boxdown's packaged `@devcontainers/cli` dependency and uses that binary to `up` the workspace and `exec` into `bash`; it does not install or use a host/global Dev Containers CLI package.
44
+
45
+ ### GitHub CLI auth from host `gh`
46
+
47
+ If your host machine is already authenticated with the GitHub CLI, refresh the container's
48
+ GitHub CLI auth from the host token:
49
+
50
+ ```bash
51
+ bash .devcontainer/start.sh --refresh-gh-token
52
+ ```
53
+
54
+ This starts or reuses the dev container, reads the host token with:
55
+
56
+ ```bash
57
+ gh auth token
58
+ ```
59
+
60
+ and stores it using the container's own `gh auth login --with-token` flow. After that,
61
+ `gh` commands inside the container can use the normal GitHub CLI auth store without
62
+ sourcing an environment file:
63
+
64
+ ```bash
65
+ gh auth status
66
+ gh pr status
67
+ ```
68
+
69
+ The refresh also configures this repository's local Git config so GitHub remotes
70
+ use HTTPS and ask the container's `gh` for credentials during `git fetch`,
71
+ `git pull`, and `git push`. This is intentionally tied to the explicit refresh
72
+ command; regular SSH remote connections do not copy GitHub credentials.
73
+
74
+ If your host `.gitconfig` is mounted into the container, Boxdown adds local
75
+ repository settings that neutralize incompatible host-only helpers such as
76
+ `/opt/homebrew/bin/gh` and broad rewrites such as
77
+ `url.git@github.com:.insteadOf=https://github.com/`.
78
+
79
+ If the container is already running and you only want to refresh its GitHub auth:
80
+
81
+ ```bash
82
+ bash .devcontainer/start.sh --refresh-gh-token-running
83
+ ```
84
+
85
+ The refresh is intentionally non-interactive. It does not start a browser login or ask
86
+ for a device code. If host `gh` is missing, logged out, or cannot return a token, the
87
+ refresh is skipped so container startup is not blocked. Run `gh auth login` on the host
88
+ first when you need to repair host GitHub auth.
89
+
90
+ ### Portless SSH alias
91
+
92
+ From the **repository root** on your host, install or update the SSH alias:
93
+
94
+ ```bash
95
+ bash .devcontainer/start.sh ssh-config install
96
+ ```
97
+
98
+ By default, this creates:
99
+
100
+ - A repo-local SSH identity at `.devcontainer/.ssh/id_ed25519`.
101
+ - A marked `Host <repo-name>-devcontainer` block in `~/.ssh/config`, where `<repo-name>` is the local repository directory name.
102
+ - A `ProxyCommand` that runs `.devcontainer/start.sh --ssh-proxy`.
103
+
104
+ Validate with plain OpenSSH first:
105
+
106
+ ```bash
107
+ ssh <repo-name>-devcontainer 'whoami && pwd'
108
+ ```
109
+
110
+ Then use the same host alias in Cursor, Claude, or any other SSH client:
111
+
112
+ - **SSH Host:** `<repo-name>-devcontainer`
113
+ - **SSH Port:** leave empty
114
+ - **Identity File:** leave empty if the client reads `~/.ssh/config`; otherwise use `.devcontainer/.ssh/id_ed25519`
115
+ - **Remote Folder:** select `<repo-name>` from the default home folder, or enter `/workspaces/<repo-name>`
116
+
117
+ To customize the alias, run:
118
+
119
+ ```bash
120
+ bash .devcontainer/ssh-config-install.sh --alias my-project-devcontainer
121
+ ```
122
+
123
+ This workflow does not publish an SSH port. OpenSSH talks to `sshd -i` over `docker exec`, while `@devcontainers/cli up` still owns the devcontainer lifecycle. The installer is idempotent and `start.sh --ssh-proxy` quietly refreshes the generated SSH config before proxying.
124
+
125
+ ### Coding agents over SSH
126
+
127
+ If you are a coding agent running on the host OS, prefer the SSH alias workflow. It gives Claude, Cursor, Codex, and plain OpenSSH a normal SSH host while preserving this repo's devcontainer lifecycle.
128
+
129
+ From the repository root on the host:
130
+
131
+ ```bash
132
+ bash .devcontainer/start.sh ssh-config install
133
+ ssh <repo-name>-devcontainer 'whoami && pwd'
134
+ ```
135
+
136
+ Use the generated host alias when configuring the agent:
137
+
138
+ - **SSH Host:** `<repo-name>-devcontainer`
139
+ - **SSH Port:** leave empty
140
+ - **Identity File:** leave empty if the agent honors `~/.ssh/config`; otherwise use `.devcontainer/.ssh/id_ed25519`
141
+ - **Remote Folder:** select `<repo-name>` from the default home folder, or enter `/workspaces/<repo-name>`
142
+
143
+ `start.sh` has two modes:
144
+
145
+ - `bash .devcontainer/start.sh` starts or reuses the devcontainer and opens an interactive shell. Use this for a local terminal session.
146
+ - `bash .devcontainer/start.sh ssh-config install` installs or refreshes the host SSH alias and exits.
147
+ - `bash .devcontainer/start.sh --ssh-proxy` refreshes the SSH alias, starts or reuses the devcontainer, and then bridges SSH over `docker exec`. Do not keep this running manually in a terminal; it is meant to be launched by OpenSSH as the `ProxyCommand` in the generated SSH config.
148
+ - `bash .devcontainer/start.sh --refresh-gh-token` starts or reuses the devcontainer, then refreshes container `gh` auth from host `gh` when a token is available.
149
+ - `bash .devcontainer/start.sh --refresh-gh-token-running` refreshes container `gh` auth from host `gh` only when the devcontainer is already running.
150
+
151
+ If the devcontainer does not exist yet, the first SSH connection through `<repo-name>-devcontainer` will create it with `@devcontainers/cli up`, including `initializeCommand`, features, mounts, `postCreateCommand`, and `postStartCommand`. The first connection may take longer while the container is created.
152
+
153
+ ## Environment variables (host → container)
154
+
155
+ Set these **on your machine** before opening/rebuilding the container so they appear inside:
156
+
157
+ ```bash
158
+ export ANTHROPIC_API_KEY=sk-...
159
+ export SNYK_TOKEN=...
160
+ ```
161
+
162
+ They are wired in `devcontainer.json` under `containerEnv` via `localEnv`.
163
+
164
+ If `OP_SERVICE_ACCOUNT_TOKEN` is present, it authenticates the 1Password CLI.
165
+ It is not a GitHub token and does not authenticate `gh` or GitHub Git remotes.
166
+
167
+ ## Optional customization
168
+
169
+ - **Global agent config** — Boxdown automatically mounts host `~/.agents`
170
+ read-only at `/home/node/.agents` when that directory exists. Recreate the
171
+ devcontainer after creating or removing it so the mount set is refreshed.
172
+ - **Agent config on the host** — Uncomment the `mounts` entries in `devcontainer.json` to bind `~/.claude`, `~/.gemini`, or `~/.codex` into the container so coding agents see your existing settings.
173
+ - **1Password / other CLIs** — Follow the commented blocks in `devcontainer.json` and `hooks/post-create.sh` if you need them; keep the image lean by default.
174
+
175
+ ---
176
+
177
+ After scaffolding, edit paths and secrets to match your team’s policies; this folder is yours to extend.
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "Project Devcontainer",
3
+ "image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie",
4
+ "features": {
5
+ "ghcr.io/devcontainers/features/python@sha256:fbcad6955caeecc5ad3f7886baf652e25cba5225a6c4c2287c536de2e5607511": {
6
+ "version": "3.12",
7
+ "installPythonDevDependencies": true
8
+ },
9
+ "ghcr.io/devcontainer-community/devcontainer-features/astral.sh-uv@sha256:36f95b90080248a05aba7b1b3cecf8018bb6d7222f6274f03f050b502abd4fe7": {
10
+ "shellautocompletion": true
11
+ },
12
+ "ghcr.io/devcontainers-extra/features/ripgrep@sha256:0dfc0ac16f0d6aa754d006a138fd4cb4a62c245d308306edf8ad1b7a80b8fdf2": {},
13
+ "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671": {}
14
+ },
15
+ // Ask the editor to forward these container ports (no Docker appPort).
16
+ "forwardPorts": [8787, 3005, 3001, 3000],
17
+
18
+ "portsAttributes": {
19
+ "8787": {
20
+ "label": "Hono Dev Server",
21
+ "onAutoForward": "notify"
22
+ },
23
+ "3005": {
24
+ "label": "Nuxt Dev Server",
25
+ "onAutoForward": "notify"
26
+ },
27
+ "3001": {
28
+ "label": "Nuxt Preview Server",
29
+ "onAutoForward": "silent"
30
+ },
31
+ "3000": {
32
+ "label": "Published dev server",
33
+ "protocol": "http",
34
+ "onAutoForward": "notify",
35
+ "requireLocalPort": false
36
+ },
37
+ // only enable when running Caddy http proxy in the container
38
+ // "80": {
39
+ // "label": "Caddy HTTP",
40
+ // "onAutoForward": "notify"
41
+ // },
42
+ // "443": {
43
+ // "label": "Caddy HTTPS",
44
+ // "onAutoForward": "notify"
45
+ // }
46
+ },
47
+
48
+ "otherPortsAttributes": {
49
+ "onAutoForward": "notify",
50
+ "requireLocalPort": false
51
+ },
52
+
53
+ "mounts": [
54
+ "source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached",
55
+ // mount host user home directories for agents:
56
+ // "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind,consistency=cached",
57
+ // "source=${localEnv:HOME}/.gemini,target=/home/node/.claude,type=bind,consistency=cached",
58
+ // "source=${localEnv:HOME}/.codex,target=/home/node/.codex,type=bind,consistency=cached"
59
+ ],
60
+
61
+ // Initialize optional host-side secrets before container create/start.
62
+ "initializeCommand": "bash .devcontainer/hooks/initialize.sh",
63
+ // After up, discover the published host binding, e.g.:
64
+ // docker port <container-name-or-id> 3000/tcp
65
+ "runArgs": [
66
+ // publish container port 3000 with dynamic host port (CLI / start.sh)
67
+ "-p",
68
+ "127.0.0.1::3000",
69
+ // pass the development environment file to the container
70
+ "--env-file",
71
+ "${localWorkspaceFolder}/.env.development"
72
+ ],
73
+ // --
74
+ "postCreateCommand": "bash .devcontainer/hooks/post-create.sh",
75
+ "postStartCommand": "bash .devcontainer/hooks/post-start.sh",
76
+ "remoteUser": "node",
77
+ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
78
+ "containerEnv": {
79
+ "NODE_ENV": "development",
80
+ "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}",
81
+ "SNYK_TOKEN": "${localEnv:SNYK_TOKEN}"
82
+ }
83
+ }
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # initialize: runs on host before container create/start (initializeCommand).
3
+ # Prepares .env.development and, when possible, injects OP_SERVICE_ACCOUNT_TOKEN from 1Password.
4
+
5
+ set -euo pipefail
6
+
7
+ HOOKS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ WORKSPACE_DIR="${BOXDOWN_WORKSPACE_FOLDER:-$(cd "${HOOKS_DIR}/../.." && pwd)}"
9
+ ENV_FILE="${WORKSPACE_DIR}/.env.development"
10
+ OP_TOKEN_REFERENCE="op://Private/1Password op CLI Service Account for DevContainers/password"
11
+
12
+ main() {
13
+ ensure_env_file_exists
14
+ maybe_inject_1password_service_account_token
15
+ }
16
+
17
+ ensure_env_file_exists() {
18
+ if [[ ! -f "${ENV_FILE}" ]]; then
19
+ : > "${ENV_FILE}"
20
+ fi
21
+ }
22
+
23
+ maybe_inject_1password_service_account_token() {
24
+ local token
25
+
26
+ if ! command -v op >/dev/null 2>&1; then
27
+ echo "initialize.sh: op CLI not found; leaving ${ENV_FILE} unchanged."
28
+ return 0
29
+ fi
30
+
31
+ if ! token="$(op read "${OP_TOKEN_REFERENCE}" 2>/dev/null)"; then
32
+ echo "initialize.sh: could not read OP service token from 1Password; leaving ${ENV_FILE} unchanged."
33
+ return 0
34
+ fi
35
+
36
+ if [[ -z "${token}" ]]; then
37
+ echo "initialize.sh: OP service token is empty; leaving ${ENV_FILE} unchanged."
38
+ return 0
39
+ fi
40
+
41
+ upsert_env_var "OP_SERVICE_ACCOUNT_TOKEN" "${token}"
42
+ }
43
+
44
+ upsert_env_var() {
45
+ local key="$1"
46
+ local value="$2"
47
+ local tmp_file
48
+
49
+ tmp_file="$(mktemp)"
50
+ awk -F= -v k="${key}" '$1 != k' "${ENV_FILE}" > "${tmp_file}"
51
+ printf '%s=%s\n' "${key}" "${value}" >> "${tmp_file}"
52
+ mv "${tmp_file}" "${ENV_FILE}"
53
+ }
54
+
55
+ main "$@"