@planu/cli 4.14.1 → 5.1.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/CHANGELOG.md +82 -0
- package/LICENSE +55 -12
- package/README.md +10 -2
- package/dist/cli/commands/install.d.ts +1 -12
- package/dist/cli/commands/install.js +9 -65
- package/dist/cli/commands/job.js +4 -3
- package/dist/cli/commands/spec.js +12 -3
- package/dist/cli/commands/validate.js +2 -2
- package/dist/cli/router.js +1 -3
- package/dist/config/environment-schema.json +1 -3
- package/dist/config/official-sdd-tools.d.ts +4 -0
- package/dist/config/official-sdd-tools.js +35 -0
- package/dist/config/product-public.d.ts +139 -3
- package/dist/config/product-public.js +8 -1
- package/dist/config/product-public.json +7 -36
- package/dist/config/registries/hosts/codex.json +20 -363
- package/dist/config/release-policy.json +84 -2
- package/dist/config/runtime-policy.json +12 -1
- package/dist/config/skill-templates/planu-resume-work.md +2 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/core/spec-validator.d.ts +4 -4
- package/dist/core/spec-validator.js +33 -19
- package/dist/engine/abortable-process-runner.d.ts +20 -2
- package/dist/engine/abortable-process-runner.js +243 -74
- package/dist/engine/ambiguity-scorer.js +4 -26
- package/dist/engine/auth/scope-mapper.js +1 -7
- package/dist/engine/autopilot/state-updater.js +4 -4
- package/dist/engine/cascade-hooks/hooks/review-enricher.hook.js +9 -6
- package/dist/engine/cascade-hooks/state-drift-detector.d.ts +3 -3
- package/dist/engine/cascade-hooks/state-drift-detector.js +1 -1
- package/dist/engine/ci-generator/planu-config.js +1 -7
- package/dist/engine/clarification-gate/gate.d.ts +3 -3
- package/dist/engine/code-scanner/layer-scanner.js +6 -22
- package/dist/engine/core-bridge.d.ts +3 -3
- package/dist/engine/cost-guardrails.d.ts +1 -1
- package/dist/engine/cost-guardrails.js +1 -1
- package/dist/engine/criterion-identity.d.ts +1 -0
- package/dist/engine/criterion-identity.js +7 -0
- package/dist/engine/dashboard/data-loader.js +2 -7
- package/dist/engine/dashboard/templates-layout.js +0 -3
- package/dist/engine/dashboard/templates-project.js +1 -13
- package/dist/engine/docs-site-generator/data-collector.d.ts +1 -1
- package/dist/engine/docs-site-generator/data-collector.js +7 -28
- package/dist/engine/docs-site-generator/tools-renderer.js +3 -10
- package/dist/engine/evidence-gates/artifact-reader.d.ts +12 -1
- package/dist/engine/evidence-gates/artifact-reader.js +174 -4
- package/dist/engine/evidence-gates/evidence-autofill.d.ts +10 -0
- package/dist/engine/evidence-gates/evidence-autofill.js +148 -0
- package/dist/engine/evidence-gates/evidence-skeletons.d.ts +19 -0
- package/dist/engine/evidence-gates/evidence-skeletons.js +69 -0
- package/dist/engine/evidence-gates/lifecycle-gate.js +4 -3
- package/dist/engine/evidence-gates/reconciliation-freshness.d.ts +11 -0
- package/dist/engine/evidence-gates/reconciliation-freshness.js +72 -0
- package/dist/engine/evidence-index/done-drift.d.ts +1 -1
- package/dist/engine/evidence-index/done-drift.js +40 -18
- package/dist/engine/execution/context.js +3 -0
- package/dist/engine/execution/durable-job-heartbeat-runtime.d.ts +4 -0
- package/dist/engine/execution/durable-job-heartbeat-runtime.js +400 -0
- package/dist/engine/execution/job-runtime.d.ts +30 -0
- package/dist/engine/execution/job-runtime.js +114 -6
- package/dist/engine/execution/operation-journal.js +10 -4
- package/dist/engine/execution/public-job-sanitizer.d.ts +4 -0
- package/dist/engine/execution/public-job-sanitizer.js +31 -0
- package/dist/engine/execution/validate-job-executor.d.ts +12 -1
- package/dist/engine/execution/validate-job-executor.js +549 -86
- package/dist/engine/execution/validate-job-payload.js +107 -50
- package/dist/engine/execution/validate-job-recovery.js +1 -1
- package/dist/engine/execution/validate-worker-runtime.d.ts +5 -0
- package/dist/engine/execution/validate-worker-runtime.js +90 -2
- package/dist/engine/execution/validate-worker-thread.js +17 -24
- package/dist/engine/handoff-artifacts/schemas.d.ts +2 -1
- package/dist/engine/handoff-artifacts/schemas.js +33 -0
- package/dist/engine/handoff-packager.d.ts +19 -0
- package/dist/engine/handoff-packager.js +415 -13
- package/dist/engine/hooks/effort-configurator.js +1 -1
- package/dist/engine/impact-detector/test-break-predictor.js +3 -3
- package/dist/engine/impact-detector/tool-registration.js +1 -1
- package/dist/engine/implementation-contract/renderer.js +23 -8
- package/dist/engine/lifecycle-reconciliation-io.d.ts +11 -0
- package/dist/engine/lifecycle-reconciliation-io.js +180 -0
- package/dist/engine/lifecycle-reconciliation.d.ts +16 -0
- package/dist/engine/lifecycle-reconciliation.js +406 -0
- package/dist/engine/local-first/tool-classification.js +2 -0
- package/dist/engine/macos-keychain-native-port.d.ts +5 -0
- package/dist/engine/macos-keychain-native-port.js +19 -7
- package/dist/engine/migrations/remove-commercial-state.d.ts +3 -0
- package/dist/engine/migrations/remove-commercial-state.js +343 -0
- package/dist/engine/minimality/policy-loader.js +247 -6
- package/dist/engine/network-policy.js +1 -0
- package/dist/engine/planu-core.darwin-arm64.node.manifest.json +7 -7
- package/dist/engine/planu-core.darwin-arm64.node.sbom.json +20 -20
- package/dist/engine/planu-core.darwin-x64.node.manifest.json +7 -7
- package/dist/engine/planu-core.darwin-x64.node.sbom.json +20 -20
- package/dist/engine/planu-core.linux-arm64-gnu.node.manifest.json +7 -7
- package/dist/engine/planu-core.linux-arm64-gnu.node.sbom.json +20 -20
- package/dist/engine/planu-core.linux-arm64-musl.node.manifest.json +7 -7
- package/dist/engine/planu-core.linux-arm64-musl.node.sbom.json +20 -20
- package/dist/engine/planu-core.linux-x64-gnu.node.manifest.json +7 -7
- package/dist/engine/planu-core.linux-x64-gnu.node.sbom.json +20 -20
- package/dist/engine/planu-core.linux-x64-musl.node.manifest.json +7 -7
- package/dist/engine/planu-core.linux-x64-musl.node.sbom.json +20 -20
- package/dist/engine/planu-core.win32-arm64-msvc.node.manifest.json +7 -7
- package/dist/engine/planu-core.win32-arm64-msvc.node.sbom.json +20 -20
- package/dist/engine/planu-core.win32-x64-msvc.node.manifest.json +7 -7
- package/dist/engine/planu-core.win32-x64-msvc.node.sbom.json +20 -20
- package/dist/engine/readiness-checker.d.ts +1 -16
- package/dist/engine/readiness-checker.js +27 -88
- package/dist/engine/reverse-engineer/api-detector.js +2 -13
- package/dist/engine/reverse-engineer/complexity-analyzer.js +2 -13
- package/dist/engine/reverse-engineer/config-analyzer.js +2 -13
- package/dist/engine/reverse-engineer/dependency-graph.js +2 -13
- package/dist/engine/reverse-engineer/test-analyzer.js +2 -13
- package/dist/engine/reverse-engineer/walk-ignore.d.ts +3 -0
- package/dist/engine/reverse-engineer/walk-ignore.js +26 -0
- package/dist/engine/runtime-policy.d.ts +2 -0
- package/dist/engine/runtime-policy.js +42 -5
- package/dist/engine/runtime-security/rate-limiter.js +0 -1
- package/dist/engine/safety/contained-project-file.d.ts +3 -0
- package/dist/engine/safety/contained-project-file.js +23 -0
- package/dist/engine/scope-boundaries/contradiction-checker.js +63 -1
- package/dist/engine/scope-boundaries/scope-validator.js +45 -7
- package/dist/engine/session/checkpoint-writer.js +0 -9
- package/dist/engine/spec-format/acceptance-criteria.d.ts +6 -2
- package/dist/engine/spec-format/acceptance-criteria.js +82 -22
- package/dist/engine/spec-format/markdown-sections.d.ts +14 -0
- package/dist/engine/spec-format/markdown-sections.js +105 -0
- package/dist/engine/spec-format/read-technical-section.js +33 -5
- package/dist/engine/spec-format/technical-md-populator.js +3 -2
- package/dist/engine/spec-format/text-fences.js +20 -2
- package/dist/engine/spec-format/unified-spec-builder.d.ts +7 -0
- package/dist/engine/spec-format/unified-spec-builder.js +202 -0
- package/dist/engine/spec-migrator/canonical-deduplicator.d.ts +18 -0
- package/dist/engine/spec-migrator/canonical-deduplicator.js +479 -0
- package/dist/engine/spec-migrator/filesystem-import.d.ts +4 -8
- package/dist/engine/spec-migrator/filesystem-import.js +121 -14
- package/dist/engine/spec-migrator/frontmatter-parser.js +32 -15
- package/dist/engine/spec-migrator/index.d.ts +1 -0
- package/dist/engine/spec-migrator/index.js +1 -0
- package/dist/engine/spec-state-machine/transition-spec.d.ts +6 -1
- package/dist/engine/spec-state-machine/transition-spec.js +10 -1
- package/dist/engine/spec-state-syncer.js +1 -1
- package/dist/engine/technical-enricher/index.js +16 -8
- package/dist/engine/technical-enricher/render-enriched.d.ts +1 -0
- package/dist/engine/technical-enricher/render-enriched.js +42 -14
- package/dist/engine/telemetry/health-checker.js +53 -17
- package/dist/engine/telemetry/telemetry-client.js +26 -8
- package/dist/engine/text-signal-boundaries.d.ts +2 -0
- package/dist/engine/text-signal-boundaries.js +25 -2
- package/dist/engine/time/relative-date.d.ts +3 -0
- package/dist/engine/time/relative-date.js +16 -0
- package/dist/engine/timing/budget.d.ts +11 -0
- package/dist/engine/timing/budget.js +31 -9
- package/dist/engine/token-optimizer/analytics.d.ts +1 -1
- package/dist/engine/token-optimizer/analytics.js +5 -6
- package/dist/engine/usage-tracker/core.d.ts +2 -2
- package/dist/engine/usage-tracker/core.js +1 -2
- package/dist/engine/usage-tracker/index.d.ts +0 -3
- package/dist/engine/usage-tracker/index.js +0 -3
- package/dist/engine/usage-tracker/stats.d.ts +2 -2
- package/dist/engine/usage-tracker/stats.js +1 -28
- package/dist/engine/validation/durable-validation.d.ts +1 -1
- package/dist/engine/validation/durable-validation.js +3 -82
- package/dist/engine/validation/validation-freshness.d.ts +11 -1
- package/dist/engine/validation/validation-freshness.js +231 -91
- package/dist/engine/validation/validation-receipt.d.ts +9 -6
- package/dist/engine/validation/validation-receipt.js +84 -24
- package/dist/engine/validation/validation-source-digest.d.ts +2 -0
- package/dist/engine/validation/validation-source-digest.js +86 -0
- package/dist/engine/validation/validation-submission.d.ts +5 -4
- package/dist/engine/validation/validation-submission.js +25 -11
- package/dist/engine/validation/validation-worktree.d.ts +21 -0
- package/dist/engine/validation/validation-worktree.js +260 -0
- package/dist/engine/validation-impact-planner.d.ts +14 -2
- package/dist/engine/validation-impact-planner.js +0 -3
- package/dist/engine/validator/dor-dod.d.ts +1 -0
- package/dist/engine/validator/dor-dod.js +5 -3
- package/dist/engine/validator/extractors.d.ts +1 -5
- package/dist/engine/validator/extractors.js +24 -69
- package/dist/engine/validator/spec-compliance-runner.d.ts +12 -24
- package/dist/engine/validator/spec-compliance-runner.js +429 -211
- package/dist/engine/validator.js +35 -22
- package/dist/index.js +4 -16
- package/dist/resources/usage-stats-resource.js +2 -18
- package/dist/security/adapters/linux-secret-service.js +7 -3
- package/dist/security/adapters/windows-credential-manager.js +6 -4
- package/dist/server/routes/specs.js +13 -1
- package/dist/storage/base-store.d.ts +1 -1
- package/dist/storage/base-store.js +1 -1
- package/dist/storage/feedback-remote.d.ts +2 -3
- package/dist/storage/feedback-remote.js +45 -31
- package/dist/storage/global-store.d.ts +1 -17
- package/dist/storage/global-store.js +1 -42
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -2
- package/dist/storage/migrations/canonical-storage.js +124 -11
- package/dist/storage/runtime-db.d.ts +9 -0
- package/dist/storage/runtime-db.js +64 -8
- package/dist/storage/spec-store.d.ts +14 -2
- package/dist/storage/spec-store.js +104 -14
- package/dist/storage/status-store/atomic-status-write.d.ts +5 -0
- package/dist/storage/status-store/atomic-status-write.js +57 -0
- package/dist/storage/status-store/file-lock.js +30 -11
- package/dist/storage/status-store/self-healing.js +3 -3
- package/dist/storage/status-store/version-sync.d.ts +2 -1
- package/dist/storage/status-store/version-sync.js +35 -40
- package/dist/storage/usage-store.d.ts +1 -5
- package/dist/storage/usage-store.js +0 -35
- package/dist/tools/auto-update-handler.d.ts +3 -3
- package/dist/tools/auto-update-handler.js +3 -3
- package/dist/tools/challenge-spec/resilience-challenge-scenarios.d.ts +2 -1
- package/dist/tools/challenge-spec/resilience-challenge-scenarios.js +10 -7
- package/dist/tools/challenge-spec/scenario-collector.js +1 -1
- package/dist/tools/challenge-spec/scenarios-data.js +1 -1
- package/dist/tools/challenge-spec/scenarios-utils.d.ts +1 -1
- package/dist/tools/challenge-spec/scenarios-utils.js +35 -11
- package/dist/tools/challenge-spec-helpers.d.ts +10 -1
- package/dist/tools/challenge-spec-helpers.js +63 -22
- package/dist/tools/challenge-spec.js +23 -8
- package/dist/tools/check-readiness.js +38 -14
- package/dist/tools/configure-telemetry.js +30 -2
- package/dist/tools/create-spec/spec-builder.d.ts +7 -0
- package/dist/tools/create-spec/spec-builder.js +19 -15
- package/dist/tools/create-spec.d.ts +1 -0
- package/dist/tools/create-spec.js +584 -309
- package/dist/tools/git/branch-ops.d.ts +1 -1
- package/dist/tools/git/branch-ops.js +3 -2
- package/dist/tools/init-project/handler.js +10 -12
- package/dist/tools/init-project/host-assets-writer.js +26 -1
- package/dist/tools/init-project/lint-scaffolder.d.ts +3 -3
- package/dist/tools/init-project/migration-runner.d.ts +2 -4
- package/dist/tools/init-project/migration-runner.js +3 -2
- package/dist/tools/init-project/portable-index-reconciler.d.ts +4 -0
- package/dist/tools/init-project/portable-index-reconciler.js +14 -0
- package/dist/tools/init-project/result-builder.js +1 -3
- package/dist/tools/jobs/handlers.js +38 -6
- package/dist/tools/list-specs.js +5 -26
- package/dist/tools/merge-risk-handler.js +2 -2
- package/dist/tools/package-handoff.js +2 -0
- package/dist/tools/reconcile-spec.js +0 -27
- package/dist/tools/register-agent-squad-tools.js +2 -2
- package/dist/tools/register-platform-tools/design-stack-tools.js +11 -11
- package/dist/tools/register-platform-tools/lifecycle-infra-tools.js +7 -7
- package/dist/tools/register-sdd-tools.d.ts +1 -1
- package/dist/tools/register-sdd-tools.js +2 -29
- package/dist/tools/register-spec-tools/analysis-tools.js +8 -8
- package/dist/tools/register-spec-tools/core-spec-tools.js +29 -19
- package/dist/tools/safe-handler.d.ts +5 -13
- package/dist/tools/safe-handler.js +7 -23
- package/dist/tools/schemas/index.d.ts +1 -1
- package/dist/tools/schemas/index.js +1 -1
- package/dist/tools/schemas/output-schemas.d.ts +0 -23
- package/dist/tools/schemas/output-schemas.js +0 -28
- package/dist/tools/schemas/spec.d.ts +4 -0
- package/dist/tools/schemas/spec.js +3 -0
- package/dist/tools/schemas/validate-output-schema.d.ts +11 -0
- package/dist/tools/schemas/validate-output-schema.js +7 -0
- package/dist/tools/spec-prompt-handler.js +3 -3
- package/dist/tools/sync-spec-state-handler.d.ts +1 -1
- package/dist/tools/sync-spec-state-handler.js +50 -2
- package/dist/tools/tool-entry.d.ts +4 -4
- package/dist/tools/tool-entry.js +3 -3
- package/dist/tools/tool-registry/core-tools.js +31 -15
- package/dist/tools/tool-registry/group-infra.js +27 -110
- package/dist/tools/tool-registry/group-quality-compliance.js +26 -26
- package/dist/tools/tool-registry/inventory.d.ts +2 -0
- package/dist/tools/tool-registry/inventory.js +2 -0
- package/dist/tools/tool-registry-helpers.d.ts +3 -3
- package/dist/tools/tool-registry-helpers.js +3 -3
- package/dist/tools/tool-usage-report/registered-tools.d.ts +1 -1
- package/dist/tools/tool-usage-report/registered-tools.js +3 -15
- package/dist/tools/update-status/approval-gates.js +3 -0
- package/dist/tools/update-status/batch.d.ts +6 -2
- package/dist/tools/update-status/batch.js +58 -1
- package/dist/tools/update-status/dod-gates.d.ts +16 -1
- package/dist/tools/update-status/dod-gates.js +191 -1
- package/dist/tools/update-status/done-receipt-verifier.d.ts +8 -0
- package/dist/tools/update-status/done-receipt-verifier.js +75 -27
- package/dist/tools/update-status/evidence-gate.d.ts +4 -0
- package/dist/tools/update-status/evidence-gate.js +103 -3
- package/dist/tools/update-status/file-sync.d.ts +4 -3
- package/dist/tools/update-status/file-sync.js +57 -6
- package/dist/tools/update-status/index.d.ts +25 -1
- package/dist/tools/update-status/index.js +292 -78
- package/dist/tools/update-status/response-builder.js +3 -3
- package/dist/tools/update-status/side-effects.d.ts +2 -0
- package/dist/tools/update-status/side-effects.js +2 -2
- package/dist/tools/update-status/transition-guard.js +45 -16
- package/dist/tools/update-status-actions.d.ts +4 -2
- package/dist/tools/update-status-actions.js +16 -14
- package/dist/tools/usage-report.js +1 -16
- package/dist/tools/usage-stats.js +1 -18
- package/dist/tools/usage-tracking.d.ts +4 -0
- package/dist/tools/usage-tracking.js +20 -0
- package/dist/tools/validate-lint.d.ts +1 -0
- package/dist/tools/validate-lint.js +1 -1
- package/dist/tools/validate.d.ts +2 -1
- package/dist/tools/validate.js +114 -34
- package/dist/tools/workspace-dashboard-handler.js +38 -0
- package/dist/transports/http-transport.js +6 -8
- package/dist/transports/mcp-types.d.ts +0 -2
- package/dist/transports/session-context.js +1 -1
- package/dist/types/cascade-hooks.d.ts +1 -1
- package/dist/types/ci.d.ts +0 -4
- package/dist/types/clarification-token.d.ts +1 -1
- package/dist/types/claude-code-runtime.d.ts +0 -27
- package/dist/types/commercial-migration.d.ts +17 -0
- package/dist/types/commercial-migration.js +2 -0
- package/dist/types/common/primitives.d.ts +0 -2
- package/dist/types/core-bridge.d.ts +4 -10
- package/dist/types/dashboard.d.ts +3 -7
- package/dist/types/docs.d.ts +0 -1
- package/dist/types/durable-job.d.ts +4 -4
- package/dist/types/durable-validation.d.ts +100 -2
- package/dist/types/durable-validation.js +165 -1
- package/dist/types/errors/structured-error.d.ts +3 -3
- package/dist/types/estimation.d.ts +2 -0
- package/dist/types/evidence-autofill.d.ts +34 -0
- package/dist/types/evidence-autofill.js +2 -0
- package/dist/types/evidence-gates.d.ts +9 -1
- package/dist/types/execution.d.ts +2 -0
- package/dist/types/gemini-integration.d.ts +0 -11
- package/dist/types/handoff-artifacts.d.ts +41 -0
- package/dist/types/hooks-advanced.d.ts +0 -13
- package/dist/types/impact-detection.d.ts +2 -2
- package/dist/types/index.d.ts +3 -6
- package/dist/types/index.js +2 -5
- package/dist/types/kiro-integration.d.ts +0 -6
- package/dist/types/network-policy.d.ts +1 -1
- package/dist/types/project/lint-scaffolder.d.ts +1 -1
- package/dist/types/runtime-policy.d.ts +11 -0
- package/dist/types/session-safeguard.d.ts +0 -31
- package/dist/types/spec/canonical-repair.d.ts +81 -0
- package/dist/types/spec/canonical-repair.js +2 -0
- package/dist/types/spec/core.d.ts +20 -0
- package/dist/types/spec/index.d.ts +1 -0
- package/dist/types/spec/index.js +1 -0
- package/dist/types/spec/inputs.d.ts +35 -1
- package/dist/types/spec-format.d.ts +25 -1
- package/dist/types/telemetry.d.ts +4 -1
- package/dist/types/transition-log.d.ts +1 -1
- package/dist/types/transport.d.ts +0 -2
- package/dist/types/usage.d.ts +1 -36
- package/dist/types/usage.js +1 -1
- package/dist/types/validate-worker.d.ts +6 -0
- package/dist/types/validation-receipt.d.ts +1 -1
- package/dist/types/validation.d.ts +10 -4
- package/package.json +17 -12
- package/planu-native.json +1 -1
- package/planu-plugin.json +23 -40
- package/scripts/lib/pending-release-file.mjs +93 -0
- package/src/i18n/messages/en.json +0 -41
- package/src/i18n/messages/es.json +0 -41
- package/src/i18n/messages/pt.json +0 -41
- package/dist/cli/commands/activate.d.ts +0 -14
- package/dist/cli/commands/activate.js +0 -174
- package/dist/config/license-plans.json +0 -251
- package/dist/config/product-public.ts +0 -148
- package/dist/config/server-instructions.ts +0 -121
- package/dist/config/version-defaults.ts +0 -76
- package/dist/config/version.ts +0 -21
- package/dist/engine/ai-integration/gemini/settings-generator.d.ts +0 -4
- package/dist/engine/ai-integration/gemini/settings-generator.js +0 -195
- package/dist/engine/ai-integration/kiro/hooks-generator.d.ts +0 -6
- package/dist/engine/ai-integration/kiro/hooks-generator.js +0 -75
- package/dist/engine/hooks/full-spectrum-generator.d.ts +0 -32
- package/dist/engine/hooks/full-spectrum-generator.js +0 -117
- package/dist/engine/license-validator/config-loader.d.ts +0 -5
- package/dist/engine/license-validator/config-loader.js +0 -16
- package/dist/engine/license-validator/core.d.ts +0 -15
- package/dist/engine/license-validator/core.js +0 -151
- package/dist/engine/license-validator/fingerprint.d.ts +0 -3
- package/dist/engine/license-validator/fingerprint.js +0 -17
- package/dist/engine/license-validator/lemon-squeezy.d.ts +0 -5
- package/dist/engine/license-validator/lemon-squeezy.js +0 -55
- package/dist/engine/license-validator.d.ts +0 -5
- package/dist/engine/license-validator.js +0 -6
- package/dist/engine/product-intelligence/index.d.ts +0 -7
- package/dist/engine/product-intelligence/index.js +0 -211
- package/dist/engine/session/auto-save.d.ts +0 -18
- package/dist/engine/session/auto-save.js +0 -98
- package/dist/engine/session/context-snapshot.d.ts +0 -8
- package/dist/engine/session/context-snapshot.js +0 -49
- package/dist/engine/session/memory-sync.d.ts +0 -12
- package/dist/engine/session/memory-sync.js +0 -34
- package/dist/engine/session/session-diff.d.ts +0 -11
- package/dist/engine/session/session-diff.js +0 -42
- package/dist/engine/session/session-merge.d.ts +0 -12
- package/dist/engine/session/session-merge.js +0 -55
- package/dist/engine/session-safeguard/checkpoint-runner.d.ts +0 -4
- package/dist/engine/session-safeguard/checkpoint-runner.js +0 -70
- package/dist/engine/session-safeguard/learnings-buffer.d.ts +0 -15
- package/dist/engine/session-safeguard/learnings-buffer.js +0 -91
- package/dist/engine/session-safeguard/precompaction-drain.d.ts +0 -10
- package/dist/engine/session-safeguard/precompaction-drain.js +0 -82
- package/dist/engine/session-safeguard/unpushed-detector.d.ts +0 -7
- package/dist/engine/session-safeguard/unpushed-detector.js +0 -59
- package/dist/engine/spec-changelog/core.d.ts +0 -16
- package/dist/engine/spec-changelog/core.js +0 -176
- package/dist/engine/spec-changelog/diff.d.ts +0 -18
- package/dist/engine/spec-changelog/diff.js +0 -121
- package/dist/engine/spec-changelog/index.d.ts +0 -3
- package/dist/engine/spec-changelog/index.js +0 -4
- package/dist/engine/trial-engine.d.ts +0 -5
- package/dist/engine/trial-engine.js +0 -14
- package/dist/engine/usage-tracker/rate-check.d.ts +0 -7
- package/dist/engine/usage-tracker/rate-check.js +0 -18
- package/dist/engine/usage-tracker/rate-limiter.d.ts +0 -14
- package/dist/engine/usage-tracker/rate-limiter.js +0 -73
- package/dist/engine/usage-tracker/trial.d.ts +0 -27
- package/dist/engine/usage-tracker/trial.js +0 -49
- package/dist/engine/webhook/event-handlers.d.ts +0 -25
- package/dist/engine/webhook/event-handlers.js +0 -89
- package/dist/engine/webhook/index.d.ts +0 -4
- package/dist/engine/webhook/index.js +0 -5
- package/dist/engine/webhook/server.d.ts +0 -12
- package/dist/engine/webhook/server.js +0 -249
- package/dist/engine/webhook/signature.d.ts +0 -16
- package/dist/engine/webhook/signature.js +0 -49
- package/dist/storage/license-store.d.ts +0 -6
- package/dist/storage/license-store.js +0 -63
- package/dist/storage/session-store.d.ts +0 -20
- package/dist/storage/session-store.js +0 -136
- package/dist/tools/activate-license.d.ts +0 -6
- package/dist/tools/activate-license.js +0 -132
- package/dist/tools/checkpoint-handler.d.ts +0 -3
- package/dist/tools/checkpoint-handler.js +0 -130
- package/dist/tools/export-session.d.ts +0 -3
- package/dist/tools/export-session.js +0 -90
- package/dist/tools/license-gate.d.ts +0 -18
- package/dist/tools/license-gate.js +0 -222
- package/dist/tools/license-status.d.ts +0 -3
- package/dist/tools/license-status.js +0 -93
- package/dist/tools/list-sessions.d.ts +0 -3
- package/dist/tools/list-sessions.js +0 -46
- package/dist/tools/planu-session-checkpoint.d.ts +0 -6
- package/dist/tools/planu-session-checkpoint.js +0 -42
- package/dist/tools/restore-session.d.ts +0 -3
- package/dist/tools/restore-session.js +0 -71
- package/dist/tools/spec-history.d.ts +0 -3
- package/dist/tools/spec-history.js +0 -59
- package/dist/tools/webhook.d.ts +0 -6
- package/dist/tools/webhook.js +0 -150
- package/dist/types/changelog.d.ts +0 -49
- package/dist/types/changelog.js +0 -3
- package/dist/types/licensing.d.ts +0 -109
- package/dist/types/licensing.js +0 -4
- package/dist/types/product-intelligence.d.ts +0 -60
- package/dist/types/product-intelligence.js +0 -3
- package/dist/types/session.d.ts +0 -84
- package/dist/types/session.js +0 -3
- package/dist/types/webhook.d.ts +0 -62
- package/dist/types/webhook.js +0 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
4
|
+
const POLL_INTERVAL_MS = 10;
|
|
5
|
+
const ABANDONED_LOCK_MS = 30_000;
|
|
6
|
+
|
|
7
|
+
function delay(milliseconds) {
|
|
8
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isProcessAlive(pid) {
|
|
12
|
+
try {
|
|
13
|
+
process.kill(pid, 0);
|
|
14
|
+
return true;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return error?.code !== 'ESRCH';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function removeAbandonedLock(lockPath) {
|
|
21
|
+
try {
|
|
22
|
+
const owner = JSON.parse(await readFile(`${lockPath}/owner.json`, 'utf8'));
|
|
23
|
+
if (Number.isInteger(owner.pid) && owner.pid > 0 && !isProcessAlive(owner.pid)) {
|
|
24
|
+
await rm(lockPath, { recursive: true, force: true });
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
try {
|
|
29
|
+
const lockStat = await stat(lockPath);
|
|
30
|
+
if (Date.now() - lockStat.mtimeMs > ABANDONED_LOCK_MS) {
|
|
31
|
+
await rm(lockPath, { recursive: true, force: true });
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function acquireLock(pendingPath, { timeoutMs, signal }) {
|
|
42
|
+
const lockPath = `${pendingPath}.lock`;
|
|
43
|
+
const deadline = Date.now() + timeoutMs;
|
|
44
|
+
while (true) {
|
|
45
|
+
if (signal?.aborted) throw new Error('pending release lock acquisition aborted');
|
|
46
|
+
try {
|
|
47
|
+
await mkdir(lockPath);
|
|
48
|
+
await writeFile(
|
|
49
|
+
`${lockPath}/owner.json`,
|
|
50
|
+
`${JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() })}\n`,
|
|
51
|
+
{ flag: 'wx', mode: 0o600 },
|
|
52
|
+
);
|
|
53
|
+
return lockPath;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (error?.code !== 'EEXIST') {
|
|
56
|
+
await rm(lockPath, { recursive: true, force: true });
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
if (await removeAbandonedLock(lockPath)) continue;
|
|
60
|
+
if (Date.now() >= deadline) {
|
|
61
|
+
throw new Error(`timed out waiting for pending release lock: ${lockPath}`);
|
|
62
|
+
}
|
|
63
|
+
await delay(POLL_INTERVAL_MS);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function withPendingReleaseLock(pendingPath, options, task) {
|
|
69
|
+
const lockPath = await acquireLock(pendingPath, {
|
|
70
|
+
timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
71
|
+
signal: options?.signal,
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
return await task();
|
|
75
|
+
} finally {
|
|
76
|
+
await rm(lockPath, { recursive: true, force: true });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function writePendingReleaseLedger(pendingPath, entries) {
|
|
81
|
+
const temporaryPath = `${pendingPath}.${process.pid}.${Date.now()}.tmp`;
|
|
82
|
+
try {
|
|
83
|
+
await writeFile(temporaryPath, `${JSON.stringify(entries, null, 2)}\n`, {
|
|
84
|
+
encoding: 'utf8',
|
|
85
|
+
flag: 'wx',
|
|
86
|
+
mode: 0o644,
|
|
87
|
+
});
|
|
88
|
+
await rename(temporaryPath, pendingPath);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
await rm(temporaryPath, { force: true });
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -346,45 +346,6 @@
|
|
|
346
346
|
"actionFailed": "{action} failed: {details}",
|
|
347
347
|
"error": "Manage trash failed: {message}"
|
|
348
348
|
},
|
|
349
|
-
"activate_license": {
|
|
350
|
-
"description": "Activate or deactivate a Planu Pro license key to unlock all tools and increased limits.",
|
|
351
|
-
"keyRequired": "Error: licenseKey is required.",
|
|
352
|
-
"activationFailed": "License activation failed: {error}",
|
|
353
|
-
"activatedSuccess": "License activated successfully!",
|
|
354
|
-
"plan": "Plan: {tier}",
|
|
355
|
-
"customer": "Customer: {name}",
|
|
356
|
-
"instance": "Instance: {name}",
|
|
357
|
-
"proAccess": "You now have access to all 65 Planu tools and increased limits.",
|
|
358
|
-
"tierAccess": "You now have {tier} access with all tools and unlimited projects/specs.",
|
|
359
|
-
"commonCauses": "Common causes:",
|
|
360
|
-
"causeInvalidKey": "Invalid license key — check for typos",
|
|
361
|
-
"causeAlreadyActivated": "License already activated on another machine — deactivate first",
|
|
362
|
-
"causeNetwork": "Network issue — check your internet connection",
|
|
363
|
-
"deactivationCancelled": "Deactivation cancelled. Set confirm: true to proceed.",
|
|
364
|
-
"noActiveLicense": "No active license found. You are on the Free plan.",
|
|
365
|
-
"deactivatedSuccess": "License deactivated successfully.",
|
|
366
|
-
"deactivatedFreePlan": "You are now on the Free plan ({count} tools, 2 projects, 5 active specs).",
|
|
367
|
-
"keyReusable": "Your license key can be activated on another machine."
|
|
368
|
-
},
|
|
369
|
-
"license_status": {
|
|
370
|
-
"description": "Check your current license status, tier, limits, and available tools.",
|
|
371
|
-
"title": "Planu License Status",
|
|
372
|
-
"version": "Version:",
|
|
373
|
-
"plan": "Plan:",
|
|
374
|
-
"customer": "Customer:",
|
|
375
|
-
"variant": "Variant:",
|
|
376
|
-
"activated": "Activated:",
|
|
377
|
-
"lastValidated": "Last validated:",
|
|
378
|
-
"toolsAvailable": "Tools available:",
|
|
379
|
-
"limitsTitle": "Limits",
|
|
380
|
-
"projects": "Projects:",
|
|
381
|
-
"activeSpecs": "Active specs:",
|
|
382
|
-
"perProject": "per project",
|
|
383
|
-
"activationSlots": "Activation slots:",
|
|
384
|
-
"upgradeTitle": "Upgrade",
|
|
385
|
-
"upgradeMessage": "Unlock all {count} tools, 10 projects, and unlimited specs.",
|
|
386
|
-
"activateHint": "Already have a key? Use `activate_license` to activate it."
|
|
387
|
-
},
|
|
388
349
|
"spec_templates": {
|
|
389
350
|
"description": "List and browse available spec templates — filter by category, complexity, or tags.",
|
|
390
351
|
"listTitle": "Available Spec Templates",
|
|
@@ -502,8 +463,6 @@
|
|
|
502
463
|
"approvedChanges": "Approved Changes",
|
|
503
464
|
"pendingChanges": "Pending Changes",
|
|
504
465
|
"versionCreated": "Version Created",
|
|
505
|
-
"changelogUpdated": "Changelog Updated",
|
|
506
|
-
"yes": "Yes",
|
|
507
466
|
"livingSpec": "Living Spec",
|
|
508
467
|
"coverage": "coverage",
|
|
509
468
|
"nextValidate": "Run `validate` to check implementation coverage",
|
|
@@ -346,45 +346,6 @@
|
|
|
346
346
|
"actionFailed": "{action} falló: {details}",
|
|
347
347
|
"error": "Error al gestionar papelera: {message}"
|
|
348
348
|
},
|
|
349
|
-
"activate_license": {
|
|
350
|
-
"description": "Activar o desactivar una clave de licencia Planu Pro para desbloquear todas las herramientas y límites aumentados.",
|
|
351
|
-
"keyRequired": "Error: licenseKey es requerido.",
|
|
352
|
-
"activationFailed": "Error al activar licencia: {error}",
|
|
353
|
-
"activatedSuccess": "¡Licencia activada exitosamente!",
|
|
354
|
-
"plan": "Plan: {tier}",
|
|
355
|
-
"customer": "Cliente: {name}",
|
|
356
|
-
"instance": "Instancia: {name}",
|
|
357
|
-
"proAccess": "Ahora tienes acceso a las 65 herramientas de Planu y límites aumentados.",
|
|
358
|
-
"tierAccess": "Ahora tienes acceso {tier} con todas las herramientas y proyectos/specs ilimitados.",
|
|
359
|
-
"commonCauses": "Causas comunes:",
|
|
360
|
-
"causeInvalidKey": "Clave de licencia inválida — verifica errores de tipeo",
|
|
361
|
-
"causeAlreadyActivated": "Licencia ya activada en otra máquina — desactívala primero",
|
|
362
|
-
"causeNetwork": "Problema de red — verifica tu conexión a internet",
|
|
363
|
-
"deactivationCancelled": "Desactivación cancelada. Establece confirm: true para proceder.",
|
|
364
|
-
"noActiveLicense": "No se encontró licencia activa. Estás en el plan Free.",
|
|
365
|
-
"deactivatedSuccess": "Licencia desactivada exitosamente.",
|
|
366
|
-
"deactivatedFreePlan": "Ahora estás en el plan Free ({count} herramientas, 2 proyectos, 5 specs activas).",
|
|
367
|
-
"keyReusable": "Tu clave de licencia puede ser activada en otra máquina."
|
|
368
|
-
},
|
|
369
|
-
"license_status": {
|
|
370
|
-
"description": "Verificar el estado actual de tu licencia, tier, límites y herramientas disponibles.",
|
|
371
|
-
"title": "Estado de Licencia Planu",
|
|
372
|
-
"version": "Versión:",
|
|
373
|
-
"plan": "Plan:",
|
|
374
|
-
"customer": "Cliente:",
|
|
375
|
-
"variant": "Variante:",
|
|
376
|
-
"activated": "Activada:",
|
|
377
|
-
"lastValidated": "Última validación:",
|
|
378
|
-
"toolsAvailable": "Herramientas disponibles:",
|
|
379
|
-
"limitsTitle": "Límites",
|
|
380
|
-
"projects": "Proyectos:",
|
|
381
|
-
"activeSpecs": "Specs activas:",
|
|
382
|
-
"perProject": "por proyecto",
|
|
383
|
-
"activationSlots": "Slots de activación:",
|
|
384
|
-
"upgradeTitle": "Upgrade",
|
|
385
|
-
"upgradeMessage": "Desbloquea las {count} herramientas, 10 proyectos y specs ilimitadas.",
|
|
386
|
-
"activateHint": "¿Ya tienes una clave? Usa `activate_license` para activarla."
|
|
387
|
-
},
|
|
388
349
|
"spec_templates": {
|
|
389
350
|
"description": "Listar y explorar plantillas de specs disponibles — filtrar por categoría, complejidad o tags.",
|
|
390
351
|
"listTitle": "Plantillas de Specs Disponibles",
|
|
@@ -502,8 +463,6 @@
|
|
|
502
463
|
"approvedChanges": "Cambios Aprobados",
|
|
503
464
|
"pendingChanges": "Cambios Pendientes",
|
|
504
465
|
"versionCreated": "Versión Creada",
|
|
505
|
-
"changelogUpdated": "Changelog Actualizado",
|
|
506
|
-
"yes": "Sí",
|
|
507
466
|
"livingSpec": "Spec Viva",
|
|
508
467
|
"coverage": "cobertura",
|
|
509
468
|
"nextValidate": "Ejecuta `validate` para verificar la cobertura de implementación",
|
|
@@ -346,45 +346,6 @@
|
|
|
346
346
|
"actionFailed": "{action} falhou: {details}",
|
|
347
347
|
"error": "Erro ao gerenciar lixeira: {message}"
|
|
348
348
|
},
|
|
349
|
-
"activate_license": {
|
|
350
|
-
"description": "Ativar ou desativar uma chave de licença Planu Pro para desbloquear todas as ferramentas e limites aumentados.",
|
|
351
|
-
"keyRequired": "Erro: licenseKey é obrigatório.",
|
|
352
|
-
"activationFailed": "Falha na ativação da licença: {error}",
|
|
353
|
-
"activatedSuccess": "Licença ativada com sucesso!",
|
|
354
|
-
"plan": "Plano: {tier}",
|
|
355
|
-
"customer": "Cliente: {name}",
|
|
356
|
-
"instance": "Instância: {name}",
|
|
357
|
-
"proAccess": "Agora você tem acesso a todas as 65 ferramentas do Planu e limites aumentados.",
|
|
358
|
-
"tierAccess": "Agora você tem acesso {tier} com todas as ferramentas e projetos/specs ilimitados.",
|
|
359
|
-
"commonCauses": "Causas comuns:",
|
|
360
|
-
"causeInvalidKey": "Chave de licença inválida — verifique erros de digitação",
|
|
361
|
-
"causeAlreadyActivated": "Licença já ativada em outra máquina — desative primeiro",
|
|
362
|
-
"causeNetwork": "Problema de rede — verifique sua conexão com a internet",
|
|
363
|
-
"deactivationCancelled": "Desativação cancelada. Defina confirm: true para prosseguir.",
|
|
364
|
-
"noActiveLicense": "Nenhuma licença ativa encontrada. Você está no plano Free.",
|
|
365
|
-
"deactivatedSuccess": "Licença desativada com sucesso.",
|
|
366
|
-
"deactivatedFreePlan": "Agora você está no plano Free ({count} ferramentas, 2 projetos, 5 specs ativas).",
|
|
367
|
-
"keyReusable": "Sua chave de licença pode ser ativada em outra máquina."
|
|
368
|
-
},
|
|
369
|
-
"license_status": {
|
|
370
|
-
"description": "Verificar o status atual da sua licença, tier, limites e ferramentas disponíveis.",
|
|
371
|
-
"title": "Status da Licença Planu",
|
|
372
|
-
"version": "Versão:",
|
|
373
|
-
"plan": "Plano:",
|
|
374
|
-
"customer": "Cliente:",
|
|
375
|
-
"variant": "Variante:",
|
|
376
|
-
"activated": "Ativada:",
|
|
377
|
-
"lastValidated": "Última validação:",
|
|
378
|
-
"toolsAvailable": "Ferramentas disponíveis:",
|
|
379
|
-
"limitsTitle": "Limites",
|
|
380
|
-
"projects": "Projetos:",
|
|
381
|
-
"activeSpecs": "Specs ativas:",
|
|
382
|
-
"perProject": "por projeto",
|
|
383
|
-
"activationSlots": "Slots de ativação:",
|
|
384
|
-
"upgradeTitle": "Upgrade",
|
|
385
|
-
"upgradeMessage": "Desbloqueie todas as {count} ferramentas, 10 projetos e specs ilimitadas.",
|
|
386
|
-
"activateHint": "Já tem uma chave? Use `activate_license` para ativá-la."
|
|
387
|
-
},
|
|
388
349
|
"spec_templates": {
|
|
389
350
|
"description": "Listar e explorar modelos de specs disponíveis — filtrar por categoria, complexidade ou tags.",
|
|
390
351
|
"listTitle": "Modelos de Specs Disponíveis",
|
|
@@ -502,8 +463,6 @@
|
|
|
502
463
|
"approvedChanges": "Mudanças Aprovadas",
|
|
503
464
|
"pendingChanges": "Mudanças Pendentes",
|
|
504
465
|
"versionCreated": "Versão Criada",
|
|
505
|
-
"changelogUpdated": "Changelog Atualizado",
|
|
506
|
-
"yes": "Sim",
|
|
507
466
|
"livingSpec": "Spec Viva",
|
|
508
467
|
"coverage": "cobertura",
|
|
509
468
|
"nextValidate": "Execute `validate` para verificar a cobertura da implementação",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CliCommand } from '../../types/cli.js';
|
|
2
|
-
type ToolFormat = 'standard' | 'zed';
|
|
3
|
-
interface ConfigTarget {
|
|
4
|
-
name: string;
|
|
5
|
-
path: string;
|
|
6
|
-
format: ToolFormat;
|
|
7
|
-
}
|
|
8
|
-
declare function buildTargets(): ConfigTarget[];
|
|
9
|
-
declare function hasPlanu(config: unknown, format: ToolFormat): boolean;
|
|
10
|
-
declare function updateStandardToken(filePath: string, licenseKey: string): void;
|
|
11
|
-
declare function updateZedToken(filePath: string, licenseKey: string): void;
|
|
12
|
-
export { buildTargets, hasPlanu, updateStandardToken, updateZedToken };
|
|
13
|
-
export declare const activateCommand: CliCommand;
|
|
14
|
-
//# sourceMappingURL=activate.d.ts.map
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
// cli/commands/activate.ts — planu activate <key>: add/update license in all installed configs (SPEC-237)
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { bold, green, yellow, dim, cyan } from '../colors.js';
|
|
6
|
-
import { activateLicense } from '../../engine/license-validator.js';
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Constants — same paths as install.ts
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
const PLANU_KEY = 'planu';
|
|
11
|
-
function buildTargets() {
|
|
12
|
-
const home = homedir();
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
name: 'Claude Code',
|
|
16
|
-
path: join(home, '.claude.json'),
|
|
17
|
-
format: 'standard',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: 'Cursor',
|
|
21
|
-
path: join(home, '.cursor', 'mcp.json'),
|
|
22
|
-
format: 'standard',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'Windsurf',
|
|
26
|
-
path: join(home, '.codeium', 'windsurf', 'mcp_config.json'),
|
|
27
|
-
format: 'standard',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Zed',
|
|
31
|
-
path: join(home, '.config', 'zed', 'settings.json'),
|
|
32
|
-
format: 'zed',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'Cline',
|
|
36
|
-
path: join(home, '.vscode', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'),
|
|
37
|
-
format: 'standard',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'Continue',
|
|
41
|
-
path: join(home, '.continue', 'config.json'),
|
|
42
|
-
format: 'standard',
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
}
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Helpers
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
49
|
-
function readJson(filePath) {
|
|
50
|
-
if (!existsSync(filePath)) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const raw = readFileSync(filePath, 'utf-8').trim();
|
|
54
|
-
if (!raw) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return JSON.parse(raw);
|
|
58
|
-
}
|
|
59
|
-
function hasPlanu(config, format) {
|
|
60
|
-
if (format === 'zed') {
|
|
61
|
-
const zed = config;
|
|
62
|
-
return Boolean(zed.context_servers?.[PLANU_KEY]);
|
|
63
|
-
}
|
|
64
|
-
const std = config;
|
|
65
|
-
return Boolean(std.mcpServers?.[PLANU_KEY]);
|
|
66
|
-
}
|
|
67
|
-
function updateStandardToken(filePath, licenseKey) {
|
|
68
|
-
const parsed = readJson(filePath);
|
|
69
|
-
if (!parsed) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const raw = parsed;
|
|
73
|
-
const entry = raw.mcpServers?.[PLANU_KEY];
|
|
74
|
-
if (!entry) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
entry.env = { ...(entry.env ?? {}), SDD_OWNER_TOKEN: licenseKey };
|
|
78
|
-
writeFileSync(filePath, JSON.stringify(raw, null, 2) + '\n', 'utf-8');
|
|
79
|
-
}
|
|
80
|
-
function updateZedToken(filePath, licenseKey) {
|
|
81
|
-
const parsed = readJson(filePath);
|
|
82
|
-
if (!parsed) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const raw = parsed;
|
|
86
|
-
const entry = raw.context_servers?.[PLANU_KEY];
|
|
87
|
-
if (!entry) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
entry.env = { ...(entry.env ?? {}), SDD_OWNER_TOKEN: licenseKey };
|
|
91
|
-
writeFileSync(filePath, JSON.stringify(raw, null, 2) + '\n', 'utf-8');
|
|
92
|
-
}
|
|
93
|
-
// Exported for tests
|
|
94
|
-
export { buildTargets, hasPlanu, updateStandardToken, updateZedToken };
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Command
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
export const activateCommand = {
|
|
99
|
-
name: 'activate',
|
|
100
|
-
description: 'Activate a Pro license key in all installed Planu configs',
|
|
101
|
-
usage: 'planu activate <license-key>',
|
|
102
|
-
async run(args, _flags) {
|
|
103
|
-
const licenseKey = args[0];
|
|
104
|
-
if (!licenseKey) {
|
|
105
|
-
process.stderr.write(`${yellow('!')} Usage: planu activate <license-key>\n` +
|
|
106
|
-
`Example: planu activate PLN-XXXX-XXXX-XXXX\n`);
|
|
107
|
-
process.exitCode = 1;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
process.stdout.write(`\n${bold('Planu License Activation')}\n\n`);
|
|
111
|
-
process.stdout.write(`${dim('Validating license key...')}\n`);
|
|
112
|
-
// Validate key via license API
|
|
113
|
-
let customerEmail;
|
|
114
|
-
let variantName;
|
|
115
|
-
try {
|
|
116
|
-
const result = await activateLicense(licenseKey, 'planu-cli');
|
|
117
|
-
if (!result.activated) {
|
|
118
|
-
const errMsg = result.error ?? 'Invalid license key';
|
|
119
|
-
process.stderr.write(`${yellow('!')} License validation failed: ${errMsg}\n`);
|
|
120
|
-
process.exitCode = 1;
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
customerEmail = result.meta.customer_email;
|
|
124
|
-
variantName = result.meta.variant_name;
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
128
|
-
process.stderr.write(`${yellow('!')} License API error: ${msg}\n`);
|
|
129
|
-
process.exitCode = 1;
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
process.stdout.write(`${green('+')} ${variantName} license — ${customerEmail}\n\n`);
|
|
133
|
-
process.stdout.write(`${cyan('Updating Planu configs:')}\n`);
|
|
134
|
-
const targets = buildTargets();
|
|
135
|
-
let updated = 0;
|
|
136
|
-
for (const target of targets) {
|
|
137
|
-
let config;
|
|
138
|
-
try {
|
|
139
|
-
config = readJson(target.path);
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
process.stdout.write(` ${yellow('!')} ${target.name}: could not read config\n`);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (config === null || !hasPlanu(config, target.format)) {
|
|
146
|
-
process.stdout.write(` ${dim('\u25a1')} ${target.name} — Planu not installed here\n`);
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
if (target.format === 'zed') {
|
|
151
|
-
updateZedToken(target.path, licenseKey);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
updateStandardToken(target.path, licenseKey);
|
|
155
|
-
}
|
|
156
|
-
process.stdout.write(` ${green('+')} ${target.name} — updated\n`);
|
|
157
|
-
updated++;
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
161
|
-
process.stdout.write(` ${yellow('!')} ${target.name}: failed to write — ${msg}\n`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
process.stdout.write('\n');
|
|
165
|
-
if (updated === 0) {
|
|
166
|
-
process.stdout.write(`${yellow('!')} Planu is not installed in any tool. Run ${cyan('planu install')} first.\n\n`);
|
|
167
|
-
process.exitCode = 1;
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
process.stdout.write(`${green('+')} License activated in ${String(updated)} config(s). ` +
|
|
171
|
-
`${dim('Restart your AI tools to apply.')}\n\n`);
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
//# sourceMappingURL=activate.js.map
|