@cyanautomation/kaseki-agent 1.4.1
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/.dockerignore +54 -0
- package/.eslintignore +11 -0
- package/.eslintrc.json +95 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +53 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +53 -0
- package/.github/ISSUE_TEMPLATE/security.md +51 -0
- package/.github/PULL_REQUEST_TEMPLATE/default.md +71 -0
- package/.github/dependabot.yml +38 -0
- package/.github/skills/dependency-cache-optimization/SKILL.md +526 -0
- package/.github/skills/docker-image-management/SKILL.md +532 -0
- package/.github/skills/frontend-design/SKILL.md +782 -0
- package/.github/skills/prompt-engineering/SKILL.md +360 -0
- package/.github/skills/quality-gate-config/SKILL.md +591 -0
- package/.github/skills/result-report-analysis/SKILL.md +576 -0
- package/.github/skills/test-automation/SKILL.md +593 -0
- package/.github/skills/workflow-diagnosis/SKILL.md +468 -0
- package/.github/workflows/build-docker-image.yml +453 -0
- package/.github/workflows/release.yml +68 -0
- package/.releaserc.json +135 -0
- package/CHANGELOG.md +117 -0
- package/CLAUDE.md +336 -0
- package/CONTRIBUTING.md +339 -0
- package/Dockerfile +217 -0
- package/README.md +1527 -0
- package/STYLE.md +521 -0
- package/add-js-extensions.d.ts +9 -0
- package/add-js-extensions.d.ts.map +1 -0
- package/add-js-extensions.js.map +1 -0
- package/dist/add-js-extensions.d.ts +9 -0
- package/dist/add-js-extensions.d.ts.map +1 -0
- package/dist/add-js-extensions.js +52 -0
- package/dist/add-js-extensions.js.map +1 -0
- package/dist/ansi-colors.d.ts +26 -0
- package/dist/ansi-colors.d.ts.map +1 -0
- package/dist/ansi-colors.js +51 -0
- package/dist/ansi-colors.js.map +1 -0
- package/dist/cli/BaseCommand.d.ts +18 -0
- package/dist/cli/BaseCommand.d.ts.map +1 -0
- package/dist/cli/BaseCommand.js +31 -0
- package/dist/cli/BaseCommand.js.map +1 -0
- package/dist/cli/KasekiCLI.d.ts +30 -0
- package/dist/cli/KasekiCLI.d.ts.map +1 -0
- package/dist/cli/KasekiCLI.js +134 -0
- package/dist/cli/KasekiCLI.js.map +1 -0
- package/dist/cli/commands/ConfigCommand.d.ts +13 -0
- package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/cli/commands/ConfigCommand.js +131 -0
- package/dist/cli/commands/ConfigCommand.js.map +1 -0
- package/dist/cli/commands/DoctorCommand.d.ts +45 -0
- package/dist/cli/commands/DoctorCommand.d.ts.map +1 -0
- package/dist/cli/commands/DoctorCommand.js +309 -0
- package/dist/cli/commands/DoctorCommand.js.map +1 -0
- package/dist/cli/commands/ListCommand.d.ts +9 -0
- package/dist/cli/commands/ListCommand.d.ts.map +1 -0
- package/dist/cli/commands/ListCommand.js +81 -0
- package/dist/cli/commands/ListCommand.js.map +1 -0
- package/dist/cli/commands/ReportCommand.d.ts +9 -0
- package/dist/cli/commands/ReportCommand.d.ts.map +1 -0
- package/dist/cli/commands/ReportCommand.js +98 -0
- package/dist/cli/commands/ReportCommand.js.map +1 -0
- package/dist/cli/commands/RunCommand.d.ts +13 -0
- package/dist/cli/commands/RunCommand.d.ts.map +1 -0
- package/dist/cli/commands/RunCommand.js +191 -0
- package/dist/cli/commands/RunCommand.js.map +1 -0
- package/dist/cli/commands/SecretsCommand.d.ts +9 -0
- package/dist/cli/commands/SecretsCommand.d.ts.map +1 -0
- package/dist/cli/commands/SecretsCommand.js +109 -0
- package/dist/cli/commands/SecretsCommand.js.map +1 -0
- package/dist/cli/commands/ServeCommand.d.ts +9 -0
- package/dist/cli/commands/ServeCommand.d.ts.map +1 -0
- package/dist/cli/commands/ServeCommand.js +50 -0
- package/dist/cli/commands/ServeCommand.js.map +1 -0
- package/dist/cli/commands/SetupCommand.d.ts +42 -0
- package/dist/cli/commands/SetupCommand.d.ts.map +1 -0
- package/dist/cli/commands/SetupCommand.js +249 -0
- package/dist/cli/commands/SetupCommand.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +130 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +395 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +446 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/docker/DockerManager.d.ts +69 -0
- package/dist/docker/DockerManager.d.ts.map +1 -0
- package/dist/docker/DockerManager.js +266 -0
- package/dist/docker/DockerManager.js.map +1 -0
- package/dist/event-aggregator.d.ts +71 -0
- package/dist/event-aggregator.d.ts.map +1 -0
- package/dist/event-aggregator.js +95 -0
- package/dist/event-aggregator.js.map +1 -0
- package/dist/github-app-token.d.ts +16 -0
- package/dist/github-app-token.d.ts.map +1 -0
- package/dist/github-app-token.js +148 -0
- package/dist/github-app-token.js.map +1 -0
- package/dist/idempotency-store.d.ts +61 -0
- package/dist/idempotency-store.d.ts.map +1 -0
- package/dist/idempotency-store.js +321 -0
- package/dist/idempotency-store.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/instance/InstanceManager.d.ts +81 -0
- package/dist/instance/InstanceManager.d.ts.map +1 -0
- package/dist/instance/InstanceManager.js +220 -0
- package/dist/instance/InstanceManager.js.map +1 -0
- package/dist/instance-metadata-reader.d.ts +48 -0
- package/dist/instance-metadata-reader.d.ts.map +1 -0
- package/dist/instance-metadata-reader.js +94 -0
- package/dist/instance-metadata-reader.js.map +1 -0
- package/dist/instance-state-derivation.d.ts +42 -0
- package/dist/instance-state-derivation.d.ts.map +1 -0
- package/dist/instance-state-derivation.js +133 -0
- package/dist/instance-state-derivation.js.map +1 -0
- package/dist/job-scheduler.d.ts +124 -0
- package/dist/job-scheduler.d.ts.map +1 -0
- package/dist/job-scheduler.js +992 -0
- package/dist/job-scheduler.js.map +1 -0
- package/dist/kaseki-api-client.d.ts +89 -0
- package/dist/kaseki-api-client.d.ts.map +1 -0
- package/dist/kaseki-api-client.js +405 -0
- package/dist/kaseki-api-client.js.map +1 -0
- package/dist/kaseki-api-config.d.ts +34 -0
- package/dist/kaseki-api-config.d.ts.map +1 -0
- package/dist/kaseki-api-config.js +113 -0
- package/dist/kaseki-api-config.js.map +1 -0
- package/dist/kaseki-api-routes.d.ts +13 -0
- package/dist/kaseki-api-routes.d.ts.map +1 -0
- package/dist/kaseki-api-routes.js +559 -0
- package/dist/kaseki-api-routes.js.map +1 -0
- package/dist/kaseki-api-service-wrapper.d.ts +43 -0
- package/dist/kaseki-api-service-wrapper.d.ts.map +1 -0
- package/dist/kaseki-api-service-wrapper.js +150 -0
- package/dist/kaseki-api-service-wrapper.js.map +1 -0
- package/dist/kaseki-api-service.d.ts +16 -0
- package/dist/kaseki-api-service.d.ts.map +1 -0
- package/dist/kaseki-api-service.js +143 -0
- package/dist/kaseki-api-service.js.map +1 -0
- package/dist/kaseki-api-types.d.ts +440 -0
- package/dist/kaseki-api-types.d.ts.map +1 -0
- package/dist/kaseki-api-types.js +64 -0
- package/dist/kaseki-api-types.js.map +1 -0
- package/dist/kaseki-cli-lib.d.ts +219 -0
- package/dist/kaseki-cli-lib.d.ts.map +1 -0
- package/dist/kaseki-cli-lib.js +523 -0
- package/dist/kaseki-cli-lib.js.map +1 -0
- package/dist/kaseki-cli.d.ts +38 -0
- package/dist/kaseki-cli.d.ts.map +1 -0
- package/dist/kaseki-cli.js +559 -0
- package/dist/kaseki-cli.js.map +1 -0
- package/dist/kaseki-report.d.ts +3 -0
- package/dist/kaseki-report.d.ts.map +1 -0
- package/dist/kaseki-report.js +140 -0
- package/dist/kaseki-report.js.map +1 -0
- package/dist/lib/subprocess-helpers.d.ts +98 -0
- package/dist/lib/subprocess-helpers.d.ts.map +1 -0
- package/dist/lib/subprocess-helpers.js +136 -0
- package/dist/lib/subprocess-helpers.js.map +1 -0
- package/dist/logger.d.ts +39 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +79 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.d.ts +19 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +59 -0
- package/dist/metrics.js.map +1 -0
- package/dist/middleware/job-lookup.d.ts +27 -0
- package/dist/middleware/job-lookup.d.ts.map +1 -0
- package/dist/middleware/job-lookup.js +28 -0
- package/dist/middleware/job-lookup.js.map +1 -0
- package/dist/pi-event-filter.d.ts +3 -0
- package/dist/pi-event-filter.d.ts.map +1 -0
- package/dist/pi-event-filter.js +126 -0
- package/dist/pi-event-filter.js.map +1 -0
- package/dist/pi-progress-stream.d.ts +3 -0
- package/dist/pi-progress-stream.d.ts.map +1 -0
- package/dist/pi-progress-stream.js +205 -0
- package/dist/pi-progress-stream.js.map +1 -0
- package/dist/pi-progress-summarizer.d.ts +61 -0
- package/dist/pi-progress-summarizer.d.ts.map +1 -0
- package/dist/pi-progress-summarizer.js +246 -0
- package/dist/pi-progress-summarizer.js.map +1 -0
- package/dist/pre-flight-validator.d.ts +72 -0
- package/dist/pre-flight-validator.d.ts.map +1 -0
- package/dist/pre-flight-validator.js +513 -0
- package/dist/pre-flight-validator.js.map +1 -0
- package/dist/progress-stream-utils.d.ts +3 -0
- package/dist/progress-stream-utils.d.ts.map +1 -0
- package/dist/progress-stream-utils.js +15 -0
- package/dist/progress-stream-utils.js.map +1 -0
- package/dist/result-cache.d.ts +52 -0
- package/dist/result-cache.d.ts.map +1 -0
- package/dist/result-cache.js +134 -0
- package/dist/result-cache.js.map +1 -0
- package/dist/routes/artifact-routes.d.ts +10 -0
- package/dist/routes/artifact-routes.d.ts.map +1 -0
- package/dist/routes/artifact-routes.js +126 -0
- package/dist/routes/artifact-routes.js.map +1 -0
- package/dist/routes/log-routes.d.ts +8 -0
- package/dist/routes/log-routes.d.ts.map +1 -0
- package/dist/routes/log-routes.js +345 -0
- package/dist/routes/log-routes.js.map +1 -0
- package/dist/routes/status-routes.d.ts +8 -0
- package/dist/routes/status-routes.d.ts.map +1 -0
- package/dist/routes/status-routes.js +82 -0
- package/dist/routes/status-routes.js.map +1 -0
- package/dist/routes/webhook-routes.d.ts +6 -0
- package/dist/routes/webhook-routes.d.ts.map +1 -0
- package/dist/routes/webhook-routes.js +86 -0
- package/dist/routes/webhook-routes.js.map +1 -0
- package/dist/run-artifact-metadata-cache.d.ts +42 -0
- package/dist/run-artifact-metadata-cache.d.ts.map +1 -0
- package/dist/run-artifact-metadata-cache.js +139 -0
- package/dist/run-artifact-metadata-cache.js.map +1 -0
- package/dist/secret-value-cache.d.ts +13 -0
- package/dist/secret-value-cache.d.ts.map +1 -0
- package/dist/secret-value-cache.js +44 -0
- package/dist/secret-value-cache.js.map +1 -0
- package/dist/secrets/SecretsManager.d.ts +80 -0
- package/dist/secrets/SecretsManager.d.ts.map +1 -0
- package/dist/secrets/SecretsManager.js +306 -0
- package/dist/secrets/SecretsManager.js.map +1 -0
- package/dist/test-utils.d.ts +55 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +48 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/timestamp-tracker.d.ts +75 -0
- package/dist/timestamp-tracker.d.ts.map +1 -0
- package/dist/timestamp-tracker.js +121 -0
- package/dist/timestamp-tracker.js.map +1 -0
- package/dist/utils/failure-artifact-writer.d.ts +29 -0
- package/dist/utils/failure-artifact-writer.d.ts.map +1 -0
- package/dist/utils/failure-artifact-writer.js +157 -0
- package/dist/utils/failure-artifact-writer.js.map +1 -0
- package/dist/utils/file-helpers.d.ts +41 -0
- package/dist/utils/file-helpers.d.ts.map +1 -0
- package/dist/utils/file-helpers.js +143 -0
- package/dist/utils/file-helpers.js.map +1 -0
- package/dist/utils/http-client-factory.d.ts +46 -0
- package/dist/utils/http-client-factory.d.ts.map +1 -0
- package/dist/utils/http-client-factory.js +114 -0
- package/dist/utils/http-client-factory.js.map +1 -0
- package/dist/utils/progress-normalizer.d.ts +13 -0
- package/dist/utils/progress-normalizer.d.ts.map +1 -0
- package/dist/utils/progress-normalizer.js +57 -0
- package/dist/utils/progress-normalizer.js.map +1 -0
- package/dist/utils/response-helpers.d.ts +34 -0
- package/dist/utils/response-helpers.d.ts.map +1 -0
- package/dist/utils/response-helpers.js +78 -0
- package/dist/utils/response-helpers.js.map +1 -0
- package/dist/utils/route-helpers.d.ts +17 -0
- package/dist/utils/route-helpers.d.ts.map +1 -0
- package/dist/utils/route-helpers.js +22 -0
- package/dist/utils/route-helpers.js.map +1 -0
- package/dist/utils/status-response-builder.d.ts +23 -0
- package/dist/utils/status-response-builder.d.ts.map +1 -0
- package/dist/utils/status-response-builder.js +144 -0
- package/dist/utils/status-response-builder.js.map +1 -0
- package/dist/utils/type-guards.d.ts +37 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +45 -0
- package/dist/utils/type-guards.js.map +1 -0
- package/dist/utils/utf8-helpers.d.ts +32 -0
- package/dist/utils/utf8-helpers.d.ts.map +1 -0
- package/dist/utils/utf8-helpers.js +97 -0
- package/dist/utils/utf8-helpers.js.map +1 -0
- package/dist/utils/webhook-event-builder.d.ts +26 -0
- package/dist/utils/webhook-event-builder.d.ts.map +1 -0
- package/dist/utils/webhook-event-builder.js +77 -0
- package/dist/utils/webhook-event-builder.js.map +1 -0
- package/dist/webhook-manager.d.ts +56 -0
- package/dist/webhook-manager.d.ts.map +1 -0
- package/dist/webhook-manager.js +359 -0
- package/dist/webhook-manager.js.map +1 -0
- package/docker/workspace-cache/package-lock.json +13 -0
- package/docker/workspace-cache/package.json +7 -0
- package/docker-compose.yml +53 -0
- package/docs/API.md +708 -0
- package/docs/BACKLOG.md +19 -0
- package/docs/BUILD_STRATEGY.md +404 -0
- package/docs/CLI.md +569 -0
- package/docs/DEPLOYMENT.md +521 -0
- package/docs/DEVELOPMENT.md +459 -0
- package/docs/DOCKER_SETUP.md +522 -0
- package/docs/ENHANCED_PROGRESS_LOGS.md +264 -0
- package/docs/IMPLEMENTATION_SUMMARY.md +549 -0
- package/docs/INTEGRATION_EXAMPLE.md +217 -0
- package/docs/NPM_SETUP.md +468 -0
- package/docs/PHASE1-4_IMPLEMENTATION.md +302 -0
- package/docs/PHASE1_COMPLETION.md +192 -0
- package/docs/PHASE2_COMPLETION.md +134 -0
- package/docs/PHASE6_MIGRATION.md +392 -0
- package/docs/PRINTF_SAFETY_FIX.md +282 -0
- package/docs/QUALITY_GATES.md +369 -0
- package/docs/SETUP_GUIDE.md +482 -0
- package/docs/TASK_PROMPT_TEMPLATES.md +533 -0
- package/docs/VALIDATION_FIX.md +139 -0
- package/docs/VERIFICATION_CHECKLIST.md +335 -0
- package/docs/repo-maturity.md +760 -0
- package/fix-tests.d.ts +9 -0
- package/fix-tests.d.ts.map +1 -0
- package/fix-tests.js.map +1 -0
- package/fix-tests.ts +53 -0
- package/jest.config.ts +31 -0
- package/kaseki +183 -0
- package/kaseki-agent.sh +1961 -0
- package/ops/logrotate/kaseki +10 -0
- package/package.json +83 -0
- package/perf/README.md +54 -0
- package/perf/pi-event-filter.benchmark.test.ts +98 -0
- package/run-kaseki-json.test.sh +106 -0
- package/run-kaseki.sh +990 -0
- package/scripts/allowlist-helper.sh +56 -0
- package/scripts/cleanup-kaseki.sh +168 -0
- package/scripts/deploy-pi-template.sh +293 -0
- package/scripts/docker-entrypoint.sh +71 -0
- package/scripts/dry-run-allowlist.sh +161 -0
- package/scripts/kaseki-activate.sh +396 -0
- package/scripts/kaseki-api.service +62 -0
- package/scripts/kaseki-container-entrypoint-wrapper.sh +119 -0
- package/scripts/kaseki-container-setup-remote.sh +172 -0
- package/scripts/kaseki-container-setup.sh +193 -0
- package/scripts/kaseki-healthcheck.sh +95 -0
- package/scripts/kaseki-install.sh +50 -0
- package/scripts/kaseki-maturity-score.sh +291 -0
- package/scripts/kaseki-performance-metrics.sh +122 -0
- package/scripts/kaseki-preflight.sh +270 -0
- package/scripts/kaseki-setup.sh +265 -0
- package/scripts/pi-setup-remote.sh +213 -0
- package/scripts/setup-github-labels.sh +42 -0
- package/scripts/suggest-allowlist.sh +68 -0
- package/scripts/templates/MULTI_HOST_DISTRIBUTED.md +337 -0
- package/scripts/templates/REST_API_SERVICE.md +490 -0
- package/scripts/templates/SINGLE_HOST_CLI.md +194 -0
- package/scripts/test-github-app.sh +248 -0
- package/src/add-js-extensions.ts +61 -0
- package/src/ansi-colors.test.ts +62 -0
- package/src/ansi-colors.ts +67 -0
- package/src/cli/BaseCommand.ts +40 -0
- package/src/cli/KasekiCLI.ts +154 -0
- package/src/cli/commands/ConfigCommand.ts +145 -0
- package/src/cli/commands/DoctorCommand.ts +329 -0
- package/src/cli/commands/ListCommand.ts +105 -0
- package/src/cli/commands/ReportCommand.ts +110 -0
- package/src/cli/commands/RunCommand.ts +218 -0
- package/src/cli/commands/SecretsCommand.ts +120 -0
- package/src/cli/commands/ServeCommand.ts +62 -0
- package/src/cli/commands/SetupCommand.ts +301 -0
- package/src/cli.ts +138 -0
- package/src/config/ConfigManager.ts +476 -0
- package/src/docker/DockerManager.ts +319 -0
- package/src/docker-entrypoint-packaging.test.ts +33 -0
- package/src/event-aggregator.test.ts +117 -0
- package/src/event-aggregator.ts +126 -0
- package/src/github-app-token.ts +215 -0
- package/src/idempotency-store.test.ts +117 -0
- package/src/idempotency-store.ts +385 -0
- package/src/index.ts +89 -0
- package/src/instance/InstanceManager.ts +285 -0
- package/src/instance-metadata-reader.test.ts +190 -0
- package/src/instance-metadata-reader.ts +129 -0
- package/src/instance-state-derivation.test.ts +263 -0
- package/src/instance-state-derivation.ts +148 -0
- package/src/job-scheduler.test.ts +1236 -0
- package/src/job-scheduler.ts +1117 -0
- package/src/kaseki-api-client.ts +488 -0
- package/src/kaseki-api-config.test.ts +315 -0
- package/src/kaseki-api-config.ts +175 -0
- package/src/kaseki-api-routes.test.ts +1615 -0
- package/src/kaseki-api-routes.ts +643 -0
- package/src/kaseki-api-service-wrapper.ts +188 -0
- package/src/kaseki-api-service.test.ts +418 -0
- package/src/kaseki-api-service.ts +192 -0
- package/src/kaseki-api-types.ts +320 -0
- package/src/kaseki-cli-lib.test.ts +552 -0
- package/src/kaseki-cli-lib.ts +760 -0
- package/src/kaseki-cli.ts +682 -0
- package/src/kaseki-report.test.ts +118 -0
- package/src/kaseki-report.ts +192 -0
- package/src/lib/subprocess-helpers.ts +177 -0
- package/src/logger.ts +114 -0
- package/src/metrics.ts +66 -0
- package/src/middleware/job-lookup.test.ts +113 -0
- package/src/middleware/job-lookup.ts +45 -0
- package/src/pi-event-filter.test.ts +183 -0
- package/src/pi-event-filter.ts +183 -0
- package/src/pi-progress-stream.ts +287 -0
- package/src/pi-progress-summarizer.test.ts +302 -0
- package/src/pi-progress-summarizer.ts +287 -0
- package/src/pre-flight-validator.test.ts +512 -0
- package/src/pre-flight-validator.ts +618 -0
- package/src/progress-stream-utils.test.ts +35 -0
- package/src/progress-stream-utils.ts +14 -0
- package/src/result-cache.test.ts +195 -0
- package/src/result-cache.ts +181 -0
- package/src/routes/artifact-routes.ts +169 -0
- package/src/routes/log-routes.ts +391 -0
- package/src/routes/status-routes.ts +92 -0
- package/src/routes/webhook-routes.ts +97 -0
- package/src/run-artifact-metadata-cache.test.ts +80 -0
- package/src/run-artifact-metadata-cache.ts +184 -0
- package/src/secret-value-cache.test.ts +66 -0
- package/src/secret-value-cache.ts +55 -0
- package/src/secrets/SecretsManager.ts +343 -0
- package/src/test-utils.ts +81 -0
- package/src/timestamp-tracker.test.ts +134 -0
- package/src/timestamp-tracker.ts +132 -0
- package/src/utils/failure-artifact-writer.ts +187 -0
- package/src/utils/file-helpers.test.ts +235 -0
- package/src/utils/file-helpers.ts +150 -0
- package/src/utils/http-client-factory.test.ts +245 -0
- package/src/utils/http-client-factory.ts +157 -0
- package/src/utils/progress-normalizer.test.ts +442 -0
- package/src/utils/progress-normalizer.ts +68 -0
- package/src/utils/response-helpers.test.ts +122 -0
- package/src/utils/response-helpers.ts +101 -0
- package/src/utils/route-helpers.ts +30 -0
- package/src/utils/status-response-builder.ts +159 -0
- package/src/utils/type-guards.ts +52 -0
- package/src/utils/utf8-helpers.ts +102 -0
- package/src/utils/webhook-event-builder.test.ts +143 -0
- package/src/utils/webhook-event-builder.ts +87 -0
- package/src/webhook-manager.test.ts +152 -0
- package/src/webhook-manager.ts +445 -0
- package/templates/allowlist-api-route.txt +7 -0
- package/templates/allowlist-comprehensive.txt +8 -0
- package/templates/allowlist-parser-fix.txt +6 -0
- package/templates/allowlist-ui-component.txt +9 -0
- package/templates/allowlist-utility.txt +9 -0
- package/test/actual-model-metadata.test.sh +102 -0
- package/test/dry-run.test.sh +131 -0
- package/test/fixtures/kaseki-report-exit-codes/metadata-exit-0.json +1 -0
- package/test/fixtures/kaseki-report-exit-codes/metadata-exit-1.json +1 -0
- package/test/fixtures/kaseki-report-exit-codes/metadata-exit-invalid.json +1 -0
- package/test/fixtures/kaseki-report-exit-codes/metadata-exit-str-0.json +1 -0
- package/test/fixtures/kaseki-report-exit-codes/metadata-exit-str-1.json +1 -0
- package/test/kaseki-api.integration.test.sh +165 -0
- package/test/pi-event-filter-failure.test.sh +83 -0
- package/test/printf-safety-focused.test.sh +99 -0
- package/test/printf-safety-results/results/restoration.jsonl +10 -0
- package/test/printf-safety-results/results/test.jsonl +0 -0
- package/test/printf-safety.test.sh +297 -0
- package/test/validation-fix.test.sh +79 -0
- package/test/validation-integration.test.sh +109 -0
- package/tests/allowlist-glob.test.sh +61 -0
- package/tests/dependency-cache-key.test.sh +48 -0
- package/tests/dependency-restore-mode.test.sh +48 -0
- package/tests/doctor-template-parity.test.sh +95 -0
- package/tests/github-operations.test.sh +142 -0
- package/tests/npm-install-flags.test.sh +58 -0
- package/tests/quality-gates.test.sh +178 -0
- package/tests/repo-memory.test.sh +103 -0
- package/tests/restore-disallowed-changes.test.sh +80 -0
- package/tests/validation-missing-npm-scripts.test.sh +93 -0
- package/tests/validation-strict-mode.test.sh +118 -0
- package/tsconfig.changed.json +7 -0
- package/tsconfig.json +39 -0
package/STYLE.md
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
# Kaseki Agent Code Style Guide
|
|
2
|
+
|
|
3
|
+
This document outlines the code style expectations for contributions to the Kaseki Agent repository. All code must pass linting checks before submission. See [CONTRIBUTING.md](CONTRIBUTING.md#3-code-quality-linting-and-style) for how to run linters locally.
|
|
4
|
+
|
|
5
|
+
## TypeScript Style
|
|
6
|
+
|
|
7
|
+
### General Principles
|
|
8
|
+
|
|
9
|
+
- **Clarity over cleverness:** Write code that is easy to understand and maintain.
|
|
10
|
+
- **Node.js idioms:** Follow standard Node.js conventions and built-in modules (fs, path, child_process, etc.).
|
|
11
|
+
- **JSDoc comments:** Document public functions, classes, and complex logic with JSDoc.
|
|
12
|
+
|
|
13
|
+
### Formatting Rules (Enforced by ESLint)
|
|
14
|
+
|
|
15
|
+
| Rule | Style |
|
|
16
|
+
|------|-------|
|
|
17
|
+
| **Indentation** | 2 spaces (no tabs) |
|
|
18
|
+
| **Line endings** | Unix (LF) — enforced via `linebreak-style` |
|
|
19
|
+
| **Quotes** | Single quotes (`'string'`), except where escaping is needed or template literals are required |
|
|
20
|
+
| **Semicolons** | Required at end of statements |
|
|
21
|
+
| **Trailing whitespace** | Not allowed |
|
|
22
|
+
| **Blank lines** | Max 1 consecutive blank line |
|
|
23
|
+
| **Line length** | No strict limit; aim for readability (typically <100 chars per line) |
|
|
24
|
+
|
|
25
|
+
### Examples
|
|
26
|
+
|
|
27
|
+
**Good:**
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
/**
|
|
31
|
+
* List all kaseki instances.
|
|
32
|
+
* Returns array of instance objects with metadata.
|
|
33
|
+
*/
|
|
34
|
+
function listInstances() {
|
|
35
|
+
const instances = [];
|
|
36
|
+
const results = fs.readdirSync(config.KASEKI_RESULTS_DIR);
|
|
37
|
+
for (const dir of results) {
|
|
38
|
+
instances.push({ name: dir });
|
|
39
|
+
}
|
|
40
|
+
return instances;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Bad:**
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// Don't use double quotes unless escaping is needed
|
|
48
|
+
function listInstances() {
|
|
49
|
+
const instances = []
|
|
50
|
+
const results = fs.readdirSync(config.KASEKI_RESULTS_DIR); // missing indentation or semicolon
|
|
51
|
+
for (const dir of results)
|
|
52
|
+
instances.push({ name: dir }) // missing semicolon
|
|
53
|
+
return instances
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Variable and Function Naming
|
|
58
|
+
|
|
59
|
+
- Use **camelCase** for variables and functions
|
|
60
|
+
- Use **UPPER_SNAKE_CASE** for constants (e.g., `KASEKI_RESULTS_DIR`)
|
|
61
|
+
- Use **PascalCase** for classes (rare in this repo, but when used)
|
|
62
|
+
- **Descriptive names:** `listInstances()` not `list()`, `exitCode` not `code`
|
|
63
|
+
|
|
64
|
+
### Comments
|
|
65
|
+
|
|
66
|
+
- Use `//` for single-line comments
|
|
67
|
+
- Use `/* */` for multi-line comments (rare)
|
|
68
|
+
- Use JSDoc (`/** */`) for function and class documentation
|
|
69
|
+
- Keep comments concise and explain *why*, not *what* (code shows what)
|
|
70
|
+
|
|
71
|
+
**Example JSDoc:**
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
/**
|
|
75
|
+
* Resolve a memory file path to its fully qualified URI.
|
|
76
|
+
* @param {string} path - The memory file path (e.g., /memories/session/plan.md)
|
|
77
|
+
* @returns {string} The resolved URI
|
|
78
|
+
*/
|
|
79
|
+
function resolveMemoryFileUri(path) {
|
|
80
|
+
// implementation
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Imports and Requires
|
|
85
|
+
|
|
86
|
+
Use `require()` for Node.js modules (consistent with existing codebase):
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
const fs = require('fs');
|
|
90
|
+
const path = require('path');
|
|
91
|
+
const { execSync } = require('child_process');
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Avoid wildcard imports; be specific:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Good
|
|
98
|
+
const { listInstances, getStatus } = require('./kaseki-cli-lib.js');
|
|
99
|
+
|
|
100
|
+
// Avoid
|
|
101
|
+
const * as lib = require('./kaseki-cli-lib.js');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Error Handling
|
|
105
|
+
|
|
106
|
+
- Always handle errors explicitly; avoid swallowing errors silently
|
|
107
|
+
- Use `try-catch` for synchronous operations with error recovery
|
|
108
|
+
- Use descriptive error messages
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
try {
|
|
112
|
+
const metadata = JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
113
|
+
return metadata;
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error(`Failed to load metadata from ${path}: ${err.message}`);
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Console Output
|
|
121
|
+
|
|
122
|
+
- `console.log()` is allowed (this is a CLI tool)
|
|
123
|
+
- Use `console.error()` for error/warning output
|
|
124
|
+
- Avoid debug logs in production; use conditional logging if needed
|
|
125
|
+
|
|
126
|
+
## TypeScript Style
|
|
127
|
+
|
|
128
|
+
### General Principles
|
|
129
|
+
|
|
130
|
+
- **Type Safety:** `npm run type-check:changed` is the required PR gate. `npm run type-check` / `npm run type-check:full` report full-project debt and are currently non-blocking while debt is tracked.
|
|
131
|
+
- **Explicit Types:** Function parameters, return types, and complex variables must have explicit type annotations. Never use implicit `any`.
|
|
132
|
+
- **Clarity:** Type signatures should make code intent clear; avoid overly complex generic types.
|
|
133
|
+
- **Consistency:** Follow the same patterns established in existing `.ts` files (e.g., `src/kaseki-cli-lib.ts`).
|
|
134
|
+
|
|
135
|
+
### Type Annotations
|
|
136
|
+
|
|
137
|
+
**Always annotate:**
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Good: explicit parameter and return types
|
|
141
|
+
function listInstances(): KasekiInstance[] {
|
|
142
|
+
const instances: KasekiInstance[] = [];
|
|
143
|
+
// ...
|
|
144
|
+
return instances;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Good: interface for complex data
|
|
148
|
+
interface Metadata {
|
|
149
|
+
exitCode: number;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
model: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Bad: implicit any
|
|
155
|
+
function listInstances() {
|
|
156
|
+
const instances = []; // any[], should be typed
|
|
157
|
+
return instances;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Bad: missing return type
|
|
161
|
+
function getStatus(name: string) {
|
|
162
|
+
return { running: true };
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Interface and Type Definitions
|
|
167
|
+
|
|
168
|
+
- Use **PascalCase** for interface and type names
|
|
169
|
+
- Group related interfaces at the top of the file
|
|
170
|
+
- Document with JSDoc comments
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
/**
|
|
174
|
+
* Represents a kaseki instance with metadata and status.
|
|
175
|
+
*/
|
|
176
|
+
interface KasekiInstance {
|
|
177
|
+
name: string;
|
|
178
|
+
running: boolean;
|
|
179
|
+
elapsed?: number;
|
|
180
|
+
timeout?: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Configuration for kaseki directories.
|
|
185
|
+
*/
|
|
186
|
+
interface Config {
|
|
187
|
+
resultsDir: string;
|
|
188
|
+
runsDir: string;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Imports and Exports
|
|
193
|
+
|
|
194
|
+
Use **ES2024 import/export syntax** in source files:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// Good: ES2024 imports
|
|
198
|
+
import fs from 'node:fs';
|
|
199
|
+
import path from 'node:path';
|
|
200
|
+
import { spawn } from 'node:child_process';
|
|
201
|
+
|
|
202
|
+
export interface KasekiInstance { ... }
|
|
203
|
+
export function listInstances(): KasekiInstance[] { ... }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The build process compiles to CommonJS for Node.js compatibility.
|
|
207
|
+
|
|
208
|
+
### Union Types and Type Guards
|
|
209
|
+
|
|
210
|
+
Use discriminated unions and type guards for flexibility:
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Good: discriminated union
|
|
214
|
+
type EventType =
|
|
215
|
+
| { type: 'tool_start'; timestamp: string }
|
|
216
|
+
| { type: 'tool_end'; timestamp: string };
|
|
217
|
+
|
|
218
|
+
function handleEvent(event: EventType): void {
|
|
219
|
+
switch (event.type) {
|
|
220
|
+
case 'tool_start':
|
|
221
|
+
console.log('Tool started:', event.timestamp);
|
|
222
|
+
break;
|
|
223
|
+
case 'tool_end':
|
|
224
|
+
console.log('Tool ended:', event.timestamp);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Bad: optional fields without discrimination
|
|
230
|
+
interface Event {
|
|
231
|
+
type?: string;
|
|
232
|
+
startTime?: string;
|
|
233
|
+
endTime?: string;
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Null and Undefined Handling
|
|
238
|
+
|
|
239
|
+
Use explicit null checks and nullish coalescing:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
// Good: explicit null check
|
|
243
|
+
function readMetadata(path: string): Metadata | null {
|
|
244
|
+
try {
|
|
245
|
+
const text = fs.readFileSync(path, 'utf8');
|
|
246
|
+
return JSON.parse(text) as Metadata;
|
|
247
|
+
} catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Good: nullish coalescing
|
|
253
|
+
const timeout = metadata.timeout ?? 3600;
|
|
254
|
+
|
|
255
|
+
// Good: optional chaining
|
|
256
|
+
const model = metadata?.model?.toLowerCase();
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Generics
|
|
260
|
+
|
|
261
|
+
Use generics for reusable functions, but keep them readable:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
// Good: simple generic
|
|
265
|
+
function first<T>(array: T[]): T | undefined {
|
|
266
|
+
return array[0];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Avoid: overly complex generics without clear benefit
|
|
270
|
+
function transform<T, U extends Record<string, T>, V = U>(input: U): V { ... }
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Async/Await
|
|
274
|
+
|
|
275
|
+
Always use async/await; avoid bare Promises when possible:
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Good: async function
|
|
279
|
+
async function loadConfig(): Promise<Config> {
|
|
280
|
+
const text = await fs.promises.readFile(configPath, 'utf8');
|
|
281
|
+
return JSON.parse(text);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Acceptable: Promise for library functions
|
|
285
|
+
function createReadStream(path: string): Promise<void> {
|
|
286
|
+
return new Promise((resolve, reject) => {
|
|
287
|
+
// ...
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Error Handling
|
|
293
|
+
|
|
294
|
+
Handle errors explicitly with specific types:
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
// Good: specific error type
|
|
298
|
+
async function processFile(path: string): Promise<void> {
|
|
299
|
+
try {
|
|
300
|
+
const text = await fs.promises.readFile(path, 'utf8');
|
|
301
|
+
const data = JSON.parse(text) as PiEvent;
|
|
302
|
+
// ...
|
|
303
|
+
} catch (err) {
|
|
304
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
305
|
+
console.error(`Failed to process ${path}: ${message}`);
|
|
306
|
+
throw err;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Comments and JSDoc
|
|
312
|
+
|
|
313
|
+
Use JSDoc for public functions and complex logic:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
/**
|
|
317
|
+
* Load and parse a Pi event from a JSONL file.
|
|
318
|
+
* @param path - Path to the JSONL file
|
|
319
|
+
* @returns Parsed event, or null if file not found
|
|
320
|
+
* @throws Error if JSON parsing fails
|
|
321
|
+
*/
|
|
322
|
+
function loadEvent(path: string): PiEvent | null {
|
|
323
|
+
// ...
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Const Assertions and readonly
|
|
328
|
+
|
|
329
|
+
Use `as const` for literal tuples and type-safe constants:
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
// Good: const assertion for tuple
|
|
333
|
+
const ENV_VARS = ['OPENROUTER_API_KEY', 'KASEKI_TIMEOUT'] as const;
|
|
334
|
+
|
|
335
|
+
// Good: readonly for immutable arrays
|
|
336
|
+
function processItems(items: readonly string[]): void {
|
|
337
|
+
// items cannot be modified
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Testing TypeScript Files
|
|
342
|
+
|
|
343
|
+
Jest tests for TypeScript use the same style rules:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
describe('MyFunction', () => {
|
|
347
|
+
it('should return correct result', () => {
|
|
348
|
+
const input: MyType = { ... };
|
|
349
|
+
const result: ExpectedType = myFunction(input);
|
|
350
|
+
expect(result).toBe(expected);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Shell Script Style
|
|
356
|
+
|
|
357
|
+
### General Principles
|
|
358
|
+
|
|
359
|
+
- **Bash idioms:** Use standard Bash 4.x+ features; avoid overly POSIX-only code
|
|
360
|
+
- **Error handling:** Always use `set -euo pipefail` at the top to catch errors
|
|
361
|
+
- **Comments:** Document non-obvious logic
|
|
362
|
+
- **Readability:** Prefer clarity over brevity
|
|
363
|
+
|
|
364
|
+
### Formatting Rules (Checked by ShellCheck)
|
|
365
|
+
|
|
366
|
+
| Rule | Style |
|
|
367
|
+
|------|-------|
|
|
368
|
+
| **Indentation** | 2 spaces (no tabs) |
|
|
369
|
+
| **Line endings** | Unix (LF) |
|
|
370
|
+
| **Function declarations** | `function_name() { ... }` (preferred) or `function function_name { ... }` |
|
|
371
|
+
| **Variables** | Quote expansions: `"$var"` not `$var` |
|
|
372
|
+
| **Conditionals** | Use `[[ ]]` for conditions (Bash), not `[ ]` (POSIX) |
|
|
373
|
+
| **Command substitution** | Use `$(...)` not `` `...` `` |
|
|
374
|
+
|
|
375
|
+
### Examples
|
|
376
|
+
|
|
377
|
+
**Good:**
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
#!/usr/bin/env bash
|
|
381
|
+
set -euo pipefail
|
|
382
|
+
|
|
383
|
+
# Initialize paths
|
|
384
|
+
KASEKI_ROOT="${KASEKI_ROOT:-/agents}"
|
|
385
|
+
RESULTS="$KASEKI_ROOT/kaseki-results"
|
|
386
|
+
|
|
387
|
+
# Create directories
|
|
388
|
+
mkdir -p "$RESULTS"
|
|
389
|
+
|
|
390
|
+
# Loop with proper quoting
|
|
391
|
+
for instance in "${instances[@]}"; do
|
|
392
|
+
echo "Instance: $instance"
|
|
393
|
+
done
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**Bad:**
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
#!/bin/bash
|
|
400
|
+
# Missing error handling (no set -euo pipefail)
|
|
401
|
+
KASEKI_ROOT=${KASEKI_ROOT:-/agents} # Unquoted expansion
|
|
402
|
+
mkdir $RESULTS # Unquoted variable
|
|
403
|
+
for instance in $instances # No array handling
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Variable Naming
|
|
407
|
+
|
|
408
|
+
- Use **UPPER_SNAKE_CASE** for environment variables and constants
|
|
409
|
+
- Use **lower_snake_case** for local variables
|
|
410
|
+
- Quote all variable expansions: `"$var"` not `$var`
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Good
|
|
414
|
+
KASEKI_ROOT="${KASEKI_ROOT:-/agents}"
|
|
415
|
+
results_dir="$KASEKI_ROOT/results"
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Functions
|
|
419
|
+
|
|
420
|
+
- Declare functions at the top of the script
|
|
421
|
+
- Use descriptive names
|
|
422
|
+
- Document non-obvious behavior
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
# Good
|
|
426
|
+
doctor() {
|
|
427
|
+
# Check Docker availability
|
|
428
|
+
if command -v docker >/dev/null 2>&1; then
|
|
429
|
+
printf 'Docker: %s\n' "$(docker --version)"
|
|
430
|
+
else
|
|
431
|
+
printf 'Docker: missing\n' >&2
|
|
432
|
+
return 1
|
|
433
|
+
fi
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Error Handling
|
|
438
|
+
|
|
439
|
+
- Use `set -euo pipefail` to catch failures
|
|
440
|
+
- Use `|| true` to explicitly ignore an expected error
|
|
441
|
+
- Use `&& command` to chain dependent operations
|
|
442
|
+
- Provide clear error messages
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# Good
|
|
446
|
+
PI_VERSION="$(pi --version 2>&1 | head -n 1 || true)"
|
|
447
|
+
mkdir -p "$RESULTS" || { printf 'Failed to create %s\n' "$RESULTS" >&2; return 1; }
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### Comments
|
|
451
|
+
|
|
452
|
+
- Use `#` for single-line comments
|
|
453
|
+
- Keep comments concise
|
|
454
|
+
- Explain the "why" not the "what"
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Initialize with environment default, fallback to /agents
|
|
458
|
+
KASEKI_ROOT="${KASEKI_ROOT:-/agents}"
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Linting and Auto-Fix
|
|
462
|
+
|
|
463
|
+
### Running Linters
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
npm install # One-time setup
|
|
467
|
+
npm run type-check # Check TypeScript types
|
|
468
|
+
npm run lint # Check all TypeScript and shell files
|
|
469
|
+
npm run lint:fix # Auto-fix issues
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Common Issues and Fixes
|
|
473
|
+
|
|
474
|
+
| Issue | Fix |
|
|
475
|
+
|-------|-----|
|
|
476
|
+
| Double quotes in JS | `npm run lint:js:fix` auto-fixes to single quotes |
|
|
477
|
+
| Missing semicolons | `npm run lint:js:fix` adds them |
|
|
478
|
+
| Trailing whitespace | `npm run lint:js:fix` removes it |
|
|
479
|
+
| Incorrect indentation | `npm run lint:js:fix` corrects to 2 spaces |
|
|
480
|
+
| Shell quoting errors | Review `npm run lint:sh` output; fix manually |
|
|
481
|
+
|
|
482
|
+
### Exceptions and Overrides
|
|
483
|
+
|
|
484
|
+
If you disagree with a linting rule:
|
|
485
|
+
|
|
486
|
+
1. **File an issue** describing the rule and why it's problematic for your use case
|
|
487
|
+
2. **Document the exception** in the PR description
|
|
488
|
+
3. **Discuss with reviewers** before committing
|
|
489
|
+
|
|
490
|
+
Avoid inline ESLint directives (e.g., `// eslint-disable`) unless absolutely necessary and well-justified.
|
|
491
|
+
|
|
492
|
+
## Testing and Validation
|
|
493
|
+
|
|
494
|
+
### Unit Tests
|
|
495
|
+
|
|
496
|
+
This repo includes Jest test suites for TypeScript utilities and CLI functions:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
npm test # Run type-check, Jest tests, and bash integration tests
|
|
500
|
+
npm run test:watch # Watch mode for active development
|
|
501
|
+
npm run test:coverage # Generate coverage report
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
- **Location:** `src/**/*.test.ts`
|
|
505
|
+
- **Framework:** Jest 29.7 with ts-jest 29.2
|
|
506
|
+
- **Coverage:** Collected from all `src/**/*.ts` files, excluding tests
|
|
507
|
+
- **Timeout:** Most tests complete in milliseconds; memory stress test has 120s timeout
|
|
508
|
+
|
|
509
|
+
### Integration Tests
|
|
510
|
+
|
|
511
|
+
The scripts are also validated by the target repositories they orchestrate. Keep scripts:
|
|
512
|
+
|
|
513
|
+
- **Deterministic:** Same inputs → same outputs
|
|
514
|
+
- **Idempotent where possible:** Running twice is safe
|
|
515
|
+
- **Well-documented:** Explain environment variables and options
|
|
516
|
+
|
|
517
|
+
## Related Documents
|
|
518
|
+
|
|
519
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — Contribution guidelines
|
|
520
|
+
- [README.md](README.md) — Project overview and usage
|
|
521
|
+
- [CLAUDE.md](CLAUDE.md) — Internal guidance for Claude Code
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* add-js-extensions.ts
|
|
4
|
+
*
|
|
5
|
+
* Post-compilation script to add .js extensions to local imports in ES modules.
|
|
6
|
+
* This is required for proper ES module resolution in Node.js.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=add-js-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-js-extensions.d.ts","sourceRoot":"","sources":["add-js-extensions.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["add-js-extensions.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAE7C,SAAS,eAAe,CAAC,QAAgB;IACvC,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEhD,+DAA+D;IAC/D,0CAA0C;IAC1C,gFAAgF;IAChF,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,6CAA6C,EAC7C,CAAC,KAAa,EAAE,UAAkB,EAAE,EAAE;QACpC,oCAAoC;QACpC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,wCAAwC;QACxC,OAAO,SAAS,UAAU,MAAM,CAAC;IACnC,CAAC,CACF,CAAC;IAEF,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEnC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,CAAC;IACH,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,GAAG,GAAG,KAAc,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* add-js-extensions.ts
|
|
4
|
+
*
|
|
5
|
+
* Post-compilation script to add .js extensions to local imports in ES modules.
|
|
6
|
+
* This is required for proper ES module resolution in Node.js.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=add-js-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-js-extensions.d.ts","sourceRoot":"","sources":["../src/add-js-extensions.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* add-js-extensions.ts
|
|
4
|
+
*
|
|
5
|
+
* Post-compilation script to add .js extensions to local imports in ES modules.
|
|
6
|
+
* This is required for proper ES module resolution in Node.js.
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const distDir = __dirname;
|
|
13
|
+
function addJsExtensions(filePath) {
|
|
14
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
15
|
+
// Match imports/exports from relative paths without extensions
|
|
16
|
+
// Pattern: from './path.js', from '../path.js', from '../../path.js', etc.
|
|
17
|
+
// But not: from './path.js' or from 'npm-package' or from 'npm-package/subpath'
|
|
18
|
+
content = content.replace(/from\s+['"](\.[.]*[/\\][^'"]*?)['"](?!\.js\b)/g, (match, importPath) => {
|
|
19
|
+
// Skip if already has .js extension
|
|
20
|
+
if (importPath.endsWith('.js')) {
|
|
21
|
+
return match;
|
|
22
|
+
}
|
|
23
|
+
// Add .js extension to relative imports
|
|
24
|
+
return `from '${importPath}.js'`;
|
|
25
|
+
});
|
|
26
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
27
|
+
}
|
|
28
|
+
function processDirectory(dir) {
|
|
29
|
+
const files = fs.readdirSync(dir);
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const filePath = path.join(dir, file);
|
|
32
|
+
const stat = fs.statSync(filePath);
|
|
33
|
+
if (stat.isDirectory()) {
|
|
34
|
+
processDirectory(filePath);
|
|
35
|
+
}
|
|
36
|
+
else if (file.endsWith('.js')) {
|
|
37
|
+
addJsExtensions(filePath);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
if (fs.existsSync(distDir)) {
|
|
43
|
+
processDirectory(distDir);
|
|
44
|
+
console.log('✓ Added .js extensions to imports in dist/');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const err = error;
|
|
49
|
+
console.error('Error adding .js extensions:', err.message);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=add-js-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["../src/add-js-extensions.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,SAAS,eAAe,CAAC,QAAgB;IACvC,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEhD,+DAA+D;IAC/D,kEAAkE;IAClE,gFAAgF;IAChF,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,gDAAgD,EAChD,CAAC,KAAa,EAAE,UAAkB,EAAE,EAAE;QACpC,oCAAoC;QACpC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,wCAAwC;QACxC,OAAO,SAAS,UAAU,MAAM,CAAC;IACnC,CAAC,CACF,CAAC;IAEF,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEnC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,CAAC;IACH,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,GAAG,GAAG,KAAc,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI Color codes for terminal output
|
|
3
|
+
* Only applied when outputting to a TTY
|
|
4
|
+
*/
|
|
5
|
+
export interface AnsiColorSet {
|
|
6
|
+
RED: string;
|
|
7
|
+
YELLOW: string;
|
|
8
|
+
GREEN: string;
|
|
9
|
+
BLUE: string;
|
|
10
|
+
CYAN: string;
|
|
11
|
+
MAGENTA: string;
|
|
12
|
+
WHITE: string;
|
|
13
|
+
RESET: string;
|
|
14
|
+
BOLD: string;
|
|
15
|
+
DIM: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ANSI color codes
|
|
19
|
+
* Only include actual colors if output is to a TTY
|
|
20
|
+
*/
|
|
21
|
+
export declare const ANSI_COLORS: AnsiColorSet;
|
|
22
|
+
/**
|
|
23
|
+
* Strip ANSI codes from a string
|
|
24
|
+
*/
|
|
25
|
+
export declare function stripAnsi(text: string): string;
|
|
26
|
+
//# sourceMappingURL=ansi-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi-colors.d.ts","sourceRoot":"","sources":["../src/ansi-colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAcD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,YAwBvB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI Color codes for terminal output
|
|
3
|
+
* Only applied when outputting to a TTY
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if output should be colored (not piped, is TTY)
|
|
7
|
+
*/
|
|
8
|
+
function shouldUseColor() {
|
|
9
|
+
// Check if stdout is a TTY and TERM is not 'dumb'
|
|
10
|
+
const isTTY = process.stdout?.isTTY ?? false;
|
|
11
|
+
const notDumb = process.env.TERM !== 'dumb';
|
|
12
|
+
const noColorEnv = process.env.NO_COLOR;
|
|
13
|
+
return isTTY && notDumb && !noColorEnv;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ANSI color codes
|
|
17
|
+
* Only include actual colors if output is to a TTY
|
|
18
|
+
*/
|
|
19
|
+
export const ANSI_COLORS = shouldUseColor()
|
|
20
|
+
? {
|
|
21
|
+
RED: '\x1b[31m',
|
|
22
|
+
YELLOW: '\x1b[33m',
|
|
23
|
+
GREEN: '\x1b[32m',
|
|
24
|
+
BLUE: '\x1b[34m',
|
|
25
|
+
CYAN: '\x1b[36m',
|
|
26
|
+
MAGENTA: '\x1b[35m',
|
|
27
|
+
WHITE: '\x1b[37m',
|
|
28
|
+
RESET: '\x1b[0m',
|
|
29
|
+
BOLD: '\x1b[1m',
|
|
30
|
+
DIM: '\x1b[2m',
|
|
31
|
+
}
|
|
32
|
+
: {
|
|
33
|
+
RED: '',
|
|
34
|
+
YELLOW: '',
|
|
35
|
+
GREEN: '',
|
|
36
|
+
BLUE: '',
|
|
37
|
+
CYAN: '',
|
|
38
|
+
MAGENTA: '',
|
|
39
|
+
WHITE: '',
|
|
40
|
+
RESET: '',
|
|
41
|
+
BOLD: '',
|
|
42
|
+
DIM: '',
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Strip ANSI codes from a string
|
|
46
|
+
*/
|
|
47
|
+
export function stripAnsi(text) {
|
|
48
|
+
// eslint-disable-next-line no-control-regex
|
|
49
|
+
return text.replace(/\x1b\[[0-9;]*m/g, '');
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ansi-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi-colors.js","sourceRoot":"","sources":["../src/ansi-colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH;;GAEG;AACH,SAAS,cAAc;IACrB,kDAAkD;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,IAAI,KAAK,CAAC;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAExC,OAAO,KAAK,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAiB,cAAc,EAAE;IACvD,CAAC,CAAC;QACA,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,SAAS;KACf;IACD,CAAC,CAAC;QACA,GAAG,EAAE,EAAE;QACP,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;KACR,CAAC;AAEJ;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,4CAA4C;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC"}
|