Skip to content

Commit b2288ad

Browse files
committed
chore: harden project quality and release workflow
1 parent f0b10bc commit b2288ad

25 files changed

Lines changed: 805 additions & 129 deletions

‎.editorconfig‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.ps1]
15+
indent_size = 4

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @TheStreamCode

‎.github/ISSUE_TEMPLATE/bug_report.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ What actually happens.
2828

2929
## Logs
3030
```
31-
Paste relevant output from Help > Toggle Developer Tools > Console.
32-
```
31+
Paste relevant integrated-terminal output. Redact paths, tokens, and personal data.
32+
```

‎.github/pull_request_template.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
## Testing
66

77
- [ ] `npm run check` passes
8+
- [ ] `npm run check:security` passes
89
- [ ] Manually verified in Extension Development Host
910
- [ ] Tested on Windows / macOS / Linux (list which)
1011

12+
## Security and compatibility
13+
14+
- [ ] Workspace Trust and user-level command protections are preserved
15+
- [ ] No secrets, generated output, or VSIX files are included
16+
- [ ] User-facing behavior and documentation remain aligned
17+
1118
## Notes
1219

13-
-
20+
-

‎.github/workflows/ci.yml‎

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,43 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68

79
permissions:
810
contents: read
911

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
1016
jobs:
1117
validate:
1218
runs-on: ${{ matrix.os }}
19+
timeout-minutes: 15
1320
strategy:
1421
fail-fast: false
1522
matrix:
1623
os:
1724
- windows-latest
1825
- ubuntu-latest
1926

27+
env:
28+
VSCODE_TEST_VERSION: stable
29+
2030
steps:
2131
- name: Checkout repository
22-
uses: actions/checkout@v7
32+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
2333

2434
- name: Setup Node.js
25-
uses: actions/setup-node@v6
35+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
2636
with:
2737
node-version: 22
2838
cache: npm
2939

3040
- name: Install dependencies
31-
run: npm ci
41+
run: npm ci --ignore-scripts
3242

3343
- name: Run validation suite on Windows
3444
if: runner.os == 'Windows'
@@ -37,3 +47,58 @@ jobs:
3747
- name: Run validation suite on Linux
3848
if: runner.os == 'Linux'
3949
run: xvfb-run -a npm run check
50+
51+
compatibility:
52+
name: Compatibility (${{ matrix.os }}, VS Code ${{ matrix.vscode }})
53+
runs-on: ${{ matrix.os }}
54+
timeout-minutes: 15
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
include:
59+
- os: macos-latest
60+
vscode: stable
61+
- os: ubuntu-latest
62+
vscode: '1.103.0'
63+
64+
env:
65+
VSCODE_TEST_VERSION: ${{ matrix.vscode }}
66+
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
70+
71+
- name: Setup Node.js
72+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
73+
with:
74+
node-version: 22
75+
cache: npm
76+
77+
- name: Install dependencies
78+
run: npm ci --ignore-scripts
79+
80+
- name: Run validation suite on Linux
81+
if: runner.os == 'Linux'
82+
run: xvfb-run -a npm run check
83+
84+
- name: Run validation suite on macOS
85+
if: runner.os == 'macOS'
86+
run: npm run check
87+
88+
dependency-audit:
89+
name: Dependency audit
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 5
92+
93+
steps:
94+
- name: Checkout repository
95+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
96+
97+
- name: Setup Node.js
98+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
99+
with:
100+
node-version: 22
101+
cache: npm
102+
103+
- name: Audit locked dependencies
104+
run: npm run check:security

‎.github/workflows/release.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
github-release:
13+
name: Package GitHub release
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
permissions:
17+
contents: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
25+
with:
26+
node-version: 22
27+
cache: npm
28+
29+
- name: Verify tag and package versions
30+
shell: bash
31+
run: |
32+
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
33+
test "$GITHUB_REF_NAME" = "v$PACKAGE_VERSION"
34+
35+
- name: Install dependencies
36+
run: npm ci --ignore-scripts
37+
38+
- name: Run validation suite
39+
run: xvfb-run -a npm run check
40+
41+
- name: Audit locked dependencies
42+
run: npm run check:security
43+
44+
- name: Build VSIX
45+
run: npm run package
46+
47+
- name: Create or update GitHub release
48+
shell: bash
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
53+
VSIX="vscode-kimi-code-cli-launcher-$PACKAGE_VERSION.vsix"
54+
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
55+
gh release upload "$GITHUB_REF_NAME" "$VSIX" --clobber
56+
else
57+
gh release create "$GITHUB_REF_NAME" "$VSIX" --generate-notes --title "$GITHUB_REF_NAME" --verify-tag
58+
fi

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ node_modules/
22
out/
33
out/**/*.map
44
.kimi/
5+
.env
6+
.env.*
7+
!.env.example
58
*.vsix
69
*.tgz
710
.vscode-test/
811
.vsce/
912
coverage/
13+
test-results/
14+
.idea/
15+
.history/
1016
*.log
17+
*.tmp
1118
*.tsbuildinfo
1219
.DS_Store
1320
Thumbs.db

‎.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

‎.vscodeignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ node_modules/**
66
.git/**
77
.gitignore
88
.github/**
9+
.editorconfig
10+
.env*
11+
.nvmrc
912
.kimi/**
1013
.vscode/**
1114
.vsce/**
15+
AGENTS.md
16+
biome.json
1217
*.vsix
1318
*.log
1419
out/**/*.map
1520
*.tsbuildinfo
1621
tsconfig.json
1722
package-lock.json
23+
SECURITY_REVIEW.md

‎AGENTS.md‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# AGENTS.md
2+
3+
## Scope
4+
5+
These instructions apply to the entire repository. This project is a deliberately small, dependency-free-at-runtime VS Code extension; prefer focused changes over new layers, frameworks, or abstractions.
6+
7+
## Project Contract
8+
9+
- The extension opens a fresh side terminal and sends the user-configured Kimi command.
10+
- The default command is `kimi`; official updates use `kimi upgrade`.
11+
- The active editor's workspace is preferred, followed by the first open workspace.
12+
- The launch command must come from user-level configuration only. Never consume workspace or workspace-folder values for executable commands.
13+
- Terminal execution must remain blocked while `vscode.workspace.isTrusted` is false, even when the command is invoked programmatically.
14+
- The runtime must remain transparent: no hidden child processes, installers, downloads, telemetry, terminal-output inspection, or credential handling.
15+
- Do not change the existing design, icons, or media assets unless the task explicitly requests it. Never run `npm run generate:icon` during unrelated work.
16+
17+
## Repository Map
18+
19+
- `src/extension.ts`: VS Code integration, commands, trust check, and terminal creation.
20+
- `src/command-utils.ts`: pure helpers; keep this module independent of the VS Code runtime where practical.
21+
- `test/command-utils.test.js`: helper behavior and security-boundary tests.
22+
- `test/metadata.test.js`: manifest, documentation, workflow, and package-contract tests.
23+
- `test/integration/`: Extension Host smoke test.
24+
- `media/`: Marketplace and toolbar artwork; preserve format, dimensions, transparency, and appearance.
25+
- `out/`, `.vscode-test/`, `node_modules/`, and `*.vsix`: generated or downloaded artifacts; do not commit them.
26+
27+
## Required Workflow
28+
29+
1. Read the relevant source, tests, manifest, and documentation before editing.
30+
2. Check `git status` and preserve unrelated user changes in dirty worktrees.
31+
3. Keep security and behavior invariants covered by targeted tests.
32+
4. Run the smallest relevant checks while iterating.
33+
5. Before handoff, run `npm run check`, `npm run check:security`, and `git diff --check`.
34+
6. Inspect `npm run package:list` when package contents change. Build a VSIX only when requested or when validating release behavior.
35+
36+
Use `npm ci --ignore-scripts` for a clean, reproducible install. Do not replace `package-lock.json` with another package-manager lockfile.
37+
38+
## Coding Standards
39+
40+
- Use strict TypeScript and the existing ESM-style source imports compiled with `NodeNext`.
41+
- Keep runtime behavior in `extension.ts` and reusable decision logic in pure, directly testable helpers.
42+
- Prefer VS Code APIs over Node filesystem, process, or shell APIs.
43+
- Do not add production dependencies unless the functionality cannot reasonably be implemented with the VS Code or JavaScript standard APIs.
44+
- Preserve LF endings, two-space indentation, single quotes, trailing commas, and semicolons. Biome is authoritative for source and test formatting.
45+
- Avoid duplicated constants and command IDs; keep manifest contributions, implementation, tests, and documentation synchronized.
46+
- Handle errors at the user boundary with actionable messages, without logging secrets or full sensitive paths.
47+
48+
## Security and Secrets
49+
50+
- Treat any terminal command as code execution. Keep the Workspace Trust guard and the user-level-only configuration resolution together with regression tests.
51+
- Never read executable commands from `.vscode/settings.json`, workspace files, environment files, or repository content.
52+
- Do not add API keys, tokens, publisher credentials, `.env` files, or real user paths. Use redacted examples only.
53+
- The launcher does not own Kimi authentication. Direct users to official Kimi login and configuration documentation.
54+
- Keep GitHub workflow permissions minimal and pin actions to full commit SHAs with the release tag in a same-line comment.
55+
- `pull_request_target` workflows must never check out or execute pull-request code with write permissions.
56+
57+
## Tests and Compatibility
58+
59+
- Add unit tests for helper edge cases and metadata tests for public contract changes.
60+
- Keep `@types/vscode` pinned to the minimum version declared by `engines.vscode`.
61+
- The integration runner accepts `VSCODE_TEST_VERSION`; CI covers stable VS Code on Windows, Linux, and macOS plus the minimum supported VS Code on Linux.
62+
- Never weaken tests merely to make a change pass. Update brittle exact assertions only when the public contract intentionally changes.
63+
64+
## Documentation and Releases
65+
66+
- Update `README.md` for requirements, settings, commands, environment behavior, build, or release changes.
67+
- Add user-visible changes to the `Unreleased` section of `CHANGELOG.md`.
68+
- For a release, keep versions synchronized in `package.json`, `package-lock.json`, and `CITATION.cff`; update metadata tests when appropriate.
69+
- A `v<version>` tag triggers the GitHub release workflow. Do not create tags, push, publish, or upload Marketplace packages unless explicitly authorized.
70+
- Maintain the unofficial-project and trademark disclaimer. Do not imply endorsement by Moonshot AI or Kimi.
71+
72+
## Dependency Policy
73+
74+
- Confirm a dependency is used before adding it; prefer development-only tooling when runtime code does not need the package.
75+
- Review direct and transitive changes in `package-lock.json`, run the high-severity audit, and avoid forced major upgrades.
76+
- The absence of `.github/dependabot.yml` is intentional: periodic version-update PRs were disabled. Do not reintroduce them without maintainer approval; Dependabot security alerts are managed in repository settings.

0 commit comments

Comments
 (0)