@iamdevlinph/codex-kit 1.1.6 → 1.1.8

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 CHANGED
@@ -60,6 +60,12 @@ existing active guidance. During reconciliation, Codex merges only applicable
60
60
  rules into the project's `AGENTS.md` and preserves its local organization and
61
61
  adaptations.
62
62
 
63
+ Both `project init` and `project sync` contact the public npm registry before
64
+ writing project files. If the installed CLI is stale, or npm is unreachable or
65
+ returns invalid metadata, the command fails without changing the project. Rerun
66
+ with `pnpm dlx @iamdevlinph/codex-kit@latest` after the registry is available;
67
+ stale builds print the exact command.
68
+
63
69
  ## Commands
64
70
 
65
71
  | Action | Command |
@@ -119,6 +125,13 @@ configuration, and scripts for Codex to derive reliable guidance. It creates:
119
125
  - `TEMPLATE_AGENTS.md` as the local template reference;
120
126
  - `.codex-kit-state.json` for reconciliation bookkeeping.
121
127
 
128
+ The CLI continues to create only this scaffold, template reference, and state
129
+ file set. During semantic reconciliation, Codex may create or maintain
130
+ `PLANS.md` when repository evidence supports real durable decisions,
131
+ roadmap/status, or resume-worthy completed milestones. Existing `PLANS.md`
132
+ content is preserved and semantically merged; speculative history is never
133
+ invented or backfilled.
134
+
122
135
  Initialization includes the first template sync. When the CLI prints an
123
136
  initialization or reconciliation prompt, copy the complete marked block into a
124
137
  Codex task opened at the project root.
@@ -129,11 +142,15 @@ After installing a newer package version, refresh the reference template:
129
142
  codex-kit project sync
130
143
  ```
131
144
 
132
- `project sync` never edits `AGENTS.md` or project skills. The reconciliation skill
133
- compares the refreshed template with the project's guidance and merges only
134
- applicable rules while preserving local organization and adaptations. If
145
+ `project sync` never edits `AGENTS.md`, `PLANS.md`, or project skills. The
146
+ reconciliation skill compares the refreshed template with the project's
147
+ guidance and merges only applicable rules while preserving local organization
148
+ and adaptations. It keeps always-on instructions in `AGENTS.md`, moves durable
149
+ roadmap or history out of that file into `PLANS.md`, and reports any created or
150
+ changed plan content. If
135
151
  `TEMPLATE_AGENTS.md` was modified locally, sync overwrites it with the packaged
136
- template. Keep durable local rules in `AGENTS.md`; recover overwritten template
152
+ template. Keep always-on local rules in `AGENTS.md` and durable product context
153
+ in `PLANS.md`; recover overwritten template
137
154
  edits through Git history when needed.
138
155
 
139
156
  After reconciliation and validation, Codex runs:
@@ -168,7 +185,10 @@ codex-kit project sync --cwd /path/to/project
168
185
  - Codex with custom subagent and lifecycle-hook support
169
186
 
170
187
  The published package contains no credentials or runtime dependencies. Version
171
- checks contact the public npm registry only when `codex-kit version check` runs.
188
+ checks and project initialization/synchronization contact the public npm
189
+ registry; project operations fail closed before writing when that check cannot
190
+ verify the latest release. The CLI never auto-installs or executes downloaded
191
+ code.
172
192
 
173
193
  ## Security and license
174
194
 
@@ -12,6 +12,18 @@ product context, and local conventions in the project's active `AGENTS.md`.
12
12
  priorities, deferred requirements, product or implementation decisions, and
13
13
  major completed milestones.
14
14
 
15
+ ## PLANS.md Maintenance
16
+
17
+ - Read and preserve an existing `PLANS.md` during initialization and template
18
+ reconciliation; semantically merge durable content instead of replacing it.
19
+ - Create `PLANS.md` only when repository evidence contains real roadmap items,
20
+ durable decisions, or resume-worthy completed work. Never invent or backfill
21
+ speculative history.
22
+ - Keep it concise, using sections such as current context, decisions,
23
+ roadmap/status, and major milestones. It is not a per-change changelog.
24
+ - Move roadmap or history misplaced in `AGENTS.md` into `PLANS.md` when the
25
+ content is durable, and keep `AGENTS.md` focused on always-on instructions.
26
+
15
27
  ## Instructions And Skills
16
28
 
17
29
  - Keep `AGENTS.md` focused on durable, always-applicable repository context:
@@ -7,24 +7,32 @@ description: Reconcile a refreshed TEMPLATE_AGENTS.md with a project's AGENTS.md
7
7
 
8
8
  ## Procedure
9
9
 
10
- 1. Inspect `AGENTS.md`, `TEMPLATE_AGENTS.md`, `.codex-kit-state.json`, the
11
- project's existing `.agents/skills`, and `codex-kit project status`. Record
12
- the initial status before making changes.
13
- 2. Preserve the existing `AGENTS.md` organization and all project-specific
14
- adaptations. Merge only reusable template guidance that applies to this
15
- repository; report conflicts between local and template rules, and do not
16
- replace `AGENTS.md` wholesale or copy the complete template into it.
10
+ 1. Inspect `AGENTS.md`, any existing `PLANS.md`, `TEMPLATE_AGENTS.md`,
11
+ `.codex-kit-state.json`, the project's existing `.agents/skills`, and
12
+ `codex-kit project status`. Record the initial status before making changes.
13
+ 2. Preserve the existing `AGENTS.md` and `PLANS.md` organization and all
14
+ project-specific adaptations. Merge only reusable template guidance that
15
+ applies to this repository; report conflicts between local and template
16
+ rules, and do not replace `AGENTS.md` wholesale or copy the complete
17
+ template into it.
17
18
  3. Keep critical always-on safety, authorization, secrets, database,
18
19
  deployment, and destructive-operation rules in `AGENTS.md`.
19
- 4. Extract only concrete, conditional, repeatable project procedures into a
20
+ 4. Preserve an existing `PLANS.md` and semantically merge durable product
21
+ context, decisions, roadmap/status, and resume-worthy milestones. Create it
22
+ only when repository evidence contains real durable content; never invent or
23
+ backfill speculative history. Move durable roadmap or history misplaced in
24
+ `AGENTS.md` into `PLANS.md`, keeping it concise rather than turning it into a
25
+ per-change changelog. Report whether `PLANS.md` was preserved, created, or
26
+ updated and why.
27
+ 5. Extract only concrete, conditional, repeatable project procedures into a
20
28
  focused skill under `.agents/skills/<skill-name>/SKILL.md`. Preserve relevant
21
29
  existing skills, use valid YAML frontmatter, and do not create speculative
22
30
  skills or duplicate detailed instructions.
23
- 5. Review the final instruction diff for preserved local rules, duplicates, and
31
+ 6. Review the final instruction diff for preserved local rules, duplicates, and
24
32
  unintended template edits. Validate every created or modified project skill
25
33
  with an available skill validator and run the repository's documented checks.
26
34
  Do not mark the template applied until reconciliation and validation succeed.
27
- 6. Never run `codex-kit project sync` on the user's behalf or recommend it for
35
+ 7. Never run `codex-kit project sync` on the user's behalf or recommend it for
28
36
  an unreleased local template edit. The user should run `project sync` only
29
37
  after updating codex-kit to a released version containing the template
30
38
  change. Run `codex-kit project mark-applied` only when the task follows a
@@ -32,7 +40,7 @@ description: Reconcile a refreshed TEMPLATE_AGENTS.md with a project's AGENTS.md
32
40
  recorded in step 1 was `reconciliation required`, and reconciliation and
33
41
  validation succeeded. Otherwise leave project state unchanged and report the
34
42
  remaining release, codex-kit update, user-run sync, and reconciliation steps.
35
- 7. Summarize added, updated, skipped, adapted, and skill-moved guidance, with
43
+ 8. Summarize added, updated, skipped, adapted, and skill-moved guidance, with
36
44
  reasons. Identify genuinely reusable, generalized changes that should be
37
45
  promoted to codex-kit's canonical template and report the target section and
38
46
  wording.
package/bin/codex-kit.js CHANGED
@@ -575,6 +575,87 @@ function uninstallGlobal(options) {
575
575
  // src/project/commands.ts
576
576
  import { existsSync as existsSync6, statSync as statSync2 } from "node:fs";
577
577
  import { join as join6 } from "node:path";
578
+
579
+ // src/version.ts
580
+ function parseVersion(value) {
581
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(value);
582
+ if (!match) throw new Error(`Invalid package version: ${value}`);
583
+ return {
584
+ numbers: [Number(match[1]), Number(match[2]), Number(match[3])],
585
+ prerelease: match[4] ?? null
586
+ };
587
+ }
588
+ function compareVersions(left, right) {
589
+ const a = parseVersion(left);
590
+ const b = parseVersion(right);
591
+ for (const [leftNumber, rightNumber] of [
592
+ [a.numbers[0], b.numbers[0]],
593
+ [a.numbers[1], b.numbers[1]],
594
+ [a.numbers[2], b.numbers[2]]
595
+ ])
596
+ if (leftNumber !== rightNumber) return Math.sign(leftNumber - rightNumber);
597
+ if (a.prerelease === b.prerelease) return 0;
598
+ if (!a.prerelease) return 1;
599
+ if (!b.prerelease) return -1;
600
+ return Math.sign(
601
+ a.prerelease.localeCompare(b.prerelease, "en", { numeric: true })
602
+ );
603
+ }
604
+ async function fetchLatestVersion() {
605
+ const url = `${REGISTRY}/${encodeURIComponent(PACKAGE.name)}/latest`;
606
+ let response;
607
+ try {
608
+ response = await fetch(url, { signal: AbortSignal.timeout(15e3) });
609
+ } catch (error) {
610
+ throw new Error(
611
+ `Unable to check ${REGISTRY}: ${error instanceof Error ? error.message : String(error)}`
612
+ );
613
+ }
614
+ if (!response.ok)
615
+ throw new Error(
616
+ `Unable to check ${REGISTRY}: ${response.status} ${response.statusText}`
617
+ );
618
+ let value;
619
+ try {
620
+ value = await response.json();
621
+ } catch {
622
+ throw new Error("Registry returned no package version.");
623
+ }
624
+ if (!value || typeof value !== "object" || Array.isArray(value) || typeof value.version !== "string")
625
+ throw new Error("Registry returned no package version.");
626
+ const latest = value.version;
627
+ parseVersion(latest);
628
+ return latest;
629
+ }
630
+ async function getLatestVersion() {
631
+ const override = process.env.CODEX_KIT_LATEST_VERSION;
632
+ if (override) {
633
+ parseVersion(override);
634
+ return override;
635
+ }
636
+ return fetchLatestVersion();
637
+ }
638
+ async function checkVersion() {
639
+ const latest = await getLatestVersion();
640
+ console.log(`Installed: ${PACKAGE.version}`);
641
+ console.log(`Latest: ${latest}`);
642
+ const comparison = compareVersions(PACKAGE.version, latest);
643
+ if (comparison === 0) {
644
+ console.log("codex-kit is up to date.");
645
+ return;
646
+ }
647
+ if (comparison > 0) {
648
+ console.log("This local build is newer than the published package.");
649
+ return;
650
+ }
651
+ console.log(
652
+ `Update available. Run:
653
+ pnpm add --global ${PACKAGE.name}@latest
654
+ codex-kit global install`
655
+ );
656
+ }
657
+
658
+ // src/project/commands.ts
578
659
  var STATE_FILE2 = ".codex-kit-state.json";
579
660
  var PROJECT_BEGIN = "<!-- BEGIN codex-kit:shared-template -->";
580
661
  var PROJECT_END = "<!-- END codex-kit:shared-template -->";
@@ -612,6 +693,11 @@ project-specific guidance to AGENTS.md based only on repository evidence,
612
693
  including exact verification commands. Then use the global
613
694
  $${RECONCILE_SKILL} skill to merge applicable reusable guidance from
614
695
  TEMPLATE_AGENTS.md while preserving AGENTS.md organization and local rules.
696
+ Inspect and preserve any existing PLANS.md. Create or maintain a concise
697
+ PLANS.md only when repository evidence contains real roadmap items, durable
698
+ decisions, or resume-worthy completed work; never invent or backfill speculative
699
+ history. Keep always-on repository instructions in AGENTS.md, move misplaced
700
+ roadmap or history into PLANS.md, and report what PLANS.md work was done.
615
701
  Validate the final instruction changes, mark the template applied only after
616
702
  validation succeeds, and confirm codex-kit project status is up to date.
617
703
  ===== END CODEX INITIALIZATION PROMPT =====`;
@@ -623,21 +709,33 @@ function reconciliationPrompt() {
623
709
  Use the global $${RECONCILE_SKILL} skill to reconcile the existing AGENTS.md
624
710
  with the refreshed TEMPLATE_AGENTS.md.
625
711
 
626
- Inspect TEMPLATE_AGENTS.md, AGENTS.md, .codex-kit-state.json, existing
627
- .agents/skills, and codex-kit project status. Preserve local adaptations and
628
- AGENTS.md organization; merge only applicable reusable guidance. Keep critical
629
- always-on safety and authorization rules in AGENTS.md, extract only concrete
630
- conditional procedures into validated skills, and do not copy the complete
631
- template or introduce managed markers.
712
+ Inspect TEMPLATE_AGENTS.md, AGENTS.md, PLANS.md, .codex-kit-state.json,
713
+ existing .agents/skills, and codex-kit project status. Preserve local
714
+ adaptations and AGENTS.md/PLANS.md organization; merge only applicable reusable
715
+ guidance. Preserve an existing PLANS.md, and create or update it only for
716
+ evidence-backed durable decisions, roadmap/status, or resume-worthy milestones.
717
+ Never invent or backfill speculative history. Move misplaced roadmap or history
718
+ out of AGENTS.md, keeping critical always-on safety and authorization rules in
719
+ AGENTS.md. The reconciliation must extract only concrete conditional procedures
720
+ into validated skills. Do not copy the complete template or introduce managed
721
+ markers. Report what PLANS.md content was preserved, created, or changed.
632
722
 
633
723
  Validate the final instruction changes. Mark applied only after reconciliation
634
724
  and validation succeed, confirm codex-kit project status is up to date, then
635
725
  report any template-worthy generalized promotion.
636
726
  ===== END CODEX RECONCILIATION PROMPT =====`;
637
727
  }
638
- function syncProject(options) {
728
+ async function syncProject(options, action = "sync") {
639
729
  const { cwd } = options;
640
730
  requireDirectory(cwd);
731
+ const latest = await getLatestVersion();
732
+ if (compareVersions(PACKAGE.version, latest) < 0)
733
+ throw new Error(
734
+ `Installed: ${PACKAGE.version}
735
+ Latest: ${latest}
736
+ Published guidelines are newer than this local build. Rerun with:
737
+ pnpm dlx ${PACKAGE.name}@latest project ${action} --cwd '${cwd.replaceAll("'", "'\\''")}'`
738
+ );
641
739
  const agentsFile = join6(cwd, "AGENTS.md");
642
740
  const stagedTemplate = join6(cwd, "TEMPLATE_AGENTS.md");
643
741
  const desired = Buffer.from(readText(TEMPLATE_FILE));
@@ -735,79 +833,6 @@ function markApplied(options) {
735
833
  console.log(`recorded template reconciliation: ${stagedTemplate}`);
736
834
  }
737
835
 
738
- // src/version.ts
739
- function parseVersion(value) {
740
- const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(value);
741
- if (!match) throw new Error(`Invalid package version: ${value}`);
742
- return {
743
- numbers: [Number(match[1]), Number(match[2]), Number(match[3])],
744
- prerelease: match[4] ?? null
745
- };
746
- }
747
- function compareVersions(left, right) {
748
- const a = parseVersion(left);
749
- const b = parseVersion(right);
750
- for (const [leftNumber, rightNumber] of [
751
- [a.numbers[0], b.numbers[0]],
752
- [a.numbers[1], b.numbers[1]],
753
- [a.numbers[2], b.numbers[2]]
754
- ])
755
- if (leftNumber !== rightNumber) return Math.sign(leftNumber - rightNumber);
756
- if (a.prerelease === b.prerelease) return 0;
757
- if (!a.prerelease) return 1;
758
- if (!b.prerelease) return -1;
759
- return Math.sign(
760
- a.prerelease.localeCompare(b.prerelease, "en", { numeric: true })
761
- );
762
- }
763
- async function fetchLatestVersion() {
764
- const url = `${REGISTRY}/${encodeURIComponent(PACKAGE.name)}/latest`;
765
- let response;
766
- try {
767
- response = await fetch(url, { signal: AbortSignal.timeout(15e3) });
768
- } catch (error) {
769
- throw new Error(
770
- `Unable to check ${REGISTRY}: ${error instanceof Error ? error.message : String(error)}`
771
- );
772
- }
773
- if (!response.ok)
774
- throw new Error(
775
- `Unable to check ${REGISTRY}: ${response.status} ${response.statusText}`
776
- );
777
- let value;
778
- try {
779
- value = await response.json();
780
- } catch {
781
- throw new Error("Registry returned no package version.");
782
- }
783
- if (!value || typeof value !== "object" || Array.isArray(value) || typeof value.version !== "string")
784
- throw new Error("Registry returned no package version.");
785
- const latest = value.version;
786
- parseVersion(latest);
787
- return latest;
788
- }
789
- async function checkVersion() {
790
- let latest = process.env.CODEX_KIT_LATEST_VERSION;
791
- if (!latest) latest = await fetchLatestVersion();
792
- if (!latest) throw new Error("Registry returned no package version.");
793
- console.log(`Installed: ${PACKAGE.version}`);
794
- console.log(`Latest: ${latest}`);
795
- const comparison = compareVersions(PACKAGE.version, latest);
796
- if (comparison === 0) {
797
- console.log("codex-kit is up to date.");
798
- return;
799
- }
800
- if (comparison > 0) {
801
- console.log("This local build is newer than the published package.");
802
- return;
803
- }
804
- console.log(
805
- `Update available. Run:
806
- pnpm add --global ${PACKAGE.name}@latest
807
- codex-kit global install`
808
- );
809
- }
810
-
811
836
  // src/cli/options.ts
812
837
  import { homedir } from "node:os";
813
838
  import { join as join7, resolve as resolve2 } from "node:path";
@@ -856,8 +881,8 @@ Commands:
856
881
  global configure Set the orchestrator and normal/Plan reasoning defaults.
857
882
  global list Show model settings, routing status, and custom agents.
858
883
  global uninstall Restore managed config values and remove package-owned files.
859
- project init Initialize AGENTS.md, TEMPLATE_AGENTS.md, and project state.
860
- project sync Refresh TEMPLATE_AGENTS.md without editing AGENTS.md.
884
+ project init Initialize project files after checking the latest npm release.
885
+ project sync Refresh the template after checking the latest npm release.
861
886
  project status Show whether template changes still need reconciliation.
862
887
  project mark-applied Record the current template as reconciled with AGENTS.md.
863
888
  version check Compare the installed version with the latest npm release.
@@ -882,6 +907,7 @@ Options by command:
882
907
 
883
908
  project init, project sync
884
909
  --cwd PATH Use a project directory other than the current directory.
910
+ npm access is required; stale or unverifiable builds fail before writes.
885
911
 
886
912
  project status, project mark-applied
887
913
  --cwd PATH Use a project directory other than the current directory.
@@ -910,7 +936,7 @@ async function main(argv = process.argv.slice(2)) {
910
936
  else if (scope === "global" && action === "uninstall")
911
937
  uninstallGlobal(options);
912
938
  else if (scope === "project" && (action === "init" || action === "sync"))
913
- syncProject(options);
939
+ await syncProject(options, action);
914
940
  else if (scope === "project" && action === "status") projectStatus(options);
915
941
  else if (scope === "project" && action === "mark-applied")
916
942
  markApplied(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamdevlinph/codex-kit",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Portable Codex subagents and project AGENTS.md defaults.",
5
5
  "type": "module",
6
6
  "bin": {