@litfamily/litcodex 1.0.0 → 1.0.2

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.
Files changed (121) hide show
  1. package/README.md +18 -21
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.js +2 -38
  4. package/dist/config-migration/profile-files.d.ts +4 -0
  5. package/dist/config-migration/profile-files.js +22 -0
  6. package/dist/install/capability-preflight-error.js +5 -1
  7. package/dist/install/codex.d.ts +1 -0
  8. package/dist/install/generated-skill-payload-hashes.d.ts +1 -6
  9. package/dist/install/generated-skill-payload-hashes.js +1 -6
  10. package/dist/install/host-capabilities.d.ts +2 -0
  11. package/dist/install/host-capabilities.js +13 -1
  12. package/dist/install/index.js +3 -1
  13. package/dist/install/skill-catalog.d.ts +1 -1
  14. package/dist/install/skill-catalog.js +1 -6
  15. package/dist/install/skill-resource-hashes.d.ts +1 -1
  16. package/dist/install/skill-resource-hashes.js +1 -1
  17. package/dist/install/strict-config-probe.d.ts +2 -0
  18. package/dist/install/strict-config-probe.js +34 -5
  19. package/dist/install/uninstall.d.ts +2 -0
  20. package/dist/install/uninstall.js +34 -0
  21. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  22. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  23. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  24. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  25. package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +3 -20
  26. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +1 -8
  27. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +2 -1
  28. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +4 -27
  29. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +0 -2
  30. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +0 -2
  31. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -3
  32. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +1 -10
  33. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  34. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  35. package/marketplace/plugins/litcodex/components/rules/dist/static-injection.js +2 -2
  36. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  37. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  38. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  39. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  40. package/marketplace/plugins/litcodex/skills/browser-drive/scripts/capability-probe.mjs +13 -5
  41. package/node_modules/@litcodex/lit-loop/README.md +1 -7
  42. package/node_modules/@litcodex/lit-loop/dist/cli.js +3 -20
  43. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +1 -8
  44. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +2 -1
  45. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +4 -27
  46. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +0 -2
  47. package/node_modules/@litcodex/lit-loop/dist/markers.js +0 -2
  48. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -3
  49. package/node_modules/@litcodex/lit-loop/dist/modes.js +1 -10
  50. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  51. package/node_modules/@litcodex/lit-loop/skills/browser-drive/scripts/capability-probe.mjs +13 -5
  52. package/package.json +2 -2
  53. package/readme-assets/badge-version.svg +1 -1
  54. package/readme-assets/cover-motion.webp +0 -0
  55. package/marketplace/plugins/litcodex/components/lit-loop/directives/skill-observer.md +0 -105
  56. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/apply.d.ts +0 -16
  57. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/apply.js +0 -227
  58. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/config.d.ts +0 -13
  59. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/config.js +0 -12
  60. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/curator.d.ts +0 -14
  61. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/curator.js +0 -112
  62. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/hook.d.ts +0 -19
  63. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/hook.js +0 -435
  64. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/ownership.d.ts +0 -6
  65. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/ownership.js +0 -145
  66. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/paths.d.ts +0 -18
  67. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/paths.js +0 -43
  68. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/review.d.ts +0 -28
  69. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/review.js +0 -702
  70. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/store.d.ts +0 -32
  71. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/store.js +0 -667
  72. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/transaction.d.ts +0 -26
  73. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/transaction.js +0 -524
  74. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/types.d.ts +0 -81
  75. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/types.js +0 -246
  76. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/usage.d.ts +0 -6
  77. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/usage.js +0 -119
  78. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop-cli.d.ts +0 -8
  79. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop-cli.js +0 -111
  80. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-cli.d.ts +0 -3
  81. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-cli.js +0 -116
  82. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-route.d.ts +0 -6
  83. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-route.js +0 -12
  84. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer.d.ts +0 -18
  85. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer.js +0 -946
  86. package/marketplace/plugins/litcodex/skills/skill-observer/SKILL.md +0 -215
  87. package/marketplace/plugins/litcodex/skills/skill-observer/agents/openai.yaml +0 -6
  88. package/marketplace/plugins/litcodex/skills/skill-observer/references/review-contract.md +0 -77
  89. package/node_modules/@litcodex/lit-loop/directives/skill-observer.md +0 -105
  90. package/node_modules/@litcodex/lit-loop/dist/skill-loop/apply.d.ts +0 -16
  91. package/node_modules/@litcodex/lit-loop/dist/skill-loop/apply.js +0 -227
  92. package/node_modules/@litcodex/lit-loop/dist/skill-loop/config.d.ts +0 -13
  93. package/node_modules/@litcodex/lit-loop/dist/skill-loop/config.js +0 -12
  94. package/node_modules/@litcodex/lit-loop/dist/skill-loop/curator.d.ts +0 -14
  95. package/node_modules/@litcodex/lit-loop/dist/skill-loop/curator.js +0 -112
  96. package/node_modules/@litcodex/lit-loop/dist/skill-loop/hook.d.ts +0 -19
  97. package/node_modules/@litcodex/lit-loop/dist/skill-loop/hook.js +0 -435
  98. package/node_modules/@litcodex/lit-loop/dist/skill-loop/ownership.d.ts +0 -6
  99. package/node_modules/@litcodex/lit-loop/dist/skill-loop/ownership.js +0 -145
  100. package/node_modules/@litcodex/lit-loop/dist/skill-loop/paths.d.ts +0 -18
  101. package/node_modules/@litcodex/lit-loop/dist/skill-loop/paths.js +0 -43
  102. package/node_modules/@litcodex/lit-loop/dist/skill-loop/review.d.ts +0 -28
  103. package/node_modules/@litcodex/lit-loop/dist/skill-loop/review.js +0 -702
  104. package/node_modules/@litcodex/lit-loop/dist/skill-loop/store.d.ts +0 -32
  105. package/node_modules/@litcodex/lit-loop/dist/skill-loop/store.js +0 -667
  106. package/node_modules/@litcodex/lit-loop/dist/skill-loop/transaction.d.ts +0 -26
  107. package/node_modules/@litcodex/lit-loop/dist/skill-loop/transaction.js +0 -524
  108. package/node_modules/@litcodex/lit-loop/dist/skill-loop/types.d.ts +0 -81
  109. package/node_modules/@litcodex/lit-loop/dist/skill-loop/types.js +0 -246
  110. package/node_modules/@litcodex/lit-loop/dist/skill-loop/usage.d.ts +0 -6
  111. package/node_modules/@litcodex/lit-loop/dist/skill-loop/usage.js +0 -119
  112. package/node_modules/@litcodex/lit-loop/dist/skill-loop-cli.d.ts +0 -8
  113. package/node_modules/@litcodex/lit-loop/dist/skill-loop-cli.js +0 -111
  114. package/node_modules/@litcodex/lit-loop/dist/skill-observer-cli.d.ts +0 -3
  115. package/node_modules/@litcodex/lit-loop/dist/skill-observer-cli.js +0 -116
  116. package/node_modules/@litcodex/lit-loop/dist/skill-observer-route.d.ts +0 -6
  117. package/node_modules/@litcodex/lit-loop/dist/skill-observer-route.js +0 -12
  118. package/node_modules/@litcodex/lit-loop/dist/skill-observer.d.ts +0 -18
  119. package/node_modules/@litcodex/lit-loop/dist/skill-observer.js +0 -946
  120. package/node_modules/@litcodex/lit-loop/skills/skill-observer/SKILL.md +0 -215
  121. package/node_modules/@litcodex/lit-loop/skills/skill-observer/references/review-contract.md +0 -77
@@ -1,145 +0,0 @@
1
- import { TextDecoder } from "node:util";
2
- import { readBlob } from "./store.js";
3
- import { SkillLoopError } from "./types.js";
4
- const utf8 = new TextDecoder("utf-8", { fatal: true });
5
- const MARKER_KEY = "litcodexAgentGenerated";
6
- const metadataEntry = /^metadata\s*:\s*$/u;
7
- const markerEntry = new RegExp(`^${MARKER_KEY}:\\s*(true|false)\\s*$`, "u");
8
- const exactMetadataKeys = new Set(["metadata"]);
9
- const exactMarkerKeys = new Set(["litcodexAgentGenerated"]);
10
- function mappingKey(line) {
11
- const indent = /^ */u.exec(line)?.[0].length ?? 0;
12
- const body = line.slice(indent);
13
- const colon = body.indexOf(":");
14
- if (colon < 0)
15
- return null;
16
- return { indent, key: body.slice(0, colon).trim() };
17
- }
18
- function hasUnsafeSemanticAlias(line, expectedIndent) {
19
- const parsed = mappingKey(line);
20
- if (parsed === null || (expectedIndent !== undefined && parsed.indent !== expectedIndent))
21
- return false;
22
- if (parsed.key.includes("\\"))
23
- return true;
24
- const normalized = parsed.key.normalize("NFKC");
25
- if (parsed.indent === 0 && normalized.toLocaleLowerCase("en-US").includes("metadata")) {
26
- return !exactMetadataKeys.has(parsed.key);
27
- }
28
- if (normalized.toLocaleLowerCase("en-US").includes("litcodexagentgenerated")) {
29
- return !exactMarkerKeys.has(parsed.key);
30
- }
31
- return false;
32
- }
33
- function hasUnsupportedYamlSyntax(line) {
34
- const body = line.trim();
35
- if (body === "" || body.startsWith("#"))
36
- return false;
37
- if (/^[?%{[]/u.test(body))
38
- return true;
39
- const parsed = mappingKey(line);
40
- if (parsed === null)
41
- return false;
42
- if (parsed.key === "<<" || /^[&*!{[]/u.test(parsed.key))
43
- return true;
44
- const colon = line.indexOf(":");
45
- const value = colon < 0 ? "" : line.slice(colon + 1).trimStart();
46
- return (/^(?:[!{[]|\*[^\s]+)/u.test(value) ||
47
- /(?:^|\s)&[A-Za-z0-9_-]+(?:\s|$)/u.test(value) ||
48
- /(?:^|\s)\*[A-Za-z0-9_-]+(?:\s|$)/u.test(value));
49
- }
50
- export function markerPresent(content) {
51
- if (!content.startsWith("---\n"))
52
- return false;
53
- const lines = content.split("\n");
54
- const end = lines.indexOf("---", 1);
55
- if (end < 0)
56
- return false;
57
- const frontmatter = lines.slice(1, end);
58
- if (frontmatter.some((line) => hasUnsupportedYamlSyntax(line) || hasUnsafeSemanticAlias(line)))
59
- return false;
60
- const metadataEntries = frontmatter
61
- .map((line, index) => ({ line, index }))
62
- .filter(({ line }) => /^metadata\s*:/u.test(line));
63
- if (metadataEntries.length !== 1 || !metadataEntry.test(metadataEntries[0]?.line ?? ""))
64
- return false;
65
- const metadata = metadataEntries[0]?.index;
66
- if (metadata === undefined)
67
- return false;
68
- let directIndent;
69
- let markerCount = 0;
70
- let markerIsTrue = false;
71
- for (let index = metadata + 1; index < frontmatter.length; index += 1) {
72
- const line = frontmatter[index] ?? "";
73
- if (line.trim() === "" || line.trimStart().startsWith("#"))
74
- continue;
75
- const indent = /^ */u.exec(line)?.[0].length ?? 0;
76
- if (indent === 0)
77
- break;
78
- directIndent ??= indent;
79
- if (indent === directIndent) {
80
- if (hasUnsafeSemanticAlias(line, directIndent))
81
- return false;
82
- const direct = line.slice(indent);
83
- if (mappingKey(line)?.key !== MARKER_KEY)
84
- continue;
85
- markerCount += 1;
86
- const marker = markerEntry.exec(direct);
87
- if (marker === null || marker[1] !== "true")
88
- return false;
89
- markerIsTrue = true;
90
- }
91
- }
92
- return markerCount === 1 && markerIsTrue;
93
- }
94
- export function stampMarker(content, skillId) {
95
- if (markerPresent(content))
96
- return content;
97
- if (!content.startsWith("---\n")) {
98
- return `---\nname: ${skillId}\ndescription: Agent-owned reusable skill.\nmetadata:\n litcodexAgentGenerated: true\n---\n\n${content}`;
99
- }
100
- const lines = content.split("\n");
101
- const end = lines.indexOf("---", 1);
102
- if (end < 0)
103
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md frontmatter is incomplete");
104
- const frontmatter = lines.slice(1, end);
105
- if (frontmatter.some((line) => hasUnsupportedYamlSyntax(line) || hasUnsafeSemanticAlias(line))) {
106
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md metadata contains a noncanonical YAML key");
107
- }
108
- const metadataEntries = frontmatter
109
- .map((line, index) => ({ line, index }))
110
- .filter(({ line }) => /^metadata\s*:/u.test(line));
111
- if (metadataEntries.length > 1 ||
112
- (metadataEntries[0] !== undefined && !metadataEntry.test(metadataEntries[0].line))) {
113
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md metadata must be a direct YAML mapping");
114
- }
115
- const metadata = metadataEntries[0]?.index;
116
- if (metadata === undefined)
117
- frontmatter.push("metadata:", " litcodexAgentGenerated: true");
118
- else {
119
- let indent = " ";
120
- for (let index = metadata + 1; index < frontmatter.length; index += 1) {
121
- const line = frontmatter[index] ?? "";
122
- if (line.trim() === "" || line.trimStart().startsWith("#"))
123
- continue;
124
- const current = /^ */u.exec(line)?.[0] ?? "";
125
- if (current.length === 0)
126
- break;
127
- indent = current;
128
- break;
129
- }
130
- frontmatter.splice(metadata + 1, 0, `${indent}litcodexAgentGenerated: true`);
131
- }
132
- return ["---", ...frontmatter, "---", ...lines.slice(end + 1)].join("\n");
133
- }
134
- export function decodeSkillItem(paths, item) {
135
- try {
136
- return utf8.decode(readBlob(paths, item));
137
- }
138
- catch {
139
- throw new SkillLoopError("TARGET_TEXT_INVALID", "the target skill file is not valid UTF-8");
140
- }
141
- }
142
- export function snapshotIsAgentOwned(paths, snapshot) {
143
- const skillFile = snapshot.find((item) => item.file === "SKILL.md");
144
- return skillFile !== undefined && markerPresent(decodeSkillItem(paths, skillFile));
145
- }
@@ -1,18 +0,0 @@
1
- export interface SkillLoopPaths {
2
- readonly workspaceRoot: string;
3
- readonly stateRoot: string;
4
- readonly proposalsDir: string;
5
- readonly ledgerPath: string;
6
- readonly blobsDir: string;
7
- readonly lockPath: string;
8
- readonly agentMutationLockPath: string;
9
- readonly transactionPath: string;
10
- readonly agentRoot: string;
11
- readonly usagePath: string;
12
- readonly archiveRoot: string;
13
- readonly curatorBackupsRoot: string;
14
- }
15
- export declare function agentSkillRoot(env?: NodeJS.ProcessEnv): string;
16
- export declare function skillLoopPaths(workspaceRoot: string, env?: NodeJS.ProcessEnv): SkillLoopPaths;
17
- export declare function isWithin(root: string, candidate: string): boolean;
18
- export declare function targetSkillDir(paths: SkillLoopPaths, skillId: string): string;
@@ -1,43 +0,0 @@
1
- import { isAbsolute, join, resolve, sep } from "node:path";
2
- import { SkillLoopError } from "./types.js";
3
- export function agentSkillRoot(env = process.env) {
4
- const home = env["HOME"]?.trim();
5
- if (!home || !isAbsolute(home)) {
6
- throw new SkillLoopError("HOME_INVALID", "the skill-loop HOME is unavailable");
7
- }
8
- return resolve(home, ".agents", "skills");
9
- }
10
- export function skillLoopPaths(workspaceRoot, env = process.env) {
11
- if (!isAbsolute(workspaceRoot)) {
12
- throw new SkillLoopError("WORKSPACE_ROOT_INVALID", "the skill-loop workspace root must be absolute");
13
- }
14
- const root = resolve(workspaceRoot);
15
- const stateRoot = join(root, ".litcodex");
16
- const agentRoot = agentSkillRoot(env);
17
- return {
18
- workspaceRoot: root,
19
- stateRoot,
20
- proposalsDir: join(stateRoot, "skill-proposals"),
21
- ledgerPath: join(stateRoot, "skill-ledger.jsonl"),
22
- blobsDir: join(stateRoot, "skill-ledger-blobs"),
23
- lockPath: join(stateRoot, "skill-loop.lock"),
24
- agentMutationLockPath: join(resolve(agentRoot, ".."), ".litcodex-skill-loop-mutation.lock"),
25
- transactionPath: join(stateRoot, "skill-transaction.json"),
26
- agentRoot,
27
- usagePath: join(agentRoot, ".litcodex-usage.json"),
28
- archiveRoot: join(agentRoot, ".litcodex-archive"),
29
- curatorBackupsRoot: join(agentRoot, ".litcodex-curator-backups"),
30
- };
31
- }
32
- export function isWithin(root, candidate) {
33
- const normalizedRoot = resolve(root);
34
- const normalizedCandidate = resolve(candidate);
35
- return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(`${normalizedRoot}${sep}`);
36
- }
37
- export function targetSkillDir(paths, skillId) {
38
- const target = resolve(paths.agentRoot, skillId);
39
- if (!isWithin(paths.agentRoot, target) || target === paths.agentRoot) {
40
- throw new SkillLoopError("TARGET_NOT_AGENT_OWNED", "the proposal target is not agent-owned");
41
- }
42
- return target;
43
- }
@@ -1,28 +0,0 @@
1
- export interface ReviewOptions {
2
- readonly env?: NodeJS.ProcessEnv | undefined;
3
- readonly now?: () => Date;
4
- readonly spawn?: ReviewSpawn;
5
- /** Test-only race seam; production callers leave this unset. */
6
- readonly beforeRead?: ((path: string) => void) | undefined;
7
- }
8
- export interface ReviewSpawnOptions {
9
- readonly cwd: string;
10
- readonly env: NodeJS.ProcessEnv;
11
- readonly encoding: "utf8";
12
- readonly stdio: ["ignore", "pipe", "pipe"];
13
- readonly maxBuffer: number;
14
- readonly timeout: number;
15
- }
16
- export interface ReviewSpawnResult {
17
- readonly status: number | null;
18
- readonly stdout: string;
19
- readonly stderr: string;
20
- readonly error?: Error;
21
- }
22
- export type ReviewSpawn = (command: string, args: readonly string[], options: ReviewSpawnOptions) => ReviewSpawnResult;
23
- export declare function buildReviewPacket(workspaceRoot: string, options?: Pick<ReviewOptions, "env" | "beforeRead">): string;
24
- export declare function runCodexReview(workspaceRoot: string, options?: ReviewOptions): {
25
- readonly ok: true;
26
- readonly proposalIds: readonly string[];
27
- readonly noOp: boolean;
28
- };