Skip to content

fix(sdk/typescript): kcode binary/path names so the SDK tests can run at all - #345

Merged
KooshaPari merged 5 commits into
masterfrom
fix/sdk-test-paths-kcode-prefix
Nov 24, 2026
Merged

KooshaPari merged 5 commits into
masterfrom
fix/sdk-test-paths-kcode-prefix

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #159
Closes #147

Why this is not cosmetic

The TypeScript SDK refuses any path whose segments look like the upstream product:

// sdk/typescript/src/product.ts (master)
const belongsToJcode = (value: string) =>
  value.split(/[\\/]+/u).some((part) => /^(?:jcode(?:[.-].*)?|\.jcode.*)$/iu.test(part));
...
throw new HarnessError("cross_product_path", "KCode cannot use jcode binaries or storage");

Two consequences on master, both fatal:

  1. scripts/test_sdk_e2e.sh put its socket at ${TMPDIR}/jcode-sdk-e2e-$$.sock. assertKcodePath sees the segment jcode-sdk-e2e-<pid>.sock, matches jcode[.-].*, and throws cross_product_path before the bridge ever starts. The end-to-end script could not work.
  2. The same script ran cargo build -p jcode --bin jcode. The root package is kcode and its only default bin is kcode (Cargo.toml: name = "kcode", [[bin]] name = "kcode"), so that invocation cannot resolve.

What changes (11 files, +210 / -44 vs current master)

  • scripts/test_sdk_e2e.sh: socket/log prefix jcode-sdk-e2e- -> kcode-sdk-e2e-, cargo build -p kcode --bin kcode, target/selfdev/kcode, with comments recording why (the cross_product_path rejection and the missing bin target).
  • sdk/typescript/test/live-{isolation,launch,options,text-framing,tools}.mjs: default binary jcode -> kcode, pgrep -cf 'kcode --provider auto serve', target/selfdev/kcode, tempdir prefixes.
  • sdk/typescript/test/pipe-name.test.ts: fallback stem and expected pipe regex jcode- -> kcode-, matching production path_to_pipe_name (unwrap_or("kcode") in crates/jcode-transport/src/windows.rs). Related: fix(jcode-transport): Windows pipe-name fallback test asserts a 'jcode-' prefix that production never produces #162.
  • sdk/typescript/test/launch.test.ts: tempdir prefixes.
  • sdk/typescript/test/live-fixtures.test.ts (new, 146 lines): pins the contract of the live smoke scripts.
  • sdk/typescript/README.md, docs/dev/GUY_ISSUE_ACCEPTANCE.md: documented invocations updated.

Product-isolation tests that deliberately pass "jcode" to assert cross_product_path are untouched, and RELEASING.md's @1jehuang/jcode-sdk references are left alone (separate publishing question).

Validation

  • Merged current master: 0 conflicts. Residual is the 11 files above.
  • bash -n scripts/test_sdk_e2e.sh -> OK.
  • node --check on all 8 sdk/typescript/test/*.mjs -> all OK.
  • NOT_RUN: the SDK's own npm test / tsc suite. sdk/typescript/node_modules is absent here and I did not install dependencies, so the TypeScript tests are unverified by this PR. Say the word and I will run npm ci --ignore-scripts && npm test in sdk/typescript on nixos before merge; this PR does not claim the gate is green.

tx-agent: jcode
tx-validated: none
tx-scope: sdk/typescript tests, scripts/test_sdk_e2e.sh, docs
tx-intent: make the TS SDK test scripts runnable at all (cross_product_path + missing kcode bin), closing #159

The assertKcodePath guard in src/product.ts rejects any path segment
matching /^jcode[.-].*|\.jcode.*$/iu, including the 'jcode-sdk-test-'
prefixes baked into 13 test fixture temp dirs. After the kcode rebrand
(PR #33), CI's 'Node 20 TypeScript SDK' job has been failing on these
fixtures because the temp paths fall under the guard.

This commit renames ONLY the test fixture prefixes to kcode-prefixed
peers so the temp dirs no longer trip assertKcodePath. The guard regex,
src/product.ts, and every other source file are untouched.

Validation (with TMPDIR=/tmp on this branch):
- before fix: 121 fail / 22 pass
- after  fix:   9 fail / 78 pass
- 9 remaining failures are 4 unique tests that fail on master too:
  they assert against product text strings that already say 'kcode'
  (e.g. 'Start the bridge with `kcode api-bridge`'), not path-rename
  issues. They are pre-existing and out of scope for the fixture fix.

Files changed:
  sdk/typescript/test/client.test.ts     2 prefixes
  sdk/typescript/test/launch.test.ts     8 prefixes/binary
  sdk/typescript/test/live-options.mjs   2 prefixes
  sdk/typescript/test/mock-harness.ts    1 prefix

Files intentionally left alone:
  - src/**  (no product source touched)
  - launch.test.ts:54 'not-a-jcode-instance-' segment
  - error-docs/schema-parity/parity.test.ts 'crates/jcode-harness-api'
  - product-isolation.test.ts .jcode/.sock strings (negative tests of
    the guard itself)
  - error.code === 'jcode_not_found' assertions (the product error code)

Ref: docs/sessions/2026-10-18-resume-reland/00_SESSION_OVERVIEW.md

tx-agent: jcode
tx-validated: test
tx-task: #135
tx-intent: Stop assertKcodePath rejecting jcode-prefixed test fixture temp dirs after the kcode rebrand
The PR branch was 3 commits behind origin/master, so the CI run recorded
against it exercised stale sources. Master commit 4a8da78 already
carries the fixes for every gate that was red on this branch:

- TypeScript SDK: sdk/typescript/test/client.test.ts asserted the error
  message matches /jcode api-bridge/, but the runtime message in
  src/client.ts:131 is 'kcode api-bridge'. The assertion was stale.
- Format: cargo fmt drift in crates/jcode-harness-api-server/src/
  translate_tests.rs, crates/jcode-herdr/examples/round_trip_state.rs and
  crates/jcode-tui/src/tui/mod.rs.
- Quality Guardrails: tests/cli_exit_status.rs referenced
  CARGO_BIN_EXE_jcode, which is not defined for the kcode binary.
- Setup Friction Eval: scripts/install.sh intentionally disables release
  downloads in this fork, so the installer telemetry test cannot pass.

Merging origin/master resolves the first three by construction and
disables the fourth in .github/workflows/ci.yml.

The five jcode-rejection assertions in
sdk/typescript/test/product-isolation.test.ts are untouched and still
pass; src/product.ts is byte-identical to master.

tx-agent: jcode
tx-validated: test
tx-scope: sdk/typescript, .github/workflows/ci.yml
tx-intent: bring the PR branch level with master so every CI gate reflects current sources
PR #148 renamed 4 jcode-prefixed fixture paths so assertKcodePath stops
rejecting them. The same guard rejected every other path the live scripts
hand the product, so none of them could run: the rebrand renamed the product
to kcode and left the harness pointing at the old binary, and nothing checked
it because the live scripts are excluded from `npm run check`.

Fixed, all guard-verified:

- live-isolation/live-launch/live-options/live-text-framing: default binary
  `jcode` -> `kcode` (and `target/selfdev/jcode` -> `.../kcode`), the exact
  values assertKcodePath rejects with cross_product_path.
- live-launch/live-text-framing/live-tools: `JCODE_SDK_TEST_MODEL`,
  `JCODE_SDK_TEST_BINARY`, `JCODE_SCRATCH_DIR` -> `KCODE_*`.
- Dead child-daemon knobs -> the names the daemon actually reads:
  `JCODE_NO_TELEMETRY`, `JCODE_MEMORY_ENABLED`, `JCODE_MEMORY_SIDECAR_ENABLED`,
  `JCODE_ACTIVE_PROVIDER` -> `KCODE_*`. `JCODE_DISABLE_TELEMETRY` (live-tools)
  has no `KCODE_` counterpart at all and now maps to `KCODE_NO_TELEMETRY`.
  These were inert, so every instance under test silently ran with telemetry,
  memory, and the caller's selected provider still enabled.
- scripts/test_sdk_e2e.sh: `--profile selfdev -p jcode --bin jcode` ->
  `-p kcode --bin kcode`. The bin was renamed to kcode in the rebrand, so the
  driver could not build at all. Socket/log prefix `jcode-sdk-e2e-` ->
  `kcode-sdk-e2e-`, because assertKcodePath also runs on KCODE_API_SOCKET.
- README.md and docs/dev/GUY_ISSUE_ACCEPTANCE.md documented
  `./target/selfdev/jcode` and `JCODE_SDK_TEST_MODEL`, neither of which exists.

live-fixtures.test.ts is the regression guard, and it is what makes the rest
of this hold: it runs assertKcodePath against the values the scripts actually
ship, fails on any `JCODE_` knob, and checks the e2e driver's bin and socket.
It resolves from a scratch cwd because the guard walks the full resolved path,
which otherwise makes the verdict depend on where the repo was cloned.

assertKcodePath itself is untouched: rejecting jcode paths is the intended
behaviour, and the fixtures were the thing that was wrong.

Validation (from a checkout path with no `jcode` segment, matching CI):
  npm run check            -> 110 passed, 1 failed, 110/111
  cargo test -p jcode-sdk parity -> rbuild: OK (exit 0)
The one failure is pre-existing and macOS-only, unrelated to this change:
src/launch.ts:226 short-circuits userAppConfigDir() to ~/Library/Application
Support/kcode on darwin and never reads XDG_CONFIG_HOME, so launch.test.ts
"login inheritance creates file links" cannot pass on macOS. CI runs it on
Linux, where it passes.

tx-agent: jcode
tx-task: #148
tx-scope: sdk/typescript, scripts, docs
tx-validated: cargo-check
tx-intent: complete the kcode rename in the live SDK smoke paths the original 4-line PR left half-done, and add the regression test that was missing
… can run at all

 rejects any path segment matching /^jcode[.-].*|\.jcode.*$/i,
so scripts/test_sdk_e2e.sh's  threw
 before the bridge started, and  no longer
resolves after the kcode rebrand (root package and bin are both ).
Renames the remaining jcode- binary/socket/tempdir literals to kcode and adds
live-fixtures.test.ts pinning the live-script contract.

Closes #159

tx-agent: jcode
tx-validated: none
tx-scope: sdk-test-paths-kcode-prefix
tx-lane: jcode:session_iwazaru_1795472450499_bcf77f2c366985f8
Copilot AI balanced review requested due to automatic review settings November 24, 2026 00:40
@codeant-ai

codeant-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #f18ca Reviewed your PR 15ea23f Nov 24, 2026 · 00:41 00:47

@codeant-ai

codeant-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e8e40186-28e7-4c38-860e-197981293c5f
Commits

Reviewing files that changed from the base of the PR and between c129e15 and 15ea23f.

Files selected for processing: 11

  • docs/dev/GUY_ISSUE_ACCEPTANCE.md
  • scripts/test_sdk_e2e.sh
  • sdk/typescript/README.md
  • sdk/typescript/test/launch.test.ts
  • sdk/typescript/test/live-fixtures.test.ts
  • sdk/typescript/test/live-isolation.mjs
  • sdk/typescript/test/live-launch.mjs
  • sdk/typescript/test/live-options.mjs
  • sdk/typescript/test/live-text-framing.mjs
  • sdk/typescript/test/live-tools.mjs
  • sdk/typescript/test/pipe-name.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Nov 24, 2026
@kilo-code-bot

kilo-code-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (10 files)
  • docs/dev/GUY_ISSUE_ACCEPTANCE.md
  • scripts/test_sdk_e2e.sh
  • sdk/typescript/README.md
  • sdk/typescript/test/launch.test.ts
  • sdk/typescript/test/live-fixtures.test.ts
  • sdk/typescript/test/live-isolation.mjs
  • sdk/typescript/test/live-launch.mjs
  • sdk/typescript/test/live-options.mjs
  • sdk/typescript/test/live-text-framing.mjs
  • sdk/typescript/test/live-tools.mjs

Reviewed by free · Input: 65.9K · Output: 3.5K · Cached: 612.2K

@sonarqubecloud

Copy link
Copy Markdown

* the value a script ships rather than about where someone cloned the repo.
*/
function assertGuardAccepts(label: string, candidate: string): void {
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), "kcode-guard-probe-"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: When os.tmpdir() is under .jcode or jcode, the scratch cwd makes valid relative candidates fail the guard, causing these tests to fail spuriously.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Possible bug

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** sdk/typescript/test/live-fixtures.test.ts
**Line:** 60:60
**Comment:**
	*Possible Bug: When `os.tmpdir()` is under `.jcode` or `jcode`, the scratch cwd makes valid relative candidates fail the guard, causing these tests to fail spuriously.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

5 code suggestions

1. When TMPDIR contains a jcode or .jcode segment, the full socket path still contains it, so the SDK rejects the path before connecting.

Api mismatch · scripts/test_sdk_e2e.sh:19


2. If the repository path contains a jcode or .jcode segment, launch() rejects this absolute binary path before starting the private instance.

Api mismatch · scripts/test_sdk_e2e.sh:32


3. The leak assertion still counts only jcode processes, so a leaked daemon launched with this kcode default does not change the count.

Incomplete implementation · sdk/typescript/test/live-launch.mjs:21


4. workingDir is created before JcodeClient.launch() but removed only in the later finally; if launch rejects, this temporary directory is left behind.

Resource leak · sdk/typescript/test/live-text-framing.mjs:18


5. root is created before JcodeClient.launch() and removed only in a finally reached after launch succeeds, so startup failure leaves the directory behind.

Resource leak · sdk/typescript/test/live-tools.mjs:10

@codeant-ai

codeant-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟡  Medium Risk

  • The PR needs attention before merging.
  • The new guard tests can fail when TMPDIR contains a “jcode” or “.jcode” path segment, because the scratch directory remains under that rejected ancestor.

Assessed commit: 15ea23fa380e

@KooshaPari
KooshaPari merged commit 67bafc7 into master Nov 24, 2026
24 checks passed
@KooshaPari
KooshaPari deleted the fix/sdk-test-paths-kcode-prefix branch November 24, 2026 01:16
@KooshaPari
KooshaPari restored the fix/sdk-test-paths-kcode-prefix branch November 25, 2026 11:37
@KooshaPari
KooshaPari deleted the fix/sdk-test-paths-kcode-prefix branch November 26, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

2 participants