Repository navigation
fix(sdk/typescript): kcode binary/path names so the SDK tests can run at all - #345
Conversation
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
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reachedYou'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. View limit details
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. |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (10 files)
Reviewed by free · Input: 65.9K · Output: 3.5K · Cached: 612.2K |
|
| * 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-")); |
There was a problem hiding this comment.
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
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
|



Closes #159
Closes #147
Why this is not cosmetic
The TypeScript SDK refuses any path whose segments look like the upstream product:
Two consequences on master, both fatal:
scripts/test_sdk_e2e.shput its socket at${TMPDIR}/jcode-sdk-e2e-$$.sock.assertKcodePathsees the segmentjcode-sdk-e2e-<pid>.sock, matchesjcode[.-].*, and throwscross_product_pathbefore the bridge ever starts. The end-to-end script could not work.cargo build -p jcode --bin jcode. The root package iskcodeand its only default bin iskcode(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 prefixjcode-sdk-e2e-->kcode-sdk-e2e-,cargo build -p kcode --bin kcode,target/selfdev/kcode, with comments recording why (thecross_product_pathrejection and the missing bin target).sdk/typescript/test/live-{isolation,launch,options,text-framing,tools}.mjs: default binaryjcode->kcode,pgrep -cf 'kcode --provider auto serve',target/selfdev/kcode, tempdir prefixes.sdk/typescript/test/pipe-name.test.ts: fallback stem and expected pipe regexjcode-->kcode-, matching productionpath_to_pipe_name(unwrap_or("kcode")incrates/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 assertcross_product_pathare untouched, andRELEASING.md's@1jehuang/jcode-sdkreferences are left alone (separate publishing question).Validation
bash -n scripts/test_sdk_e2e.sh-> OK.node --checkon all 8sdk/typescript/test/*.mjs-> all OK.npm test/tscsuite.sdk/typescript/node_modulesis absent here and I did not install dependencies, so the TypeScript tests are unverified by this PR. Say the word and I will runnpm ci --ignore-scripts && npm testinsdk/typescripton 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