ndomo 0.1.0 → 0.2.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.
- package/.env.example +4 -0
- package/README.es.md +29 -23
- package/README.md +64 -24
- package/bun.lock +447 -0
- package/docs/configuration.md +4 -4
- package/docs/installation.md +53 -34
- package/docs/installer.md +164 -0
- package/docs/integrations.md +1 -1
- package/docs/web-ui.md +124 -0
- package/package.json +43 -4
- package/scripts/install.sh +28 -0
- package/scripts/smoke-install.sh +47 -0
- package/scripts/smoke-web.sh +335 -0
- package/src/cli/__tests__/install.test.ts +733 -0
- package/src/cli/index.ts +8 -0
- package/src/cli/install.ts +1273 -0
- package/src/config/__tests__/schema.test.ts +223 -0
- package/src/config/schema.ts +129 -16
- package/src/http/__tests__/auth.test.ts +10 -10
- package/src/http/__tests__/spa.test.ts +296 -0
- package/src/http/auth.ts +8 -1
- package/src/http/server.ts +71 -2
- package/.bun-version +0 -1
- package/.dockerignore +0 -79
- package/.editorconfig +0 -18
- package/.github/CODEOWNERS +0 -8
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -62
- package/.github/ISSUE_TEMPLATE/config.yml +0 -2
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
- package/.github/dependabot.yml +0 -36
- package/.github/pull_request_template.md +0 -24
- package/.github/release.yml +0 -30
- package/.github/workflows/gitleaks.yml +0 -28
- package/.github/workflows/release-please.yml +0 -27
- package/.github/workflows/smoke.yml +0 -29
- package/.husky/commit-msg +0 -1
- package/CHANGELOG.md +0 -114
- package/Dockerfile +0 -32
- package/bin/ndomo-analyses.ts +0 -4
- package/bin/ndomo-status.ts +0 -4
- package/biome.json +0 -57
- package/commitlint.config.js +0 -3
- package/opencode.json +0 -5
- package/release-please-config.json +0 -11
- package/scripts/dev-bust-cache.sh +0 -164
- package/scripts/smoke-e2e.ts +0 -704
- package/scripts/smoke-hot.ts +0 -417
- package/scripts/smoke-v4.ts +0 -256
- package/scripts/smoke-v5.ts +0 -397
- package/scripts/uninstall.sh +0 -224
- package/src/index.ts +0 -37
- package/src/lib.ts +0 -65
- package/src/mem/scoped.ts +0 -65
- package/src/orchestrator/background.test.ts +0 -268
- package/src/orchestrator/background.ts +0 -293
- package/src/orchestrator/memory-hook.ts +0 -182
- package/src/orchestrator/reconciler.ts +0 -123
- package/src/orchestrator/scheduler.test.ts +0 -300
- package/src/orchestrator/scheduler.ts +0 -243
- package/src/plugin.test.ts +0 -2574
- package/src/plugin.ts +0 -1690
- package/src/worktrees/manager.ts +0 -236
- package/src/worktrees/state.ts +0 -87
- package/tests/integration/ranger-flow.test.ts +0 -257
- package/tsconfig.json +0 -31
package/.github/release.yml
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Configures GitHub release notes auto-generation
|
|
2
|
-
# See: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
|
|
3
|
-
changelog:
|
|
4
|
-
exclude:
|
|
5
|
-
labels:
|
|
6
|
-
- ignore-for-release
|
|
7
|
-
- duplicate
|
|
8
|
-
- invalid
|
|
9
|
-
categorize:
|
|
10
|
-
- title: Breaking Changes
|
|
11
|
-
labels:
|
|
12
|
-
- breaking-change
|
|
13
|
-
- breaking
|
|
14
|
-
- title: 🚀 Features
|
|
15
|
-
labels:
|
|
16
|
-
- enhancement
|
|
17
|
-
- feature
|
|
18
|
-
- title: 🐛 Bug Fixes
|
|
19
|
-
labels:
|
|
20
|
-
- bug
|
|
21
|
-
- fix
|
|
22
|
-
- title: 📚 Documentation
|
|
23
|
-
labels:
|
|
24
|
-
- documentation
|
|
25
|
-
- docs
|
|
26
|
-
- title: 🔧 Maintenance
|
|
27
|
-
labels:
|
|
28
|
-
- chore
|
|
29
|
-
- dependencies
|
|
30
|
-
- ci
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# .github/workflows/gitleaks.yml
|
|
2
|
-
# Secret scanning via gitleaks
|
|
3
|
-
name: gitleaks
|
|
4
|
-
|
|
5
|
-
on:
|
|
6
|
-
push:
|
|
7
|
-
branches: [main, develop]
|
|
8
|
-
pull_request:
|
|
9
|
-
branches: [main, develop]
|
|
10
|
-
|
|
11
|
-
permissions:
|
|
12
|
-
contents: read
|
|
13
|
-
pull-requests: read
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
scan:
|
|
17
|
-
name: gitleaks scan
|
|
18
|
-
runs-on: ubuntu-latest
|
|
19
|
-
steps:
|
|
20
|
-
- name: Checkout
|
|
21
|
-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
22
|
-
|
|
23
|
-
- name: Run gitleaks
|
|
24
|
-
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
|
|
25
|
-
env:
|
|
26
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
-
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: true
|
|
28
|
-
GITLEAKS_ENABLE_SUMMARY: true
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 — ndomo-v2 contributors
|
|
2
|
-
# SPDX-License-Identifier: MIT
|
|
3
|
-
#
|
|
4
|
-
# Release-please workflow — automated versioning + GitHub Releases
|
|
5
|
-
# Pinned to v5.0.0 commit SHA (audit MISSING-007 principle).
|
|
6
|
-
# See: https://github.com/googleapis/release-please-action
|
|
7
|
-
|
|
8
|
-
name: release-please
|
|
9
|
-
|
|
10
|
-
on:
|
|
11
|
-
push:
|
|
12
|
-
branches:
|
|
13
|
-
- main
|
|
14
|
-
|
|
15
|
-
permissions:
|
|
16
|
-
contents: write
|
|
17
|
-
pull-requests: write
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
release-please:
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
steps:
|
|
23
|
-
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
|
|
24
|
-
with:
|
|
25
|
-
release-type: node
|
|
26
|
-
package-name: ndomo
|
|
27
|
-
config-file: release-please-config.json
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: smoke
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
smoke:
|
|
11
|
-
runs-on: ${{ matrix.os }}
|
|
12
|
-
strategy:
|
|
13
|
-
fail-fast: false
|
|
14
|
-
matrix:
|
|
15
|
-
os: [ubuntu-latest, ubuntu-24.04, macos-latest]
|
|
16
|
-
bun-version: ['1.3.14', 'latest']
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
19
|
-
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
|
20
|
-
with:
|
|
21
|
-
bun-version: ${{ matrix.bun-version }}
|
|
22
|
-
cache: true
|
|
23
|
-
- run: bun install
|
|
24
|
-
- name: Security audit (bun audit)
|
|
25
|
-
run: bun audit --audit-level=high
|
|
26
|
-
- run: bun run lint
|
|
27
|
-
- run: bun run typecheck
|
|
28
|
-
- run: bun test
|
|
29
|
-
- run: bun run test:smoke
|
package/.husky/commit-msg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bunx --no -- commitlint --edit ${1}
|
package/CHANGELOG.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- **Ranger agent** — 4th primary agent (`mode: primary`, `model:
|
|
13
|
-
minimax/MiniMax-M3`, `temp: 0.3`) for analysis/cartography/onboarding
|
|
14
|
-
workflows. Read-write guard rails: `edit: deny` for source code,
|
|
15
|
-
`write: ask`, `bash: ask` with read-only allowlist. Delegates to
|
|
16
|
-
`scout` / `sage` / `scribe` for mapping and research.
|
|
17
|
-
- **`analyses` table + FTS5** — standalone SQLite table for persisted
|
|
18
|
-
research output (slug, title, project_path, summary, findings_json,
|
|
19
|
-
source_plan_id, agent, session_id, archived_at). External-content
|
|
20
|
-
FTS5 index over `title` + `summary` + `findings_json` with sync
|
|
21
|
-
triggers. Migration v14.
|
|
22
|
-
- **Analysis CRUD module** (`src/db/analyses.ts`) — `createAnalysis`,
|
|
23
|
-
`getAnalysis`, `getAnalysisBySlug`, `listAnalyses`, `searchAnalyses`
|
|
24
|
-
(FTS), `updateAnalysis`, `archiveAnalysis`, `linkAnalysisToPlan`,
|
|
25
|
-
`unlinkAnalysisFromPlan`. 40 unit tests covering FK validation,
|
|
26
|
-
FTS sync, soft-delete, and slug uniqueness.
|
|
27
|
-
- **7 analysis tools** registered in the OpenCode plugin:
|
|
28
|
-
`analysis_create`, `analysis_get`, `analysis_list`,
|
|
29
|
-
`analysis_search`, `analysis_update`, `analysis_archive`,
|
|
30
|
-
`analysis_link_plan`.
|
|
31
|
-
- **`ndomo-analyses` CLI** — `list` / `get` / `search` / `archive`
|
|
32
|
-
subcommands reading from the project-local `.ndomo/state.db`.
|
|
33
|
-
- **Integration test suite** (`tests/integration/ranger-flow.test.ts`)
|
|
34
|
-
— 13 end-to-end tests covering create→link→search→archive→unlink
|
|
35
|
-
flows and FK CASCADE behavior on plan deletion.
|
|
36
|
-
|
|
37
|
-
### Changed
|
|
38
|
-
|
|
39
|
-
- Updated `docs/agents.md` from 21 agents (3 primaries) to 22 agents
|
|
40
|
-
(4 primaries), including cross-primary routing table for the new
|
|
41
|
-
ranger entry point.
|
|
42
|
-
- Routing tables in `foreman.md`, `craftsman.md`, and `warden.md`
|
|
43
|
-
now list ranger alongside the existing primary peers.
|
|
44
|
-
|
|
45
|
-
### Fixed
|
|
46
|
-
|
|
47
|
-
- DB hygiene: enable WAL journal mode, NORMAL synchronous, INCREMENTAL
|
|
48
|
-
auto_vacuum to prevent unbounded `.ndomo/state.db` growth on long-running
|
|
49
|
-
installs. Sticky one-time migration per DB on first open after upgrade.
|
|
50
|
-
New `ndomo vacuum` CLI subcommand (or `bun run src/cli/vacuum.ts`) for
|
|
51
|
-
manual space reclaim via `PRAGMA incremental_vacuum` + `wal_checkpoint(TRUNCATE)`.
|
|
52
|
-
WAL sidecars (`*.db-wal`, `*.db-shm`) added to `.gitignore`.
|
|
53
|
-
- Shutdown cleanup: `src/db/shutdown.ts` now tracks every `openDb()` call in
|
|
54
|
-
a `Set<Database>` so each connection gets `SIGTERM`/`SIGINT`/`beforeExit`
|
|
55
|
-
cleanup. Replaces the module-level `registered` boolean that silently
|
|
56
|
-
skipped every call after the first (leaked file handles on hot-reload,
|
|
57
|
-
CLI tools alongside plugin, smoke tests).
|
|
58
|
-
- Background task retention: `BackgroundDispatcher.finalize(maxAgeMs)` prunes
|
|
59
|
-
terminal tasks (completed/failed/cancelled) older than the threshold; auto-
|
|
60
|
-
called from plugin init when row count exceeds `backgroundRetention.softCap`
|
|
61
|
-
(default 1000). Stops unbounded growth of `background_tasks` on long-running
|
|
62
|
-
installs.
|
|
63
|
-
- Write-tool lock leaks: replaced raw `Map<string, string>` for active writes
|
|
64
|
-
with a `FileLock` class that stamps each entry with `setAt` and prunes stale
|
|
65
|
-
locks via TTL sweep. SDK hook-chain breaks (where `tool.execute.after` never
|
|
66
|
-
fires) no longer block subsequent writes indefinitely. Admin tool
|
|
67
|
-
`ndomo_write_unlock` exposed for manual recovery.
|
|
68
|
-
|
|
69
|
-
## [0.1.0] - 2026-06-20
|
|
70
|
-
|
|
71
|
-
### Added
|
|
72
|
-
|
|
73
|
-
- Initial ndomo orchestrator: `routeTask`, `canRunParallel`, and reconciler
|
|
74
|
-
primitives for multi-agent task dispatch and lifecycle management
|
|
75
|
-
- Multi-agent fleet: `foreman` and `craftsman` primaries plus 19 specialist
|
|
76
|
-
subagents (scout, scribe, painter, smith, sage, guild, inspector,
|
|
77
|
-
chronicler, stack-smiths, and warden ops fleet)
|
|
78
|
-
- OpenCode plugin layer with hooks, custom tools, hot-swap support, and
|
|
79
|
-
frontmatter sync for agent and skill metadata
|
|
80
|
-
- DB module: SQLite-backed plans, tasks, and sessions tables with FTS5 search,
|
|
81
|
-
migrations v1 through v11, and dual plan system (global state.db +
|
|
82
|
-
per-project archive)
|
|
83
|
-
- Memory system integration with `opencode-mem` including scoped tags,
|
|
84
|
-
cross-project retrieval, and project-scoped instincts to prevent
|
|
85
|
-
cross-project contamination
|
|
86
|
-
- Worktree management under `.slim/worktrees/` for parallel, isolated coding
|
|
87
|
-
lanes
|
|
88
|
-
- Flexible builder pipeline (v2 + v3-lows) and `craftsman` primary agent with
|
|
89
|
-
plan_db audit trail and pre-merge critical fixes
|
|
90
|
-
- Curl-based install script with provider picker (ndomo vs stock OpenCode)
|
|
91
|
-
- `reasoning_effort` configuration and bundled skills directory for offline
|
|
92
|
-
distribution
|
|
93
|
-
- `state.db` CLI with 14 tools and 5 migrations covering plan/task/session
|
|
94
|
-
CRUD, FTS search, and checkpoint helpers
|
|
95
|
-
|
|
96
|
-
### Changed
|
|
97
|
-
|
|
98
|
-
- Biome-formatted source tree across all TypeScript modules
|
|
99
|
-
- Documentation refresh covering DB module, flexible builder primary, and
|
|
100
|
-
ad-hoc flow spec
|
|
101
|
-
|
|
102
|
-
### Fixed
|
|
103
|
-
|
|
104
|
-
- Per-project plan archive: drop the global `~/.ndomo/mem/plans` default in
|
|
105
|
-
favor of project-local storage
|
|
106
|
-
- Scoped session foreign-key upsert (Issue #1 hybrid) so session rows respect
|
|
107
|
-
plan scoping rules
|
|
108
|
-
- DB query layer: `getPlan`, `getPlanBySlug`, and `listPlans` now JOIN with
|
|
109
|
-
`plan_files` so file links ship with every plan read
|
|
110
|
-
- Seven medium-priority `craftsman` fixes shipped alongside the Bun skill
|
|
111
|
-
bootstrap for the `js-smith` specialist
|
|
112
|
-
|
|
113
|
-
[Unreleased]: https://github.com/nicosup98/ndomo-v2/compare/v0.1.0...HEAD
|
|
114
|
-
[0.1.0]: https://github.com/nicosup98/ndomo-v2/releases/tag/v0.1.0
|
package/Dockerfile
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# ndomo — OpenCode multi-agent plugin container image
|
|
2
|
-
# Entry point: bun run src/index.ts
|
|
3
|
-
# Base image pinned to bun version from .bun-version (never use `latest`).
|
|
4
|
-
# Multi-stage build keeps final image lean (distroless, no shell).
|
|
5
|
-
|
|
6
|
-
# ---- Stage 1: Install dependencies ----
|
|
7
|
-
FROM oven/bun:1.3.14-distroless AS deps
|
|
8
|
-
WORKDIR /app
|
|
9
|
-
|
|
10
|
-
# Copy package manifests first for layer caching (deps only rebuild when manifests change)
|
|
11
|
-
COPY package.json bun.lock ./
|
|
12
|
-
RUN bun install --frozen-lockfile
|
|
13
|
-
|
|
14
|
-
# Copy application source, bundled assets, and configuration
|
|
15
|
-
COPY src/ ./src/
|
|
16
|
-
COPY skills/ ./skills/
|
|
17
|
-
COPY agents/ ./agents/
|
|
18
|
-
COPY config/ ./config/
|
|
19
|
-
COPY scripts/ ./scripts/
|
|
20
|
-
COPY bin/ ./bin/
|
|
21
|
-
COPY tools/ ./tools/
|
|
22
|
-
COPY opencode.json tsconfig.json biome.json ./
|
|
23
|
-
|
|
24
|
-
# ---- Stage 2: Runtime ----
|
|
25
|
-
FROM oven/bun:1.3.14-distroless
|
|
26
|
-
WORKDIR /app
|
|
27
|
-
|
|
28
|
-
COPY --from=deps /app /app
|
|
29
|
-
|
|
30
|
-
# Plugins are invoked by the OpenCode host; peer deps provided at runtime.
|
|
31
|
-
# JSON-array form avoids shell dependency (distroless has no shell).
|
|
32
|
-
ENTRYPOINT ["bun", "run", "src/index.ts"]
|
package/bin/ndomo-analyses.ts
DELETED
package/bin/ndomo-status.ts
DELETED
package/biome.json
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.5.0/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": false,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": true
|
|
7
|
-
},
|
|
8
|
-
"files": {
|
|
9
|
-
"ignoreUnknown": true,
|
|
10
|
-
"includes": [
|
|
11
|
-
"**/src/**/*",
|
|
12
|
-
"**/scripts/**/*",
|
|
13
|
-
"**/*.ts",
|
|
14
|
-
"**/*.json",
|
|
15
|
-
"!**/.cache",
|
|
16
|
-
"!**/skills",
|
|
17
|
-
"!**/node_modules"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"formatter": {
|
|
21
|
-
"enabled": true,
|
|
22
|
-
"indentStyle": "space",
|
|
23
|
-
"indentWidth": 2,
|
|
24
|
-
"lineWidth": 100,
|
|
25
|
-
"lineEnding": "lf"
|
|
26
|
-
},
|
|
27
|
-
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
28
|
-
"linter": {
|
|
29
|
-
"enabled": true,
|
|
30
|
-
"rules": {
|
|
31
|
-
"preset": "recommended",
|
|
32
|
-
"correctness": {
|
|
33
|
-
"noUnusedVariables": "error",
|
|
34
|
-
"useImportExtensions": "error"
|
|
35
|
-
},
|
|
36
|
-
"style": {
|
|
37
|
-
"noNonNullAssertion": "warn",
|
|
38
|
-
"useConst": "error",
|
|
39
|
-
"useTemplate": "error"
|
|
40
|
-
},
|
|
41
|
-
"suspicious": {
|
|
42
|
-
"noExplicitAny": "warn"
|
|
43
|
-
},
|
|
44
|
-
"complexity": {
|
|
45
|
-
"noBannedTypes": "error"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"javascript": {
|
|
50
|
-
"formatter": {
|
|
51
|
-
"quoteStyle": "double",
|
|
52
|
-
"semicolons": "always",
|
|
53
|
-
"trailingCommas": "all",
|
|
54
|
-
"arrowParentheses": "always"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
package/commitlint.config.js
DELETED
package/opencode.json
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# dev-bust-cache.sh — bust Bun transpiler cache for ndomo dev loop
|
|
3
|
-
#
|
|
4
|
-
# Root cause: Bun caches TS modules in ~/.bun/install/cache/ keyed by resolved
|
|
5
|
-
# path. When ndomo is loaded via symlink, the cache key uses the symlink path,
|
|
6
|
-
# so editing source files doesn't invalidate the cache → stale code served.
|
|
7
|
-
#
|
|
8
|
-
# This script:
|
|
9
|
-
# 1. Optionally kills running opencode processes (--kill)
|
|
10
|
-
# 2. Removes Bun cache entries referencing ndomo or src/index.ts
|
|
11
|
-
# 3. Touches all src/*.ts to bump mtime (forces re-transpilation)
|
|
12
|
-
#
|
|
13
|
-
# Usage:
|
|
14
|
-
# ./scripts/dev-bust-cache.sh # dry-run (show what would be done)
|
|
15
|
-
# ./scripts/dev-bust-cache.sh --apply # actually execute
|
|
16
|
-
# ./scripts/dev-bust-cache.sh --apply --kill # kill opencode + bust cache
|
|
17
|
-
# bun run dev:bust # via package.json (dry-run)
|
|
18
|
-
# bun run dev:reset # kill opencode + bust (apply)
|
|
19
|
-
#
|
|
20
|
-
# Idempotent: safe to run multiple times. No-op if cache is already clean.
|
|
21
|
-
|
|
22
|
-
set -euo pipefail
|
|
23
|
-
|
|
24
|
-
# ── Colors ────────────────────────────────────────────────────────────────────
|
|
25
|
-
RED='\033[0;31m'
|
|
26
|
-
GREEN='\033[0;32m'
|
|
27
|
-
YELLOW='\033[1;33m'
|
|
28
|
-
BLUE='\033[0;34m'
|
|
29
|
-
BOLD='\033[1m'
|
|
30
|
-
NC='\033[0m'
|
|
31
|
-
|
|
32
|
-
info() { printf "${BLUE}[info]${NC} %s\n" "$*"; }
|
|
33
|
-
ok() { printf "${GREEN}[ok]${NC} %s\n" "$*"; }
|
|
34
|
-
warn() { printf "${YELLOW}[warn]${NC} %s\n" "$*"; }
|
|
35
|
-
err() { printf "${RED}[error]${NC} %s\n" "$*" >&2; }
|
|
36
|
-
|
|
37
|
-
# ── Parse flags ───────────────────────────────────────────────────────────────
|
|
38
|
-
APPLY=false
|
|
39
|
-
KILL=false
|
|
40
|
-
|
|
41
|
-
for arg in "$@"; do
|
|
42
|
-
case "$arg" in
|
|
43
|
-
--apply|--force|-f) APPLY=true ;;
|
|
44
|
-
--kill) KILL=true ;;
|
|
45
|
-
--help|-h)
|
|
46
|
-
cat <<EOF
|
|
47
|
-
${BOLD}dev-bust-cache.sh — bust Bun cache for ndomo dev loop${NC}
|
|
48
|
-
|
|
49
|
-
Usage:
|
|
50
|
-
./scripts/dev-bust-cache.sh [OPTIONS]
|
|
51
|
-
|
|
52
|
-
Options:
|
|
53
|
-
--apply Actually execute (default: dry-run, show what would be done)
|
|
54
|
-
--kill Kill running opencode processes before busting
|
|
55
|
-
--help Show this help
|
|
56
|
-
|
|
57
|
-
Without --apply, shows what would be done (dry-run).
|
|
58
|
-
EOF
|
|
59
|
-
exit 0
|
|
60
|
-
;;
|
|
61
|
-
*) err "Unknown option: $arg (try --help)"; exit 1 ;;
|
|
62
|
-
esac
|
|
63
|
-
done
|
|
64
|
-
|
|
65
|
-
# ── Detect project root ───────────────────────────────────────────────────────
|
|
66
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
67
|
-
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
68
|
-
SRC_DIR="$PROJECT_ROOT/src"
|
|
69
|
-
|
|
70
|
-
# ── Bun cache dir ─────────────────────────────────────────────────────────────
|
|
71
|
-
BUN_CACHE="${HOME}/.bun/install/cache"
|
|
72
|
-
|
|
73
|
-
if [[ ! -d "$BUN_CACHE" ]]; then
|
|
74
|
-
warn "Bun cache not found at $BUN_CACHE — nothing to bust"
|
|
75
|
-
exit 0
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# ── Step 1: Kill opencode processes (if --kill) ──────────────────────────────
|
|
79
|
-
if [[ "$KILL" == true ]]; then
|
|
80
|
-
info "Looking for opencode processes..."
|
|
81
|
-
PIDS=$(pgrep -f "opencode" 2>/dev/null || true)
|
|
82
|
-
if [[ -n "$PIDS" ]]; then
|
|
83
|
-
if [[ "$APPLY" == false ]]; then
|
|
84
|
-
info "[dry-run] would kill opencode PIDs: ${PIDS//$'\n'/, }"
|
|
85
|
-
else
|
|
86
|
-
for pid in $PIDS; do
|
|
87
|
-
kill "$pid" 2>/dev/null || true
|
|
88
|
-
done
|
|
89
|
-
sleep 1
|
|
90
|
-
ok "Killed opencode processes"
|
|
91
|
-
fi
|
|
92
|
-
else
|
|
93
|
-
info "No opencode processes found"
|
|
94
|
-
fi
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
|
-
# ── Step 2: Remove Bun cache entries referencing ndomo ───────────────────────
|
|
98
|
-
info "Searching Bun cache for ndomo references..."
|
|
99
|
-
NDOMO_CACHE_FILES=$(grep -rl "ndomo" "$BUN_CACHE" 2>/dev/null || true)
|
|
100
|
-
|
|
101
|
-
if [[ -n "$NDOMO_CACHE_FILES" ]]; then
|
|
102
|
-
COUNT=$(echo "$NDOMO_CACHE_FILES" | wc -l)
|
|
103
|
-
if [[ "$APPLY" == false ]]; then
|
|
104
|
-
info "[dry-run] would remove $COUNT cache file(s) referencing ndomo:"
|
|
105
|
-
echo "$NDOMO_CACHE_FILES" | sed 's/^/ /'
|
|
106
|
-
else
|
|
107
|
-
echo "$NDOMO_CACHE_FILES" | while IFS= read -r f; do
|
|
108
|
-
rm -f "$f"
|
|
109
|
-
done
|
|
110
|
-
ok "Removed $COUNT cache file(s) referencing ndomo"
|
|
111
|
-
fi
|
|
112
|
-
else
|
|
113
|
-
info "No cache files reference ndomo"
|
|
114
|
-
fi
|
|
115
|
-
|
|
116
|
-
# ── Step 3: Remove Bun cache entries referencing ndomo source path ───────────
|
|
117
|
-
# Narrow grep to $PROJECT_ROOT/src to avoid matching unrelated packages
|
|
118
|
-
# that happen to have index.ts in their dist files.
|
|
119
|
-
info "Searching Bun cache for ndomo source path references..."
|
|
120
|
-
INDEX_CACHE_FILES=$(grep -rl "$PROJECT_ROOT/src" "$BUN_CACHE" 2>/dev/null || true)
|
|
121
|
-
|
|
122
|
-
if [[ -n "$INDEX_CACHE_FILES" ]]; then
|
|
123
|
-
COUNT=$(echo "$INDEX_CACHE_FILES" | wc -l)
|
|
124
|
-
if [[ "$APPLY" == false ]]; then
|
|
125
|
-
info "[dry-run] would remove $COUNT cache file(s) referencing $PROJECT_ROOT/src:"
|
|
126
|
-
echo "$INDEX_CACHE_FILES" | sed 's/^/ /'
|
|
127
|
-
else
|
|
128
|
-
echo "$INDEX_CACHE_FILES" | while IFS= read -r f; do
|
|
129
|
-
rm -f "$f"
|
|
130
|
-
done
|
|
131
|
-
ok "Removed $COUNT cache file(s) referencing ndomo source path"
|
|
132
|
-
fi
|
|
133
|
-
else
|
|
134
|
-
info "No cache files reference ndomo source path"
|
|
135
|
-
fi
|
|
136
|
-
|
|
137
|
-
# ── Step 4: Touch all src/*.ts to bump mtime ─────────────────────────────────
|
|
138
|
-
if [[ -d "$SRC_DIR" ]]; then
|
|
139
|
-
info "Touching src/*.ts files to bump mtime..."
|
|
140
|
-
TS_FILES=$(find "$SRC_DIR" -name "*.ts" -type f 2>/dev/null || true)
|
|
141
|
-
if [[ -n "$TS_FILES" ]]; then
|
|
142
|
-
COUNT=$(echo "$TS_FILES" | wc -l)
|
|
143
|
-
if [[ "$APPLY" == false ]]; then
|
|
144
|
-
info "[dry-run] would touch $COUNT .ts file(s) in $SRC_DIR"
|
|
145
|
-
else
|
|
146
|
-
echo "$TS_FILES" | while IFS= read -r f; do
|
|
147
|
-
touch "$f"
|
|
148
|
-
done
|
|
149
|
-
ok "Touched $COUNT .ts file(s)"
|
|
150
|
-
fi
|
|
151
|
-
else
|
|
152
|
-
info "No .ts files found in $SRC_DIR"
|
|
153
|
-
fi
|
|
154
|
-
else
|
|
155
|
-
warn "src/ directory not found at $SRC_DIR"
|
|
156
|
-
fi
|
|
157
|
-
|
|
158
|
-
# ── Summary ──────────────────────────────────────────────────────────────────
|
|
159
|
-
echo ""
|
|
160
|
-
if [[ "$APPLY" == false ]]; then
|
|
161
|
-
warn "DRY RUN — no changes made. Run with --apply to execute."
|
|
162
|
-
else
|
|
163
|
-
ok "Cache busted. Restart opencode to pick up changes."
|
|
164
|
-
fi
|