newtype-profile 1.0.63 → 1.0.64

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/dist/cli/index.js CHANGED
@@ -2253,7 +2253,7 @@ var require_picocolors = __commonJS((exports, module) => {
2253
2253
  var require_package = __commonJS((exports, module) => {
2254
2254
  module.exports = {
2255
2255
  name: "newtype-profile",
2256
- version: "1.0.63",
2256
+ version: "1.0.64",
2257
2257
  description: "AI Agent Collaboration System for Content Creation - Based on oh-my-opencode",
2258
2258
  main: "dist/index.js",
2259
2259
  types: "dist/index.d.ts",
package/dist/index.js CHANGED
@@ -1980,11 +1980,11 @@ var require_codegen = __commonJS((exports) => {
1980
1980
  const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`;
1981
1981
  return `${varKind} ${this.name}${rhs};` + _n;
1982
1982
  }
1983
- optimizeNames(names, constants15) {
1983
+ optimizeNames(names, constants16) {
1984
1984
  if (!names[this.name.str])
1985
1985
  return;
1986
1986
  if (this.rhs)
1987
- this.rhs = optimizeExpr(this.rhs, names, constants15);
1987
+ this.rhs = optimizeExpr(this.rhs, names, constants16);
1988
1988
  return this;
1989
1989
  }
1990
1990
  get names() {
@@ -2002,10 +2002,10 @@ var require_codegen = __commonJS((exports) => {
2002
2002
  render({ _n }) {
2003
2003
  return `${this.lhs} = ${this.rhs};` + _n;
2004
2004
  }
2005
- optimizeNames(names, constants15) {
2005
+ optimizeNames(names, constants16) {
2006
2006
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
2007
2007
  return;
2008
- this.rhs = optimizeExpr(this.rhs, names, constants15);
2008
+ this.rhs = optimizeExpr(this.rhs, names, constants16);
2009
2009
  return this;
2010
2010
  }
2011
2011
  get names() {
@@ -2071,8 +2071,8 @@ var require_codegen = __commonJS((exports) => {
2071
2071
  optimizeNodes() {
2072
2072
  return `${this.code}` ? this : undefined;
2073
2073
  }
2074
- optimizeNames(names, constants15) {
2075
- this.code = optimizeExpr(this.code, names, constants15);
2074
+ optimizeNames(names, constants16) {
2075
+ this.code = optimizeExpr(this.code, names, constants16);
2076
2076
  return this;
2077
2077
  }
2078
2078
  get names() {
@@ -2102,12 +2102,12 @@ var require_codegen = __commonJS((exports) => {
2102
2102
  }
2103
2103
  return nodes.length > 0 ? this : undefined;
2104
2104
  }
2105
- optimizeNames(names, constants15) {
2105
+ optimizeNames(names, constants16) {
2106
2106
  const { nodes } = this;
2107
2107
  let i2 = nodes.length;
2108
2108
  while (i2--) {
2109
2109
  const n = nodes[i2];
2110
- if (n.optimizeNames(names, constants15))
2110
+ if (n.optimizeNames(names, constants16))
2111
2111
  continue;
2112
2112
  subtractNames(names, n.names);
2113
2113
  nodes.splice(i2, 1);
@@ -2164,12 +2164,12 @@ var require_codegen = __commonJS((exports) => {
2164
2164
  return;
2165
2165
  return this;
2166
2166
  }
2167
- optimizeNames(names, constants15) {
2167
+ optimizeNames(names, constants16) {
2168
2168
  var _a;
2169
- this.else = (_a = this.else) === null || _a === undefined ? undefined : _a.optimizeNames(names, constants15);
2170
- if (!(super.optimizeNames(names, constants15) || this.else))
2169
+ this.else = (_a = this.else) === null || _a === undefined ? undefined : _a.optimizeNames(names, constants16);
2170
+ if (!(super.optimizeNames(names, constants16) || this.else))
2171
2171
  return;
2172
- this.condition = optimizeExpr(this.condition, names, constants15);
2172
+ this.condition = optimizeExpr(this.condition, names, constants16);
2173
2173
  return this;
2174
2174
  }
2175
2175
  get names() {
@@ -2194,10 +2194,10 @@ var require_codegen = __commonJS((exports) => {
2194
2194
  render(opts) {
2195
2195
  return `for(${this.iteration})` + super.render(opts);
2196
2196
  }
2197
- optimizeNames(names, constants15) {
2198
- if (!super.optimizeNames(names, constants15))
2197
+ optimizeNames(names, constants16) {
2198
+ if (!super.optimizeNames(names, constants16))
2199
2199
  return;
2200
- this.iteration = optimizeExpr(this.iteration, names, constants15);
2200
+ this.iteration = optimizeExpr(this.iteration, names, constants16);
2201
2201
  return this;
2202
2202
  }
2203
2203
  get names() {
@@ -2235,10 +2235,10 @@ var require_codegen = __commonJS((exports) => {
2235
2235
  render(opts) {
2236
2236
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
2237
2237
  }
2238
- optimizeNames(names, constants15) {
2239
- if (!super.optimizeNames(names, constants15))
2238
+ optimizeNames(names, constants16) {
2239
+ if (!super.optimizeNames(names, constants16))
2240
2240
  return;
2241
- this.iterable = optimizeExpr(this.iterable, names, constants15);
2241
+ this.iterable = optimizeExpr(this.iterable, names, constants16);
2242
2242
  return this;
2243
2243
  }
2244
2244
  get names() {
@@ -2283,11 +2283,11 @@ var require_codegen = __commonJS((exports) => {
2283
2283
  (_b = this.finally) === null || _b === undefined || _b.optimizeNodes();
2284
2284
  return this;
2285
2285
  }
2286
- optimizeNames(names, constants15) {
2286
+ optimizeNames(names, constants16) {
2287
2287
  var _a, _b;
2288
- super.optimizeNames(names, constants15);
2289
- (_a = this.catch) === null || _a === undefined || _a.optimizeNames(names, constants15);
2290
- (_b = this.finally) === null || _b === undefined || _b.optimizeNames(names, constants15);
2288
+ super.optimizeNames(names, constants16);
2289
+ (_a = this.catch) === null || _a === undefined || _a.optimizeNames(names, constants16);
2290
+ (_b = this.finally) === null || _b === undefined || _b.optimizeNames(names, constants16);
2291
2291
  return this;
2292
2292
  }
2293
2293
  get names() {
@@ -2561,7 +2561,7 @@ var require_codegen = __commonJS((exports) => {
2561
2561
  function addExprNames(names, from) {
2562
2562
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
2563
2563
  }
2564
- function optimizeExpr(expr, names, constants15) {
2564
+ function optimizeExpr(expr, names, constants16) {
2565
2565
  if (expr instanceof code_1.Name)
2566
2566
  return replaceName(expr);
2567
2567
  if (!canOptimize(expr))
@@ -2576,14 +2576,14 @@ var require_codegen = __commonJS((exports) => {
2576
2576
  return items;
2577
2577
  }, []));
2578
2578
  function replaceName(n) {
2579
- const c = constants15[n.str];
2579
+ const c = constants16[n.str];
2580
2580
  if (c === undefined || names[n.str] !== 1)
2581
2581
  return n;
2582
2582
  delete names[n.str];
2583
2583
  return c;
2584
2584
  }
2585
2585
  function canOptimize(e2) {
2586
- return e2 instanceof code_1._Code && e2._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants15[c.str] !== undefined);
2586
+ return e2 instanceof code_1._Code && e2._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants16[c.str] !== undefined);
2587
2587
  }
2588
2588
  }
2589
2589
  function subtractNames(names, from) {
@@ -3030,37 +3030,37 @@ var require_dataType = __commonJS((exports) => {
3030
3030
  DataType2[DataType2["Wrong"] = 1] = "Wrong";
3031
3031
  })(DataType || (exports.DataType = DataType = {}));
3032
3032
  function getSchemaTypes(schema2) {
3033
- const types19 = getJSONTypes(schema2.type);
3034
- const hasNull = types19.includes("null");
3033
+ const types20 = getJSONTypes(schema2.type);
3034
+ const hasNull = types20.includes("null");
3035
3035
  if (hasNull) {
3036
3036
  if (schema2.nullable === false)
3037
3037
  throw new Error("type: null contradicts nullable: false");
3038
3038
  } else {
3039
- if (!types19.length && schema2.nullable !== undefined) {
3039
+ if (!types20.length && schema2.nullable !== undefined) {
3040
3040
  throw new Error('"nullable" cannot be used without "type"');
3041
3041
  }
3042
3042
  if (schema2.nullable === true)
3043
- types19.push("null");
3043
+ types20.push("null");
3044
3044
  }
3045
- return types19;
3045
+ return types20;
3046
3046
  }
3047
3047
  exports.getSchemaTypes = getSchemaTypes;
3048
3048
  function getJSONTypes(ts) {
3049
- const types19 = Array.isArray(ts) ? ts : ts ? [ts] : [];
3050
- if (types19.every(rules_1.isJSONType))
3051
- return types19;
3052
- throw new Error("type must be JSONType or JSONType[]: " + types19.join(","));
3049
+ const types20 = Array.isArray(ts) ? ts : ts ? [ts] : [];
3050
+ if (types20.every(rules_1.isJSONType))
3051
+ return types20;
3052
+ throw new Error("type must be JSONType or JSONType[]: " + types20.join(","));
3053
3053
  }
3054
3054
  exports.getJSONTypes = getJSONTypes;
3055
- function coerceAndCheckDataType(it, types19) {
3055
+ function coerceAndCheckDataType(it, types20) {
3056
3056
  const { gen, data, opts } = it;
3057
- const coerceTo = coerceToTypes(types19, opts.coerceTypes);
3058
- const checkTypes = types19.length > 0 && !(coerceTo.length === 0 && types19.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types19[0]));
3057
+ const coerceTo = coerceToTypes(types20, opts.coerceTypes);
3058
+ const checkTypes = types20.length > 0 && !(coerceTo.length === 0 && types20.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types20[0]));
3059
3059
  if (checkTypes) {
3060
- const wrongType = checkDataTypes(types19, data, opts.strictNumbers, DataType.Wrong);
3060
+ const wrongType = checkDataTypes(types20, data, opts.strictNumbers, DataType.Wrong);
3061
3061
  gen.if(wrongType, () => {
3062
3062
  if (coerceTo.length)
3063
- coerceData(it, types19, coerceTo);
3063
+ coerceData(it, types20, coerceTo);
3064
3064
  else
3065
3065
  reportTypeError(it);
3066
3066
  });
@@ -3069,15 +3069,15 @@ var require_dataType = __commonJS((exports) => {
3069
3069
  }
3070
3070
  exports.coerceAndCheckDataType = coerceAndCheckDataType;
3071
3071
  var COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
3072
- function coerceToTypes(types19, coerceTypes) {
3073
- return coerceTypes ? types19.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
3072
+ function coerceToTypes(types20, coerceTypes) {
3073
+ return coerceTypes ? types20.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
3074
3074
  }
3075
- function coerceData(it, types19, coerceTo) {
3075
+ function coerceData(it, types20, coerceTo) {
3076
3076
  const { gen, data, opts } = it;
3077
3077
  const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
3078
3078
  const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
3079
3079
  if (opts.coerceTypes === "array") {
3080
- gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types19, data, opts.strictNumbers), () => gen.assign(coerced, data)));
3080
+ gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types20, data, opts.strictNumbers), () => gen.assign(coerced, data)));
3081
3081
  }
3082
3082
  gen.if((0, codegen_1._)`${coerced} !== undefined`);
3083
3083
  for (const t of coerceTo) {
@@ -3153,19 +3153,19 @@ var require_dataType = __commonJS((exports) => {
3153
3153
  return checkDataType(dataTypes[0], data, strictNums, correct);
3154
3154
  }
3155
3155
  let cond;
3156
- const types19 = (0, util_1.toHash)(dataTypes);
3157
- if (types19.array && types19.object) {
3156
+ const types20 = (0, util_1.toHash)(dataTypes);
3157
+ if (types20.array && types20.object) {
3158
3158
  const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
3159
- cond = types19.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
3160
- delete types19.null;
3161
- delete types19.array;
3162
- delete types19.object;
3159
+ cond = types20.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
3160
+ delete types20.null;
3161
+ delete types20.array;
3162
+ delete types20.object;
3163
3163
  } else {
3164
3164
  cond = codegen_1.nil;
3165
3165
  }
3166
- if (types19.number)
3167
- delete types19.integer;
3168
- for (const t in types19)
3166
+ if (types20.number)
3167
+ delete types20.integer;
3168
+ for (const t in types20)
3169
3169
  cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
3170
3170
  return cond;
3171
3171
  }
@@ -3953,9 +3953,9 @@ var require_validate = __commonJS((exports) => {
3953
3953
  function typeAndKeywords(it, errsCount) {
3954
3954
  if (it.opts.jtd)
3955
3955
  return schemaKeywords(it, [], false, errsCount);
3956
- const types19 = (0, dataType_1.getSchemaTypes)(it.schema);
3957
- const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types19);
3958
- schemaKeywords(it, types19, !checkedTypes, errsCount);
3956
+ const types20 = (0, dataType_1.getSchemaTypes)(it.schema);
3957
+ const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types20);
3958
+ schemaKeywords(it, types20, !checkedTypes, errsCount);
3959
3959
  }
3960
3960
  function checkRefsAndKeywords(it) {
3961
3961
  const { schema: schema2, errSchemaPath, opts, self } = it;
@@ -4005,7 +4005,7 @@ var require_validate = __commonJS((exports) => {
4005
4005
  if (items instanceof codegen_1.Name)
4006
4006
  gen.assign((0, codegen_1._)`${evaluated}.items`, items);
4007
4007
  }
4008
- function schemaKeywords(it, types19, typeErrors, errsCount) {
4008
+ function schemaKeywords(it, types20, typeErrors, errsCount) {
4009
4009
  const { gen, schema: schema2, data, allErrors, opts, self } = it;
4010
4010
  const { RULES } = self;
4011
4011
  if (schema2.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema2, RULES))) {
@@ -4013,7 +4013,7 @@ var require_validate = __commonJS((exports) => {
4013
4013
  return;
4014
4014
  }
4015
4015
  if (!opts.jtd)
4016
- checkStrictTypes(it, types19);
4016
+ checkStrictTypes(it, types20);
4017
4017
  gen.block(() => {
4018
4018
  for (const group of RULES.rules)
4019
4019
  groupKeywords(group);
@@ -4025,7 +4025,7 @@ var require_validate = __commonJS((exports) => {
4025
4025
  if (group.type) {
4026
4026
  gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
4027
4027
  iterateKeywords(it, group);
4028
- if (types19.length === 1 && types19[0] === group.type && typeErrors) {
4028
+ if (types20.length === 1 && types20[0] === group.type && typeErrors) {
4029
4029
  gen.else();
4030
4030
  (0, dataType_2.reportTypeError)(it);
4031
4031
  }
@@ -4049,27 +4049,27 @@ var require_validate = __commonJS((exports) => {
4049
4049
  }
4050
4050
  });
4051
4051
  }
4052
- function checkStrictTypes(it, types19) {
4052
+ function checkStrictTypes(it, types20) {
4053
4053
  if (it.schemaEnv.meta || !it.opts.strictTypes)
4054
4054
  return;
4055
- checkContextTypes(it, types19);
4055
+ checkContextTypes(it, types20);
4056
4056
  if (!it.opts.allowUnionTypes)
4057
- checkMultipleTypes(it, types19);
4057
+ checkMultipleTypes(it, types20);
4058
4058
  checkKeywordTypes(it, it.dataTypes);
4059
4059
  }
4060
- function checkContextTypes(it, types19) {
4061
- if (!types19.length)
4060
+ function checkContextTypes(it, types20) {
4061
+ if (!types20.length)
4062
4062
  return;
4063
4063
  if (!it.dataTypes.length) {
4064
- it.dataTypes = types19;
4064
+ it.dataTypes = types20;
4065
4065
  return;
4066
4066
  }
4067
- types19.forEach((t) => {
4067
+ types20.forEach((t) => {
4068
4068
  if (!includesType(it.dataTypes, t)) {
4069
4069
  strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
4070
4070
  }
4071
4071
  });
4072
- narrowSchemaTypes(it, types19);
4072
+ narrowSchemaTypes(it, types20);
4073
4073
  }
4074
4074
  function checkMultipleTypes(it, ts) {
4075
4075
  if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
@@ -45321,6 +45321,277 @@ var session_info = tool({
45321
45321
  }
45322
45322
  }
45323
45323
  });
45324
+ // src/tools/knowledge-base/constants.ts
45325
+ var TOOL_DESCRIPTION = `Progressive disclosure tool for accessing memory and knowledge.
45326
+
45327
+ Three actions, from lightweight to detailed:
45328
+
45329
+ 1. list \u2014 Browse all memory entries (dates, tags, summary headlines)
45330
+ knowledge_base({ action: "list" })
45331
+
45332
+ 2. search \u2014 Find relevant memories with matching snippets
45333
+ knowledge_base({ action: "search", query: "API design discussion" })
45334
+
45335
+ 3. get \u2014 Retrieve full content of a specific memory entry
45336
+ knowledge_base({ action: "get", id: "2026-02-20/ses_abc123" })
45337
+
45338
+ Sources: "memory" (default, conversation memories), "archive" (long-term MEMORY.md), "knowledge" (KNOWLEDGE.md)
45339
+ Only "memory" source is currently supported.`;
45340
+
45341
+ // src/tools/knowledge-base/memory-source.ts
45342
+ import { existsSync as existsSync51, readdirSync as readdirSync19, readFileSync as readFileSync32 } from "fs";
45343
+ import { join as join59 } from "path";
45344
+
45345
+ // src/tools/knowledge-base/utils.ts
45346
+ function formatMemoryList(entries) {
45347
+ if (entries.length === 0) {
45348
+ return "No memory entries found.";
45349
+ }
45350
+ const lines = [
45351
+ "| Date | Session | Tags | Decisions | Summary |",
45352
+ "|------|---------|------|-----------|---------|"
45353
+ ];
45354
+ for (const entry of entries) {
45355
+ const sessionDisplay = entry.sessionID ? entry.sessionID.slice(0, 12) : "-";
45356
+ const tagsDisplay = entry.tags.length > 0 ? entry.tags.join(", ") : "-";
45357
+ const summaryDisplay = entry.summaryLine.length > 50 ? entry.summaryLine.slice(0, 50) + "..." : entry.summaryLine;
45358
+ lines.push(`| ${entry.date} | ${sessionDisplay} | ${tagsDisplay} | ${entry.decisionsCount} | ${summaryDisplay} |`);
45359
+ }
45360
+ return lines.join(`
45361
+ `);
45362
+ }
45363
+ function formatMemorySearchResults(results, query) {
45364
+ if (results.length === 0) {
45365
+ return `No matches found for "${query}".`;
45366
+ }
45367
+ const lines = [`Found ${results.length} match(es) for "${query}":
45368
+ `];
45369
+ for (let i2 = 0;i2 < results.length; i2++) {
45370
+ const result = results[i2];
45371
+ const sessionDisplay = result.sessionID ? ` (${result.sessionID.slice(0, 12)})` : "";
45372
+ const tagsDisplay = result.tags.length > 0 ? ` [${result.tags.join(", ")}]` : "";
45373
+ lines.push(`${i2 + 1}. **${result.date}${sessionDisplay}**${tagsDisplay}`);
45374
+ lines.push(` ${result.snippet}`);
45375
+ if (result.matchCount > 1) {
45376
+ lines.push(` _(${result.matchCount} matches in this entry)_`);
45377
+ }
45378
+ lines.push("");
45379
+ }
45380
+ return lines.join(`
45381
+ `);
45382
+ }
45383
+ function extractSnippet(text, query, contextChars = 80) {
45384
+ const lowerText = text.toLowerCase();
45385
+ const lowerQuery = query.toLowerCase();
45386
+ const matchIndex = lowerText.indexOf(lowerQuery);
45387
+ if (matchIndex === -1) {
45388
+ return text.slice(0, contextChars * 2) + (text.length > contextChars * 2 ? "..." : "");
45389
+ }
45390
+ const start = Math.max(0, matchIndex - contextChars);
45391
+ const end = Math.min(text.length, matchIndex + query.length + contextChars);
45392
+ let snippet2 = text.slice(start, end);
45393
+ if (start > 0) {
45394
+ snippet2 = "..." + snippet2;
45395
+ }
45396
+ if (end < text.length) {
45397
+ snippet2 = snippet2 + "...";
45398
+ }
45399
+ return snippet2.replace(/\n+/g, " ").trim();
45400
+ }
45401
+ function extractSummaryLine(rawBlock) {
45402
+ const lines = rawBlock.split(`
45403
+ `);
45404
+ for (const line of lines) {
45405
+ const trimmed = line.trim();
45406
+ if (!trimmed)
45407
+ continue;
45408
+ if (trimmed.startsWith("#"))
45409
+ continue;
45410
+ if (trimmed.startsWith("SessionID:"))
45411
+ continue;
45412
+ if (trimmed.startsWith("Full transcript:"))
45413
+ continue;
45414
+ if (trimmed.startsWith("**") && trimmed.endsWith(":**"))
45415
+ continue;
45416
+ return trimmed;
45417
+ }
45418
+ return "";
45419
+ }
45420
+
45421
+ // src/tools/knowledge-base/memory-source.ts
45422
+ function listMemoryEntries(projectDir, limit) {
45423
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45424
+ if (!existsSync51(memoryDir)) {
45425
+ return "No memory entries found.";
45426
+ }
45427
+ const files = readdirSync19(memoryDir).filter((f) => f.endsWith(".md") && f !== "full").sort().reverse();
45428
+ const entries = [];
45429
+ const effectiveLimit = limit ?? 20;
45430
+ for (const file2 of files) {
45431
+ if (entries.length >= effectiveLimit)
45432
+ break;
45433
+ const filePath = join59(memoryDir, file2);
45434
+ const dateMatch = file2.match(/^(\d{4}-\d{2}-\d{2})\.md$/);
45435
+ if (!dateMatch)
45436
+ continue;
45437
+ const date5 = dateMatch[1];
45438
+ try {
45439
+ const content = readFileSync32(filePath, "utf-8");
45440
+ const sessions = parseDailyLogSessions(content);
45441
+ for (const session of sessions) {
45442
+ if (entries.length >= effectiveLimit)
45443
+ break;
45444
+ entries.push({
45445
+ date: date5,
45446
+ sessionID: session.sessionID,
45447
+ tags: session.tags,
45448
+ decisionsCount: session.decisions.length,
45449
+ todosCount: session.todos.length,
45450
+ summaryLine: extractSummaryLine(session.raw)
45451
+ });
45452
+ }
45453
+ } catch {
45454
+ continue;
45455
+ }
45456
+ }
45457
+ return formatMemoryList(entries);
45458
+ }
45459
+ function searchMemoryEntries(projectDir, query, limit) {
45460
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45461
+ if (!existsSync51(memoryDir)) {
45462
+ return `No matches found for "${query}".`;
45463
+ }
45464
+ const files = readdirSync19(memoryDir).filter((f) => f.endsWith(".md") && f !== "full").sort().reverse();
45465
+ const results = [];
45466
+ const effectiveLimit = limit ?? 10;
45467
+ const lowerQuery = query.toLowerCase();
45468
+ for (const file2 of files) {
45469
+ if (results.length >= effectiveLimit)
45470
+ break;
45471
+ const filePath = join59(memoryDir, file2);
45472
+ const dateMatch = file2.match(/^(\d{4}-\d{2}-\d{2})\.md$/);
45473
+ if (!dateMatch)
45474
+ continue;
45475
+ const date5 = dateMatch[1];
45476
+ try {
45477
+ const content = readFileSync32(filePath, "utf-8");
45478
+ const sessions = parseDailyLogSessions(content);
45479
+ for (const session of sessions) {
45480
+ if (results.length >= effectiveLimit)
45481
+ break;
45482
+ const lowerRaw = session.raw.toLowerCase();
45483
+ if (!lowerRaw.includes(lowerQuery))
45484
+ continue;
45485
+ const matches = lowerRaw.split(lowerQuery).length - 1;
45486
+ results.push({
45487
+ date: date5,
45488
+ sessionID: session.sessionID,
45489
+ tags: session.tags,
45490
+ snippet: extractSnippet(session.raw, query),
45491
+ matchCount: matches
45492
+ });
45493
+ }
45494
+ } catch {
45495
+ continue;
45496
+ }
45497
+ }
45498
+ return formatMemorySearchResults(results, query);
45499
+ }
45500
+ function getMemoryEntry(projectDir, id, includeFull) {
45501
+ const parts = id.split("/");
45502
+ const date5 = parts[0];
45503
+ const sessionID = parts[1];
45504
+ const dateMatch = date5.match(/^\d{4}-\d{2}-\d{2}$/);
45505
+ if (!dateMatch) {
45506
+ return `Invalid id format: ${id}. Expected YYYY-MM-DD or YYYY-MM-DD/sessionID`;
45507
+ }
45508
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45509
+ const filePath = join59(memoryDir, `${date5}.md`);
45510
+ if (!existsSync51(filePath)) {
45511
+ return `Memory entry not found: ${id}`;
45512
+ }
45513
+ try {
45514
+ const content = readFileSync32(filePath, "utf-8");
45515
+ const sessions = parseDailyLogSessions(content);
45516
+ if (!sessionID) {
45517
+ const output2 = sessions.map((s) => s.raw).join(`
45518
+
45519
+ ---
45520
+
45521
+ `);
45522
+ return output2 || `Memory entry not found: ${id}`;
45523
+ }
45524
+ const session = sessions.find((s) => s.sessionID === sessionID || s.sessionID?.startsWith(sessionID));
45525
+ if (!session) {
45526
+ return `Memory entry not found: ${id}`;
45527
+ }
45528
+ let output = session.raw;
45529
+ if (includeFull && session.sessionID) {
45530
+ const fullPath = getFullTranscriptPath(projectDir, session.sessionID);
45531
+ if (existsSync51(fullPath)) {
45532
+ try {
45533
+ const fullContent = readFileSync32(fullPath, "utf-8");
45534
+ output += `
45535
+
45536
+ ---
45537
+
45538
+ ## Full Transcript
45539
+
45540
+ ` + fullContent;
45541
+ } catch {
45542
+ output += `
45543
+
45544
+ _(Full transcript could not be read)_`;
45545
+ }
45546
+ } else {
45547
+ output += `
45548
+
45549
+ _(Full transcript not available)_`;
45550
+ }
45551
+ }
45552
+ return output;
45553
+ } catch (error45) {
45554
+ return `Error reading memory entry: ${error45 instanceof Error ? error45.message : String(error45)}`;
45555
+ }
45556
+ }
45557
+
45558
+ // src/tools/knowledge-base/tools.ts
45559
+ var knowledge_base = tool({
45560
+ description: TOOL_DESCRIPTION,
45561
+ args: {
45562
+ action: tool.schema.enum(["list", "search", "get"]).describe("Action: list (browse), search (find), get (retrieve full)"),
45563
+ source: tool.schema.enum(["memory", "archive", "knowledge"]).optional().describe("Data source (default: memory)"),
45564
+ query: tool.schema.string().optional().describe("Search query (required for search action)"),
45565
+ id: tool.schema.string().optional().describe("Entry ID in format YYYY-MM-DD/sessionID (required for get action)"),
45566
+ limit: tool.schema.number().optional().describe("Max results to return (default: 20 for list, 10 for search)"),
45567
+ include_full: tool.schema.boolean().optional().describe("Include full transcript in get results (default: false)")
45568
+ },
45569
+ execute: async (args, _context) => {
45570
+ try {
45571
+ const source = args.source ?? "memory";
45572
+ const projectDir = process.cwd();
45573
+ if (source !== "memory") {
45574
+ return `Source "${source}" is not yet supported. Currently available: memory`;
45575
+ }
45576
+ switch (args.action) {
45577
+ case "list":
45578
+ return listMemoryEntries(projectDir, args.limit);
45579
+ case "search":
45580
+ if (!args.query)
45581
+ return "Error: query is required for search action";
45582
+ return searchMemoryEntries(projectDir, args.query, args.limit);
45583
+ case "get":
45584
+ if (!args.id)
45585
+ return "Error: id is required for get action";
45586
+ return getMemoryEntry(projectDir, args.id, args.include_full);
45587
+ default:
45588
+ return `Unknown action: ${args.action}. Available: list, search, get`;
45589
+ }
45590
+ } catch (error45) {
45591
+ return `Error: ${error45 instanceof Error ? error45.message : String(error45)}`;
45592
+ }
45593
+ }
45594
+ });
45324
45595
  // src/tools/interactive-bash/tools.ts
45325
45596
  import { spawn as spawn4 } from "child_process";
45326
45597
 
@@ -45491,7 +45762,7 @@ Skills provide specialized knowledge and step-by-step guidance.
45491
45762
  Use this when a task matches an available skill's description.`;
45492
45763
  // src/tools/skill/tools.ts
45493
45764
  import { dirname as dirname14 } from "path";
45494
- import { readFileSync as readFileSync32 } from "fs";
45765
+ import { readFileSync as readFileSync33 } from "fs";
45495
45766
  function loadedSkillToInfo(skill) {
45496
45767
  return {
45497
45768
  name: skill.name,
@@ -45534,7 +45805,7 @@ async function extractSkillBody(skill) {
45534
45805
  return templateMatch2 ? templateMatch2[1].trim() : fullTemplate;
45535
45806
  }
45536
45807
  if (skill.path) {
45537
- const content = readFileSync32(skill.path, "utf-8");
45808
+ const content = readFileSync33(skill.path, "utf-8");
45538
45809
  const { body } = parseFrontmatter(content);
45539
45810
  return body.trim();
45540
45811
  }
@@ -45559,15 +45830,15 @@ async function formatMcpCapabilities(skill, manager, sessionID) {
45559
45830
  sections.push(`### ${serverName}`);
45560
45831
  sections.push("");
45561
45832
  try {
45562
- const [tools4, resources, prompts] = await Promise.all([
45833
+ const [tools5, resources, prompts] = await Promise.all([
45563
45834
  manager.listTools(info, context).catch(() => []),
45564
45835
  manager.listResources(info, context).catch(() => []),
45565
45836
  manager.listPrompts(info, context).catch(() => [])
45566
45837
  ]);
45567
- if (tools4.length > 0) {
45838
+ if (tools5.length > 0) {
45568
45839
  sections.push("**Tools:**");
45569
45840
  sections.push("");
45570
- for (const t of tools4) {
45841
+ for (const t of tools5) {
45571
45842
  sections.push(`#### \`${t.name}\``);
45572
45843
  if (t.description) {
45573
45844
  sections.push(t.description);
@@ -45586,7 +45857,7 @@ async function formatMcpCapabilities(skill, manager, sessionID) {
45586
45857
  if (prompts.length > 0) {
45587
45858
  sections.push(`**Prompts**: ${prompts.map((p2) => p2.name).join(", ")}`);
45588
45859
  }
45589
- if (tools4.length === 0 && resources.length === 0 && prompts.length === 0) {
45860
+ if (tools5.length === 0 && resources.length === 0 && prompts.length === 0) {
45590
45861
  sections.push("*No capabilities discovered*");
45591
45862
  }
45592
45863
  } catch (error45) {
@@ -46148,8 +46419,8 @@ If the requested information is not found, clearly state what is missing.`;
46148
46419
  });
46149
46420
  }
46150
46421
  // src/tools/chief-task/tools.ts
46151
- import { existsSync as existsSync51, readdirSync as readdirSync19 } from "fs";
46152
- import { join as join59 } from "path";
46422
+ import { existsSync as existsSync52, readdirSync as readdirSync20 } from "fs";
46423
+ import { join as join60 } from "path";
46153
46424
 
46154
46425
  // src/tools/chief-task/constants.ts
46155
46426
  var RESEARCH_CATEGORY_PROMPT_APPEND = `<Category_Context>
@@ -46724,14 +46995,14 @@ function parseModelString(model) {
46724
46995
  return;
46725
46996
  }
46726
46997
  function getMessageDir12(sessionID) {
46727
- if (!existsSync51(MESSAGE_STORAGE))
46998
+ if (!existsSync52(MESSAGE_STORAGE))
46728
46999
  return null;
46729
- const directPath = join59(MESSAGE_STORAGE, sessionID);
46730
- if (existsSync51(directPath))
47000
+ const directPath = join60(MESSAGE_STORAGE, sessionID);
47001
+ if (existsSync52(directPath))
46731
47002
  return directPath;
46732
- for (const dir of readdirSync19(MESSAGE_STORAGE)) {
46733
- const sessionPath = join59(MESSAGE_STORAGE, dir, sessionID);
46734
- if (existsSync51(sessionPath))
47003
+ for (const dir of readdirSync20(MESSAGE_STORAGE)) {
47004
+ const sessionPath = join60(MESSAGE_STORAGE, dir, sessionID);
47005
+ if (existsSync52(sessionPath))
46735
47006
  return sessionPath;
46736
47007
  }
46737
47008
  return null;
@@ -47173,7 +47444,8 @@ var builtinTools = {
47173
47444
  session_list,
47174
47445
  session_read,
47175
47446
  session_search,
47176
- session_info
47447
+ session_info,
47448
+ knowledge_base
47177
47449
  };
47178
47450
  // src/features/background-agent/concurrency.ts
47179
47451
  class ConcurrencyManager {
@@ -50016,11 +50288,11 @@ class Client extends Protocol {
50016
50288
  isToolTaskRequired(toolName) {
50017
50289
  return this._cachedRequiredTaskTools.has(toolName);
50018
50290
  }
50019
- cacheToolMetadata(tools4) {
50291
+ cacheToolMetadata(tools5) {
50020
50292
  this._cachedToolOutputValidators.clear();
50021
50293
  this._cachedKnownTaskTools.clear();
50022
50294
  this._cachedRequiredTaskTools.clear();
50023
- for (const tool3 of tools4) {
50295
+ for (const tool3 of tools5) {
50024
50296
  if (tool3.outputSchema) {
50025
50297
  const toolValidator = this._jsonSchemaValidator.getValidator(tool3.outputSchema);
50026
50298
  this._cachedToolOutputValidators.set(tool3.name, toolValidator);
@@ -50935,6 +51207,7 @@ var CHIEF_ALLOWED_TOOLS = [
50935
51207
  "read",
50936
51208
  "glob",
50937
51209
  "grep",
51210
+ "knowledge_base",
50938
51211
  "lsp_hover",
50939
51212
  "lsp_goto_definition",
50940
51213
  "lsp_find_references",
@@ -51213,44 +51486,37 @@ When discussion crystallizes into a task:
51213
51486
 
51214
51487
  <Memory_System>
51215
51488
  ## \u8BB0\u5FC6\u7CFB\u7EDF
51489
+ \u4F60\u6709\u4E00\u4E2A\u8DE8\u4F1A\u8BDD\u8BB0\u5FC6\u7CFB\u7EDF\u3002\u901A\u8FC7 \`knowledge_base\` \u5DE5\u5177\u8BBF\u95EE\uFF0C**\u6E10\u8FDB\u5F0F**\u83B7\u53D6\u4FE1\u606F\u3002
51216
51490
 
51217
- \u4F60\u6709\u4E00\u4E2A\u53CC\u5C42\u6587\u4EF6\u7CFB\u7EDF\u8BB0\u5FC6\uFF0C\u7528\u4E8E\u8DE8\u4F1A\u8BDD\u4FDD\u7559\u91CD\u8981\u4FE1\u606F\u3002
51218
-
51219
- ### \u5B58\u50A8\u7ED3\u6784
51220
-
51221
- | \u5C42\u7EA7 | \u8DEF\u5F84 | \u7528\u9014 |
51222
- |------|------|------|
51223
- | \u77E5\u8BC6\u5E93 | \`KNOWLEDGE.md\` | \u9879\u76EE\u7EA7\u77E5\u8BC6\uFF08\u7ED3\u6784\u5316\u4E8B\u5B9E\uFF09 |
51224
- | \u957F\u671F\u8BB0\u5FC6 | \`.opencode/MEMORY.md\` | \u5F52\u6863\u7CBE\u534E\uFF087\u5929\u540E\u81EA\u52A8\u6574\u7406\uFF09 |
51225
- | \u65E5\u8BB0\u6458\u8981 | \`.opencode/memory/YYYY-MM-DD.md\` | \u6BCF\u65E5\u5BF9\u8BDD\u6458\u8981\uFF08\u542B SessionID\uFF09 |
51226
- | \u5B8C\u6574\u5BF9\u8BDD | \`.opencode/memory/full/<sessionID>.md\` | \u539F\u59CB\u5BF9\u8BDD\u5168\u6587 |
51491
+ ### \u4F7F\u7528\u65B9\u5F0F\uFF08\u5148\u7C97\u540E\u7EC6\uFF09
51227
51492
 
51228
- ### \u68C0\u7D22\u6A21\u5F0F
51493
+ **\u7B2C\u4E00\u6B65\uFF1A\u6D4F\u89C8\u6982\u89C8**
51494
+ \`\`\`
51495
+ knowledge_base({ action: "list" })
51496
+ \`\`\`
51497
+ \u2192 \u8FD4\u56DE\u6240\u6709\u8BB0\u5FC6\u6761\u76EE\u7684\u65E5\u671F\u3001\u6807\u7B7E\u3001\u51B3\u7B56\u6570\u3001\u6458\u8981\u9996\u884C
51229
51498
 
51230
- **\u6A21\u5F0F 1\uFF1A\u5FEB\u901F\u68C0\u7D22**\uFF08\u627E\u5F97\u5230\u3001\u626B\u5F97\u5FEB\u3001\u53EF\u805A\u5408\uFF09
51499
+ **\u7B2C\u4E8C\u6B65\uFF1A\u641C\u7D22\u5B9A\u4F4D**
51231
51500
  \`\`\`
51232
- grep("\u5173\u952E\u8BCD", ".opencode/memory/") # \u641C\u7D22\u6240\u6709\u6458\u8981
51233
- read(".opencode/MEMORY.md") # \u67E5\u770B\u957F\u671F\u8BB0\u5FC6\u7CBE\u534E
51234
- glob(".opencode/memory/*.md") # \u5217\u51FA\u6240\u6709\u65E5\u8BB0
51501
+ knowledge_base({ action: "search", query: "API\u8BBE\u8BA1" })
51235
51502
  \`\`\`
51236
- \u8FD4\u56DE\uFF1ATopic + Key Points + SessionID
51503
+ \u2192 \u8FD4\u56DE\u5339\u914D\u7684\u6761\u76EE + \u5173\u952E\u7247\u6BB5
51237
51504
 
51238
- **\u6A21\u5F0F 2\uFF1A\u5B8C\u6574\u8FFD\u6EAF**\uFF08\u53EF\u8FD8\u539F\u3001\u53EF\u5BA1\u8BA1\u3001\u53EF\u5F15\u7528\uFF09
51505
+ **\u7B2C\u4E09\u6B65\uFF1A\u83B7\u53D6\u8BE6\u60C5**
51239
51506
  \`\`\`
51240
- # \u4ECE\u6458\u8981\u4E2D\u627E\u5230 SessionID\uFF08\u5982 ses_abc123\uFF09
51241
- read(".opencode/memory/full/ses_abc123.md")
51507
+ knowledge_base({ action: "get", id: "2026-02-20/ses_abc123" })
51242
51508
  \`\`\`
51243
- \u8FD4\u56DE\uFF1A\u539F\u59CB\u5BF9\u8BDD\u5168\u6587\uFF0C\u53EF\u5F15\u7528\u5177\u4F53\u5185\u5BB9
51509
+ \u2192 \u8FD4\u56DE\u5B8C\u6574\u6458\u8981\u548C\u51B3\u7B56
51510
+ \u2192 \u52A0 \`include_full: true\` \u53EF\u83B7\u53D6\u539F\u59CB\u5BF9\u8BDD\u5168\u6587
51244
51511
 
51245
51512
  ### \u4F55\u65F6\u4F7F\u7528
51246
51513
 
51247
- | \u89E6\u53D1\u4FE1\u53F7 | \u68C0\u7D22\u6A21\u5F0F |
51248
- |----------|----------|
51249
- | "\u4E4B\u524D\u8BA8\u8BBA\u8FC7"\u3001"\u4E0A\u6B21"\u3001"\u6211\u4EEC\u51B3\u5B9A\u7684" | \u5FEB\u901F\u68C0\u7D22 |
51250
- | "\u4F60\u8FD8\u8BB0\u5F97...\u5417"\u3001"\u5927\u6982\u4EC0\u4E48\u65F6\u5019" | \u5FEB\u901F\u68C0\u7D22 |
51251
- | "\u539F\u8BDD\u600E\u4E48\u8BF4\u7684"\u3001"\u5B8C\u6574\u4E0A\u4E0B\u6587" | \u5B8C\u6574\u8FFD\u6EAF |
51252
- | "\u90A3\u6B21\u5BF9\u8BDD\u7684\u7EC6\u8282" | \u5B8C\u6574\u8FFD\u6EAF |
51253
-
51514
+ | \u89E6\u53D1\u4FE1\u53F7 | \u64CD\u4F5C |
51515
+ |----------|------|
51516
+ | "\u4E4B\u524D\u8BA8\u8BBA\u8FC7"\u3001"\u4E0A\u6B21"\u3001"\u6211\u4EEC\u51B3\u5B9A\u7684" | search \u2192 get |
51517
+ | "\u4F60\u8FD8\u8BB0\u5F97...\u5417" | search |
51518
+ | "\u539F\u8BDD\u600E\u4E48\u8BF4\u7684"\u3001"\u5B8C\u6574\u4E0A\u4E0B\u6587" | get with include_full: true |
51519
+ | \u65B0\u4F1A\u8BDD\u5F00\u59CB\uFF0C\u9700\u8981\u4E86\u89E3\u4E0A\u4E0B\u6587 | list\uFF08\u6D4F\u89C8\u8FD1\u671F\uFF09 |
51254
51520
  **\u8BB0\u5FC6\u662F\u4F60\u7684\u8D44\u4EA7**\uFF1A\u5584\u7528\u5B83\u4FDD\u6301\u8FDE\u8D2F\u6027\uFF0C\u907F\u514D\u91CD\u590D\u8BA8\u8BBA\u5DF2\u51B3\u5B9A\u7684\u4E8B\u9879\u3002
51255
51521
  </Memory_System>`;
51256
51522
  var CHIEF_INNER_PERSONA = `<Philosophy>
@@ -51976,16 +52242,16 @@ function isGptModel(model) {
51976
52242
  return model.startsWith("openai/") || model.startsWith("github-copilot/gpt-");
51977
52243
  }
51978
52244
  // src/features/soul-loader/index.ts
51979
- import { existsSync as existsSync53, readFileSync as readFileSync34 } from "fs";
51980
- import { join as join61 } from "path";
52245
+ import { existsSync as existsSync54, readFileSync as readFileSync35 } from "fs";
52246
+ import { join as join62 } from "path";
51981
52247
  var SOUL_FILE_PATH = ".opencode/SOUL.md";
51982
52248
  function loadSoulFile(directory) {
51983
- const soulPath = join61(directory, SOUL_FILE_PATH);
51984
- if (!existsSync53(soulPath)) {
52249
+ const soulPath = join62(directory, SOUL_FILE_PATH);
52250
+ if (!existsSync54(soulPath)) {
51985
52251
  return;
51986
52252
  }
51987
52253
  try {
51988
- const content = readFileSync34(soulPath, "utf-8").trim();
52254
+ const content = readFileSync35(soulPath, "utf-8").trim();
51989
52255
  if (!content) {
51990
52256
  return;
51991
52257
  }
@@ -52322,7 +52588,7 @@ function createDeputyAgent(categoryConfig, promptAppend) {
52322
52588
  }
52323
52589
  // src/features/claude-code-command-loader/loader.ts
52324
52590
  import { promises as fs19 } from "fs";
52325
- import { join as join62, basename as basename6 } from "path";
52591
+ import { join as join63, basename as basename6 } from "path";
52326
52592
  import { homedir as homedir17 } from "os";
52327
52593
  async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
52328
52594
  try {
@@ -52353,7 +52619,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
52353
52619
  if (entry.isDirectory()) {
52354
52620
  if (entry.name.startsWith("."))
52355
52621
  continue;
52356
- const subDirPath = join62(commandsDir, entry.name);
52622
+ const subDirPath = join63(commandsDir, entry.name);
52357
52623
  const subPrefix = prefix ? `${prefix}:${entry.name}` : entry.name;
52358
52624
  const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
52359
52625
  commands.push(...subCommands);
@@ -52361,7 +52627,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
52361
52627
  }
52362
52628
  if (!isMarkdownFile(entry))
52363
52629
  continue;
52364
- const commandPath = join62(commandsDir, entry.name);
52630
+ const commandPath = join63(commandsDir, entry.name);
52365
52631
  const baseCommandName = basename6(entry.name, ".md");
52366
52632
  const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName;
52367
52633
  try {
@@ -52408,22 +52674,22 @@ function commandsToRecord(commands) {
52408
52674
  return result;
52409
52675
  }
52410
52676
  async function loadUserCommands() {
52411
- const userCommandsDir = join62(getClaudeConfigDir(), "commands");
52677
+ const userCommandsDir = join63(getClaudeConfigDir(), "commands");
52412
52678
  const commands = await loadCommandsFromDir(userCommandsDir, "user");
52413
52679
  return commandsToRecord(commands);
52414
52680
  }
52415
52681
  async function loadProjectCommands() {
52416
- const projectCommandsDir = join62(process.cwd(), ".claude", "commands");
52682
+ const projectCommandsDir = join63(process.cwd(), ".claude", "commands");
52417
52683
  const commands = await loadCommandsFromDir(projectCommandsDir, "project");
52418
52684
  return commandsToRecord(commands);
52419
52685
  }
52420
52686
  async function loadOpencodeGlobalCommands() {
52421
- const opencodeCommandsDir = join62(homedir17(), ".config", "opencode", "command");
52687
+ const opencodeCommandsDir = join63(homedir17(), ".config", "opencode", "command");
52422
52688
  const commands = await loadCommandsFromDir(opencodeCommandsDir, "opencode");
52423
52689
  return commandsToRecord(commands);
52424
52690
  }
52425
52691
  async function loadOpencodeProjectCommands() {
52426
- const opencodeProjectDir = join62(process.cwd(), ".opencode", "command");
52692
+ const opencodeProjectDir = join63(process.cwd(), ".opencode", "command");
52427
52693
  const commands = await loadCommandsFromDir(opencodeProjectDir, "opencode-project");
52428
52694
  return commandsToRecord(commands);
52429
52695
  }
@@ -53233,33 +53499,33 @@ function loadBuiltinCommands(disabledCommands) {
53233
53499
  return commands;
53234
53500
  }
53235
53501
  // src/features/claude-code-agent-loader/loader.ts
53236
- import { existsSync as existsSync54, readdirSync as readdirSync20, readFileSync as readFileSync35 } from "fs";
53237
- import { join as join63, basename as basename7 } from "path";
53502
+ import { existsSync as existsSync55, readdirSync as readdirSync21, readFileSync as readFileSync36 } from "fs";
53503
+ import { join as join64, basename as basename7 } from "path";
53238
53504
  function parseToolsConfig(toolsStr) {
53239
53505
  if (!toolsStr)
53240
53506
  return;
53241
- const tools4 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53242
- if (tools4.length === 0)
53507
+ const tools5 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53508
+ if (tools5.length === 0)
53243
53509
  return;
53244
53510
  const result = {};
53245
- for (const tool3 of tools4) {
53511
+ for (const tool3 of tools5) {
53246
53512
  result[tool3.toLowerCase()] = true;
53247
53513
  }
53248
53514
  return result;
53249
53515
  }
53250
53516
  function loadAgentsFromDir(agentsDir, scope) {
53251
- if (!existsSync54(agentsDir)) {
53517
+ if (!existsSync55(agentsDir)) {
53252
53518
  return [];
53253
53519
  }
53254
- const entries = readdirSync20(agentsDir, { withFileTypes: true });
53520
+ const entries = readdirSync21(agentsDir, { withFileTypes: true });
53255
53521
  const agents = [];
53256
53522
  for (const entry of entries) {
53257
53523
  if (!isMarkdownFile(entry))
53258
53524
  continue;
53259
- const agentPath = join63(agentsDir, entry.name);
53525
+ const agentPath = join64(agentsDir, entry.name);
53260
53526
  const agentName = basename7(entry.name, ".md");
53261
53527
  try {
53262
- const content = readFileSync35(agentPath, "utf-8");
53528
+ const content = readFileSync36(agentPath, "utf-8");
53263
53529
  const { data, body } = parseFrontmatter(content);
53264
53530
  const name = data.name || agentName;
53265
53531
  const originalDescription = data.description || "";
@@ -53286,7 +53552,7 @@ function loadAgentsFromDir(agentsDir, scope) {
53286
53552
  return agents;
53287
53553
  }
53288
53554
  function loadUserAgents() {
53289
- const userAgentsDir = join63(getClaudeConfigDir(), "agents");
53555
+ const userAgentsDir = join64(getClaudeConfigDir(), "agents");
53290
53556
  const agents = loadAgentsFromDir(userAgentsDir, "user");
53291
53557
  const result = {};
53292
53558
  for (const agent of agents) {
@@ -53295,7 +53561,7 @@ function loadUserAgents() {
53295
53561
  return result;
53296
53562
  }
53297
53563
  function loadProjectAgents() {
53298
- const projectAgentsDir = join63(process.cwd(), ".claude", "agents");
53564
+ const projectAgentsDir = join64(process.cwd(), ".claude", "agents");
53299
53565
  const agents = loadAgentsFromDir(projectAgentsDir, "project");
53300
53566
  const result = {};
53301
53567
  for (const agent of agents) {
@@ -53304,18 +53570,18 @@ function loadProjectAgents() {
53304
53570
  return result;
53305
53571
  }
53306
53572
  // src/features/claude-code-plugin-loader/loader.ts
53307
- import { existsSync as existsSync55, readdirSync as readdirSync21, readFileSync as readFileSync36 } from "fs";
53573
+ import { existsSync as existsSync56, readdirSync as readdirSync22, readFileSync as readFileSync37 } from "fs";
53308
53574
  import { homedir as homedir18 } from "os";
53309
- import { join as join64, basename as basename8 } from "path";
53575
+ import { join as join65, basename as basename8 } from "path";
53310
53576
  var CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}";
53311
53577
  function getPluginsBaseDir() {
53312
53578
  if (process.env.CLAUDE_PLUGINS_HOME) {
53313
53579
  return process.env.CLAUDE_PLUGINS_HOME;
53314
53580
  }
53315
- return join64(homedir18(), ".claude", "plugins");
53581
+ return join65(homedir18(), ".claude", "plugins");
53316
53582
  }
53317
53583
  function getInstalledPluginsPath() {
53318
- return join64(getPluginsBaseDir(), "installed_plugins.json");
53584
+ return join65(getPluginsBaseDir(), "installed_plugins.json");
53319
53585
  }
53320
53586
  function resolvePluginPath(path10, pluginRoot) {
53321
53587
  return path10.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot);
@@ -53340,11 +53606,11 @@ function resolvePluginPaths(obj, pluginRoot) {
53340
53606
  }
53341
53607
  function loadInstalledPlugins() {
53342
53608
  const dbPath = getInstalledPluginsPath();
53343
- if (!existsSync55(dbPath)) {
53609
+ if (!existsSync56(dbPath)) {
53344
53610
  return null;
53345
53611
  }
53346
53612
  try {
53347
- const content = readFileSync36(dbPath, "utf-8");
53613
+ const content = readFileSync37(dbPath, "utf-8");
53348
53614
  return JSON.parse(content);
53349
53615
  } catch (error45) {
53350
53616
  log("Failed to load installed plugins database", error45);
@@ -53355,15 +53621,15 @@ function getClaudeSettingsPath() {
53355
53621
  if (process.env.CLAUDE_SETTINGS_PATH) {
53356
53622
  return process.env.CLAUDE_SETTINGS_PATH;
53357
53623
  }
53358
- return join64(homedir18(), ".claude", "settings.json");
53624
+ return join65(homedir18(), ".claude", "settings.json");
53359
53625
  }
53360
53626
  function loadClaudeSettings() {
53361
53627
  const settingsPath = getClaudeSettingsPath();
53362
- if (!existsSync55(settingsPath)) {
53628
+ if (!existsSync56(settingsPath)) {
53363
53629
  return null;
53364
53630
  }
53365
53631
  try {
53366
- const content = readFileSync36(settingsPath, "utf-8");
53632
+ const content = readFileSync37(settingsPath, "utf-8");
53367
53633
  return JSON.parse(content);
53368
53634
  } catch (error45) {
53369
53635
  log("Failed to load Claude settings", error45);
@@ -53371,12 +53637,12 @@ function loadClaudeSettings() {
53371
53637
  }
53372
53638
  }
53373
53639
  function loadPluginManifest(installPath) {
53374
- const manifestPath = join64(installPath, ".claude-plugin", "plugin.json");
53375
- if (!existsSync55(manifestPath)) {
53640
+ const manifestPath = join65(installPath, ".claude-plugin", "plugin.json");
53641
+ if (!existsSync56(manifestPath)) {
53376
53642
  return null;
53377
53643
  }
53378
53644
  try {
53379
- const content = readFileSync36(manifestPath, "utf-8");
53645
+ const content = readFileSync37(manifestPath, "utf-8");
53380
53646
  return JSON.parse(content);
53381
53647
  } catch (error45) {
53382
53648
  log(`Failed to load plugin manifest from ${manifestPath}`, error45);
@@ -53423,7 +53689,7 @@ function discoverInstalledPlugins(options) {
53423
53689
  continue;
53424
53690
  }
53425
53691
  const { installPath, scope, version: version2 } = installation;
53426
- if (!existsSync55(installPath)) {
53692
+ if (!existsSync56(installPath)) {
53427
53693
  errors3.push({
53428
53694
  pluginKey,
53429
53695
  installPath,
@@ -53441,21 +53707,21 @@ function discoverInstalledPlugins(options) {
53441
53707
  pluginKey,
53442
53708
  manifest: manifest ?? undefined
53443
53709
  };
53444
- if (existsSync55(join64(installPath, "commands"))) {
53445
- loadedPlugin.commandsDir = join64(installPath, "commands");
53710
+ if (existsSync56(join65(installPath, "commands"))) {
53711
+ loadedPlugin.commandsDir = join65(installPath, "commands");
53446
53712
  }
53447
- if (existsSync55(join64(installPath, "agents"))) {
53448
- loadedPlugin.agentsDir = join64(installPath, "agents");
53713
+ if (existsSync56(join65(installPath, "agents"))) {
53714
+ loadedPlugin.agentsDir = join65(installPath, "agents");
53449
53715
  }
53450
- if (existsSync55(join64(installPath, "skills"))) {
53451
- loadedPlugin.skillsDir = join64(installPath, "skills");
53716
+ if (existsSync56(join65(installPath, "skills"))) {
53717
+ loadedPlugin.skillsDir = join65(installPath, "skills");
53452
53718
  }
53453
- const hooksPath = join64(installPath, "hooks", "hooks.json");
53454
- if (existsSync55(hooksPath)) {
53719
+ const hooksPath = join65(installPath, "hooks", "hooks.json");
53720
+ if (existsSync56(hooksPath)) {
53455
53721
  loadedPlugin.hooksPath = hooksPath;
53456
53722
  }
53457
- const mcpPath = join64(installPath, ".mcp.json");
53458
- if (existsSync55(mcpPath)) {
53723
+ const mcpPath = join65(installPath, ".mcp.json");
53724
+ if (existsSync56(mcpPath)) {
53459
53725
  loadedPlugin.mcpPath = mcpPath;
53460
53726
  }
53461
53727
  plugins.push(loadedPlugin);
@@ -53466,17 +53732,17 @@ function discoverInstalledPlugins(options) {
53466
53732
  function loadPluginCommands(plugins) {
53467
53733
  const commands2 = {};
53468
53734
  for (const plugin2 of plugins) {
53469
- if (!plugin2.commandsDir || !existsSync55(plugin2.commandsDir))
53735
+ if (!plugin2.commandsDir || !existsSync56(plugin2.commandsDir))
53470
53736
  continue;
53471
- const entries = readdirSync21(plugin2.commandsDir, { withFileTypes: true });
53737
+ const entries = readdirSync22(plugin2.commandsDir, { withFileTypes: true });
53472
53738
  for (const entry of entries) {
53473
53739
  if (!isMarkdownFile(entry))
53474
53740
  continue;
53475
- const commandPath = join64(plugin2.commandsDir, entry.name);
53741
+ const commandPath = join65(plugin2.commandsDir, entry.name);
53476
53742
  const commandName = basename8(entry.name, ".md");
53477
53743
  const namespacedName = `${plugin2.name}:${commandName}`;
53478
53744
  try {
53479
- const content = readFileSync36(commandPath, "utf-8");
53745
+ const content = readFileSync37(commandPath, "utf-8");
53480
53746
  const { data, body } = parseFrontmatter(content);
53481
53747
  const wrappedTemplate = `<command-instruction>
53482
53748
  ${body.trim()}
@@ -53508,21 +53774,21 @@ $ARGUMENTS
53508
53774
  function loadPluginSkillsAsCommands(plugins) {
53509
53775
  const skills = {};
53510
53776
  for (const plugin2 of plugins) {
53511
- if (!plugin2.skillsDir || !existsSync55(plugin2.skillsDir))
53777
+ if (!plugin2.skillsDir || !existsSync56(plugin2.skillsDir))
53512
53778
  continue;
53513
- const entries = readdirSync21(plugin2.skillsDir, { withFileTypes: true });
53779
+ const entries = readdirSync22(plugin2.skillsDir, { withFileTypes: true });
53514
53780
  for (const entry of entries) {
53515
53781
  if (entry.name.startsWith("."))
53516
53782
  continue;
53517
- const skillPath = join64(plugin2.skillsDir, entry.name);
53783
+ const skillPath = join65(plugin2.skillsDir, entry.name);
53518
53784
  if (!entry.isDirectory() && !entry.isSymbolicLink())
53519
53785
  continue;
53520
53786
  const resolvedPath = resolveSymlink(skillPath);
53521
- const skillMdPath = join64(resolvedPath, "SKILL.md");
53522
- if (!existsSync55(skillMdPath))
53787
+ const skillMdPath = join65(resolvedPath, "SKILL.md");
53788
+ if (!existsSync56(skillMdPath))
53523
53789
  continue;
53524
53790
  try {
53525
- const content = readFileSync36(skillMdPath, "utf-8");
53791
+ const content = readFileSync37(skillMdPath, "utf-8");
53526
53792
  const { data, body } = parseFrontmatter(content);
53527
53793
  const skillName = data.name || entry.name;
53528
53794
  const namespacedName = `${plugin2.name}:${skillName}`;
@@ -53557,11 +53823,11 @@ $ARGUMENTS
53557
53823
  function parseToolsConfig2(toolsStr) {
53558
53824
  if (!toolsStr)
53559
53825
  return;
53560
- const tools4 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53561
- if (tools4.length === 0)
53826
+ const tools5 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53827
+ if (tools5.length === 0)
53562
53828
  return;
53563
53829
  const result = {};
53564
- for (const tool3 of tools4) {
53830
+ for (const tool3 of tools5) {
53565
53831
  result[tool3.toLowerCase()] = true;
53566
53832
  }
53567
53833
  return result;
@@ -53569,17 +53835,17 @@ function parseToolsConfig2(toolsStr) {
53569
53835
  function loadPluginAgents(plugins) {
53570
53836
  const agents = {};
53571
53837
  for (const plugin2 of plugins) {
53572
- if (!plugin2.agentsDir || !existsSync55(plugin2.agentsDir))
53838
+ if (!plugin2.agentsDir || !existsSync56(plugin2.agentsDir))
53573
53839
  continue;
53574
- const entries = readdirSync21(plugin2.agentsDir, { withFileTypes: true });
53840
+ const entries = readdirSync22(plugin2.agentsDir, { withFileTypes: true });
53575
53841
  for (const entry of entries) {
53576
53842
  if (!isMarkdownFile(entry))
53577
53843
  continue;
53578
- const agentPath = join64(plugin2.agentsDir, entry.name);
53844
+ const agentPath = join65(plugin2.agentsDir, entry.name);
53579
53845
  const agentName = basename8(entry.name, ".md");
53580
53846
  const namespacedName = `${plugin2.name}:${agentName}`;
53581
53847
  try {
53582
- const content = readFileSync36(agentPath, "utf-8");
53848
+ const content = readFileSync37(agentPath, "utf-8");
53583
53849
  const { data, body } = parseFrontmatter(content);
53584
53850
  const name = data.name || agentName;
53585
53851
  const originalDescription = data.description || "";
@@ -53605,7 +53871,7 @@ function loadPluginAgents(plugins) {
53605
53871
  async function loadPluginMcpServers(plugins) {
53606
53872
  const servers = {};
53607
53873
  for (const plugin2 of plugins) {
53608
- if (!plugin2.mcpPath || !existsSync55(plugin2.mcpPath))
53874
+ if (!plugin2.mcpPath || !existsSync56(plugin2.mcpPath))
53609
53875
  continue;
53610
53876
  try {
53611
53877
  const content = await Bun.file(plugin2.mcpPath).text();
@@ -53637,10 +53903,10 @@ async function loadPluginMcpServers(plugins) {
53637
53903
  function loadPluginHooksConfigs(plugins) {
53638
53904
  const configs = [];
53639
53905
  for (const plugin2 of plugins) {
53640
- if (!plugin2.hooksPath || !existsSync55(plugin2.hooksPath))
53906
+ if (!plugin2.hooksPath || !existsSync56(plugin2.hooksPath))
53641
53907
  continue;
53642
53908
  try {
53643
- const content = readFileSync36(plugin2.hooksPath, "utf-8");
53909
+ const content = readFileSync37(plugin2.hooksPath, "utf-8");
53644
53910
  let config3 = JSON.parse(content);
53645
53911
  config3 = resolvePluginPaths(config3, plugin2.installPath);
53646
53912
  configs.push(config3);
@@ -0,0 +1,2 @@
1
+ export declare const TOOL_NAME = "knowledge_base";
2
+ export declare const TOOL_DESCRIPTION = "Progressive disclosure tool for accessing memory and knowledge.\n\nThree actions, from lightweight to detailed:\n\n1. list \u2014 Browse all memory entries (dates, tags, summary headlines)\n knowledge_base({ action: \"list\" })\n\n2. search \u2014 Find relevant memories with matching snippets \n knowledge_base({ action: \"search\", query: \"API design discussion\" })\n\n3. get \u2014 Retrieve full content of a specific memory entry\n knowledge_base({ action: \"get\", id: \"2026-02-20/ses_abc123\" })\n\nSources: \"memory\" (default, conversation memories), \"archive\" (long-term MEMORY.md), \"knowledge\" (KNOWLEDGE.md)\nOnly \"memory\" source is currently supported.";
@@ -0,0 +1,3 @@
1
+ export * from "./tools";
2
+ export * from "./types";
3
+ export * from "./constants";
@@ -0,0 +1,3 @@
1
+ export declare function listMemoryEntries(projectDir: string, limit?: number): string;
2
+ export declare function searchMemoryEntries(projectDir: string, query: string, limit?: number): string;
3
+ export declare function getMemoryEntry(projectDir: string, id: string, includeFull?: boolean): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin/tool";
2
+ export declare const knowledge_base: ToolDefinition;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ export interface KnowledgeBaseArgs {
2
+ action: "list" | "search" | "get";
3
+ source?: "memory" | "archive" | "knowledge";
4
+ query?: string;
5
+ id?: string;
6
+ limit?: number;
7
+ include_full?: boolean;
8
+ }
9
+ export interface MemoryListEntry {
10
+ date: string;
11
+ sessionID?: string;
12
+ tags: string[];
13
+ decisionsCount: number;
14
+ todosCount: number;
15
+ summaryLine: string;
16
+ }
17
+ export interface MemorySearchResult {
18
+ date: string;
19
+ sessionID?: string;
20
+ tags: string[];
21
+ snippet: string;
22
+ matchCount: number;
23
+ }
@@ -0,0 +1,5 @@
1
+ import type { MemoryListEntry, MemorySearchResult } from "./types";
2
+ export declare function formatMemoryList(entries: MemoryListEntry[]): string;
3
+ export declare function formatMemorySearchResults(results: MemorySearchResult[], query: string): string;
4
+ export declare function extractSnippet(text: string, query: string, contextChars?: number): string;
5
+ export declare function extractSummaryLine(rawBlock: string): string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newtype-profile",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "AI Agent Collaboration System for Content Creation - Based on oh-my-opencode",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",