@opensassi/opencode 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @opensassi/opencode
2
2
 
3
- Agent skill harness for AI-assisted software development. Delivers 12 domain-specific skills (system-design, git workflow, profiling, etc.) and supporting scripts as a standalone npm CLI package.
3
+ Agent skill harness for AI-assisted software development. Delivers 13 domain-specific skills (system-design, git workflow, profiling, etc.) and supporting scripts as a standalone npm CLI package.
4
4
 
5
5
  ```
6
6
  npx @opensassi/opencode init
@@ -43,13 +43,14 @@ npx @opensassi/opencode help # Show help
43
43
  | `daily-evaluation` | Aggregate session evaluations into dashboards |
44
44
  | `git` | Rebase-based single-commit-per-session workflow |
45
45
  | `issue` | GitHub issue management |
46
- | `npm-optimizer` | Port an npm package to a C++ native addon |
46
+ | `npm-optimizer` | Port an npm package to a C++ native addon — 100% test compatibility through profiling-driven iteration |
47
47
  | `opensassi` | Bootstrap a new project environment |
48
48
  | `profiler` | Linux perf profiling + flamegraphs |
49
49
  | `session-evaluation` | Generate structured session reports |
50
50
  | `skill-manager` | Create/revise skills interactively |
51
51
  | `system-design` | Interactive C++ spec authoring with diagrams |
52
52
  | `system-design-review` | Seven-expert panel audit of technical specs |
53
+ | `npx` | Run npx commands in a target directory with automatic directory resolution |
53
54
  | `todo` | Create issues + debugging skills from session context |
54
55
 
55
56
  ## Package Contents
@@ -58,7 +59,7 @@ npx @opensassi/opencode help # Show help
58
59
  |-----------|----------|
59
60
  | `bin/` | CLI entry point (`opencode` binary) |
60
61
  | `lib/` | Programmatic API + command implementations |
61
- | `skills/` | 12 skill definitions (SKILL.md) + skill scripts |
62
+ | `skills/` | 13 skill definitions (SKILL.md) + skill scripts |
62
63
  | `scripts/` | Artifact pipeline (extract, test, verify, check) + installers |
63
64
  | `AGENTS.md` | Agent harness instructions (appended by init) |
64
65
  | `skills-index.json` | Pre-built static skill/command index |
@@ -1,5 +1,6 @@
1
1
  import { readFileSync, existsSync, mkdirSync, writeFileSync, appendFileSync } from 'node:fs'
2
2
  import { resolve } from 'node:path'
3
+ import { spawn } from 'node:child_process'
3
4
  import { resolveAgents, resolveSkill, PKG_ROOT } from '../util/paths.js'
4
5
 
5
6
  function readPackageAgents() {
@@ -114,4 +115,40 @@ export async function initCommand(args) {
114
115
  console.log('.opencode/skills/ already in .gitignore')
115
116
  }
116
117
  }
118
+
119
+ // === Post-write: handoff to opencode ===
120
+
121
+ if (process.env.OPENCODE === '1') {
122
+ console.log('\nFiles written. Use `skill opensassi` to continue within this session.')
123
+ return
124
+ }
125
+
126
+ await spawnOpencode(cwd)
127
+ }
128
+
129
+ async function spawnOpencode(cwd) {
130
+ const { spawnSync } = await import('node:child_process')
131
+ const platform = process.platform
132
+ const whichCmd = platform === 'win32' ? 'where' : 'command'
133
+ const whichArgs = platform === 'win32' ? ['opencode.cmd'] : ['-v', 'opencode']
134
+
135
+ const check = spawnSync(whichCmd, whichArgs, { stdio: 'ignore' })
136
+ if (check.status !== 0) {
137
+ console.log('\nopencode is not installed.\nInstall it, then run: opencode')
138
+ console.log(' curl -fsSL https://opencode.ai/install.sh | sh')
139
+ return
140
+ }
141
+
142
+ console.log('\nInitializing opensassi inside opencode...')
143
+ const child = spawn('opencode', ['run', '--print-logs', 'skill opensassi'], {
144
+ cwd,
145
+ stdio: 'inherit',
146
+ env: { ...process.env }
147
+ })
148
+ return new Promise((resolve) => {
149
+ child.on('exit', (code) => {
150
+ if (code !== 0) console.log(`\nopencode exited with code ${code}`)
151
+ resolve()
152
+ })
153
+ })
117
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensassi/opencode",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Agent skill harness for opencode — bootstrap, system-design, git workflow, profiling, and more",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,4 +37,4 @@
37
37
  "playwright": "^1.60.0",
38
38
  "sharp": "^0.34.5"
39
39
  }
40
- }
40
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT="$(cd "${1:-.}" && pwd)"
5
+
6
+ echo "["
7
+
8
+ # 1. Project root
9
+ echo " {\"name\": \".\", \"path\": \"$ROOT\", \"type\": \"project-root\"}"
10
+
11
+ # 2. external/ subdirectories
12
+ sep=","
13
+ if [ -d "$ROOT/external" ]; then
14
+ for dir in "$ROOT/external"/*/; do
15
+ [ -d "$dir" ] || continue
16
+ name="$(basename "$dir")"
17
+ abspath="$(cd "$dir" && pwd)"
18
+ echo "$sep"
19
+ echo -n " {\"name\": \"$name\", \"path\": \"$abspath\", \"type\": \"external\"}"
20
+ sep=","
21
+ done
22
+ fi
23
+
24
+ # 3. packages/ workspace subdirectories (common in monorepos)
25
+ if [ -d "$ROOT/packages" ]; then
26
+ for dir in "$ROOT/packages"/*/; do
27
+ [ -d "$dir" ] || continue
28
+ name="$(basename "$dir")"
29
+ abspath="$(cd "$dir" && pwd)"
30
+ echo "$sep"
31
+ echo -n " {\"name\": \"$name\", \"path\": \"$abspath\", \"type\": \"workspace\"}"
32
+ sep=","
33
+ done
34
+ fi
35
+
36
+ # 4. src/ subdirectories (common in project dirs)
37
+ if [ -d "$ROOT/src" ]; then
38
+ for dir in "$ROOT/src"/*/; do
39
+ [ -d "$dir" ] || continue
40
+ name="$(basename "$dir")"
41
+ abspath="$(cd "$dir" && pwd)"
42
+ echo "$sep"
43
+ echo -n " {\"name\": \"$name\", \"path\": \"$abspath\", \"type\": \"project\"}"
44
+ sep=","
45
+ done
46
+ fi
47
+
48
+ echo ""
49
+ echo "]"
@@ -40,11 +40,29 @@ Complete the current session: create a single atomic commit, rebase onto latest
40
40
  > **Ordering constraint**: Commit must be created *before* rebase so that rebase moves the single commit to the tip of main. The commit message must be obtained *before* the commit because it requires data from `generate` and `opencode session list`. The evaluation `.md` sidecar is written from the `generate` output (step 10) *after* the commit, so it reflects the final session state including any test-fix loops.
41
41
 
42
42
  **Process:**
43
+
44
+ 0. **Preflight session check**: Run `opencode session list`. Save the most recent session's full ID (with `ses_` prefix). Then check `ls -1 sessions/*.md 2>/dev/null` to list existing sidecar filenames.
45
+ - If the most recent session's noprefix ID already appears in an existing sidecar filename → the current session is NOT persisted yet. **ABORT** with: "Current session ID not found in session list. Session may not be persisted. Run `opencode` to enter the session first, or provide a session ID manually."
46
+ - Do not fabricate or improvise a session ID. Using a fake ID breaks traceability between commit messages, sidecar files, and session archives.
47
+
43
48
  1. **Stage all changes**: `git add -A`
44
49
  2. **Get evaluation title slug**: Load the `session-evaluation` skill via the `skill` tool, then instruct it to run `generate`. Extract the slug from the Session ID field of its output (e.g., `2026-05-11-testing-plan-revision`).
45
- 3. **Get session ID**: Run `opencode session list` and identify the most recent session. Strip the `ses_` prefix to get the noprefix ID (e.g., `1e793e9b0ffeLqAjZOHtI8vy8v`).
50
+ 3. **Get session ID**: Run `opencode session list` and identify the most recent session whose noprefix ID has NOT been used in an existing sidecar filename. Strip the `ses_` prefix to get the noprefix ID (e.g., `1e793e9b0ffeLqAjZOHtI8vy8v`).
51
+
52
+ 3.5. **Validate session ID**:
53
+ a. Does the session ID start with `ses_` before stripping? If not → **ABORT**: "Session ID does not match expected `ses_` format."
54
+ b. Has this noprefix ID been used in an existing sidecar filename? Check `ls sessions/*-<noprefix>.md`. If it exists → **ABORT**: "Session ID has already been used in a previous archive."
55
+ c. Does `opencode export <session-id>` return valid JSON (non-zero bytes)? If not → **ABORT**: "Session ID is not exportable. The session may not be persisted."
56
+ d. If any check fails, do NOT proceed. Report the failure and stop.
46
57
  4. **Construct commit message**: `<title-slug>-<session-id-noprefix>` — this is identical to the session evaluation sidecar filename (e.g., `2026-05-11-testing-plan-revision-1e793e9b0ffeLqAjZOHtI8vy8v`).
47
58
  5. **Create commit**: `git commit -m "<commit-message>"`
59
+
60
+ 5.5. **Validate commit message**: Before proceeding to rebase, verify:
61
+ - `git log --oneline -1` shows the message as `<slug>-<noprefix>`
62
+ - The `<noprefix>` portion matches the session ID from step 3 (without `ses_`)
63
+ - A file `sessions/<message>.md` will be written in step 10 — confirm the path would be unique (not overwriting an existing file)
64
+ If any check fails → **ABORT** and report which constraint was violated. Do not proceed until the commit message is corrected.
65
+
48
66
  6. **Rebase onto main**: `git fetch origin && git rebase origin/main`
49
67
  7. **Handle conflicts**: If conflicts occur:
50
68
  - For each conflicted file, resolve manually (edit to correct state)
@@ -9,6 +9,22 @@ description: Port an existing npm package to a C++ native addon — preserve 100
9
9
 
10
10
  Senior systems engineer specializing in Node.js native addon development and performance optimization. Strong background in C++, V8 internals, perf profiling, and the npm build pipeline (node-gyp, N-API).
11
11
 
12
+ ## Context Architecture
13
+
14
+ This skill is loaded **JIT at the head** of a sub-agent context. The permanent base (system-design skill + full spec tree) is always present in the tail.
15
+
16
+ ### Sub-Agent Loading Contracts
17
+
18
+ Each phase loads skills in this deterministic order (head = last loaded, strongest attention). All stacks share the `system-design+spec` tail — the permanent base, cache-hot across all invocations.
19
+
20
+ | Phase | Skill stack (head ← tail) |
21
+ |-------|---------------------------|
22
+ | Ceiling / Naive / Pivot / Micro / Shim / Report | `npm-optimizer` → `system-design+spec` |
23
+ | Profile & Classify | `npm-optimizer` → `profiler` → `system-design+spec` |
24
+ | Handoff to asm-optimizer | `npm-optimizer` → `asm-optimizer` → `system-design+spec` |
25
+
26
+ The `system-design` skill with its spec tree is the permanent base loaded at startup. The `profiler` and `asm-optimizer` skills are loaded JIT only when their phases execute.
27
+
12
28
  ## On Activation
13
29
 
14
30
  1. Check that a target npm package name is available in context. If not, prompt.
@@ -19,13 +35,13 @@ Senior systems engineer specializing in Node.js native addon development and per
19
35
 
20
36
  ### `execute`
21
37
 
22
- Run the full port pipeline. Each phase must complete before the next begins. The agent pauses after each phase, reports results, and waits for acknowledgment before proceeding.
38
+ Run the full port pipeline. Each phase runs sequentially. The agent pauses after each phase, reports results, and waits for acknowledgment before proceeding.
23
39
 
24
40
  ---
25
41
 
26
- **Phase 1 — Spec & Discovery**
42
+ **Phase 1 — Discovery & Ceiling**
27
43
 
28
- Goal: Understand the original package's full surface area before writing any code.
44
+ Goal: Understand the original package and validate that a C++ native addon is viable.
29
45
 
30
46
  1.1. Clone the target package into `external/<name>/`:
31
47
  ```
@@ -35,35 +51,14 @@ Goal: Understand the original package's full surface area before writing any cod
35
51
  1.2. Copy the original test suite to `test/orig/`. Run it against the original to
36
52
  establish a passing baseline. These tests must never be modified.
37
53
 
38
- 1.3. Analyze the original source tree. For each source file, use the system-design
39
- skill's spec workflow to produce a spec document. Group related files into
40
- sub-modules. Output tree at:
41
- ```
42
- spec/original/
43
- ├── <sub-module-1>/README.md
44
- ├── <sub-module-2>/README.md
45
- └── technical-specification.md (root overview + data flow)
46
- ```
47
-
48
- 1.4. From the spec tree, extract:
49
- - Full API surface: every exported function, its signature, and behavior.
50
- - Edge cases: undefined properties, NaN, toJSON, circular refs, prototype chain.
51
- - Data flow: how inputs map to outputs.
54
+ 1.3. The spec tree is generated using **system-design** (permanent base context):
55
+ - Run `generate from source` to produce the full spec tree of the original package.
56
+ - Extract from the spec tree: full API surface, edge cases, data flow.
57
+ - Design the C++ addon architecture: which functions go native vs stay in JS,
58
+ N-API boundary strategy, build pipeline.
59
+ - Generate implementation spec tree at `spec/implementation/`.
52
60
 
53
- 1.5. **Validate the ceiling** Before designing the C++ architecture, build the
54
- cheapest possible pass-through: a minimal addon that takes a string blob,
55
- copies it, and returns it. Measure its ops/sec via `npm run benchmark`.
56
- This is the **upper bound** for any approach that uses this N-API profile
57
- (one crossing in, one out). If this doesn't exceed the original's speed,
58
- the entire approach is dead — reconsider at the JS/N-API design level.
59
-
60
- 1.6. Design the C++ addon architecture:
61
- - Which functions go native vs stay in JS wrapper.
62
- - N-API boundary strategy (minimize crossings per call).
63
- - Build pipeline (binding.gyp, node-addon-api, dependencies).
64
-
65
- 1.7. Generate implementation spec tree at `spec/implementation/` mirroring the
66
- original's structure, with cross-reference mappings.
61
+ 1.4. Run `assess-ceiling` to validate the approach is viable.
67
62
 
68
63
  ---
69
64
 
@@ -71,11 +66,7 @@ Goal: Understand the original package's full surface area before writing any cod
71
66
 
72
67
  Goal: Build the simplest C++ addon that passes 100% of `test/orig/*.js`.
73
68
 
74
- 2.1. Scaffold project: `package.json`, `binding.gyp`, `src/`, `index.js`
75
- 2.2. Implement the C++ module with the direct approach
76
- (e.g., traverse values through N-API, build string in C++).
77
- 2.3. Run `test/orig/` tests. Fix until all pass.
78
- 2.4. Establish baseline benchmark: `npm run benchmark` comparing against original JS.
69
+ Run `implement-naive`.
79
70
 
80
71
  ---
81
72
 
@@ -83,95 +74,188 @@ Goal: Build the simplest C++ addon that passes 100% of `test/orig/*.js`.
83
74
 
84
75
  Goal: Identify where time is actually going.
85
76
 
77
+ Loading contract: `profiler` skill loaded at the head.
78
+
86
79
  3.1. Create `prof-harness.js` — tight loop exercising the main export.
87
- 3.2. `perf record -F 199 --call-graph fp -o perf/baseline.profile.data node prof-harness.js`
88
- 3.3. `perf report -i perf/baseline.profile.data --stdio -s overhead,symbol,dso`
89
- 3.4. Classify samples into three tiers:
90
- - **Tier 1 — Infrastructure**: V8 internals, N-API boundary, allocator.
91
- - **Tier 2 — Our C++ logic**: string building, type dispatch, sorting.
92
- - **Tier 3 — The original's work**: if we're still calling it.
93
- 3.5. **Decision**: If Tier 1 > 30% of samples, mark as **architectural bottleneck**
94
- and proceed to Phase 4A (pivot). Otherwise proceed to Phase 4B (micro-optimize).
80
+ 3.2. Use the loaded **profiler** skill's `profile` command to run `perf record`
81
+ and generate flamegraphs.
82
+ 3.3. Run `classify` to sort samples into tiers and decide pivot vs micro-optimize.
95
83
 
96
84
  ---
97
85
 
98
- **Phase 4AArchitectural Pivot**
86
+ **Phase 4Optimize**
99
87
 
100
- Goal: Change the approach when the current architecture hits a fundamental ceiling.
88
+ Goal: Improve performance based on classification results.
101
89
 
102
- 4A.1. Identify the specific architectural cost (e.g., "200+ N-API crossings per call").
103
- 4A.2. Design an alternative approach that eliminates this cost. Examples:
104
- - "Let JSON.stringify do the work, then key-sort the blob in C++"
105
- - "Batch N-API calls" / "Use raw V8 API instead of N-API"
106
- - "Pre-allocate and reuse buffers across calls"
107
- 4A.3. **Validate the hypothesis** before implementing the full approach, build
108
- the cheapest functional approximation (pass-through, stub). Measure it.
109
- If the ceiling doesn't leave headroom over the original, reject this approach
110
- and go back to 4A.2.
111
- 4A.4. If validated: implement the full pivot approach. Run tests (100% pass).
112
- 4A.5. Run benchmark. If target met, proceed to Phase 5.
113
- If not, return to Phase 3 with new profile data.
90
+ If Phase 3 classified as architectural (Tier 1 > 30%):
91
+ - Run `pivot`
92
+
93
+ If Phase 3 classified as micro-optimizable:
94
+ - Run `micro-optimize`
95
+ - After each round, check: are we approaching the ceiling with diminishing returns?
96
+ If so, run `assess-handoff` to evaluate dropping to asm-optimizer.
114
97
 
115
98
  ---
116
99
 
117
- **Phase 4BMicro-Optimize**
100
+ **Phase 5Compatibility Shim**
118
101
 
119
- Goal: Attack specific C++ hotspots identified in Phase 3.
102
+ Goal: Handle edge cases where the implementation differs from the original.
120
103
 
121
- 4B.1. For each Tier-2 function, sorted by self% descending:
122
- - Read the source code of the function.
123
- - Identify the specific operation consuming time
124
- (e.g., `std::ostringstream`, repeated allocation, branch-heavy loop).
125
- - Apply one targeted fix.
126
- - Rebuild, run tests, benchmark.
127
- - If gain >= 5%: keep, move to next function.
128
- - If gain < 5%: revert, try next hypothesis for this function.
129
- 4B.2. **Three strikes rule**: if three consecutive fixes at this function
130
- each yield <5%, stop micro-optimizing. Re-run Phase 3 and check
131
- Tier 1 fraction. If it grew, proceed to Phase 4A.
132
- 4B.3. When all Tier-2 functions are exhausted: re-run Phase 3.
133
- If Tier 1 is now dominant, proceed to Phase 4A.
104
+ Run `shim`.
134
105
 
135
106
  ---
136
107
 
137
- **Phase 5Compatibility Shim & Documentation**
108
+ **Phase 6Report**
138
109
 
139
- Goal: Handle edge cases where the implementation differs from the original.
110
+ Goal: Produce the final deliverable.
140
111
 
141
- 5.1. Compare output of original vs implementation for:
142
- - All `test/orig/` cases (must pass).
143
- - Edge cases: function-valued properties, undefined, toJSON,
144
- prototype-chain access, Symbol-keyed properties.
145
- 5.2. For any behavioral difference: add JS wrapper logic in `index.js`
146
- (e.g., preprocess step for function→{} conversion).
147
- Document the difference in `spec/cross-reference.md` with rationale.
148
- 5.3. Generate `test/new/` tests covering implementation-specific behavior.
149
- 5.4. Update `spec/cross-reference.md` with final benchmark deltas.
112
+ Run `report`.
150
113
 
151
114
  ---
152
115
 
153
- **Phase 6 — Report**
116
+ ### `assess-ceiling`
154
117
 
155
- Goal: Produce the final deliverable.
118
+ Before designing the C++ architecture, build the cheapest possible pass-through:
119
+ a minimal addon that takes a string blob, copies it, and returns it.
120
+ Measure its ops/sec via `npm run benchmark`.
156
121
 
157
- 6.1. Generate comparison table:
158
- ```
159
- | Implementation | Ops/sec | Relative |
160
- |-------------------------|---------|----------|
161
- | Original JS | X | 1.0x |
162
- | C++ addon | Y | Y/X |
163
- | Pass-through (ceiling) | Z | Z/X |
164
- ```
165
- 6.2. Archive final profile: `cp perf/baseline.profile.data perf/baseline/profiles/final.profile.data`
166
- 6.3. Print the full report inline: benchmark numbers, profile summary, spec cross-reference path,
167
- and a list of known behavioral differences (if any).
122
+ This is the **upper bound** for any approach using this N-API profile
123
+ (one crossing in, one out). If this doesn't exceed the original's speed,
124
+ the entire approach is dead — reconsider at the JS/N-API design level.
125
+
126
+ Output:
127
+ ```
128
+ Ceiling pass-through: 104,866 ops/sec
129
+ Original JS: 33,199 ops/sec
130
+ Verdict: VIABLE (3.16x headroom)
131
+ ```
132
+
133
+ ### `implement-naive`
134
+
135
+ Build the simplest C++ addon that passes 100% of `test/orig/*.js`.
136
+
137
+ 1. Scaffold project: `package.json`, `binding.gyp`, `src/`, `index.js`
138
+ 2. Implement the C++ module with the direct approach
139
+ (e.g., traverse values through N-API, build string in C++).
140
+ 3. Run `test/orig/` tests. Fix until all pass.
141
+ 4. Establish baseline benchmark: `npm run benchmark` comparing against original JS.
142
+
143
+ ### `classify`
144
+
145
+ Load `prof-harness.js` perf data and sort samples into three tiers:
146
+
147
+ - **Tier 1 — Infrastructure**: V8 internals, N-API boundary, allocator.
148
+ - **Tier 2 — Our C++ logic**: string building, type dispatch, sorting.
149
+ - **Tier 3 — The original's work**: if we're still calling it.
150
+
151
+ **Decision**: If Tier 1 > 30% of samples, mark as **architectural bottleneck**
152
+ and proceed to `pivot`. Otherwise proceed to `micro-optimize`.
153
+
154
+ ### `pivot`
155
+
156
+ Change the architectural approach when the current architecture hits a fundamental ceiling.
157
+
158
+ 1. Identify the specific architectural cost (e.g., "200+ N-API crossings per call").
159
+ 2. Design an alternative approach that eliminates this cost. Examples:
160
+ - "Let JSON.stringify do the work, then key-sort the blob in C++"
161
+ - "Batch N-API calls" / "Use raw V8 API instead of N-API"
162
+ - "Pre-allocate and reuse buffers across calls"
163
+ 3. **Validate the hypothesis** — before implementing the full approach, build
164
+ the cheapest functional approximation (pass-through, stub). Measure it.
165
+ If the ceiling doesn't leave headroom over the original, reject this approach
166
+ and try another.
167
+ 4. If validated: implement the full pivot approach. Run tests (100% pass).
168
+ 5. Run `bench`. If target met, proceed. If not, return to Phase 3 with new profile data.
169
+
170
+ ### `micro-optimize`
171
+
172
+ Attack specific C++ hotspots identified during profiling.
173
+
174
+ For each Tier-2 function, sorted by self% descending:
175
+ - Read the source code of the function.
176
+ - Identify the specific operation consuming time
177
+ (e.g., `std::ostringstream`, repeated allocation, branch-heavy loop).
178
+ - Apply one targeted fix.
179
+ - Rebuild, run tests, benchmark.
180
+ - If gain >= 5%: keep, move to next function.
181
+ - If gain < 5%: revert, try next hypothesis for this function.
182
+
183
+ **Three strikes rule**: if three consecutive fixes at this function
184
+ each yield <5%, stop micro-optimizing. Re-profile. If Tier 1
185
+ fraction grew, proceed to `pivot`. If Tier 2 is exhausted and still
186
+ not at ceiling, proceed to `assess-handoff`.
187
+
188
+ When all Tier-2 functions are exhausted: re-run profiling.
189
+ If Tier 1 is now dominant, proceed to `pivot`.
190
+
191
+ ### `shim`
192
+
193
+ Handle edge cases where the implementation differs from the original.
194
+
195
+ 1. Compare output of original vs implementation for:
196
+ - All `test/orig/` cases (must pass).
197
+ - Edge cases: function-valued properties, undefined, toJSON,
198
+ prototype-chain access, Symbol-keyed properties.
199
+ 2. For any behavioral difference: add JS wrapper logic in `index.js`
200
+ (e.g., preprocess step for function->{} conversion).
201
+ Document the difference in `spec/cross-reference.md` with rationale.
202
+ 3. Generate `test/new/` tests covering implementation-specific behavior.
203
+ 4. Update `spec/cross-reference.md` with final benchmark deltas.
204
+
205
+ ### `bench`
206
+
207
+ Run benchmark comparing current implementation against the original JS.
208
+
209
+ Output:
210
+ ```
211
+ | Implementation | Ops/sec | Relative |
212
+ |-------------------------|---------|----------|
213
+ | Original JS | X | 1.0x |
214
+ | C++ addon | Y | Y/X |
215
+ | Pass-through (ceiling) | Z | Z/X |
216
+ ```
217
+
218
+ ### `assess-handoff`
219
+
220
+ Evaluate whether the remaining bottleneck is in our C++ logic (Tier 2)
221
+ and has reached diminishing returns. If so, spawn a sub-agent with
222
+ **asm-optimizer** loaded to perform assembly/SIMD-level optimization.
223
+
224
+ **Gate criteria** (all must be true):
225
+ - Tier 2 is the dominant bottleneck (>50% of remaining samples after pivots)
226
+ - Three consecutive micro-optimizations yielded <5% each (three strikes)
227
+ - Ceiling headroom still exists (pass-through is significantly faster)
228
+
229
+ **Process**:
230
+ 1. Run `assess all` from asm-optimizer on the C++ addon's hot functions.
231
+ 2. If asm-optimizer reports **Medium** or higher potential on any function:
232
+ - Run `iterative-optimize <entry>` from asm-optimizer.
233
+ - Re-benchmark after each successful optimization.
234
+ 3. Report results back to the execute pipeline.
235
+
236
+ ### `report`
237
+
238
+ Generate the final deliverable.
239
+
240
+ 1. Archive final profile:
241
+ `cp perf/baseline.profile.data perf/baseline/profiles/final.profile.data`
242
+ 2. Print the full report: benchmark numbers, profile summary,
243
+ spec cross-reference path, and a list of known behavioral differences (if any).
244
+ 3. Output comparison table:
245
+ ```
246
+ | Implementation | Ops/sec | Relative |
247
+ |-------------------------|---------|----------|
248
+ | Original JS | X | 1.0x |
249
+ | C++ addon | Y | Y/X |
250
+ | Pass-through (ceiling) | Z | Z/X |
251
+ ```
168
252
 
169
253
  ### `show-state`
170
254
 
171
255
  Output the current status of the `execute` pipeline:
172
256
 
173
257
  ```
174
- Phase 1 (Spec): COMPLETE — spec tree at spec/original/
258
+ Phase 1 (Discovery): COMPLETE
175
259
  Phase 2 (Naive): IN PROGRESS — 43/49 tests passing
176
260
  Phase 3 (Profile): PENDING
177
261
  Phase 4 (Optimize): PENDING
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: npx
3
+ description: Run npx @opensassi/opencode commands in a target directory — resolves directories via inference rules and the list-targets.sh script
4
+ ---
5
+
6
+ # Skill: npx
7
+
8
+ ## Persona
9
+
10
+ You are a **devops engineer** specializing in multi-project navigation, monorepo structure inference, and cross-project CLI dispatch. Your job is to run `@opensassi/opencode` commands inside the correct target directory given a fuzzy or partial name.
11
+
12
+ ## On Activation
13
+
14
+ 1. If already in context, show the last-used target directory. Otherwise, prompt for a target.
15
+ 2. Show available commands.
16
+
17
+ ## Dependencies
18
+
19
+ - `npx` available in PATH
20
+ - `@opensassi/opencode` installed (resolved by npx)
21
+ - `scripts/list-targets.sh` from the package
22
+
23
+ ## Commands
24
+
25
+ ### `npx <target> [<npx-command>] [args...]`
26
+
27
+ Resolve `<target>` to a directory, then run:
28
+ ```
29
+ cd <resolved-path> && npx @opensassi/opencode <npx-command> [args...]
30
+ ```
31
+
32
+ **Resolution algorithm:**
33
+
34
+ 1. Run `npx @opensassi/opencode run list-targets.sh <cwd>` to get candidates as JSON.
35
+ 2. Parse the candidates array. Each entry has `{name, path, type}`.
36
+ 3. Apply rules in order:
37
+
38
+ **Rule 1 — Absolute or explicit path**: If `<target>` starts with `/`, `./`, `~/`, or `../`, use it directly.
39
+
40
+ **Rule 2 — Exact name match**: If `<target>` matches a candidate's `name` field exactly (case-sensitive), use that candidate's `path`.
41
+
42
+ **Rule 3 — Single external candidate heuristic**: If there is exactly one `type: "external"` candidate and `<target>` is not `.`, assume the user meant that candidate. Log the assumption.
43
+
44
+ **Rule 4 — Multiple matches or no match**: Print the candidate list and ask the user to pick one by number or provide an explicit path.
45
+
46
+ 4. After resolving, store the path as the current target in conversation context so repeated commands can omit `<target>`.
47
+ 5. Run `cd <resolved-path> && npx @opensassi/opencode <npx-command> [args...]`.
48
+ 6. Display stdout/stderr output to the user.
49
+
50
+ ### `npx . <npx-command> [args...]`
51
+
52
+ Explicitly target the project root.
53
+
54
+ ### `npx list`
55
+
56
+ Print the candidate list without running anything.
57
+
58
+ ## Examples
59
+
60
+ ```
61
+ User: npx opencode system-design
62
+ Agent: Runs list-targets.sh, finds {name:"opencode", type:"external"}
63
+ Applies Rule 2: exact match → external/opencode/
64
+ Runs: cd external/opencode && npx @opensassi/opencode system-design
65
+
66
+ User: npx ../sibling-project init
67
+ Agent: Applies Rule 1: explicit relative → ../sibling-project/
68
+ Runs: cd ../sibling-project && npx @opensassi/opencode init
69
+
70
+ User: npx tinygrad profile
71
+ Agent: Runs list-targets.sh, finds {name:"tinygrad", type:"external"}
72
+ Applies Rule 2: exact match → external/tinygrad/
73
+ Runs: cd external/tinygrad && npx @opensassi/opencode profile
74
+ ```
75
+
76
+ ## Design Principles
77
+
78
+ - **Prefer external/**: External projects under `external/` are the primary target. The project root itself is only targeted explicitly via `npx .`.
79
+ - **Store last target**: Track the last resolved directory in conversation context to avoid requiring `<target>` on repeat commands within the same session.
80
+ - **Transparent output**: All command output is shown directly to the user. Do not summarize or interpret unless asked.
@@ -15,12 +15,16 @@ Senior DevOps engineer specializing in cross-platform development environment pr
15
15
  2. Run `init check` to report current environment status (OS, Node.js, git, FlameGraph, npm deps)
16
16
  3. Show available commands
17
17
 
18
- To load a sub-skill (e.g., system-design, git, profiler), the agent should run:
18
+ Available sub-skills: asm-optimizer, daily-evaluation, git, issue, npx, npm-optimizer, profiler, session-evaluation, skill-manager, system-design, system-design-review, todo
19
+
20
+ To load a sub-skill, run:
19
21
  ```
20
22
  npx @opensassi/opencode <skill-name>
21
23
  ```
22
24
  and read the output as the skill's full instructions.
23
25
 
26
+ The `npx` sub-skill provides cross-project dispatch — it runs `@opensassi/opencode` commands in a different target directory (handy for operating on `external/` projects from the root).
27
+
24
28
  ## Dependencies
25
29
 
26
30
  - `bash` or `powershell` (for bootstrap scripts — zero other deps)
package/skills-index.json CHANGED
@@ -1,26 +1,28 @@
1
1
  {
2
2
  "skills": [
3
3
  {
4
- "name": "system-design",
5
- "description": "Interactive C++ spec authoring with diagrams and D3 animations",
4
+ "name": "asm-optimizer",
5
+ "description": "SIMD/assembly optimization framework",
6
6
  "commands": [
7
- "generate sequence diagram",
8
- "generate architecture diagram",
9
- "generate class specification",
10
- "generate manim animation",
11
- "generate d3 animation",
12
- "generate testing plan",
13
- "generate from source",
14
- "load spec",
15
- "generate technical specification",
16
- "revise technical specification",
17
- "split sub-modules",
18
- "combine sub-modules",
19
- "list sub-modules",
20
- "load sub-module spec",
21
- "generate sub-module spec"
7
+ "setup-baseline",
8
+ "profile",
9
+ "assess",
10
+ "assess all",
11
+ "setup-microbench",
12
+ "spec",
13
+ "analyze-gap",
14
+ "bench",
15
+ "implement",
16
+ "iterative-optimize",
17
+ "archive-experiment",
18
+ "report"
22
19
  ]
23
20
  },
21
+ {
22
+ "name": "daily-evaluation",
23
+ "description": "Aggregate session evaluations into dashboards",
24
+ "commands": []
25
+ },
24
26
  {
25
27
  "name": "git",
26
28
  "description": "Rebase-based single-commit-per-session workflow",
@@ -31,33 +33,39 @@
31
33
  ]
32
34
  },
33
35
  {
34
- "name": "profiler",
35
- "description": "Linux perf profiling + flamegraphs",
36
+ "name": "issue",
37
+ "description": "GitHub issue management",
36
38
  "commands": [
37
- "check",
38
- "setup",
39
- "profile",
40
- "benchmark",
41
- "compare",
42
- "report"
39
+ "create issue",
40
+ "list issues",
41
+ "show issue",
42
+ "close issue"
43
43
  ]
44
44
  },
45
45
  {
46
- "name": "asm-optimizer",
47
- "description": "SIMD/assembly optimization framework",
46
+ "name": "npx",
47
+ "description": "Run npx commands in a target directory with automatic directory resolution",
48
48
  "commands": [
49
- "setup-baseline",
50
- "profile",
51
- "assess",
52
- "assess all",
53
- "setup-microbench",
54
- "spec",
55
- "analyze-gap",
49
+ "npx <target> <npx-command>",
50
+ "npx . <npx-command>",
51
+ "npx list"
52
+ ]
53
+ },
54
+ {
55
+ "name": "npm-optimizer",
56
+ "description": "Port an npm package to a C++ native addon — preserve 100% test compatibility while significantly improving performance through profiling-driven architectural iteration",
57
+ "commands": [
58
+ "execute",
59
+ "assess-ceiling",
60
+ "implement-naive",
61
+ "classify",
62
+ "pivot",
63
+ "micro-optimize",
64
+ "shim",
56
65
  "bench",
57
- "implement",
58
- "iterative-optimize",
59
- "archive-experiment",
60
- "report"
66
+ "assess-handoff",
67
+ "report",
68
+ "show-state"
61
69
  ]
62
70
  },
63
71
  {
@@ -70,6 +78,18 @@
70
78
  "init check"
71
79
  ]
72
80
  },
81
+ {
82
+ "name": "profiler",
83
+ "description": "Linux perf profiling + flamegraphs",
84
+ "commands": [
85
+ "check",
86
+ "setup",
87
+ "profile",
88
+ "benchmark",
89
+ "compare",
90
+ "report"
91
+ ]
92
+ },
73
93
  {
74
94
  "name": "session-evaluation",
75
95
  "description": "Generate structured session reports",
@@ -92,46 +112,35 @@
92
112
  ]
93
113
  },
94
114
  {
95
- "name": "issue",
96
- "description": "GitHub issue management",
115
+ "name": "system-design",
116
+ "description": "Interactive C++ spec authoring with diagrams and D3 animations",
97
117
  "commands": [
98
- "create issue",
99
- "list issues",
100
- "show issue",
101
- "close issue"
118
+ "generate sequence diagram",
119
+ "generate architecture diagram",
120
+ "generate class specification",
121
+ "generate manim animation",
122
+ "generate d3 animation",
123
+ "generate testing plan",
124
+ "generate from source",
125
+ "load spec",
126
+ "generate technical specification",
127
+ "revise technical specification",
128
+ "split sub-modules",
129
+ "combine sub-modules",
130
+ "list sub-modules",
131
+ "load sub-module spec",
132
+ "generate sub-module spec"
102
133
  ]
103
134
  },
104
135
  {
105
136
  "name": "system-design-review",
106
137
  "description": "Seven-expert panel audit of technical specs",
107
- "commands": [
108
- "review all",
109
- "review sub-module",
110
- "review file-path",
111
- "review stale"
112
- ]
113
- },
114
- {
115
- "name": "daily-evaluation",
116
- "description": "Aggregate session evaluations into dashboards",
117
- "commands": [
118
- "create",
119
- "list"
120
- ]
138
+ "commands": []
121
139
  },
122
140
  {
123
141
  "name": "todo",
124
142
  "description": "Create issues + debugging skills from session context",
125
- "commands": [
126
- "extract",
127
- "propose-skill",
128
- "save-skill"
129
- ]
130
- },
131
- {
132
- "name": "npm-optimizer",
133
- "description": "Port an npm package to a C++ native addon",
134
143
  "commands": []
135
144
  }
136
145
  ]
137
- }
146
+ }