codiedev 0.9.21 → 0.9.22

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.
@@ -1 +1,2 @@
1
+ export declare function candidateKeys(key: string): string[];
1
2
  export declare function runPull(args: string[]): Promise<void>;
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.candidateKeys = candidateKeys;
36
37
  exports.runPull = runPull;
37
38
  const fs = __importStar(require("fs"));
38
39
  const path = __importStar(require("path"));
@@ -69,21 +70,45 @@ function parseArgs(args) {
69
70
  }
70
71
  return { key, version, out };
71
72
  }
73
+ // The backend stores skills under extension-bearing keys (e.g. "pr-push.md"),
74
+ // and lookup is exact-match, so a bare "pr-push" 404s. Make pull forgiving: try
75
+ // the key as given, then a ".md" fallback when it has no extension, so the
76
+ // intuitive bare name (and the hook's suggested key) both resolve.
77
+ function candidateKeys(key) {
78
+ if (/\.[a-z0-9]+$/i.test(key))
79
+ return [key];
80
+ return [key, `${key}.md`];
81
+ }
72
82
  async function runPull(args) {
73
83
  const { key, version, out } = parseArgs(args);
74
84
  const config = (0, shared_1.requireConfig)();
85
+ const keys = candidateKeys(key);
75
86
  const start = Date.now();
76
87
  try {
77
- const res = await (0, shared_1.apiRequest)("GET", "/api/cli/pull", {
78
- config,
79
- query: { key, version },
80
- });
88
+ let res;
89
+ for (let i = 0; i < keys.length; i++) {
90
+ try {
91
+ res = await (0, shared_1.apiRequest)("GET", "/api/cli/pull", {
92
+ config,
93
+ query: { key: keys[i], version },
94
+ });
95
+ break;
96
+ }
97
+ catch (err) {
98
+ const e = err;
99
+ // A 404 on a non-final candidate is retryable (fall through to ".md");
100
+ // anything else — or the last candidate — propagates to the handler.
101
+ if (e.status === 404 && i < keys.length - 1)
102
+ continue;
103
+ throw err;
104
+ }
105
+ }
106
+ const a = res.artifact;
81
107
  (0, shared_1.recordAgentEvent)(config, {
82
108
  tool: "codiedev_pull",
83
109
  ok: true,
84
110
  latencyMs: Date.now() - start,
85
111
  });
86
- const a = res.artifact;
87
112
  if (out) {
88
113
  const absolute = path.isAbsolute(out) ? out : path.resolve(process.cwd(), out);
89
114
  fs.writeFileSync(absolute, a.markdown, "utf8");
@@ -108,7 +133,8 @@ async function runPull(args) {
108
133
  error: e.message,
109
134
  });
110
135
  if (e.status === 404) {
111
- console.error(`Not found: ${key}${version ? ` v${version}` : ""}`);
136
+ const also = keys.length > 1 ? ` (also tried ${keys.slice(1).join(", ")})` : "";
137
+ console.error(`Not found: ${key}${version ? ` v${version}` : ""}${also}`);
112
138
  }
113
139
  else {
114
140
  console.error(`Pull failed: ${e.message}`);
package/dist/hook.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ export declare function buildDiscoveryContext(skills: Array<{
3
+ key: string;
4
+ title: string;
5
+ score: number;
6
+ }>): string | null;
package/dist/hook.js CHANGED
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.buildDiscoveryContext = buildDiscoveryContext;
37
38
  const fs = __importStar(require("fs"));
38
39
  const os = __importStar(require("os"));
39
40
  const path = __importStar(require("path"));
@@ -74,6 +75,26 @@ function getJson(url, bearerToken) {
74
75
  req.end();
75
76
  });
76
77
  }
78
+ // Pure builder for the discovery additionalContext. Returns null when there are
79
+ // no matches. The suggested `codiedev pull` command carries the EXACT top key
80
+ // (e.g. "pr-push.md") rather than a "<key>" placeholder — otherwise agents
81
+ // paraphrase the key (pr-push) and the extension-sensitive `pull` 404s.
82
+ function buildDiscoveryContext(skills) {
83
+ if (skills.length === 0)
84
+ return null;
85
+ // Don't trust the API's ordering — rank by score so the suggested pull key is
86
+ // always the highest-confidence match.
87
+ const top = [...skills].sort((a, b) => b.score - a.score).slice(0, 3);
88
+ const lines = top
89
+ .map((s) => `- ${s.key} — ${(s.score * 100).toFixed(0)}% match`)
90
+ .join("\n");
91
+ return ("Your team has a CodieDev skill that fits this task — prefer it over improvising:\n" +
92
+ lines +
93
+ "\nPull and follow it now: `codiedev pull " +
94
+ top[0].key +
95
+ "`. It encodes the team's vetted " +
96
+ "approach. Skip it only if it clearly doesn't apply.");
97
+ }
77
98
  // UserPromptSubmit: query skill discovery for the prompt and, if a team skill
78
99
  // clears the confidence threshold, inject it as additionalContext so the agent
79
100
  // can offer to pull+run it. Fully silent on miss/error — never blocks input.
@@ -86,15 +107,8 @@ async function runDiscover(prompt) {
86
107
  try {
87
108
  const res = await getJson(`${config.backendUrl}/api/cli/skill-discovery?q=${encodeURIComponent(prompt)}`, config.token);
88
109
  const skills = res?.skills ?? [];
89
- if (skills.length > 0) {
90
- const lines = skills
91
- .slice(0, 3)
92
- .map((s) => `- ${s.key} — ${(s.score * 100).toFixed(0)}% match`)
93
- .join("\n");
94
- const additionalContext = "Your team has a CodieDev skill that fits this task — prefer it over improvising:\n" +
95
- lines +
96
- "\nPull and follow it now: `codiedev pull <key>`. It encodes the team's vetted " +
97
- "approach. Skip it only if it clearly doesn't apply.";
110
+ const additionalContext = buildDiscoveryContext(skills);
111
+ if (additionalContext) {
98
112
  process.stdout.write(JSON.stringify({
99
113
  hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext },
100
114
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "description": "Connect Claude Code, Codex, Cursor, or VS Code Copilot to Codiedev for org-wide session capture and artifact collaboration",
5
5
  "bin": {
6
6
  "codiedev": "dist/cli.js",