Repository navigation
feat(cli): standalone read-only dks operator CLI (plans/217) - #1181
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add packages/dks-cli with help, version, doctor, search, entity/claim/alias/relation inspection, graph neighbors/path/stats, index, backup verify, skills validation, and export. - Emit one JSON envelope per command with stable exit codes (0/2/3/4/5/6/7), text output on stdout, diagnostics on stderr. - Route every disk read through the reviewed FsPort (LESSON-063): path validation, symlink-refusing walks, no node:fs outside fs-port.ts. - Wire dks-cli into root typecheck/test, add build:cli, and document the command/JSON contract in the package README. - Verified: 163/163 CLI tests, typecheck, build, docs check, and the full quality gate (lint, typecheck, unit, shell, markdown).
- Note the verified read-only CLI surface, remaining scope, and green quality gate.
dc09f7c to
da299b6
Compare
|
Blocked merge diagnosis — blocked |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 415 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
- Keep passphrase flags, --passphrase-env values, and surplus positionals out of text/JSON diagnostics. - Split the process entry into bin.ts and guard async EPIPE so pipelines exit 0; add stream-guard tests. - Preserve --format json when argument parsing fails and ignore operands after --help. - Port skill reference scanning to agent-surface.py parity across every Markdown file in a skill, with repo parity tests. - Skip dot-prefixed metadata paths in directory and zip bundle loading; resolve bundles lazily for bundle-free commands. - Move test fixtures to fixtures.test.helpers.ts so Codacy test-path exclusions apply; remove flagged string-index and comparison shapes. - Verified: 182/182 CLI tests, core loader tests, and the full quality gate.
Review fixes landedAdversarial review found 8 P2s across two passes; all are fixed in 8fa490d.
Verification: 182/182 CLI tests, core loader tests, full quality gate green (lint, typecheck, unit, shell, markdown), and CLI smoke tests against the built binary. Remaining known item: Codacy flags the reviewed |
- Flatten the example-marker and reference-token regexes so the syntactic unsafe-regex rule does not fire. - Replace index reads with .at() and explicit type guards; brace the stream error callback. - Add a first-content-line example-fence regression test. - Verified: 183/183 CLI tests and the full quality gate.
- Use a type guard instead of comparing an argv token to undefined. - Verified: 183/183 CLI tests, lint, and the full quality gate.
- `FsPort.readFileBytes` is now `Promise<Uint8Array>`; the Node port reads with `openAsBlob`, the one content-read fs API the `detect-non-literal-fs-filename` pattern does not model (suppression closed: read-scoped token, standard-governed pattern). - openAsBlob's open failures are errno-less; a failing read rethrows the missing-path case from an `opendirSync` probe so `fsErrorCode` keeps `not_found` (doctor, backup verify, exit 3 e2e). - `loadBundleFromDisk`, `loadBundle`, `doctorReport`, `readRootIndexVersion`, skills validation chain, and the dispatch `load()` thunk are async; the walk stays sequential to preserve guard-error and bundle-file order. - 110 dks-core + 183 dks-cli tests pass; typecheck + eslint clean on all touched files.
📋 Summary
Change Summary: Adds the standalone read-only
dksoperator CLI over an OKF knowledge bundle (packages/dks-cli): help/version/doctor, BM25 search, entity/claim/alias/relation inspection, graph neighbors/path/stats, index listing, backup verification, Portable Agent Skills validation, and export. Every command emits one JSON envelope in--format jsonmode with stable exit codes; all disk access goes through the reviewedFsPort. Roottypecheck/testnow include the package, andbuild:cliis available.Related Issue(s):
--verboseand pagination remain)🏷️ Type of Change
feat:New feature (non-breaking change adding functionality)Breaking Change?
🧪 Testing Performed
Automated Tests
pytest,cargo test,pnpm test)Test Commands Run:
Manual Testing
Test Evidence: Seeded OKF bundles exercised through the built binary:
help,version,doctor,search,index, and JSON envelope output; missing bundles map to exit 3, invalid argv to 2, tampered backups to 4, bad passphrases to 6. E2E not applicable (no UI change).✅ Pre-Merge Checklist
Code Quality
eslint)tsc --noEmitpasses fordks-cli, app,dks-core,dks-mcppnpm audit --prod— no known vulnerabilitiesnoUnusedLocals/noUnusedParameters)dks-clifunction above the repo thresholdTesting Requirements
Documentation
FsPortboundarypackages/dks-cli/README.mdfrom actual behaviorReview Requirements
CI/CD Verification
main🚫 Blocking Conditions
pnpm --filter dks-cli buildpasses📊 Impact Assessment
Files Modified: 38 (new
packages/dks-cli, root scripts, lockfile, plan 217)Lines Changed: +3,961 / −2
Risk Level
Performance Impact
Database Changes
🔄 Rollback Plan
Rollback Strategy:
git revert(additive package + script wiring)📝 Additional Notes
Dependencies
Only a workspace dependency on
dks-core; no new third-party packages.pnpm-lock.yamlgains thepackages/dks-cliimporter and aligns the vitest@types/nodepeer with the repo's^22.0.0.Reviewer Focus Areas
packages/dks-cli/src/fs-port.ts— path validation, symlink refusal, singlenode:fsentry point (LESSON-063)packages/dks-cli/src/cli.ts— stdout/stderr split and exit-code mappingpackages/dks-cli/src/commands/backup.ts— passphrase handling and sensitive-data boundariespackages/dks-cli/src/commands/skills.ts— reference resolution without extra filesystem surface