newtype-profile 1.0.63 → 1.0.65

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.65",
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"))) {
@@ -8697,6 +8697,7 @@ Incomplete tasks remain in your todo list. Continue working on the next pending
8697
8697
  - Do not stop until all tasks are done`;
8698
8698
  var COUNTDOWN_SECONDS = 2;
8699
8699
  var TOAST_DURATION_MS = 900;
8700
+ var MAX_INJECTIONS = 3;
8700
8701
  var COUNTDOWN_GRACE_PERIOD_MS = 500;
8701
8702
  function getMessageDir(sessionID) {
8702
8703
  if (!existsSync2(MESSAGE_STORAGE))
@@ -8732,7 +8733,7 @@ function createTodoContinuationEnforcer(ctx, options = {}) {
8732
8733
  function getState(sessionID) {
8733
8734
  let state2 = sessions.get(sessionID);
8734
8735
  if (!state2) {
8735
- state2 = {};
8736
+ state2 = { injectionCount: 0 };
8736
8737
  sessions.set(sessionID, state2);
8737
8738
  }
8738
8739
  return state2;
@@ -8784,6 +8785,10 @@ function createTodoContinuationEnforcer(ctx, options = {}) {
8784
8785
  log(`[${HOOK_NAME}] Skipped injection: in recovery`, { sessionID });
8785
8786
  return;
8786
8787
  }
8788
+ if (state2 && state2.injectionCount >= MAX_INJECTIONS) {
8789
+ log(`[${HOOK_NAME}] Skipped injection: max retries reached (${MAX_INJECTIONS})`, { sessionID, injectionCount: state2.injectionCount });
8790
+ return;
8791
+ }
8787
8792
  const hasRunningBgTasks = backgroundManager ? backgroundManager.getTasksByParentSession(sessionID).some((t) => t.status === "running") : false;
8788
8793
  if (hasRunningBgTasks) {
8789
8794
  log(`[${HOOK_NAME}] Skipped injection: background tasks running`, { sessionID });
@@ -8830,6 +8835,9 @@ function createTodoContinuationEnforcer(ctx, options = {}) {
8830
8835
  query: { directory: ctx.directory }
8831
8836
  });
8832
8837
  log(`[${HOOK_NAME}] Injection successful`, { sessionID });
8838
+ if (state2) {
8839
+ state2.injectionCount++;
8840
+ }
8833
8841
  } catch (err) {
8834
8842
  log(`[${HOOK_NAME}] Injection failed`, { sessionID, error: String(err) });
8835
8843
  }
@@ -45321,6 +45329,277 @@ var session_info = tool({
45321
45329
  }
45322
45330
  }
45323
45331
  });
45332
+ // src/tools/knowledge-base/constants.ts
45333
+ var TOOL_DESCRIPTION = `Progressive disclosure tool for accessing memory and knowledge.
45334
+
45335
+ Three actions, from lightweight to detailed:
45336
+
45337
+ 1. list \u2014 Browse all memory entries (dates, tags, summary headlines)
45338
+ knowledge_base({ action: "list" })
45339
+
45340
+ 2. search \u2014 Find relevant memories with matching snippets
45341
+ knowledge_base({ action: "search", query: "API design discussion" })
45342
+
45343
+ 3. get \u2014 Retrieve full content of a specific memory entry
45344
+ knowledge_base({ action: "get", id: "2026-02-20/ses_abc123" })
45345
+
45346
+ Sources: "memory" (default, conversation memories), "archive" (long-term MEMORY.md), "knowledge" (KNOWLEDGE.md)
45347
+ Only "memory" source is currently supported.`;
45348
+
45349
+ // src/tools/knowledge-base/memory-source.ts
45350
+ import { existsSync as existsSync51, readdirSync as readdirSync19, readFileSync as readFileSync32 } from "fs";
45351
+ import { join as join59 } from "path";
45352
+
45353
+ // src/tools/knowledge-base/utils.ts
45354
+ function formatMemoryList(entries) {
45355
+ if (entries.length === 0) {
45356
+ return "No memory entries found.";
45357
+ }
45358
+ const lines = [
45359
+ "| Date | Session | Tags | Decisions | Summary |",
45360
+ "|------|---------|------|-----------|---------|"
45361
+ ];
45362
+ for (const entry of entries) {
45363
+ const sessionDisplay = entry.sessionID ? entry.sessionID.slice(0, 12) : "-";
45364
+ const tagsDisplay = entry.tags.length > 0 ? entry.tags.join(", ") : "-";
45365
+ const summaryDisplay = entry.summaryLine.length > 50 ? entry.summaryLine.slice(0, 50) + "..." : entry.summaryLine;
45366
+ lines.push(`| ${entry.date} | ${sessionDisplay} | ${tagsDisplay} | ${entry.decisionsCount} | ${summaryDisplay} |`);
45367
+ }
45368
+ return lines.join(`
45369
+ `);
45370
+ }
45371
+ function formatMemorySearchResults(results, query) {
45372
+ if (results.length === 0) {
45373
+ return `No matches found for "${query}".`;
45374
+ }
45375
+ const lines = [`Found ${results.length} match(es) for "${query}":
45376
+ `];
45377
+ for (let i2 = 0;i2 < results.length; i2++) {
45378
+ const result = results[i2];
45379
+ const sessionDisplay = result.sessionID ? ` (${result.sessionID.slice(0, 12)})` : "";
45380
+ const tagsDisplay = result.tags.length > 0 ? ` [${result.tags.join(", ")}]` : "";
45381
+ lines.push(`${i2 + 1}. **${result.date}${sessionDisplay}**${tagsDisplay}`);
45382
+ lines.push(` ${result.snippet}`);
45383
+ if (result.matchCount > 1) {
45384
+ lines.push(` _(${result.matchCount} matches in this entry)_`);
45385
+ }
45386
+ lines.push("");
45387
+ }
45388
+ return lines.join(`
45389
+ `);
45390
+ }
45391
+ function extractSnippet(text, query, contextChars = 80) {
45392
+ const lowerText = text.toLowerCase();
45393
+ const lowerQuery = query.toLowerCase();
45394
+ const matchIndex = lowerText.indexOf(lowerQuery);
45395
+ if (matchIndex === -1) {
45396
+ return text.slice(0, contextChars * 2) + (text.length > contextChars * 2 ? "..." : "");
45397
+ }
45398
+ const start = Math.max(0, matchIndex - contextChars);
45399
+ const end = Math.min(text.length, matchIndex + query.length + contextChars);
45400
+ let snippet2 = text.slice(start, end);
45401
+ if (start > 0) {
45402
+ snippet2 = "..." + snippet2;
45403
+ }
45404
+ if (end < text.length) {
45405
+ snippet2 = snippet2 + "...";
45406
+ }
45407
+ return snippet2.replace(/\n+/g, " ").trim();
45408
+ }
45409
+ function extractSummaryLine(rawBlock) {
45410
+ const lines = rawBlock.split(`
45411
+ `);
45412
+ for (const line of lines) {
45413
+ const trimmed = line.trim();
45414
+ if (!trimmed)
45415
+ continue;
45416
+ if (trimmed.startsWith("#"))
45417
+ continue;
45418
+ if (trimmed.startsWith("SessionID:"))
45419
+ continue;
45420
+ if (trimmed.startsWith("Full transcript:"))
45421
+ continue;
45422
+ if (trimmed.startsWith("**") && trimmed.endsWith(":**"))
45423
+ continue;
45424
+ return trimmed;
45425
+ }
45426
+ return "";
45427
+ }
45428
+
45429
+ // src/tools/knowledge-base/memory-source.ts
45430
+ function listMemoryEntries(projectDir, limit) {
45431
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45432
+ if (!existsSync51(memoryDir)) {
45433
+ return "No memory entries found.";
45434
+ }
45435
+ const files = readdirSync19(memoryDir).filter((f) => f.endsWith(".md") && f !== "full").sort().reverse();
45436
+ const entries = [];
45437
+ const effectiveLimit = limit ?? 20;
45438
+ for (const file2 of files) {
45439
+ if (entries.length >= effectiveLimit)
45440
+ break;
45441
+ const filePath = join59(memoryDir, file2);
45442
+ const dateMatch = file2.match(/^(\d{4}-\d{2}-\d{2})\.md$/);
45443
+ if (!dateMatch)
45444
+ continue;
45445
+ const date5 = dateMatch[1];
45446
+ try {
45447
+ const content = readFileSync32(filePath, "utf-8");
45448
+ const sessions = parseDailyLogSessions(content);
45449
+ for (const session of sessions) {
45450
+ if (entries.length >= effectiveLimit)
45451
+ break;
45452
+ entries.push({
45453
+ date: date5,
45454
+ sessionID: session.sessionID,
45455
+ tags: session.tags,
45456
+ decisionsCount: session.decisions.length,
45457
+ todosCount: session.todos.length,
45458
+ summaryLine: extractSummaryLine(session.raw)
45459
+ });
45460
+ }
45461
+ } catch {
45462
+ continue;
45463
+ }
45464
+ }
45465
+ return formatMemoryList(entries);
45466
+ }
45467
+ function searchMemoryEntries(projectDir, query, limit) {
45468
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45469
+ if (!existsSync51(memoryDir)) {
45470
+ return `No matches found for "${query}".`;
45471
+ }
45472
+ const files = readdirSync19(memoryDir).filter((f) => f.endsWith(".md") && f !== "full").sort().reverse();
45473
+ const results = [];
45474
+ const effectiveLimit = limit ?? 10;
45475
+ const lowerQuery = query.toLowerCase();
45476
+ for (const file2 of files) {
45477
+ if (results.length >= effectiveLimit)
45478
+ break;
45479
+ const filePath = join59(memoryDir, file2);
45480
+ const dateMatch = file2.match(/^(\d{4}-\d{2}-\d{2})\.md$/);
45481
+ if (!dateMatch)
45482
+ continue;
45483
+ const date5 = dateMatch[1];
45484
+ try {
45485
+ const content = readFileSync32(filePath, "utf-8");
45486
+ const sessions = parseDailyLogSessions(content);
45487
+ for (const session of sessions) {
45488
+ if (results.length >= effectiveLimit)
45489
+ break;
45490
+ const lowerRaw = session.raw.toLowerCase();
45491
+ if (!lowerRaw.includes(lowerQuery))
45492
+ continue;
45493
+ const matches = lowerRaw.split(lowerQuery).length - 1;
45494
+ results.push({
45495
+ date: date5,
45496
+ sessionID: session.sessionID,
45497
+ tags: session.tags,
45498
+ snippet: extractSnippet(session.raw, query),
45499
+ matchCount: matches
45500
+ });
45501
+ }
45502
+ } catch {
45503
+ continue;
45504
+ }
45505
+ }
45506
+ return formatMemorySearchResults(results, query);
45507
+ }
45508
+ function getMemoryEntry(projectDir, id, includeFull) {
45509
+ const parts = id.split("/");
45510
+ const date5 = parts[0];
45511
+ const sessionID = parts[1];
45512
+ const dateMatch = date5.match(/^\d{4}-\d{2}-\d{2}$/);
45513
+ if (!dateMatch) {
45514
+ return `Invalid id format: ${id}. Expected YYYY-MM-DD or YYYY-MM-DD/sessionID`;
45515
+ }
45516
+ const memoryDir = join59(projectDir, MEMORY_DIR);
45517
+ const filePath = join59(memoryDir, `${date5}.md`);
45518
+ if (!existsSync51(filePath)) {
45519
+ return `Memory entry not found: ${id}`;
45520
+ }
45521
+ try {
45522
+ const content = readFileSync32(filePath, "utf-8");
45523
+ const sessions = parseDailyLogSessions(content);
45524
+ if (!sessionID) {
45525
+ const output2 = sessions.map((s) => s.raw).join(`
45526
+
45527
+ ---
45528
+
45529
+ `);
45530
+ return output2 || `Memory entry not found: ${id}`;
45531
+ }
45532
+ const session = sessions.find((s) => s.sessionID === sessionID || s.sessionID?.startsWith(sessionID));
45533
+ if (!session) {
45534
+ return `Memory entry not found: ${id}`;
45535
+ }
45536
+ let output = session.raw;
45537
+ if (includeFull && session.sessionID) {
45538
+ const fullPath = getFullTranscriptPath(projectDir, session.sessionID);
45539
+ if (existsSync51(fullPath)) {
45540
+ try {
45541
+ const fullContent = readFileSync32(fullPath, "utf-8");
45542
+ output += `
45543
+
45544
+ ---
45545
+
45546
+ ## Full Transcript
45547
+
45548
+ ` + fullContent;
45549
+ } catch {
45550
+ output += `
45551
+
45552
+ _(Full transcript could not be read)_`;
45553
+ }
45554
+ } else {
45555
+ output += `
45556
+
45557
+ _(Full transcript not available)_`;
45558
+ }
45559
+ }
45560
+ return output;
45561
+ } catch (error45) {
45562
+ return `Error reading memory entry: ${error45 instanceof Error ? error45.message : String(error45)}`;
45563
+ }
45564
+ }
45565
+
45566
+ // src/tools/knowledge-base/tools.ts
45567
+ var knowledge_base = tool({
45568
+ description: TOOL_DESCRIPTION,
45569
+ args: {
45570
+ action: tool.schema.enum(["list", "search", "get"]).describe("Action: list (browse), search (find), get (retrieve full)"),
45571
+ source: tool.schema.enum(["memory", "archive", "knowledge"]).optional().describe("Data source (default: memory)"),
45572
+ query: tool.schema.string().optional().describe("Search query (required for search action)"),
45573
+ id: tool.schema.string().optional().describe("Entry ID in format YYYY-MM-DD/sessionID (required for get action)"),
45574
+ limit: tool.schema.number().optional().describe("Max results to return (default: 20 for list, 10 for search)"),
45575
+ include_full: tool.schema.boolean().optional().describe("Include full transcript in get results (default: false)")
45576
+ },
45577
+ execute: async (args, _context) => {
45578
+ try {
45579
+ const source = args.source ?? "memory";
45580
+ const projectDir = process.cwd();
45581
+ if (source !== "memory") {
45582
+ return `Source "${source}" is not yet supported. Currently available: memory`;
45583
+ }
45584
+ switch (args.action) {
45585
+ case "list":
45586
+ return listMemoryEntries(projectDir, args.limit);
45587
+ case "search":
45588
+ if (!args.query)
45589
+ return "Error: query is required for search action";
45590
+ return searchMemoryEntries(projectDir, args.query, args.limit);
45591
+ case "get":
45592
+ if (!args.id)
45593
+ return "Error: id is required for get action";
45594
+ return getMemoryEntry(projectDir, args.id, args.include_full);
45595
+ default:
45596
+ return `Unknown action: ${args.action}. Available: list, search, get`;
45597
+ }
45598
+ } catch (error45) {
45599
+ return `Error: ${error45 instanceof Error ? error45.message : String(error45)}`;
45600
+ }
45601
+ }
45602
+ });
45324
45603
  // src/tools/interactive-bash/tools.ts
45325
45604
  import { spawn as spawn4 } from "child_process";
45326
45605
 
@@ -45491,7 +45770,7 @@ Skills provide specialized knowledge and step-by-step guidance.
45491
45770
  Use this when a task matches an available skill's description.`;
45492
45771
  // src/tools/skill/tools.ts
45493
45772
  import { dirname as dirname14 } from "path";
45494
- import { readFileSync as readFileSync32 } from "fs";
45773
+ import { readFileSync as readFileSync33 } from "fs";
45495
45774
  function loadedSkillToInfo(skill) {
45496
45775
  return {
45497
45776
  name: skill.name,
@@ -45534,7 +45813,7 @@ async function extractSkillBody(skill) {
45534
45813
  return templateMatch2 ? templateMatch2[1].trim() : fullTemplate;
45535
45814
  }
45536
45815
  if (skill.path) {
45537
- const content = readFileSync32(skill.path, "utf-8");
45816
+ const content = readFileSync33(skill.path, "utf-8");
45538
45817
  const { body } = parseFrontmatter(content);
45539
45818
  return body.trim();
45540
45819
  }
@@ -45559,15 +45838,15 @@ async function formatMcpCapabilities(skill, manager, sessionID) {
45559
45838
  sections.push(`### ${serverName}`);
45560
45839
  sections.push("");
45561
45840
  try {
45562
- const [tools4, resources, prompts] = await Promise.all([
45841
+ const [tools5, resources, prompts] = await Promise.all([
45563
45842
  manager.listTools(info, context).catch(() => []),
45564
45843
  manager.listResources(info, context).catch(() => []),
45565
45844
  manager.listPrompts(info, context).catch(() => [])
45566
45845
  ]);
45567
- if (tools4.length > 0) {
45846
+ if (tools5.length > 0) {
45568
45847
  sections.push("**Tools:**");
45569
45848
  sections.push("");
45570
- for (const t of tools4) {
45849
+ for (const t of tools5) {
45571
45850
  sections.push(`#### \`${t.name}\``);
45572
45851
  if (t.description) {
45573
45852
  sections.push(t.description);
@@ -45586,7 +45865,7 @@ async function formatMcpCapabilities(skill, manager, sessionID) {
45586
45865
  if (prompts.length > 0) {
45587
45866
  sections.push(`**Prompts**: ${prompts.map((p2) => p2.name).join(", ")}`);
45588
45867
  }
45589
- if (tools4.length === 0 && resources.length === 0 && prompts.length === 0) {
45868
+ if (tools5.length === 0 && resources.length === 0 && prompts.length === 0) {
45590
45869
  sections.push("*No capabilities discovered*");
45591
45870
  }
45592
45871
  } catch (error45) {
@@ -46148,8 +46427,8 @@ If the requested information is not found, clearly state what is missing.`;
46148
46427
  });
46149
46428
  }
46150
46429
  // src/tools/chief-task/tools.ts
46151
- import { existsSync as existsSync51, readdirSync as readdirSync19 } from "fs";
46152
- import { join as join59 } from "path";
46430
+ import { existsSync as existsSync52, readdirSync as readdirSync20 } from "fs";
46431
+ import { join as join60 } from "path";
46153
46432
 
46154
46433
  // src/tools/chief-task/constants.ts
46155
46434
  var RESEARCH_CATEGORY_PROMPT_APPEND = `<Category_Context>
@@ -46724,14 +47003,14 @@ function parseModelString(model) {
46724
47003
  return;
46725
47004
  }
46726
47005
  function getMessageDir12(sessionID) {
46727
- if (!existsSync51(MESSAGE_STORAGE))
47006
+ if (!existsSync52(MESSAGE_STORAGE))
46728
47007
  return null;
46729
- const directPath = join59(MESSAGE_STORAGE, sessionID);
46730
- if (existsSync51(directPath))
47008
+ const directPath = join60(MESSAGE_STORAGE, sessionID);
47009
+ if (existsSync52(directPath))
46731
47010
  return directPath;
46732
- for (const dir of readdirSync19(MESSAGE_STORAGE)) {
46733
- const sessionPath = join59(MESSAGE_STORAGE, dir, sessionID);
46734
- if (existsSync51(sessionPath))
47011
+ for (const dir of readdirSync20(MESSAGE_STORAGE)) {
47012
+ const sessionPath = join60(MESSAGE_STORAGE, dir, sessionID);
47013
+ if (existsSync52(sessionPath))
46735
47014
  return sessionPath;
46736
47015
  }
46737
47016
  return null;
@@ -47173,7 +47452,8 @@ var builtinTools = {
47173
47452
  session_list,
47174
47453
  session_read,
47175
47454
  session_search,
47176
- session_info
47455
+ session_info,
47456
+ knowledge_base
47177
47457
  };
47178
47458
  // src/features/background-agent/concurrency.ts
47179
47459
  class ConcurrencyManager {
@@ -50016,11 +50296,11 @@ class Client extends Protocol {
50016
50296
  isToolTaskRequired(toolName) {
50017
50297
  return this._cachedRequiredTaskTools.has(toolName);
50018
50298
  }
50019
- cacheToolMetadata(tools4) {
50299
+ cacheToolMetadata(tools5) {
50020
50300
  this._cachedToolOutputValidators.clear();
50021
50301
  this._cachedKnownTaskTools.clear();
50022
50302
  this._cachedRequiredTaskTools.clear();
50023
- for (const tool3 of tools4) {
50303
+ for (const tool3 of tools5) {
50024
50304
  if (tool3.outputSchema) {
50025
50305
  const toolValidator = this._jsonSchemaValidator.getValidator(tool3.outputSchema);
50026
50306
  this._cachedToolOutputValidators.set(tool3.name, toolValidator);
@@ -50935,6 +51215,7 @@ var CHIEF_ALLOWED_TOOLS = [
50935
51215
  "read",
50936
51216
  "glob",
50937
51217
  "grep",
51218
+ "knowledge_base",
50938
51219
  "lsp_hover",
50939
51220
  "lsp_goto_definition",
50940
51221
  "lsp_find_references",
@@ -51213,44 +51494,37 @@ When discussion crystallizes into a task:
51213
51494
 
51214
51495
  <Memory_System>
51215
51496
  ## \u8BB0\u5FC6\u7CFB\u7EDF
51497
+ \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
51498
 
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
51499
+ ### \u4F7F\u7528\u65B9\u5F0F\uFF08\u5148\u7C97\u540E\u7EC6\uFF09
51218
51500
 
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 |
51227
-
51228
- ### \u68C0\u7D22\u6A21\u5F0F
51501
+ **\u7B2C\u4E00\u6B65\uFF1A\u6D4F\u89C8\u6982\u89C8**
51502
+ \`\`\`
51503
+ knowledge_base({ action: "list" })
51504
+ \`\`\`
51505
+ \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
51506
 
51230
- **\u6A21\u5F0F 1\uFF1A\u5FEB\u901F\u68C0\u7D22**\uFF08\u627E\u5F97\u5230\u3001\u626B\u5F97\u5FEB\u3001\u53EF\u805A\u5408\uFF09
51507
+ **\u7B2C\u4E8C\u6B65\uFF1A\u641C\u7D22\u5B9A\u4F4D**
51231
51508
  \`\`\`
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
51509
+ knowledge_base({ action: "search", query: "API\u8BBE\u8BA1" })
51235
51510
  \`\`\`
51236
- \u8FD4\u56DE\uFF1ATopic + Key Points + SessionID
51511
+ \u2192 \u8FD4\u56DE\u5339\u914D\u7684\u6761\u76EE + \u5173\u952E\u7247\u6BB5
51237
51512
 
51238
- **\u6A21\u5F0F 2\uFF1A\u5B8C\u6574\u8FFD\u6EAF**\uFF08\u53EF\u8FD8\u539F\u3001\u53EF\u5BA1\u8BA1\u3001\u53EF\u5F15\u7528\uFF09
51513
+ **\u7B2C\u4E09\u6B65\uFF1A\u83B7\u53D6\u8BE6\u60C5**
51239
51514
  \`\`\`
51240
- # \u4ECE\u6458\u8981\u4E2D\u627E\u5230 SessionID\uFF08\u5982 ses_abc123\uFF09
51241
- read(".opencode/memory/full/ses_abc123.md")
51515
+ knowledge_base({ action: "get", id: "2026-02-20/ses_abc123" })
51242
51516
  \`\`\`
51243
- \u8FD4\u56DE\uFF1A\u539F\u59CB\u5BF9\u8BDD\u5168\u6587\uFF0C\u53EF\u5F15\u7528\u5177\u4F53\u5185\u5BB9
51517
+ \u2192 \u8FD4\u56DE\u5B8C\u6574\u6458\u8981\u548C\u51B3\u7B56
51518
+ \u2192 \u52A0 \`include_full: true\` \u53EF\u83B7\u53D6\u539F\u59CB\u5BF9\u8BDD\u5168\u6587
51244
51519
 
51245
51520
  ### \u4F55\u65F6\u4F7F\u7528
51246
51521
 
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
-
51522
+ | \u89E6\u53D1\u4FE1\u53F7 | \u64CD\u4F5C |
51523
+ |----------|------|
51524
+ | "\u4E4B\u524D\u8BA8\u8BBA\u8FC7"\u3001"\u4E0A\u6B21"\u3001"\u6211\u4EEC\u51B3\u5B9A\u7684" | search \u2192 get |
51525
+ | "\u4F60\u8FD8\u8BB0\u5F97...\u5417" | search |
51526
+ | "\u539F\u8BDD\u600E\u4E48\u8BF4\u7684"\u3001"\u5B8C\u6574\u4E0A\u4E0B\u6587" | get with include_full: true |
51527
+ | \u65B0\u4F1A\u8BDD\u5F00\u59CB\uFF0C\u9700\u8981\u4E86\u89E3\u4E0A\u4E0B\u6587 | list\uFF08\u6D4F\u89C8\u8FD1\u671F\uFF09 |
51254
51528
  **\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
51529
  </Memory_System>`;
51256
51530
  var CHIEF_INNER_PERSONA = `<Philosophy>
@@ -51976,16 +52250,16 @@ function isGptModel(model) {
51976
52250
  return model.startsWith("openai/") || model.startsWith("github-copilot/gpt-");
51977
52251
  }
51978
52252
  // src/features/soul-loader/index.ts
51979
- import { existsSync as existsSync53, readFileSync as readFileSync34 } from "fs";
51980
- import { join as join61 } from "path";
52253
+ import { existsSync as existsSync54, readFileSync as readFileSync35 } from "fs";
52254
+ import { join as join62 } from "path";
51981
52255
  var SOUL_FILE_PATH = ".opencode/SOUL.md";
51982
52256
  function loadSoulFile(directory) {
51983
- const soulPath = join61(directory, SOUL_FILE_PATH);
51984
- if (!existsSync53(soulPath)) {
52257
+ const soulPath = join62(directory, SOUL_FILE_PATH);
52258
+ if (!existsSync54(soulPath)) {
51985
52259
  return;
51986
52260
  }
51987
52261
  try {
51988
- const content = readFileSync34(soulPath, "utf-8").trim();
52262
+ const content = readFileSync35(soulPath, "utf-8").trim();
51989
52263
  if (!content) {
51990
52264
  return;
51991
52265
  }
@@ -52322,7 +52596,7 @@ function createDeputyAgent(categoryConfig, promptAppend) {
52322
52596
  }
52323
52597
  // src/features/claude-code-command-loader/loader.ts
52324
52598
  import { promises as fs19 } from "fs";
52325
- import { join as join62, basename as basename6 } from "path";
52599
+ import { join as join63, basename as basename6 } from "path";
52326
52600
  import { homedir as homedir17 } from "os";
52327
52601
  async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix = "") {
52328
52602
  try {
@@ -52353,7 +52627,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
52353
52627
  if (entry.isDirectory()) {
52354
52628
  if (entry.name.startsWith("."))
52355
52629
  continue;
52356
- const subDirPath = join62(commandsDir, entry.name);
52630
+ const subDirPath = join63(commandsDir, entry.name);
52357
52631
  const subPrefix = prefix ? `${prefix}:${entry.name}` : entry.name;
52358
52632
  const subCommands = await loadCommandsFromDir(subDirPath, scope, visited, subPrefix);
52359
52633
  commands.push(...subCommands);
@@ -52361,7 +52635,7 @@ async function loadCommandsFromDir(commandsDir, scope, visited = new Set, prefix
52361
52635
  }
52362
52636
  if (!isMarkdownFile(entry))
52363
52637
  continue;
52364
- const commandPath = join62(commandsDir, entry.name);
52638
+ const commandPath = join63(commandsDir, entry.name);
52365
52639
  const baseCommandName = basename6(entry.name, ".md");
52366
52640
  const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName;
52367
52641
  try {
@@ -52408,22 +52682,22 @@ function commandsToRecord(commands) {
52408
52682
  return result;
52409
52683
  }
52410
52684
  async function loadUserCommands() {
52411
- const userCommandsDir = join62(getClaudeConfigDir(), "commands");
52685
+ const userCommandsDir = join63(getClaudeConfigDir(), "commands");
52412
52686
  const commands = await loadCommandsFromDir(userCommandsDir, "user");
52413
52687
  return commandsToRecord(commands);
52414
52688
  }
52415
52689
  async function loadProjectCommands() {
52416
- const projectCommandsDir = join62(process.cwd(), ".claude", "commands");
52690
+ const projectCommandsDir = join63(process.cwd(), ".claude", "commands");
52417
52691
  const commands = await loadCommandsFromDir(projectCommandsDir, "project");
52418
52692
  return commandsToRecord(commands);
52419
52693
  }
52420
52694
  async function loadOpencodeGlobalCommands() {
52421
- const opencodeCommandsDir = join62(homedir17(), ".config", "opencode", "command");
52695
+ const opencodeCommandsDir = join63(homedir17(), ".config", "opencode", "command");
52422
52696
  const commands = await loadCommandsFromDir(opencodeCommandsDir, "opencode");
52423
52697
  return commandsToRecord(commands);
52424
52698
  }
52425
52699
  async function loadOpencodeProjectCommands() {
52426
- const opencodeProjectDir = join62(process.cwd(), ".opencode", "command");
52700
+ const opencodeProjectDir = join63(process.cwd(), ".opencode", "command");
52427
52701
  const commands = await loadCommandsFromDir(opencodeProjectDir, "opencode-project");
52428
52702
  return commandsToRecord(commands);
52429
52703
  }
@@ -53233,33 +53507,33 @@ function loadBuiltinCommands(disabledCommands) {
53233
53507
  return commands;
53234
53508
  }
53235
53509
  // 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";
53510
+ import { existsSync as existsSync55, readdirSync as readdirSync21, readFileSync as readFileSync36 } from "fs";
53511
+ import { join as join64, basename as basename7 } from "path";
53238
53512
  function parseToolsConfig(toolsStr) {
53239
53513
  if (!toolsStr)
53240
53514
  return;
53241
- const tools4 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53242
- if (tools4.length === 0)
53515
+ const tools5 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53516
+ if (tools5.length === 0)
53243
53517
  return;
53244
53518
  const result = {};
53245
- for (const tool3 of tools4) {
53519
+ for (const tool3 of tools5) {
53246
53520
  result[tool3.toLowerCase()] = true;
53247
53521
  }
53248
53522
  return result;
53249
53523
  }
53250
53524
  function loadAgentsFromDir(agentsDir, scope) {
53251
- if (!existsSync54(agentsDir)) {
53525
+ if (!existsSync55(agentsDir)) {
53252
53526
  return [];
53253
53527
  }
53254
- const entries = readdirSync20(agentsDir, { withFileTypes: true });
53528
+ const entries = readdirSync21(agentsDir, { withFileTypes: true });
53255
53529
  const agents = [];
53256
53530
  for (const entry of entries) {
53257
53531
  if (!isMarkdownFile(entry))
53258
53532
  continue;
53259
- const agentPath = join63(agentsDir, entry.name);
53533
+ const agentPath = join64(agentsDir, entry.name);
53260
53534
  const agentName = basename7(entry.name, ".md");
53261
53535
  try {
53262
- const content = readFileSync35(agentPath, "utf-8");
53536
+ const content = readFileSync36(agentPath, "utf-8");
53263
53537
  const { data, body } = parseFrontmatter(content);
53264
53538
  const name = data.name || agentName;
53265
53539
  const originalDescription = data.description || "";
@@ -53286,7 +53560,7 @@ function loadAgentsFromDir(agentsDir, scope) {
53286
53560
  return agents;
53287
53561
  }
53288
53562
  function loadUserAgents() {
53289
- const userAgentsDir = join63(getClaudeConfigDir(), "agents");
53563
+ const userAgentsDir = join64(getClaudeConfigDir(), "agents");
53290
53564
  const agents = loadAgentsFromDir(userAgentsDir, "user");
53291
53565
  const result = {};
53292
53566
  for (const agent of agents) {
@@ -53295,7 +53569,7 @@ function loadUserAgents() {
53295
53569
  return result;
53296
53570
  }
53297
53571
  function loadProjectAgents() {
53298
- const projectAgentsDir = join63(process.cwd(), ".claude", "agents");
53572
+ const projectAgentsDir = join64(process.cwd(), ".claude", "agents");
53299
53573
  const agents = loadAgentsFromDir(projectAgentsDir, "project");
53300
53574
  const result = {};
53301
53575
  for (const agent of agents) {
@@ -53304,18 +53578,18 @@ function loadProjectAgents() {
53304
53578
  return result;
53305
53579
  }
53306
53580
  // src/features/claude-code-plugin-loader/loader.ts
53307
- import { existsSync as existsSync55, readdirSync as readdirSync21, readFileSync as readFileSync36 } from "fs";
53581
+ import { existsSync as existsSync56, readdirSync as readdirSync22, readFileSync as readFileSync37 } from "fs";
53308
53582
  import { homedir as homedir18 } from "os";
53309
- import { join as join64, basename as basename8 } from "path";
53583
+ import { join as join65, basename as basename8 } from "path";
53310
53584
  var CLAUDE_PLUGIN_ROOT_VAR = "${CLAUDE_PLUGIN_ROOT}";
53311
53585
  function getPluginsBaseDir() {
53312
53586
  if (process.env.CLAUDE_PLUGINS_HOME) {
53313
53587
  return process.env.CLAUDE_PLUGINS_HOME;
53314
53588
  }
53315
- return join64(homedir18(), ".claude", "plugins");
53589
+ return join65(homedir18(), ".claude", "plugins");
53316
53590
  }
53317
53591
  function getInstalledPluginsPath() {
53318
- return join64(getPluginsBaseDir(), "installed_plugins.json");
53592
+ return join65(getPluginsBaseDir(), "installed_plugins.json");
53319
53593
  }
53320
53594
  function resolvePluginPath(path10, pluginRoot) {
53321
53595
  return path10.replace(CLAUDE_PLUGIN_ROOT_VAR, pluginRoot);
@@ -53340,11 +53614,11 @@ function resolvePluginPaths(obj, pluginRoot) {
53340
53614
  }
53341
53615
  function loadInstalledPlugins() {
53342
53616
  const dbPath = getInstalledPluginsPath();
53343
- if (!existsSync55(dbPath)) {
53617
+ if (!existsSync56(dbPath)) {
53344
53618
  return null;
53345
53619
  }
53346
53620
  try {
53347
- const content = readFileSync36(dbPath, "utf-8");
53621
+ const content = readFileSync37(dbPath, "utf-8");
53348
53622
  return JSON.parse(content);
53349
53623
  } catch (error45) {
53350
53624
  log("Failed to load installed plugins database", error45);
@@ -53355,15 +53629,15 @@ function getClaudeSettingsPath() {
53355
53629
  if (process.env.CLAUDE_SETTINGS_PATH) {
53356
53630
  return process.env.CLAUDE_SETTINGS_PATH;
53357
53631
  }
53358
- return join64(homedir18(), ".claude", "settings.json");
53632
+ return join65(homedir18(), ".claude", "settings.json");
53359
53633
  }
53360
53634
  function loadClaudeSettings() {
53361
53635
  const settingsPath = getClaudeSettingsPath();
53362
- if (!existsSync55(settingsPath)) {
53636
+ if (!existsSync56(settingsPath)) {
53363
53637
  return null;
53364
53638
  }
53365
53639
  try {
53366
- const content = readFileSync36(settingsPath, "utf-8");
53640
+ const content = readFileSync37(settingsPath, "utf-8");
53367
53641
  return JSON.parse(content);
53368
53642
  } catch (error45) {
53369
53643
  log("Failed to load Claude settings", error45);
@@ -53371,12 +53645,12 @@ function loadClaudeSettings() {
53371
53645
  }
53372
53646
  }
53373
53647
  function loadPluginManifest(installPath) {
53374
- const manifestPath = join64(installPath, ".claude-plugin", "plugin.json");
53375
- if (!existsSync55(manifestPath)) {
53648
+ const manifestPath = join65(installPath, ".claude-plugin", "plugin.json");
53649
+ if (!existsSync56(manifestPath)) {
53376
53650
  return null;
53377
53651
  }
53378
53652
  try {
53379
- const content = readFileSync36(manifestPath, "utf-8");
53653
+ const content = readFileSync37(manifestPath, "utf-8");
53380
53654
  return JSON.parse(content);
53381
53655
  } catch (error45) {
53382
53656
  log(`Failed to load plugin manifest from ${manifestPath}`, error45);
@@ -53423,7 +53697,7 @@ function discoverInstalledPlugins(options) {
53423
53697
  continue;
53424
53698
  }
53425
53699
  const { installPath, scope, version: version2 } = installation;
53426
- if (!existsSync55(installPath)) {
53700
+ if (!existsSync56(installPath)) {
53427
53701
  errors3.push({
53428
53702
  pluginKey,
53429
53703
  installPath,
@@ -53441,21 +53715,21 @@ function discoverInstalledPlugins(options) {
53441
53715
  pluginKey,
53442
53716
  manifest: manifest ?? undefined
53443
53717
  };
53444
- if (existsSync55(join64(installPath, "commands"))) {
53445
- loadedPlugin.commandsDir = join64(installPath, "commands");
53718
+ if (existsSync56(join65(installPath, "commands"))) {
53719
+ loadedPlugin.commandsDir = join65(installPath, "commands");
53446
53720
  }
53447
- if (existsSync55(join64(installPath, "agents"))) {
53448
- loadedPlugin.agentsDir = join64(installPath, "agents");
53721
+ if (existsSync56(join65(installPath, "agents"))) {
53722
+ loadedPlugin.agentsDir = join65(installPath, "agents");
53449
53723
  }
53450
- if (existsSync55(join64(installPath, "skills"))) {
53451
- loadedPlugin.skillsDir = join64(installPath, "skills");
53724
+ if (existsSync56(join65(installPath, "skills"))) {
53725
+ loadedPlugin.skillsDir = join65(installPath, "skills");
53452
53726
  }
53453
- const hooksPath = join64(installPath, "hooks", "hooks.json");
53454
- if (existsSync55(hooksPath)) {
53727
+ const hooksPath = join65(installPath, "hooks", "hooks.json");
53728
+ if (existsSync56(hooksPath)) {
53455
53729
  loadedPlugin.hooksPath = hooksPath;
53456
53730
  }
53457
- const mcpPath = join64(installPath, ".mcp.json");
53458
- if (existsSync55(mcpPath)) {
53731
+ const mcpPath = join65(installPath, ".mcp.json");
53732
+ if (existsSync56(mcpPath)) {
53459
53733
  loadedPlugin.mcpPath = mcpPath;
53460
53734
  }
53461
53735
  plugins.push(loadedPlugin);
@@ -53466,17 +53740,17 @@ function discoverInstalledPlugins(options) {
53466
53740
  function loadPluginCommands(plugins) {
53467
53741
  const commands2 = {};
53468
53742
  for (const plugin2 of plugins) {
53469
- if (!plugin2.commandsDir || !existsSync55(plugin2.commandsDir))
53743
+ if (!plugin2.commandsDir || !existsSync56(plugin2.commandsDir))
53470
53744
  continue;
53471
- const entries = readdirSync21(plugin2.commandsDir, { withFileTypes: true });
53745
+ const entries = readdirSync22(plugin2.commandsDir, { withFileTypes: true });
53472
53746
  for (const entry of entries) {
53473
53747
  if (!isMarkdownFile(entry))
53474
53748
  continue;
53475
- const commandPath = join64(plugin2.commandsDir, entry.name);
53749
+ const commandPath = join65(plugin2.commandsDir, entry.name);
53476
53750
  const commandName = basename8(entry.name, ".md");
53477
53751
  const namespacedName = `${plugin2.name}:${commandName}`;
53478
53752
  try {
53479
- const content = readFileSync36(commandPath, "utf-8");
53753
+ const content = readFileSync37(commandPath, "utf-8");
53480
53754
  const { data, body } = parseFrontmatter(content);
53481
53755
  const wrappedTemplate = `<command-instruction>
53482
53756
  ${body.trim()}
@@ -53508,21 +53782,21 @@ $ARGUMENTS
53508
53782
  function loadPluginSkillsAsCommands(plugins) {
53509
53783
  const skills = {};
53510
53784
  for (const plugin2 of plugins) {
53511
- if (!plugin2.skillsDir || !existsSync55(plugin2.skillsDir))
53785
+ if (!plugin2.skillsDir || !existsSync56(plugin2.skillsDir))
53512
53786
  continue;
53513
- const entries = readdirSync21(plugin2.skillsDir, { withFileTypes: true });
53787
+ const entries = readdirSync22(plugin2.skillsDir, { withFileTypes: true });
53514
53788
  for (const entry of entries) {
53515
53789
  if (entry.name.startsWith("."))
53516
53790
  continue;
53517
- const skillPath = join64(plugin2.skillsDir, entry.name);
53791
+ const skillPath = join65(plugin2.skillsDir, entry.name);
53518
53792
  if (!entry.isDirectory() && !entry.isSymbolicLink())
53519
53793
  continue;
53520
53794
  const resolvedPath = resolveSymlink(skillPath);
53521
- const skillMdPath = join64(resolvedPath, "SKILL.md");
53522
- if (!existsSync55(skillMdPath))
53795
+ const skillMdPath = join65(resolvedPath, "SKILL.md");
53796
+ if (!existsSync56(skillMdPath))
53523
53797
  continue;
53524
53798
  try {
53525
- const content = readFileSync36(skillMdPath, "utf-8");
53799
+ const content = readFileSync37(skillMdPath, "utf-8");
53526
53800
  const { data, body } = parseFrontmatter(content);
53527
53801
  const skillName = data.name || entry.name;
53528
53802
  const namespacedName = `${plugin2.name}:${skillName}`;
@@ -53557,11 +53831,11 @@ $ARGUMENTS
53557
53831
  function parseToolsConfig2(toolsStr) {
53558
53832
  if (!toolsStr)
53559
53833
  return;
53560
- const tools4 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53561
- if (tools4.length === 0)
53834
+ const tools5 = toolsStr.split(",").map((t) => t.trim()).filter(Boolean);
53835
+ if (tools5.length === 0)
53562
53836
  return;
53563
53837
  const result = {};
53564
- for (const tool3 of tools4) {
53838
+ for (const tool3 of tools5) {
53565
53839
  result[tool3.toLowerCase()] = true;
53566
53840
  }
53567
53841
  return result;
@@ -53569,17 +53843,17 @@ function parseToolsConfig2(toolsStr) {
53569
53843
  function loadPluginAgents(plugins) {
53570
53844
  const agents = {};
53571
53845
  for (const plugin2 of plugins) {
53572
- if (!plugin2.agentsDir || !existsSync55(plugin2.agentsDir))
53846
+ if (!plugin2.agentsDir || !existsSync56(plugin2.agentsDir))
53573
53847
  continue;
53574
- const entries = readdirSync21(plugin2.agentsDir, { withFileTypes: true });
53848
+ const entries = readdirSync22(plugin2.agentsDir, { withFileTypes: true });
53575
53849
  for (const entry of entries) {
53576
53850
  if (!isMarkdownFile(entry))
53577
53851
  continue;
53578
- const agentPath = join64(plugin2.agentsDir, entry.name);
53852
+ const agentPath = join65(plugin2.agentsDir, entry.name);
53579
53853
  const agentName = basename8(entry.name, ".md");
53580
53854
  const namespacedName = `${plugin2.name}:${agentName}`;
53581
53855
  try {
53582
- const content = readFileSync36(agentPath, "utf-8");
53856
+ const content = readFileSync37(agentPath, "utf-8");
53583
53857
  const { data, body } = parseFrontmatter(content);
53584
53858
  const name = data.name || agentName;
53585
53859
  const originalDescription = data.description || "";
@@ -53605,7 +53879,7 @@ function loadPluginAgents(plugins) {
53605
53879
  async function loadPluginMcpServers(plugins) {
53606
53880
  const servers = {};
53607
53881
  for (const plugin2 of plugins) {
53608
- if (!plugin2.mcpPath || !existsSync55(plugin2.mcpPath))
53882
+ if (!plugin2.mcpPath || !existsSync56(plugin2.mcpPath))
53609
53883
  continue;
53610
53884
  try {
53611
53885
  const content = await Bun.file(plugin2.mcpPath).text();
@@ -53637,10 +53911,10 @@ async function loadPluginMcpServers(plugins) {
53637
53911
  function loadPluginHooksConfigs(plugins) {
53638
53912
  const configs = [];
53639
53913
  for (const plugin2 of plugins) {
53640
- if (!plugin2.hooksPath || !existsSync55(plugin2.hooksPath))
53914
+ if (!plugin2.hooksPath || !existsSync56(plugin2.hooksPath))
53641
53915
  continue;
53642
53916
  try {
53643
- const content = readFileSync36(plugin2.hooksPath, "utf-8");
53917
+ const content = readFileSync37(plugin2.hooksPath, "utf-8");
53644
53918
  let config3 = JSON.parse(content);
53645
53919
  config3 = resolvePluginPaths(config3, plugin2.installPath);
53646
53920
  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.65",
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",