@pzy560117/codex-harness 0.1.3 → 0.1.5
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/README.md +164 -27
- package/bin/harness.js +7 -7
- package/lib/commands/doctor.js +12 -12
- package/lib/commands/init.js +105 -105
- package/lib/commands/run.js +22 -22
- package/lib/commands/verify.js +12 -12
- package/lib/main.js +62 -62
- package/lib/powershell/find-powershell.js +20 -20
- package/lib/powershell/invoke-script.js +34 -34
- package/lib/project/assert-initialized.js +20 -20
- package/lib/project/detect-project-root.js +5 -5
- package/lib/release/cache-layout.js +34 -34
- package/lib/release/download-release.js +25 -25
- package/lib/release/package-source-layout.js +13 -13
- package/lib/release/release-config.js +6 -6
- package/lib/release/release-manifest.js +76 -76
- package/lib/release/resolve-package-source.js +21 -21
- package/lib/release/resolve-version.js +26 -26
- package/lib/release/unpack-zip.js +25 -25
- package/lib/release/verify-sha256.js +16 -16
- package/package-source/AGENTS.md +48 -57
- package/package-source/PACKAGE.md +7 -7
- package/package-source/README.md +85 -81
- package/package-source/docs/codex-harness-engineering/templates/AGENTS.md +51 -0
- package/package-source/docs/codex-harness-engineering/templates/README.md +21 -20
- package/package-source/docs/codex-harness-engineering/templates/bootstrap-codex-harness.ps1 +144 -110
- package/package-source/docs/codex-harness-engineering/templates/ci/AGENTS.md +15 -0
- package/package-source/docs/codex-harness-engineering/templates/ci/github-action-codex-review.yml +110 -110
- package/package-source/docs/codex-harness-engineering/templates/config/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/config/agents/architect.toml +18 -17
- package/package-source/docs/codex-harness-engineering/templates/config/agents/backend-worker.toml +15 -14
- package/package-source/docs/codex-harness-engineering/templates/config/agents/docs-researcher.toml +13 -12
- package/package-source/docs/codex-harness-engineering/templates/config/agents/docs-worker.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/agents/explorer.toml +15 -14
- package/package-source/docs/codex-harness-engineering/templates/config/agents/failure-triage.toml +19 -18
- package/package-source/docs/codex-harness-engineering/templates/config/agents/frontend-worker.toml +15 -14
- package/package-source/docs/codex-harness-engineering/templates/config/agents/harness-writer.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/agents/planner.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/agents/readonly-research.toml +14 -13
- package/package-source/docs/codex-harness-engineering/templates/config/agents/reviewer.toml +13 -12
- package/package-source/docs/codex-harness-engineering/templates/config/agents/security-reviewer.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/agents/stage1-reviewer.toml +15 -14
- package/package-source/docs/codex-harness-engineering/templates/config/agents/stage2-reviewer.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/agents/test-planner.toml +18 -17
- package/package-source/docs/codex-harness-engineering/templates/config/agents/test-runner.toml +15 -14
- package/package-source/docs/codex-harness-engineering/templates/config/agents/visual-reviewer.toml +16 -15
- package/package-source/docs/codex-harness-engineering/templates/config/codex-agent-roles.md +24 -24
- package/package-source/docs/codex-harness-engineering/templates/config/codex-config.toml +12 -12
- package/package-source/docs/codex-harness-engineering/templates/config/codex-readme.md +6 -6
- package/package-source/docs/codex-harness-engineering/templates/config/env-check.ps1 +44 -40
- package/package-source/docs/codex-harness-engineering/templates/config/env.example +13 -12
- package/package-source/docs/codex-harness-engineering/templates/config/global-AGENTS.md +40 -40
- package/package-source/docs/codex-harness-engineering/templates/config/global-config.toml +19 -19
- package/package-source/docs/codex-harness-engineering/templates/config/rules/agents.md +118 -115
- package/package-source/docs/codex-harness-engineering/templates/config/rules/coding-style.md +57 -74
- package/package-source/docs/codex-harness-engineering/templates/config/rules/constitution.md +4 -4
- package/package-source/docs/codex-harness-engineering/templates/config/rules/git.rules +41 -41
- package/package-source/docs/codex-harness-engineering/templates/config/rules/harness.rules +29 -29
- package/package-source/docs/codex-harness-engineering/templates/config/rules/safety.rules +35 -35
- package/package-source/docs/codex-harness-engineering/templates/context/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/context/API_MAP.md +18 -0
- package/package-source/docs/codex-harness-engineering/templates/context/CHANGELOG_AI.md +11 -0
- package/package-source/docs/codex-harness-engineering/templates/context/CURRENT_TASK.md +114 -0
- package/package-source/docs/codex-harness-engineering/templates/context/DB_SCHEMA.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/context/DECISIONS.md +12 -0
- package/package-source/docs/codex-harness-engineering/templates/context/KNOWN_ISSUES.md +12 -0
- package/package-source/docs/codex-harness-engineering/templates/context/PROJECT_CONTEXT.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/context/architecture-brief.md +58 -58
- package/package-source/docs/codex-harness-engineering/templates/context/dev-plan.md +89 -83
- package/package-source/docs/codex-harness-engineering/templates/context/feature-pack.md +101 -101
- package/package-source/docs/codex-harness-engineering/templates/context/repo-map.md +102 -78
- package/package-source/docs/codex-harness-engineering/templates/context/service-dependency-matrix.yaml +25 -25
- package/package-source/docs/codex-harness-engineering/templates/contracts/AGENTS.md +17 -0
- package/package-source/docs/codex-harness-engineering/templates/contracts/README.md +24 -16
- package/package-source/docs/codex-harness-engineering/templates/contracts/openapi.yaml +182 -182
- package/package-source/docs/codex-harness-engineering/templates/contracts/orval.config.ts +20 -20
- package/package-source/docs/codex-harness-engineering/templates/contracts/prism-usage.md +41 -34
- package/package-source/docs/codex-harness-engineering/templates/design/AGENTS.md +21 -0
- package/package-source/docs/codex-harness-engineering/templates/design/ai-image-brief.md +122 -122
- package/package-source/docs/codex-harness-engineering/templates/design/component-map.md +45 -31
- package/package-source/docs/codex-harness-engineering/templates/design/design-brief.md +183 -178
- package/package-source/docs/codex-harness-engineering/templates/design/design-tokens.json +88 -88
- package/package-source/docs/codex-harness-engineering/templates/design/frontend-architecture.md +164 -146
- package/package-source/docs/codex-harness-engineering/templates/design/image-to-frontend-spec.md +64 -52
- package/package-source/docs/codex-harness-engineering/templates/design/screen-states.md +157 -122
- package/package-source/docs/codex-harness-engineering/templates/design/visual-parity-review.md +21 -21
- package/package-source/docs/codex-harness-engineering/templates/docs/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/architecture-constraints.md +97 -83
- package/package-source/docs/codex-harness-engineering/templates/docs/code-semantics-and-navigation.md +54 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/code-style-and-naming.md +116 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/directory-structure-template.md +88 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/env-and-deployment-template.md +60 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/frontend-quality-rules.md +165 -138
- package/package-source/docs/codex-harness-engineering/templates/docs/governance-auto-repair.md +82 -80
- package/package-source/docs/codex-harness-engineering/templates/docs/harness-architecture.md +78 -78
- package/package-source/docs/codex-harness-engineering/templates/docs/install-manifest-governance.md +16 -16
- package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-architecture.md +241 -219
- package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-import.md +108 -108
- package/package-source/docs/codex-harness-engineering/templates/docs/knowledge-lint.md +98 -98
- package/package-source/docs/codex-harness-engineering/templates/docs/mcp-knowledge-governance.md +24 -0
- package/package-source/docs/codex-harness-engineering/templates/docs/new-project-checklist.md +7 -7
- package/package-source/docs/codex-harness-engineering/templates/docs/new-project-usage.md +107 -43
- package/package-source/docs/codex-harness-engineering/templates/docs/project-agents-template.md +211 -154
- package/package-source/docs/codex-harness-engineering/templates/docs/prompt-knowledge-integration.md +100 -89
- package/package-source/docs/codex-harness-engineering/templates/docs/regression-rules.md +47 -45
- package/package-source/docs/codex-harness-engineering/templates/docs/requirement-prep-kit/README.md +3 -3
- package/package-source/docs/codex-harness-engineering/templates/docs/rule-governance.md +98 -98
- package/package-source/docs/codex-harness-engineering/templates/docs/service-dependency-matrix.md +70 -55
- package/package-source/docs/codex-harness-engineering/templates/docs/task-session-strategy.md +133 -116
- package/package-source/docs/codex-harness-engineering/templates/docs/team-knowledge-sync.md +187 -187
- package/package-source/docs/codex-harness-engineering/templates/docs/trace-format.md +44 -32
- package/package-source/docs/codex-harness-engineering/templates/governance/AGENTS.md +18 -0
- package/package-source/docs/codex-harness-engineering/templates/governance/branch-protection-checklist.md +50 -50
- package/package-source/docs/codex-harness-engineering/templates/governance/feedback-evolution-loop.md +55 -55
- package/package-source/docs/codex-harness-engineering/templates/governance/retry-budget.yaml +30 -30
- package/package-source/docs/codex-harness-engineering/templates/governance/risk-levels.yaml +53 -53
- package/package-source/docs/codex-harness-engineering/templates/governance/sandbox-policy.md +13 -13
- package/package-source/docs/codex-harness-engineering/templates/hooks/AGENTS.md +15 -0
- package/package-source/docs/codex-harness-engineering/templates/hooks/hook-stop-verify.ps1 +171 -118
- package/package-source/docs/codex-harness-engineering/templates/hooks/hooks.json +40 -40
- package/package-source/docs/codex-harness-engineering/templates/knowledge/AGENTS.md +16 -0
- package/package-source/docs/codex-harness-engineering/templates/knowledge/catalog.md +6 -6
- package/package-source/docs/codex-harness-engineering/templates/knowledge/decisions/DECISION-HARNESS-001.md +39 -39
- package/package-source/docs/codex-harness-engineering/templates/knowledge/guidelines/GUIDELINE-RULES-001.md +30 -30
- package/package-source/docs/codex-harness-engineering/templates/knowledge/knowledge-catalog.md +41 -41
- package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/plan-template.md +252 -252
- package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/spec-template.md +145 -145
- package/package-source/docs/codex-harness-engineering/templates/package-assets/.specify/templates/tasks-template.md +47 -47
- package/package-source/docs/codex-harness-engineering/templates/package-assets/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/AGENTS.md +25 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/README.md +118 -42
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/START-HERE.md +66 -53
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/agent-ecosystem-practices.md +140 -140
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/best-practices.md +9 -9
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/codex-global-rules-example.md +48 -48
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/goal-templates.md +380 -380
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/README.md +64 -64
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/contracts/openapi.yaml +25 -25
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/contracts/orval.config.ts +20 -20
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/ai-image-brief.md +44 -44
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/component-map.md +17 -17
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/design-brief.md +58 -58
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/frontend-architecture.md +106 -106
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/image-to-frontend-spec.md +72 -72
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/screen-states.md +25 -25
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/design/ui-image-review.md +38 -38
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/difficulty-research.md +39 -39
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/page-inventory.md +5 -5
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/prd-lite.md +41 -41
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/requirement-interface-matrix.md +32 -32
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/docs/product/state-matrix.yaml +14 -14
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/generated/model/Ticket.ts +6 -6
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/generated/ticket-api.ts +35 -35
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/api-client/http-client.ts +8 -8
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/packages/ui/TicketFilterBar.tsx +72 -72
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/plans/features/ticket-filter.dev-plan.md +48 -48
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/progress.txt +1 -1
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/stories/TicketFilterBar.stories.tsx +33 -33
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/task.json +54 -54
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/examples/ticket-filter-demo/verify.ps1 +42 -42
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/global-rules-and-bootstrap.md +157 -157
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/goal-harness-integration-guide.md +364 -364
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/implementation-flow.md +7 -5
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/implementation-guide.md +25 -25
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/knowledge-surface-map.md +186 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/mode-matrix.md +57 -57
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/new-project-usage.md +176 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/project-agents-template.md +168 -154
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/superpowers-codex-solo-builder-playbook.md +676 -676
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/AGENTS.md +22 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/context/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/context/API_MAP.md +18 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/context/CURRENT_TASK.md +89 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/context/dev-plan.md +166 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/contracts/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/contracts/README.md +24 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/contracts/prism-usage.md +41 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/component-map.md +45 -31
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/design-brief.md +183 -178
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/design-tokens.json +88 -88
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/frontend-architecture.md +164 -146
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/image-to-frontend-spec.md +64 -52
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/screen-states.md +157 -122
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/design/visual-parity-review.md +21 -21
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/env-and-deployment-template.md +60 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/frontend-quality-rules.md +161 -138
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/regression-rules.md +47 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/docs/trace-format.md +86 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/product/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/product/prd-lite.md +166 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/product/state-matrix.yaml +116 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/prompts/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/prompts/implement-one-task.md +150 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/prompts/repair-one-finding.md +70 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/spec/11-security-design.md +43 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/spec/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/EVIDENCE_PROTOCOL.md +54 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/NATURAL_LANGUAGE_TEST_CASES.md +690 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/REGRESSION_PLAN.md +28 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/TEST_STRATEGY.md +98 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/TRACEABILITY_MATRIX.md +23 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/codex-harness-engineering/templates/testing/verify-matrix.md +51 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/README.md +10 -10
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/ecc-zh-CN/commands/e2e.md +30 -30
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/README.md +60 -60
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/app/Mobile_App_Production_Readiness_Framework_/347/247/273/345/212/250/347/253/257/345/205/250/345/271/263/345/217/260/347/224/237/344/272/247/345/217/257/344/270/212/347/272/277/350/247/204/350/214/203.md +2457 -2457
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/app/catalog.md +33 -33
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/architecture.md +358 -358
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/common/AI_Coding_Production_Control_Framework_AI/345/206/231/345/256/214/347/232/204/344/273/243/347/240/201/345/246/202/344/275/225/344/270/215/345/244/261/346/216/247.md +2055 -2055
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/common/catalog.md +34 -34
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/initial-content.md +296 -296
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/external-knowledge/integration-roadmap.md +221 -221
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/architecture-constraints.md +95 -83
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/code-semantics-and-navigation.md +17 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/code-style-and-naming.md +116 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/frontend-quality-rules.md +138 -138
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/governance-auto-repair.md +82 -80
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/mcp-knowledge-governance.md +24 -0
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/service-dependency-matrix.md +55 -55
- package/package-source/docs/codex-harness-engineering/templates/package-assets/docs/harness/speckit-requirements-gate.md +124 -124
- package/package-source/docs/codex-harness-engineering/templates/package-assets/root/PACKAGE.md +7 -7
- package/package-source/docs/codex-harness-engineering/templates/package-assets/root/README.md +52 -52
- package/package-source/docs/codex-harness-engineering/templates/package-assets/root/install-agent-here.ps1 +57 -57
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/agents.md +115 -115
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/coding-style.md +57 -74
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/constitution.md +4 -4
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/git.rules +41 -41
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/harness.rules +29 -29
- package/package-source/docs/codex-harness-engineering/templates/package-assets/rules/safety.rules +35 -35
- package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/check-ai-sync-drift.ps1 +205 -205
- package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/sync-ai-config-to-targets.ps1 +826 -826
- package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/ai-workflow/sync-targets.example.json +35 -35
- package/package-source/docs/codex-harness-engineering/templates/package-assets/scripts/harness/harness-governance-check.ps1 +864 -366
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/HOW_TO_USE_SKILLS.md +79 -79
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/academic-mermaid-diagrams/SKILL.md +172 -172
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/ai-config-git-sync/SKILL.md +152 -152
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/ai-config-git-sync/references/command-recipes.md +92 -92
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/auto-commit/SKILL.md +324 -322
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/better-icons/SKILL.md +3 -3
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/SKILL.md +100 -100
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/references/windows-openrouter-clash-playbook.md +94 -94
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/scripts/diagnose-openrouter-route.ps1 +282 -282
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/claude-openrouter-clash-debug/scripts/ensure-openrouter-rule.ps1 +101 -101
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/fixing-metadata/SKILL.md +6 -6
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/frontend-design/SKILL.md +37 -37
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/git-xianyu-analyzer/SKILL.md +3 -3
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/SKILL.md +204 -188
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/references/current-repo-sync-matrix.md +150 -110
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/harness-surface-sync/references/stale-patterns.md +65 -65
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/init-autopilot/SKILL.md +17 -15
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/log-analysis-optimization/SKILL.md +5 -5
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/prd-writer-skill/SKILL.md +28 -28
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-e2e-planner/SKILL.md +11 -11
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-e2e-runner/SKILL.md +6 -6
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qa-mock-cleaner/SKILL.md +4 -4
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/SKILL.md +67 -67
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/agents/openai.yaml +7 -7
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/qoder-codex-api-config/scripts/configure-qoder-codex-api.ps1 +278 -278
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/requirements-design-template/SKILL.md +87 -87
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/skills-index.md +12 -12
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-analyze/SKILL.md +34 -34
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-checklist/SKILL.md +8 -8
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-clarify/SKILL.md +28 -28
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-e2e-tasks/SKILL.md +12 -12
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-implement/SKILL.md +37 -37
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-plan/SKILL.md +140 -138
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-specify/SKILL.md +100 -100
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-tasks/SKILL.md +86 -86
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/speckit-verify/SKILL.md +144 -142
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/SKILL.md +145 -143
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/references/current-repo-notes.md +42 -41
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/references/github-samples.md +33 -33
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/sync-project-root-docs/scripts/collect-root-doc-facts.ps1 +174 -145
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/ai-integrity-and-originality.md +191 -191
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/citation-templates.md +99 -99
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/final-checklist.md +60 -60
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/photographer-booking-paper.md +85 -85
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/test-result-templates.md +22 -22
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/thesis-writing/references/thesis-analysis-template.md +63 -63
- package/package-source/docs/codex-harness-engineering/templates/package-assets/skills/update-codemaps/SKILL.md +31 -31
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/README.md +15 -15
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.analyze.md +60 -60
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.checklist.md +8 -8
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.clarify.md +28 -28
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.e2e-testing.md +10 -10
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.implement.md +56 -56
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.plan.md +137 -134
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.specify.md +100 -100
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.tasks.md +86 -86
- package/package-source/docs/codex-harness-engineering/templates/package-assets/workflows/speckit.verify.md +130 -130
- package/package-source/docs/codex-harness-engineering/templates/product/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/product/acceptance-criteria.md +47 -47
- package/package-source/docs/codex-harness-engineering/templates/product/difficulty-research.md +47 -47
- package/package-source/docs/codex-harness-engineering/templates/product/page-inventory.md +21 -21
- package/package-source/docs/codex-harness-engineering/templates/product/prd-lite.md +166 -158
- package/package-source/docs/codex-harness-engineering/templates/product/requirement-interface-matrix.md +37 -37
- package/package-source/docs/codex-harness-engineering/templates/product/state-matrix.yaml +116 -105
- package/package-source/docs/codex-harness-engineering/templates/prompts/AGENTS.md +15 -0
- package/package-source/docs/codex-harness-engineering/templates/prompts/controller-loop.md +88 -88
- package/package-source/docs/codex-harness-engineering/templates/prompts/failure-triage.md +71 -69
- package/package-source/docs/codex-harness-engineering/templates/prompts/harness-audit.md +54 -52
- package/package-source/docs/codex-harness-engineering/templates/prompts/implement-one-task.md +150 -148
- package/package-source/docs/codex-harness-engineering/templates/prompts/repair-one-finding.md +70 -67
- package/package-source/docs/codex-harness-engineering/templates/prompts/review-one-task.md +45 -43
- package/package-source/docs/codex-harness-engineering/templates/prompts/review-stage1-spec.md +111 -109
- package/package-source/docs/codex-harness-engineering/templates/prompts/review-stage2-quality.md +82 -80
- package/package-source/docs/codex-harness-engineering/templates/prompts/visual-evaluator.md +80 -78
- package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/backend-worker.md +41 -41
- package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/docs-worker.md +28 -28
- package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/frontend-worker.md +46 -46
- package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/harness-writer.md +40 -40
- package/package-source/docs/codex-harness-engineering/templates/prompts/worker-role/test-runner.md +27 -27
- package/package-source/docs/codex-harness-engineering/templates/runtime/AGENTS.md +66 -50
- package/package-source/docs/codex-harness-engineering/templates/runtime/codex-loop.ps1 +2129 -231
- package/package-source/docs/codex-harness-engineering/templates/runtime/doctor.ps1 +224 -224
- package/package-source/docs/codex-harness-engineering/templates/runtime/project-task-template.json +42 -39
- package/package-source/docs/codex-harness-engineering/templates/runtime/scripts/test-install-modes.ps1 +2 -2
- package/package-source/docs/codex-harness-engineering/templates/runtime/smoke-task.json +52 -52
- package/package-source/docs/codex-harness-engineering/templates/runtime/task-run-profile.json +86 -86
- package/package-source/docs/codex-harness-engineering/templates/runtime/task.json +11 -8
- package/package-source/docs/codex-harness-engineering/templates/runtime/verify.ps1 +21 -21
- package/package-source/docs/codex-harness-engineering/templates/scripts/AGENTS.md +15 -0
- package/package-source/docs/codex-harness-engineering/templates/scripts/ai-workflow/check-ai-sync-drift.ps1 +205 -205
- package/package-source/docs/codex-harness-engineering/templates/scripts/harness/harness-governance-check.ps1 +864 -366
- package/package-source/docs/codex-harness-engineering/templates/spec/10-data-model.md +23 -7
- package/package-source/docs/codex-harness-engineering/templates/spec/11-security-design.md +30 -13
- package/package-source/docs/codex-harness-engineering/templates/spec/AGENTS.md +15 -0
- package/package-source/docs/codex-harness-engineering/templates/testing/ACCEPTANCE_CRITERIA.md +39 -39
- package/package-source/docs/codex-harness-engineering/templates/testing/ACCEPTANCE_EXAMPLES.md +37 -37
- package/package-source/docs/codex-harness-engineering/templates/testing/AGENTS.md +19 -0
- package/package-source/docs/codex-harness-engineering/templates/testing/EVIDENCE_PROTOCOL.md +54 -48
- package/package-source/docs/codex-harness-engineering/templates/testing/NATURAL_LANGUAGE_TEST_CASES.md +5 -4
- package/package-source/docs/codex-harness-engineering/templates/testing/REGRESSION_PLAN.md +28 -20
- package/package-source/docs/codex-harness-engineering/templates/testing/RISK_BASED_TEST_PLAN.md +16 -16
- package/package-source/docs/codex-harness-engineering/templates/testing/TEST_STRATEGY.md +98 -97
- package/package-source/docs/codex-harness-engineering/templates/testing/TRACEABILITY_MATRIX.md +6 -5
- package/package-source/docs/codex-harness-engineering/templates/testing/coverage-policy.md +25 -25
- package/package-source/docs/codex-harness-engineering/templates/testing/e2e-plan.md +139 -139
- package/package-source/docs/codex-harness-engineering/templates/testing/failure-findings.example.json +3 -3
- package/package-source/docs/codex-harness-engineering/templates/testing/failure-triage.md +62 -62
- package/package-source/docs/codex-harness-engineering/templates/testing/test-data-plan.md +36 -36
- package/package-source/docs/codex-harness-engineering/templates/testing/test-report.md +85 -41
- package/package-source/docs/codex-harness-engineering/templates/testing/verify-matrix.md +15 -5
- package/package-source/docs/codex-harness-engineering/templates/tools/AGENTS.md +14 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/acceptance-lint.ps1 +37 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/architecture-lint.ps1 +150 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/backend-lint.ps1 +137 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/business-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/component-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/config-lint.ps1 +159 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/context-lint.ps1 +187 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/contract-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/data-lint.ps1 +37 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/directory-lint.ps1 +152 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/docs-lint.ps1 +40 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/impact-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/integration-lint.ps1 +37 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/mobile-lint.ps1 +37 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/observability-lint.ps1 +137 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/performance-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/refactor-lint.ps1 +137 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/security-lint.ps1 +159 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/session-lint.ps1 +126 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/spec-lint.ps1 +285 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/state-lint.ps1 +137 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/style-lint.ps1 +155 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/testing-lint.ps1 +192 -0
- package/package-source/docs/codex-harness-engineering/templates/tools/harness/ui-lint.ps1 +148 -0
- package/package-source/docs/codex-harness-engineering/templates/trace/AGENTS.md +16 -0
- package/package-source/docs/codex-harness-engineering/templates/trace/eval-case.yaml +24 -24
- package/package-source/docs/codex-harness-engineering/templates/trace/trace.schema.json +101 -101
- package/package-source/install-manifest.json +149 -79
- package/package-source/tools/install/ai-workflow/check-ai-sync-drift.ps1 +205 -205
- package/package-source/tools/install/ai-workflow/sync-ai-config-to-targets.ps1 +826 -826
- package/package-source/tools/install/ai-workflow/sync-targets.example.json +35 -35
- package/package-source/tools/install/bootstrap-codex-harness.ps1 +145 -129
- package/package-source/tools/install/env-check.ps1 +40 -40
- package/package-source/tools/install/init-project.ps1 +1 -1
- package/package-source/tools/install/install-agent-here.ps1 +57 -57
- package/package-source/tools/install/install-agent.ps1 +33 -31
- package/package.json +23 -23
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[string]$CodexHome = (Join-Path $env:USERPROFILE ".codex"),
|
|
3
|
-
[string]$QoderDataDir = (Join-Path $env:APPDATA "Qoder"),
|
|
4
|
-
[string]$Model = "",
|
|
5
|
-
[string]$BaseUrl = "",
|
|
6
|
-
[string]$Alias = "",
|
|
7
|
-
[string]$Provider = "openai",
|
|
8
|
-
[string]$ByokTypeKey = "openai",
|
|
9
|
-
[string]$ModelId = "",
|
|
10
|
-
[switch]$AllowRunning
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
$ErrorActionPreference = "Stop"
|
|
14
|
-
|
|
15
|
-
if (-not ("System.Security.Cryptography.AesGcm" -as [type])) {
|
|
16
|
-
$pwsh = Get-Command pwsh -ErrorAction SilentlyContinue
|
|
17
|
-
if (-not $pwsh -and (Test-Path -LiteralPath "C:\Program Files\PowerShell\7\pwsh.exe")) {
|
|
18
|
-
$pwsh = [pscustomobject]@{ Source = "C:\Program Files\PowerShell\7\pwsh.exe" }
|
|
19
|
-
}
|
|
20
|
-
if ($pwsh -and $PSCommandPath) {
|
|
21
|
-
$pwshArgs = [System.Collections.Generic.List[string]]::new()
|
|
22
|
-
@(
|
|
23
|
-
"-NoProfile",
|
|
24
|
-
"-ExecutionPolicy", "Bypass",
|
|
25
|
-
"-File", $PSCommandPath,
|
|
26
|
-
"-CodexHome", $CodexHome,
|
|
27
|
-
"-QoderDataDir", $QoderDataDir
|
|
28
|
-
) | ForEach-Object { $pwshArgs.Add($_) }
|
|
29
|
-
if (-not [string]::IsNullOrWhiteSpace($Model)) { $pwshArgs.Add("-Model"); $pwshArgs.Add($Model) }
|
|
30
|
-
if (-not [string]::IsNullOrWhiteSpace($BaseUrl)) { $pwshArgs.Add("-BaseUrl"); $pwshArgs.Add($BaseUrl) }
|
|
31
|
-
if (-not [string]::IsNullOrWhiteSpace($Alias)) { $pwshArgs.Add("-Alias"); $pwshArgs.Add($Alias) }
|
|
32
|
-
if (-not [string]::IsNullOrWhiteSpace($Provider)) { $pwshArgs.Add("-Provider"); $pwshArgs.Add($Provider) }
|
|
33
|
-
if (-not [string]::IsNullOrWhiteSpace($ByokTypeKey)) { $pwshArgs.Add("-ByokTypeKey"); $pwshArgs.Add($ByokTypeKey) }
|
|
34
|
-
if (-not [string]::IsNullOrWhiteSpace($ModelId)) { $pwshArgs.Add("-ModelId"); $pwshArgs.Add($ModelId) }
|
|
35
|
-
if ($AllowRunning) { $pwshArgs.Add("-AllowRunning") }
|
|
36
|
-
& $pwsh.Source @pwshArgs
|
|
37
|
-
exit $LASTEXITCODE
|
|
38
|
-
}
|
|
39
|
-
throw "System.Security.Cryptography.AesGcm is unavailable. Install PowerShell 7 or run this script with pwsh."
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function Resolve-Tool {
|
|
43
|
-
param(
|
|
44
|
-
[string]$Name,
|
|
45
|
-
[string[]]$Fallbacks
|
|
46
|
-
)
|
|
47
|
-
$cmd = Get-Command $Name -ErrorAction SilentlyContinue
|
|
48
|
-
if ($cmd) { return $cmd.Source }
|
|
49
|
-
foreach ($path in $Fallbacks) {
|
|
50
|
-
if (Test-Path -LiteralPath $path) { return $path }
|
|
51
|
-
}
|
|
52
|
-
throw "Tool not found: $Name"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function SqlQuote {
|
|
56
|
-
param([string]$Value)
|
|
57
|
-
return "'" + $Value.Replace("'", "''") + "'"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function Get-TomlString {
|
|
61
|
-
param(
|
|
62
|
-
[string]$Text,
|
|
63
|
-
[string]$Key
|
|
64
|
-
)
|
|
65
|
-
$match = [regex]::Match($Text, "(?m)^\s*$([regex]::Escape($Key))\s*=\s*""([^""]*)""")
|
|
66
|
-
if ($match.Success) { return $match.Groups[1].Value }
|
|
67
|
-
return ""
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function Get-ProviderBaseUrl {
|
|
71
|
-
param(
|
|
72
|
-
[string]$ConfigText,
|
|
73
|
-
[string]$ProviderName
|
|
74
|
-
)
|
|
75
|
-
if ([string]::IsNullOrWhiteSpace($ProviderName)) { return "" }
|
|
76
|
-
$escaped = [regex]::Escape($ProviderName)
|
|
77
|
-
$pattern = "(?ms)^\[model_providers\.$escaped\]\s*(.*?)(?=^\[|\z)"
|
|
78
|
-
$section = [regex]::Match($ConfigText, $pattern)
|
|
79
|
-
if (-not $section.Success) { return "" }
|
|
80
|
-
return Get-TomlString -Text $section.Groups[1].Value -Key "base_url"
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function ConvertTo-QoderEncryptedSecretJson {
|
|
84
|
-
param(
|
|
85
|
-
[string]$PlainText,
|
|
86
|
-
[string]$LocalStatePath
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
$localState = Get-Content -LiteralPath $LocalStatePath -Raw | ConvertFrom-Json
|
|
90
|
-
$encryptedKey = [Convert]::FromBase64String($localState.os_crypt.encrypted_key)
|
|
91
|
-
if ($encryptedKey.Length -le 5) { throw "Invalid Qoder os_crypt encrypted_key." }
|
|
92
|
-
|
|
93
|
-
$dpapiBlob = [byte[]]$encryptedKey[5..($encryptedKey.Length - 1)]
|
|
94
|
-
Add-Type -AssemblyName System.Security
|
|
95
|
-
$key = [System.Security.Cryptography.ProtectedData]::Unprotect(
|
|
96
|
-
$dpapiBlob,
|
|
97
|
-
$null,
|
|
98
|
-
[System.Security.Cryptography.DataProtectionScope]::CurrentUser
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
$plain = [Text.Encoding]::UTF8.GetBytes($PlainText)
|
|
102
|
-
$nonce = New-Object byte[] 12
|
|
103
|
-
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
|
|
104
|
-
try {
|
|
105
|
-
$rng.GetBytes($nonce)
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
$rng.Dispose()
|
|
109
|
-
}
|
|
110
|
-
$cipher = New-Object byte[] $plain.Length
|
|
111
|
-
$tag = New-Object byte[] 16
|
|
112
|
-
|
|
113
|
-
$aes = [System.Security.Cryptography.AesGcm]::new($key)
|
|
114
|
-
try {
|
|
115
|
-
$aes.Encrypt($nonce, $plain, $cipher, $tag, $null)
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
$aes.Dispose()
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
$encrypted = New-Object byte[] (3 + $nonce.Length + $cipher.Length + $tag.Length)
|
|
122
|
-
$prefix = [byte[]][char[]]"v10"
|
|
123
|
-
[Array]::Copy($prefix, 0, $encrypted, 0, 3)
|
|
124
|
-
[Array]::Copy($nonce, 0, $encrypted, 3, $nonce.Length)
|
|
125
|
-
[Array]::Copy($cipher, 0, $encrypted, 15, $cipher.Length)
|
|
126
|
-
[Array]::Copy($tag, 0, $encrypted, 15 + $cipher.Length, $tag.Length)
|
|
127
|
-
|
|
128
|
-
return @{
|
|
129
|
-
Json = (@{ type = "Buffer"; data = @($encrypted) } | ConvertTo-Json -Compress)
|
|
130
|
-
Key = $key
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function Test-QoderSecret {
|
|
135
|
-
param(
|
|
136
|
-
[string]$SecretJson,
|
|
137
|
-
[byte[]]$Key,
|
|
138
|
-
[string]$ExpectedPlainText
|
|
139
|
-
)
|
|
140
|
-
$obj = $SecretJson | ConvertFrom-Json
|
|
141
|
-
$bytes = [byte[]]$obj.data
|
|
142
|
-
if ($bytes.Length -lt 32) { return $false }
|
|
143
|
-
$nonce = [byte[]]$bytes[3..14]
|
|
144
|
-
$ctag = [byte[]]$bytes[15..($bytes.Length - 1)]
|
|
145
|
-
$cipher = [byte[]]$ctag[0..($ctag.Length - 17)]
|
|
146
|
-
$tag = [byte[]]$ctag[($ctag.Length - 16)..($ctag.Length - 1)]
|
|
147
|
-
$plain = New-Object byte[] $cipher.Length
|
|
148
|
-
$aes = [System.Security.Cryptography.AesGcm]::new($Key)
|
|
149
|
-
try {
|
|
150
|
-
$aes.Decrypt($nonce, $cipher, $tag, $plain, $null)
|
|
151
|
-
}
|
|
152
|
-
finally {
|
|
153
|
-
$aes.Dispose()
|
|
154
|
-
}
|
|
155
|
-
return ([Text.Encoding]::UTF8.GetString($plain)) -eq $ExpectedPlainText
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
$qoderProcess = Get-Process | Where-Object { $_.ProcessName -match "Qoder|qoder" }
|
|
159
|
-
if ($qoderProcess -and -not $AllowRunning) {
|
|
160
|
-
throw "Qoder is running. Close Qoder first, or rerun with -AllowRunning if you accept overwrite risk."
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
$sqlite = Resolve-Tool -Name "sqlite3" -Fallbacks @("D:\platform-tools\sqlite3.exe")
|
|
164
|
-
$configPath = Join-Path $CodexHome "config.toml"
|
|
165
|
-
$authPath = Join-Path $CodexHome "auth.json"
|
|
166
|
-
$dbPath = Join-Path $QoderDataDir "User\globalStorage\state.vscdb"
|
|
167
|
-
$localStatePath = Join-Path $QoderDataDir "Local State"
|
|
168
|
-
|
|
169
|
-
foreach ($path in @($configPath, $authPath, $dbPath, $localStatePath)) {
|
|
170
|
-
if (-not (Test-Path -LiteralPath $path)) { throw "Required file not found: $path" }
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
$configText = Get-Content -LiteralPath $configPath -Raw
|
|
174
|
-
if ([string]::IsNullOrWhiteSpace($Model)) {
|
|
175
|
-
$Model = Get-TomlString -Text $configText -Key "model"
|
|
176
|
-
}
|
|
177
|
-
if ([string]::IsNullOrWhiteSpace($BaseUrl)) {
|
|
178
|
-
$modelProvider = Get-TomlString -Text $configText -Key "model_provider"
|
|
179
|
-
$BaseUrl = Get-ProviderBaseUrl -ConfigText $configText -ProviderName $modelProvider
|
|
180
|
-
}
|
|
181
|
-
if ([string]::IsNullOrWhiteSpace($Model)) { throw "Model not provided and not found in Codex config." }
|
|
182
|
-
if ([string]::IsNullOrWhiteSpace($BaseUrl)) { throw "BaseUrl not provided and not found in Codex config." }
|
|
183
|
-
|
|
184
|
-
if ([string]::IsNullOrWhiteSpace($ModelId)) {
|
|
185
|
-
$safeModel = ($Model -replace "[^A-Za-z0-9]+", "_").Trim("_").ToLowerInvariant()
|
|
186
|
-
$ModelId = "model_codex_$safeModel"
|
|
187
|
-
}
|
|
188
|
-
if ([string]::IsNullOrWhiteSpace($Alias)) {
|
|
189
|
-
$Alias = "Codex $Model"
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
$auth = Get-Content -LiteralPath $authPath -Raw | ConvertFrom-Json
|
|
193
|
-
$apiKey = [string]$auth.OPENAI_API_KEY
|
|
194
|
-
if ([string]::IsNullOrWhiteSpace($apiKey)) { throw "OPENAI_API_KEY not found in Codex auth.json." }
|
|
195
|
-
|
|
196
|
-
$backup = "$dbPath.codex-backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
|
|
197
|
-
Copy-Item -LiteralPath $dbPath -Destination $backup
|
|
198
|
-
if (Test-Path -LiteralPath "$dbPath-wal") { Copy-Item -LiteralPath "$dbPath-wal" -Destination "$backup-wal" }
|
|
199
|
-
if (Test-Path -LiteralPath "$dbPath-shm") { Copy-Item -LiteralPath "$dbPath-shm" -Destination "$backup-shm" }
|
|
200
|
-
|
|
201
|
-
$encryptedSecret = ConvertTo-QoderEncryptedSecretJson -PlainText $apiKey -LocalStatePath $localStatePath
|
|
202
|
-
|
|
203
|
-
$now = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()
|
|
204
|
-
$modelKey = "custom:$ModelId"
|
|
205
|
-
$record = [ordered]@{
|
|
206
|
-
id = $ModelId
|
|
207
|
-
provider = $Provider
|
|
208
|
-
model = $Model
|
|
209
|
-
alias = $Alias
|
|
210
|
-
baseUrl = $BaseUrl
|
|
211
|
-
visible = $true
|
|
212
|
-
hasApiKey = $true
|
|
213
|
-
is_vl = $false
|
|
214
|
-
is_reasoning = $true
|
|
215
|
-
max_input_tokens = 1000000
|
|
216
|
-
byokTypeKey = $ByokTypeKey
|
|
217
|
-
createTime = $now
|
|
218
|
-
}
|
|
219
|
-
$modelsJson = "[" + ($record | ConvertTo-Json -Compress) + "]"
|
|
220
|
-
$agentJson = @{
|
|
221
|
-
"globalstate-selected-models" = @{
|
|
222
|
-
chat = $modelKey
|
|
223
|
-
assistant = $modelKey
|
|
224
|
-
inline = "auto"
|
|
225
|
-
}
|
|
226
|
-
} | ConvertTo-Json -Compress
|
|
227
|
-
|
|
228
|
-
$markerRaw = & $sqlite $dbPath "select value from ItemTable where key='__$__targetStorageMarker';"
|
|
229
|
-
if ($markerRaw) {
|
|
230
|
-
$marker = $markerRaw | ConvertFrom-Json
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
$marker = [pscustomobject]@{}
|
|
234
|
-
}
|
|
235
|
-
$marker | Add-Member -NotePropertyName "aicoding.customModels" -NotePropertyValue 1 -Force
|
|
236
|
-
$marker | Add-Member -NotePropertyName "chat.modelConfig.assistant" -NotePropertyValue 0 -Force
|
|
237
|
-
$marker | Add-Member -NotePropertyName "chat.modelConfig.experts" -NotePropertyValue 0 -Force
|
|
238
|
-
$markerJson = $marker | ConvertTo-Json -Compress
|
|
239
|
-
|
|
240
|
-
$sql = @(
|
|
241
|
-
"insert or replace into ItemTable(key,value) values('aicoding.customModels',$(SqlQuote $modelsJson));",
|
|
242
|
-
"insert or replace into ItemTable(key,value) values('chat.modelConfig.assistant',$(SqlQuote $modelKey));",
|
|
243
|
-
"insert or replace into ItemTable(key,value) values('chat.modelConfig.experts',$(SqlQuote $modelKey));",
|
|
244
|
-
"insert or replace into ItemTable(key,value) values('aicoding.aicoding-agent',$(SqlQuote $agentJson));",
|
|
245
|
-
"insert or replace into ItemTable(key,value) values('secret://aicoding.customModel.apiKey.$ModelId',$(SqlQuote $encryptedSecret.Json));",
|
|
246
|
-
"insert or replace into ItemTable(key,value) values('__$__targetStorageMarker',$(SqlQuote $markerJson));"
|
|
247
|
-
) -join "`n"
|
|
248
|
-
|
|
249
|
-
$sqlPath = Join-Path $env:TEMP ("qoder-config-" + [Guid]::NewGuid().ToString("N") + ".sql")
|
|
250
|
-
Set-Content -LiteralPath $sqlPath -Value $sql -NoNewline -Encoding UTF8
|
|
251
|
-
try {
|
|
252
|
-
& $sqlite $dbPath ".read '$sqlPath'"
|
|
253
|
-
}
|
|
254
|
-
finally {
|
|
255
|
-
Remove-Item -LiteralPath $sqlPath -Force
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
$storedModels = & $sqlite $dbPath "select value from ItemTable where key='aicoding.customModels';"
|
|
259
|
-
$parsedModels = $storedModels | ConvertFrom-Json -NoEnumerate
|
|
260
|
-
if (($parsedModels -isnot [array]) -or $parsedModels.Count -lt 1 -or $parsedModels[0].id -ne $ModelId) {
|
|
261
|
-
throw "Verification failed: aicoding.customModels was not written correctly."
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
$storedSecret = & $sqlite $dbPath "select value from ItemTable where key='secret://aicoding.customModel.apiKey.$ModelId';"
|
|
265
|
-
if (-not (Test-QoderSecret -SecretJson $storedSecret -Key $encryptedSecret.Key -ExpectedPlainText $apiKey)) {
|
|
266
|
-
throw "Verification failed: encrypted API key cannot be decrypted to the Codex API key."
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
$assistant = & $sqlite $dbPath "select value from ItemTable where key='chat.modelConfig.assistant';"
|
|
270
|
-
if ($assistant -ne $modelKey) {
|
|
271
|
-
throw "Verification failed: assistant model selection was not written."
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
Write-Output "Qoder custom model configured."
|
|
275
|
-
Write-Output "Model key: $modelKey"
|
|
276
|
-
Write-Output "Model: $Model"
|
|
277
|
-
Write-Output "Base URL: $BaseUrl"
|
|
278
|
-
Write-Output "Backup: $backup"
|
|
1
|
+
param(
|
|
2
|
+
[string]$CodexHome = (Join-Path $env:USERPROFILE ".codex"),
|
|
3
|
+
[string]$QoderDataDir = (Join-Path $env:APPDATA "Qoder"),
|
|
4
|
+
[string]$Model = "",
|
|
5
|
+
[string]$BaseUrl = "",
|
|
6
|
+
[string]$Alias = "",
|
|
7
|
+
[string]$Provider = "openai",
|
|
8
|
+
[string]$ByokTypeKey = "openai",
|
|
9
|
+
[string]$ModelId = "",
|
|
10
|
+
[switch]$AllowRunning
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
$ErrorActionPreference = "Stop"
|
|
14
|
+
|
|
15
|
+
if (-not ("System.Security.Cryptography.AesGcm" -as [type])) {
|
|
16
|
+
$pwsh = Get-Command pwsh -ErrorAction SilentlyContinue
|
|
17
|
+
if (-not $pwsh -and (Test-Path -LiteralPath "C:\Program Files\PowerShell\7\pwsh.exe")) {
|
|
18
|
+
$pwsh = [pscustomobject]@{ Source = "C:\Program Files\PowerShell\7\pwsh.exe" }
|
|
19
|
+
}
|
|
20
|
+
if ($pwsh -and $PSCommandPath) {
|
|
21
|
+
$pwshArgs = [System.Collections.Generic.List[string]]::new()
|
|
22
|
+
@(
|
|
23
|
+
"-NoProfile",
|
|
24
|
+
"-ExecutionPolicy", "Bypass",
|
|
25
|
+
"-File", $PSCommandPath,
|
|
26
|
+
"-CodexHome", $CodexHome,
|
|
27
|
+
"-QoderDataDir", $QoderDataDir
|
|
28
|
+
) | ForEach-Object { $pwshArgs.Add($_) }
|
|
29
|
+
if (-not [string]::IsNullOrWhiteSpace($Model)) { $pwshArgs.Add("-Model"); $pwshArgs.Add($Model) }
|
|
30
|
+
if (-not [string]::IsNullOrWhiteSpace($BaseUrl)) { $pwshArgs.Add("-BaseUrl"); $pwshArgs.Add($BaseUrl) }
|
|
31
|
+
if (-not [string]::IsNullOrWhiteSpace($Alias)) { $pwshArgs.Add("-Alias"); $pwshArgs.Add($Alias) }
|
|
32
|
+
if (-not [string]::IsNullOrWhiteSpace($Provider)) { $pwshArgs.Add("-Provider"); $pwshArgs.Add($Provider) }
|
|
33
|
+
if (-not [string]::IsNullOrWhiteSpace($ByokTypeKey)) { $pwshArgs.Add("-ByokTypeKey"); $pwshArgs.Add($ByokTypeKey) }
|
|
34
|
+
if (-not [string]::IsNullOrWhiteSpace($ModelId)) { $pwshArgs.Add("-ModelId"); $pwshArgs.Add($ModelId) }
|
|
35
|
+
if ($AllowRunning) { $pwshArgs.Add("-AllowRunning") }
|
|
36
|
+
& $pwsh.Source @pwshArgs
|
|
37
|
+
exit $LASTEXITCODE
|
|
38
|
+
}
|
|
39
|
+
throw "System.Security.Cryptography.AesGcm is unavailable. Install PowerShell 7 or run this script with pwsh."
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function Resolve-Tool {
|
|
43
|
+
param(
|
|
44
|
+
[string]$Name,
|
|
45
|
+
[string[]]$Fallbacks
|
|
46
|
+
)
|
|
47
|
+
$cmd = Get-Command $Name -ErrorAction SilentlyContinue
|
|
48
|
+
if ($cmd) { return $cmd.Source }
|
|
49
|
+
foreach ($path in $Fallbacks) {
|
|
50
|
+
if (Test-Path -LiteralPath $path) { return $path }
|
|
51
|
+
}
|
|
52
|
+
throw "Tool not found: $Name"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function SqlQuote {
|
|
56
|
+
param([string]$Value)
|
|
57
|
+
return "'" + $Value.Replace("'", "''") + "'"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function Get-TomlString {
|
|
61
|
+
param(
|
|
62
|
+
[string]$Text,
|
|
63
|
+
[string]$Key
|
|
64
|
+
)
|
|
65
|
+
$match = [regex]::Match($Text, "(?m)^\s*$([regex]::Escape($Key))\s*=\s*""([^""]*)""")
|
|
66
|
+
if ($match.Success) { return $match.Groups[1].Value }
|
|
67
|
+
return ""
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function Get-ProviderBaseUrl {
|
|
71
|
+
param(
|
|
72
|
+
[string]$ConfigText,
|
|
73
|
+
[string]$ProviderName
|
|
74
|
+
)
|
|
75
|
+
if ([string]::IsNullOrWhiteSpace($ProviderName)) { return "" }
|
|
76
|
+
$escaped = [regex]::Escape($ProviderName)
|
|
77
|
+
$pattern = "(?ms)^\[model_providers\.$escaped\]\s*(.*?)(?=^\[|\z)"
|
|
78
|
+
$section = [regex]::Match($ConfigText, $pattern)
|
|
79
|
+
if (-not $section.Success) { return "" }
|
|
80
|
+
return Get-TomlString -Text $section.Groups[1].Value -Key "base_url"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function ConvertTo-QoderEncryptedSecretJson {
|
|
84
|
+
param(
|
|
85
|
+
[string]$PlainText,
|
|
86
|
+
[string]$LocalStatePath
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
$localState = Get-Content -LiteralPath $LocalStatePath -Raw | ConvertFrom-Json
|
|
90
|
+
$encryptedKey = [Convert]::FromBase64String($localState.os_crypt.encrypted_key)
|
|
91
|
+
if ($encryptedKey.Length -le 5) { throw "Invalid Qoder os_crypt encrypted_key." }
|
|
92
|
+
|
|
93
|
+
$dpapiBlob = [byte[]]$encryptedKey[5..($encryptedKey.Length - 1)]
|
|
94
|
+
Add-Type -AssemblyName System.Security
|
|
95
|
+
$key = [System.Security.Cryptography.ProtectedData]::Unprotect(
|
|
96
|
+
$dpapiBlob,
|
|
97
|
+
$null,
|
|
98
|
+
[System.Security.Cryptography.DataProtectionScope]::CurrentUser
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
$plain = [Text.Encoding]::UTF8.GetBytes($PlainText)
|
|
102
|
+
$nonce = New-Object byte[] 12
|
|
103
|
+
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
|
|
104
|
+
try {
|
|
105
|
+
$rng.GetBytes($nonce)
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
$rng.Dispose()
|
|
109
|
+
}
|
|
110
|
+
$cipher = New-Object byte[] $plain.Length
|
|
111
|
+
$tag = New-Object byte[] 16
|
|
112
|
+
|
|
113
|
+
$aes = [System.Security.Cryptography.AesGcm]::new($key)
|
|
114
|
+
try {
|
|
115
|
+
$aes.Encrypt($nonce, $plain, $cipher, $tag, $null)
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
$aes.Dispose()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
$encrypted = New-Object byte[] (3 + $nonce.Length + $cipher.Length + $tag.Length)
|
|
122
|
+
$prefix = [byte[]][char[]]"v10"
|
|
123
|
+
[Array]::Copy($prefix, 0, $encrypted, 0, 3)
|
|
124
|
+
[Array]::Copy($nonce, 0, $encrypted, 3, $nonce.Length)
|
|
125
|
+
[Array]::Copy($cipher, 0, $encrypted, 15, $cipher.Length)
|
|
126
|
+
[Array]::Copy($tag, 0, $encrypted, 15 + $cipher.Length, $tag.Length)
|
|
127
|
+
|
|
128
|
+
return @{
|
|
129
|
+
Json = (@{ type = "Buffer"; data = @($encrypted) } | ConvertTo-Json -Compress)
|
|
130
|
+
Key = $key
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function Test-QoderSecret {
|
|
135
|
+
param(
|
|
136
|
+
[string]$SecretJson,
|
|
137
|
+
[byte[]]$Key,
|
|
138
|
+
[string]$ExpectedPlainText
|
|
139
|
+
)
|
|
140
|
+
$obj = $SecretJson | ConvertFrom-Json
|
|
141
|
+
$bytes = [byte[]]$obj.data
|
|
142
|
+
if ($bytes.Length -lt 32) { return $false }
|
|
143
|
+
$nonce = [byte[]]$bytes[3..14]
|
|
144
|
+
$ctag = [byte[]]$bytes[15..($bytes.Length - 1)]
|
|
145
|
+
$cipher = [byte[]]$ctag[0..($ctag.Length - 17)]
|
|
146
|
+
$tag = [byte[]]$ctag[($ctag.Length - 16)..($ctag.Length - 1)]
|
|
147
|
+
$plain = New-Object byte[] $cipher.Length
|
|
148
|
+
$aes = [System.Security.Cryptography.AesGcm]::new($Key)
|
|
149
|
+
try {
|
|
150
|
+
$aes.Decrypt($nonce, $cipher, $tag, $plain, $null)
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
$aes.Dispose()
|
|
154
|
+
}
|
|
155
|
+
return ([Text.Encoding]::UTF8.GetString($plain)) -eq $ExpectedPlainText
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
$qoderProcess = Get-Process | Where-Object { $_.ProcessName -match "Qoder|qoder" }
|
|
159
|
+
if ($qoderProcess -and -not $AllowRunning) {
|
|
160
|
+
throw "Qoder is running. Close Qoder first, or rerun with -AllowRunning if you accept overwrite risk."
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
$sqlite = Resolve-Tool -Name "sqlite3" -Fallbacks @("D:\platform-tools\sqlite3.exe")
|
|
164
|
+
$configPath = Join-Path $CodexHome "config.toml"
|
|
165
|
+
$authPath = Join-Path $CodexHome "auth.json"
|
|
166
|
+
$dbPath = Join-Path $QoderDataDir "User\globalStorage\state.vscdb"
|
|
167
|
+
$localStatePath = Join-Path $QoderDataDir "Local State"
|
|
168
|
+
|
|
169
|
+
foreach ($path in @($configPath, $authPath, $dbPath, $localStatePath)) {
|
|
170
|
+
if (-not (Test-Path -LiteralPath $path)) { throw "Required file not found: $path" }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
$configText = Get-Content -LiteralPath $configPath -Raw
|
|
174
|
+
if ([string]::IsNullOrWhiteSpace($Model)) {
|
|
175
|
+
$Model = Get-TomlString -Text $configText -Key "model"
|
|
176
|
+
}
|
|
177
|
+
if ([string]::IsNullOrWhiteSpace($BaseUrl)) {
|
|
178
|
+
$modelProvider = Get-TomlString -Text $configText -Key "model_provider"
|
|
179
|
+
$BaseUrl = Get-ProviderBaseUrl -ConfigText $configText -ProviderName $modelProvider
|
|
180
|
+
}
|
|
181
|
+
if ([string]::IsNullOrWhiteSpace($Model)) { throw "Model not provided and not found in Codex config." }
|
|
182
|
+
if ([string]::IsNullOrWhiteSpace($BaseUrl)) { throw "BaseUrl not provided and not found in Codex config." }
|
|
183
|
+
|
|
184
|
+
if ([string]::IsNullOrWhiteSpace($ModelId)) {
|
|
185
|
+
$safeModel = ($Model -replace "[^A-Za-z0-9]+", "_").Trim("_").ToLowerInvariant()
|
|
186
|
+
$ModelId = "model_codex_$safeModel"
|
|
187
|
+
}
|
|
188
|
+
if ([string]::IsNullOrWhiteSpace($Alias)) {
|
|
189
|
+
$Alias = "Codex $Model"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
$auth = Get-Content -LiteralPath $authPath -Raw | ConvertFrom-Json
|
|
193
|
+
$apiKey = [string]$auth.OPENAI_API_KEY
|
|
194
|
+
if ([string]::IsNullOrWhiteSpace($apiKey)) { throw "OPENAI_API_KEY not found in Codex auth.json." }
|
|
195
|
+
|
|
196
|
+
$backup = "$dbPath.codex-backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
|
|
197
|
+
Copy-Item -LiteralPath $dbPath -Destination $backup
|
|
198
|
+
if (Test-Path -LiteralPath "$dbPath-wal") { Copy-Item -LiteralPath "$dbPath-wal" -Destination "$backup-wal" }
|
|
199
|
+
if (Test-Path -LiteralPath "$dbPath-shm") { Copy-Item -LiteralPath "$dbPath-shm" -Destination "$backup-shm" }
|
|
200
|
+
|
|
201
|
+
$encryptedSecret = ConvertTo-QoderEncryptedSecretJson -PlainText $apiKey -LocalStatePath $localStatePath
|
|
202
|
+
|
|
203
|
+
$now = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()
|
|
204
|
+
$modelKey = "custom:$ModelId"
|
|
205
|
+
$record = [ordered]@{
|
|
206
|
+
id = $ModelId
|
|
207
|
+
provider = $Provider
|
|
208
|
+
model = $Model
|
|
209
|
+
alias = $Alias
|
|
210
|
+
baseUrl = $BaseUrl
|
|
211
|
+
visible = $true
|
|
212
|
+
hasApiKey = $true
|
|
213
|
+
is_vl = $false
|
|
214
|
+
is_reasoning = $true
|
|
215
|
+
max_input_tokens = 1000000
|
|
216
|
+
byokTypeKey = $ByokTypeKey
|
|
217
|
+
createTime = $now
|
|
218
|
+
}
|
|
219
|
+
$modelsJson = "[" + ($record | ConvertTo-Json -Compress) + "]"
|
|
220
|
+
$agentJson = @{
|
|
221
|
+
"globalstate-selected-models" = @{
|
|
222
|
+
chat = $modelKey
|
|
223
|
+
assistant = $modelKey
|
|
224
|
+
inline = "auto"
|
|
225
|
+
}
|
|
226
|
+
} | ConvertTo-Json -Compress
|
|
227
|
+
|
|
228
|
+
$markerRaw = & $sqlite $dbPath "select value from ItemTable where key='__$__targetStorageMarker';"
|
|
229
|
+
if ($markerRaw) {
|
|
230
|
+
$marker = $markerRaw | ConvertFrom-Json
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
$marker = [pscustomobject]@{}
|
|
234
|
+
}
|
|
235
|
+
$marker | Add-Member -NotePropertyName "aicoding.customModels" -NotePropertyValue 1 -Force
|
|
236
|
+
$marker | Add-Member -NotePropertyName "chat.modelConfig.assistant" -NotePropertyValue 0 -Force
|
|
237
|
+
$marker | Add-Member -NotePropertyName "chat.modelConfig.experts" -NotePropertyValue 0 -Force
|
|
238
|
+
$markerJson = $marker | ConvertTo-Json -Compress
|
|
239
|
+
|
|
240
|
+
$sql = @(
|
|
241
|
+
"insert or replace into ItemTable(key,value) values('aicoding.customModels',$(SqlQuote $modelsJson));",
|
|
242
|
+
"insert or replace into ItemTable(key,value) values('chat.modelConfig.assistant',$(SqlQuote $modelKey));",
|
|
243
|
+
"insert or replace into ItemTable(key,value) values('chat.modelConfig.experts',$(SqlQuote $modelKey));",
|
|
244
|
+
"insert or replace into ItemTable(key,value) values('aicoding.aicoding-agent',$(SqlQuote $agentJson));",
|
|
245
|
+
"insert or replace into ItemTable(key,value) values('secret://aicoding.customModel.apiKey.$ModelId',$(SqlQuote $encryptedSecret.Json));",
|
|
246
|
+
"insert or replace into ItemTable(key,value) values('__$__targetStorageMarker',$(SqlQuote $markerJson));"
|
|
247
|
+
) -join "`n"
|
|
248
|
+
|
|
249
|
+
$sqlPath = Join-Path $env:TEMP ("qoder-config-" + [Guid]::NewGuid().ToString("N") + ".sql")
|
|
250
|
+
Set-Content -LiteralPath $sqlPath -Value $sql -NoNewline -Encoding UTF8
|
|
251
|
+
try {
|
|
252
|
+
& $sqlite $dbPath ".read '$sqlPath'"
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
Remove-Item -LiteralPath $sqlPath -Force
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
$storedModels = & $sqlite $dbPath "select value from ItemTable where key='aicoding.customModels';"
|
|
259
|
+
$parsedModels = $storedModels | ConvertFrom-Json -NoEnumerate
|
|
260
|
+
if (($parsedModels -isnot [array]) -or $parsedModels.Count -lt 1 -or $parsedModels[0].id -ne $ModelId) {
|
|
261
|
+
throw "Verification failed: aicoding.customModels was not written correctly."
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
$storedSecret = & $sqlite $dbPath "select value from ItemTable where key='secret://aicoding.customModel.apiKey.$ModelId';"
|
|
265
|
+
if (-not (Test-QoderSecret -SecretJson $storedSecret -Key $encryptedSecret.Key -ExpectedPlainText $apiKey)) {
|
|
266
|
+
throw "Verification failed: encrypted API key cannot be decrypted to the Codex API key."
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
$assistant = & $sqlite $dbPath "select value from ItemTable where key='chat.modelConfig.assistant';"
|
|
270
|
+
if ($assistant -ne $modelKey) {
|
|
271
|
+
throw "Verification failed: assistant model selection was not written."
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
Write-Output "Qoder custom model configured."
|
|
275
|
+
Write-Output "Model key: $modelKey"
|
|
276
|
+
Write-Output "Model: $Model"
|
|
277
|
+
Write-Output "Base URL: $BaseUrl"
|
|
278
|
+
Write-Output "Backup: $backup"
|